Add slack and github connectors

This commit is contained in:
mudler
2024-04-09 18:24:47 +02:00
parent 414a973282
commit 4453f43bec
11 changed files with 423 additions and 34 deletions

View File

@@ -14,22 +14,29 @@ import (
type Telegram struct {
Token string
lastChatID int64
bot *bot.Bot
agent *agent.Agent
}
// Send any text message to the bot after the bot has been started
func (t *Telegram) AgentResultCallback() func(state agent.ActionState) {
return func(state agent.ActionState) {
// Send the result to the bot
t.bot.SetMyDescription(t.agent.Context(), &bot.SetMyDescriptionParams{
Description: state.Reasoning,
})
}
}
func (t *Telegram) AgentReasoningCallback() func(state agent.ActionCurrentState) bool {
return func(state agent.ActionCurrentState) bool {
// Send the reasoning to the bot
t.bot.SetMyDescription(t.agent.Context(), &bot.SetMyDescriptionParams{
Description: state.Reasoning,
})
return true
}
}
func (t *Telegram) Start(a *agent.Agent) {
ctx, cancel := signal.NotifyContext(a.Context(), os.Interrupt)
defer cancel()
@@ -54,6 +61,9 @@ func (t *Telegram) Start(a *agent.Agent) {
panic(err)
}
t.bot = b
t.agent = a
go func() {
for m := range a.ConversationChannel() {
if t.lastChatID == 0 {