From 2cba2eafe662e522fcbe21c8558e9a2553d611b1 Mon Sep 17 00:00:00 2001 From: mudler Date: Wed, 17 Apr 2024 19:54:26 +0200 Subject: [PATCH] fixups and workarounds llm want to output tags --- agent/agent.go | 11 ++++++++--- agent/templates.go | 2 +- external/githubissuesearch.go | 1 + 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/agent/agent.go b/agent/agent.go index 54eee9c..77a5033 100644 --- a/agent/agent.go +++ b/agent/agent.go @@ -5,6 +5,7 @@ import ( "fmt" "log/slog" "os" + "strings" "sync" "time" @@ -548,8 +549,11 @@ func (a *Agent) consumeJob(job *Job, role string) { // that a reply was not necessary anymore Messages: append(a.currentConversation, openai.ChatCompletionMessage{ Role: "system", - Content: "The assistant needs to reply without using any tool. " + replyResponse.Message, - }), + Content: "The assistant needs to reply without using any tool.", + // + replyResponse.Message, + }, + ), + //Messages: a.currentConversation, }, ) if err != nil { @@ -566,7 +570,8 @@ func (a *Agent) consumeJob(job *Job, role string) { msg := resp.Choices[0].Message // If we didn't got any message, we can use the response from the action - if chosenAction.Definition().Name.Is(action.ReplyActionName) && msg.Content == "" { + if chosenAction.Definition().Name.Is(action.ReplyActionName) && msg.Content == "" || + strings.Contains(msg.Content, "") { a.logger.Info("No output returned from conversation, using the action response as a reply " + replyResponse.Message) msg = openai.ChatCompletionMessage{ diff --git a/agent/templates.go b/agent/templates.go index 15dc1fa..4c63643 100644 --- a/agent/templates.go +++ b/agent/templates.go @@ -47,7 +47,7 @@ Considering the goal and the persistent goal, if you have one, and do something, const hudTemplate = `{{with .HUD }}{{if .ShowCharacter}}The assistant acts like an human, has a character and the replies and actions might be influenced by it. {{if .Character.Name}}This is the assistant name: {{.Character.Name}} {{end}}{{if .Character.Age}}This is the assistant age: {{.Character.Age}} -{{end}}{{if .Character.Occupation}}This is the assistant jop: {{.Character.Occupation}} +{{end}}{{if .Character.Occupation}}This is the assistant job: {{.Character.Occupation}} {{end}}{{if .Character.Hobbies}}This is the assistant's hobbies: {{.Character.Hobbies}} {{end}}{{if .Character.MusicTaste}}This is the assistant's music taste: {{.Character.MusicTaste}} {{end}} diff --git a/external/githubissuesearch.go b/external/githubissuesearch.go index 4c1ec85..71b9bb8 100644 --- a/external/githubissuesearch.go +++ b/external/githubissuesearch.go @@ -48,6 +48,7 @@ func (g *GithubIssueSearch) Run(ctx context.Context, params action.ActionParams) }) if err != nil { resultString = fmt.Sprintf("Error listing issues: %v", err) + return resultString, err } for _, i := range issues.Issues { slog.Info("Issue found:", i.GetTitle())