fixups and workarounds llm want to output tags

This commit is contained in:
mudler
2024-04-17 19:54:26 +02:00
parent c0773f03f8
commit 2cba2eafe6
3 changed files with 10 additions and 4 deletions

View File

@@ -5,6 +5,7 @@ import (
"fmt" "fmt"
"log/slog" "log/slog"
"os" "os"
"strings"
"sync" "sync"
"time" "time"
@@ -548,8 +549,11 @@ func (a *Agent) consumeJob(job *Job, role string) {
// that a reply was not necessary anymore // that a reply was not necessary anymore
Messages: append(a.currentConversation, openai.ChatCompletionMessage{ Messages: append(a.currentConversation, openai.ChatCompletionMessage{
Role: "system", 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 { if err != nil {
@@ -566,7 +570,8 @@ func (a *Agent) consumeJob(job *Job, role string) {
msg := resp.Choices[0].Message msg := resp.Choices[0].Message
// If we didn't got any message, we can use the response from the action // 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, "<tool_call>") {
a.logger.Info("No output returned from conversation, using the action response as a reply " + replyResponse.Message) a.logger.Info("No output returned from conversation, using the action response as a reply " + replyResponse.Message)
msg = openai.ChatCompletionMessage{ msg = openai.ChatCompletionMessage{

View File

@@ -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. 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}} {{if .Character.Name}}This is the assistant name: {{.Character.Name}}
{{end}}{{if .Character.Age}}This is the assistant age: {{.Character.Age}} {{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.Hobbies}}This is the assistant's hobbies: {{.Character.Hobbies}}
{{end}}{{if .Character.MusicTaste}}This is the assistant's music taste: {{.Character.MusicTaste}} {{end}}{{if .Character.MusicTaste}}This is the assistant's music taste: {{.Character.MusicTaste}}
{{end}} {{end}}

View File

@@ -48,6 +48,7 @@ func (g *GithubIssueSearch) Run(ctx context.Context, params action.ActionParams)
}) })
if err != nil { if err != nil {
resultString = fmt.Sprintf("Error listing issues: %v", err) resultString = fmt.Sprintf("Error listing issues: %v", err)
return resultString, err
} }
for _, i := range issues.Issues { for _, i := range issues.Issues {
slog.Info("Issue found:", i.GetTitle()) slog.Info("Issue found:", i.GetTitle())