Finish moving types
This commit is contained in:
committed by
Ettore Di Giacinto
parent
f0b8bfb4f4
commit
75a8d63e83
@@ -5,6 +5,7 @@ import (
|
||||
|
||||
"github.com/bwmarrin/discordgo"
|
||||
"github.com/mudler/LocalAgent/core/agent"
|
||||
"github.com/mudler/LocalAgent/core/types"
|
||||
"github.com/mudler/LocalAgent/pkg/xlog"
|
||||
)
|
||||
|
||||
@@ -24,14 +25,14 @@ func NewDiscord(config map[string]string) *Discord {
|
||||
}
|
||||
}
|
||||
|
||||
func (d *Discord) AgentResultCallback() func(state agent.ActionState) {
|
||||
return func(state agent.ActionState) {
|
||||
func (d *Discord) AgentResultCallback() func(state types.ActionState) {
|
||||
return func(state types.ActionState) {
|
||||
// Send the result to the bot
|
||||
}
|
||||
}
|
||||
|
||||
func (d *Discord) AgentReasoningCallback() func(state agent.ActionCurrentState) bool {
|
||||
return func(state agent.ActionCurrentState) bool {
|
||||
func (d *Discord) AgentReasoningCallback() func(state types.ActionCurrentState) bool {
|
||||
return func(state types.ActionCurrentState) bool {
|
||||
// Send the reasoning to the bot
|
||||
return true
|
||||
}
|
||||
@@ -84,7 +85,7 @@ func (d *Discord) messageCreate(a *agent.Agent) func(s *discordgo.Session, m *di
|
||||
content = strings.ReplaceAll(content, "<@"+s.State.User.ID+"> ", "")
|
||||
xlog.Info("Received message", "content", content)
|
||||
job := a.Ask(
|
||||
agent.WithText(
|
||||
types.WithText(
|
||||
content,
|
||||
),
|
||||
)
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
|
||||
"github.com/google/go-github/v69/github"
|
||||
"github.com/mudler/LocalAgent/core/agent"
|
||||
"github.com/mudler/LocalAgent/core/types"
|
||||
"github.com/mudler/LocalAgent/pkg/xlog"
|
||||
|
||||
"github.com/sashabaranov/go-openai"
|
||||
@@ -50,14 +51,14 @@ func NewGithubIssueWatcher(config map[string]string) *GithubIssues {
|
||||
}
|
||||
}
|
||||
|
||||
func (g *GithubIssues) AgentResultCallback() func(state agent.ActionState) {
|
||||
return func(state agent.ActionState) {
|
||||
func (g *GithubIssues) AgentResultCallback() func(state types.ActionState) {
|
||||
return func(state types.ActionState) {
|
||||
// Send the result to the bot
|
||||
}
|
||||
}
|
||||
|
||||
func (g *GithubIssues) AgentReasoningCallback() func(state agent.ActionCurrentState) bool {
|
||||
return func(state agent.ActionCurrentState) bool {
|
||||
func (g *GithubIssues) AgentReasoningCallback() func(state types.ActionCurrentState) bool {
|
||||
return func(state types.ActionCurrentState) bool {
|
||||
// Send the reasoning to the bot
|
||||
return true
|
||||
}
|
||||
@@ -175,7 +176,7 @@ func (g *GithubIssues) issuesService() {
|
||||
}
|
||||
|
||||
res := g.agent.Ask(
|
||||
agent.WithConversationHistory(messages),
|
||||
types.WithConversationHistory(messages),
|
||||
)
|
||||
if res.Error != nil {
|
||||
xlog.Error("Error asking", "error", res.Error, "agent", g.agent.Character.Name)
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
|
||||
"github.com/google/go-github/v69/github"
|
||||
"github.com/mudler/LocalAgent/core/agent"
|
||||
"github.com/mudler/LocalAgent/core/types"
|
||||
"github.com/mudler/LocalAgent/pkg/xlog"
|
||||
|
||||
"github.com/sashabaranov/go-openai"
|
||||
@@ -50,14 +51,14 @@ func NewGithubPRWatcher(config map[string]string) *GithubPRs {
|
||||
}
|
||||
}
|
||||
|
||||
func (g *GithubPRs) AgentResultCallback() func(state agent.ActionState) {
|
||||
return func(state agent.ActionState) {
|
||||
func (g *GithubPRs) AgentResultCallback() func(state types.ActionState) {
|
||||
return func(state types.ActionState) {
|
||||
// Send the result to the bot
|
||||
}
|
||||
}
|
||||
|
||||
func (g *GithubPRs) AgentReasoningCallback() func(state agent.ActionCurrentState) bool {
|
||||
return func(state agent.ActionCurrentState) bool {
|
||||
func (g *GithubPRs) AgentReasoningCallback() func(state types.ActionCurrentState) bool {
|
||||
return func(state types.ActionCurrentState) bool {
|
||||
// Send the reasoning to the bot
|
||||
return true
|
||||
}
|
||||
@@ -175,7 +176,7 @@ func (g *GithubPRs) prService() {
|
||||
}
|
||||
|
||||
res := g.agent.Ask(
|
||||
agent.WithConversationHistory(messages),
|
||||
types.WithConversationHistory(messages),
|
||||
)
|
||||
if res.Error != nil {
|
||||
xlog.Error("Error asking", "error", res.Error, "agent", g.agent.Character.Name)
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/mudler/LocalAgent/core/agent"
|
||||
"github.com/mudler/LocalAgent/core/types"
|
||||
"github.com/mudler/LocalAgent/pkg/xlog"
|
||||
"github.com/mudler/LocalAgent/services/actions"
|
||||
irc "github.com/thoj/go-ircevent"
|
||||
@@ -30,14 +31,14 @@ func NewIRC(config map[string]string) *IRC {
|
||||
}
|
||||
}
|
||||
|
||||
func (i *IRC) AgentResultCallback() func(state agent.ActionState) {
|
||||
return func(state agent.ActionState) {
|
||||
func (i *IRC) AgentResultCallback() func(state types.ActionState) {
|
||||
return func(state types.ActionState) {
|
||||
// Send the result to the bot
|
||||
}
|
||||
}
|
||||
|
||||
func (i *IRC) AgentReasoningCallback() func(state agent.ActionCurrentState) bool {
|
||||
return func(state agent.ActionCurrentState) bool {
|
||||
func (i *IRC) AgentReasoningCallback() func(state types.ActionCurrentState) bool {
|
||||
return func(state types.ActionCurrentState) bool {
|
||||
// Send the reasoning to the bot
|
||||
return true
|
||||
}
|
||||
@@ -105,7 +106,7 @@ func (i *IRC) Start(a *agent.Agent) {
|
||||
|
||||
go func() {
|
||||
res := a.Ask(
|
||||
agent.WithText(cleanedMessage),
|
||||
types.WithText(cleanedMessage),
|
||||
)
|
||||
|
||||
xlog.Info("Sending message", "message", res.Response, "channel", channel)
|
||||
|
||||
@@ -14,6 +14,7 @@ import (
|
||||
"github.com/sashabaranov/go-openai"
|
||||
|
||||
"github.com/mudler/LocalAgent/core/agent"
|
||||
"github.com/mudler/LocalAgent/core/types"
|
||||
|
||||
"github.com/slack-go/slack/socketmode"
|
||||
|
||||
@@ -39,14 +40,14 @@ func NewSlack(config map[string]string) *Slack {
|
||||
}
|
||||
}
|
||||
|
||||
func (t *Slack) AgentResultCallback() func(state agent.ActionState) {
|
||||
return func(state agent.ActionState) {
|
||||
func (t *Slack) AgentResultCallback() func(state types.ActionState) {
|
||||
return func(state types.ActionState) {
|
||||
// Send the result to the bot
|
||||
}
|
||||
}
|
||||
|
||||
func (t *Slack) AgentReasoningCallback() func(state agent.ActionCurrentState) bool {
|
||||
return func(state agent.ActionCurrentState) bool {
|
||||
func (t *Slack) AgentReasoningCallback() func(state types.ActionCurrentState) bool {
|
||||
return func(state types.ActionCurrentState) bool {
|
||||
// Send the reasoning to the bot
|
||||
return true
|
||||
}
|
||||
@@ -71,7 +72,7 @@ func uniqueStringSlice(s []string) []string {
|
||||
return list
|
||||
}
|
||||
|
||||
func generateAttachmentsFromJobResponse(j *agent.JobResult) (attachments []slack.Attachment) {
|
||||
func generateAttachmentsFromJobResponse(j *types.JobResult) (attachments []slack.Attachment) {
|
||||
for _, state := range j.State {
|
||||
// coming from the search action
|
||||
if urls, exists := state.Metadata[actions.MetadataUrls]; exists {
|
||||
@@ -148,7 +149,7 @@ func (t *Slack) handleChannelMessage(
|
||||
}
|
||||
}
|
||||
|
||||
agentOptions := []agent.JobOption{agent.WithText(message)}
|
||||
agentOptions := []types.JobOption{types.WithText(message)}
|
||||
|
||||
// If the last message has an image, we send it as a multi content message
|
||||
if len(imageBytes.Bytes()) > 0 {
|
||||
@@ -158,7 +159,7 @@ func (t *Slack) handleChannelMessage(
|
||||
if err != nil {
|
||||
xlog.Error(fmt.Sprintf("Error encoding image to base64: %v", err))
|
||||
} else {
|
||||
agentOptions = append(agentOptions, agent.WithImage(fmt.Sprintf("data:%s;base64,%s", mimeType, imgBase64)))
|
||||
agentOptions = append(agentOptions, types.WithImage(fmt.Sprintf("data:%s;base64,%s", mimeType, imgBase64)))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -350,8 +351,8 @@ func (t *Slack) handleMention(
|
||||
}
|
||||
|
||||
res := a.Ask(
|
||||
// agent.WithText(message),
|
||||
agent.WithConversationHistory(threadMessages),
|
||||
// types.WithText(message),
|
||||
types.WithConversationHistory(threadMessages),
|
||||
)
|
||||
|
||||
res.Response = githubmarkdownconvertergo.Slack(res.Response)
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"github.com/go-telegram/bot"
|
||||
"github.com/go-telegram/bot/models"
|
||||
"github.com/mudler/LocalAgent/core/agent"
|
||||
"github.com/mudler/LocalAgent/core/types"
|
||||
)
|
||||
|
||||
type Telegram struct {
|
||||
@@ -20,16 +21,16 @@ type Telegram struct {
|
||||
|
||||
// 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) {
|
||||
func (t *Telegram) AgentResultCallback() func(state types.ActionState) {
|
||||
return func(state types.ActionState) {
|
||||
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 {
|
||||
func (t *Telegram) AgentReasoningCallback() func(state types.ActionCurrentState) bool {
|
||||
return func(state types.ActionCurrentState) bool {
|
||||
t.bot.SetMyDescription(t.agent.Context(), &bot.SetMyDescriptionParams{
|
||||
Description: state.Reasoning,
|
||||
})
|
||||
@@ -45,7 +46,7 @@ func (t *Telegram) Start(a *agent.Agent) {
|
||||
bot.WithDefaultHandler(func(ctx context.Context, b *bot.Bot, update *models.Update) {
|
||||
go func() {
|
||||
res := a.Ask(
|
||||
agent.WithText(
|
||||
types.WithText(
|
||||
update.Message.Text,
|
||||
),
|
||||
)
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"os/signal"
|
||||
|
||||
"github.com/mudler/LocalAgent/core/agent"
|
||||
"github.com/mudler/LocalAgent/core/types"
|
||||
"github.com/mudler/LocalAgent/pkg/xlog"
|
||||
"github.com/mudler/LocalAgent/services/connectors/twitter"
|
||||
"github.com/sashabaranov/go-openai"
|
||||
@@ -19,14 +20,14 @@ type Twitter struct {
|
||||
noCharacterLimit bool
|
||||
}
|
||||
|
||||
func (t *Twitter) AgentResultCallback() func(state agent.ActionState) {
|
||||
return func(state agent.ActionState) {
|
||||
func (t *Twitter) AgentResultCallback() func(state types.ActionState) {
|
||||
return func(state types.ActionState) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
func (t *Twitter) AgentReasoningCallback() func(state agent.ActionCurrentState) bool {
|
||||
return func(state agent.ActionCurrentState) bool {
|
||||
func (t *Twitter) AgentReasoningCallback() func(state types.ActionCurrentState) bool {
|
||||
return func(state types.ActionCurrentState) bool {
|
||||
|
||||
return true
|
||||
}
|
||||
@@ -98,7 +99,7 @@ func (t *Twitter) run(a *agent.Agent) error {
|
||||
}
|
||||
|
||||
res := a.Ask(
|
||||
agent.WithConversationHistory(
|
||||
types.WithConversationHistory(
|
||||
[]openai.ChatCompletionMessage{
|
||||
{
|
||||
Role: "system",
|
||||
|
||||
Reference in New Issue
Block a user