feat(reminders): add reminder system to perform long-term goals in the background (#176)
* feat(reminders): add self-ability to set reminders Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * feat(reminders): surface reminders result to the user as new conversations Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * Fixups * Subscribe all connectors to agents new messages Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * Set reminders in the list * fix(telegram): do not always auth Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * Small fixups * Improve UX Signed-off-by: Ettore Di Giacinto <mudler@localai.io> --------- Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
This commit is contained in:
committed by
GitHub
parent
490bf998a4
commit
9a90153dc6
@@ -35,6 +35,7 @@ type Email struct {
|
||||
smtpInsecure bool
|
||||
imapServer string
|
||||
imapInsecure bool
|
||||
defaultEmail string
|
||||
}
|
||||
|
||||
func NewEmail(config map[string]string) *Email {
|
||||
@@ -48,6 +49,7 @@ func NewEmail(config map[string]string) *Email {
|
||||
smtpInsecure: config["smtpInsecure"] == "true",
|
||||
imapServer: config["imapServer"],
|
||||
imapInsecure: config["imapInsecure"] == "true",
|
||||
defaultEmail: config["defaultEmail"],
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,6 +107,12 @@ func EmailConfigMeta() []config.Field {
|
||||
Required: true,
|
||||
HelpText: "Agent email address",
|
||||
},
|
||||
{
|
||||
Name: "defaultEmail",
|
||||
Label: "Default Recipient",
|
||||
Type: config.FieldTypeText,
|
||||
HelpText: "Default email address to send messages to when the agent wants to initiate a conversation",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -367,6 +375,31 @@ func imapWorker(done chan bool, e *Email, a *agent.Agent, c *imapclient.Client,
|
||||
|
||||
func (e *Email) Start(a *agent.Agent) {
|
||||
go func() {
|
||||
if e.defaultEmail != "" {
|
||||
// handle new conversations
|
||||
a.AddSubscriber(func(ccm openai.ChatCompletionMessage) {
|
||||
xlog.Debug("Subscriber(email)", "message", ccm.Content)
|
||||
|
||||
// Send the message to the default email
|
||||
e.sendMail(
|
||||
e.defaultEmail,
|
||||
"Message from LocalAGI",
|
||||
ccm.Content,
|
||||
"",
|
||||
"",
|
||||
[]string{e.defaultEmail},
|
||||
false,
|
||||
)
|
||||
|
||||
a.SharedState().ConversationTracker.AddMessage(
|
||||
fmt.Sprintf("email:%s", e.defaultEmail),
|
||||
openai.ChatCompletionMessage{
|
||||
Content: ccm.Content,
|
||||
Role: "assistant",
|
||||
},
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
xlog.Info("Email connector is now running. Press CTRL-C to exit.")
|
||||
// IMAP dial
|
||||
|
||||
Reference in New Issue
Block a user