feat(prompts): adding better prompts & restoring tool_stop

Mistral's models seem to do something really strange if you allow for
`tool_choice` to be anything but `any`. They start putting the tool call
inside the `content` instead of an actual tool call. This means that I
need this `stop` mechanism using a tool call instead because I cannot
trust the model to do it by itself.

I quite like this model though, it's cheap, it's fast and it's open
source. And all the answers are pretty good!
This commit is contained in:
2025-04-17 15:24:21 +01:00
parent 181da1f09d
commit 15289e4965
6 changed files with 252 additions and 153 deletions

View File

@@ -194,7 +194,7 @@ func (chat *Chat) AddImage(imageName string, image []byte, query *string) error
contentLength := 1
if query != nil {
contentLength = 2
contentLength += 1
}
messageContent := ArrayMessage{

View File

@@ -160,7 +160,8 @@ func (client AgentClient) Request(req *AgentRequestBody) (AgentResponse, error)
return AgentResponse{}, errors.New("Unsupported. We currently only accept 1 choice from AI.")
}
req.Chat.AddAiResponse(agentResponse.Choices[0].Message)
msg := agentResponse.Choices[0].Message
req.Chat.AddAiResponse(msg)
return agentResponse, nil
}
@@ -178,7 +179,13 @@ func (client *AgentClient) ToolLoop(info ToolHandlerInfo, req *AgentRequestBody)
}
err = client.Process(info, req)
if err != nil {
if err == FinishedCall {
client.Log.Debug("Agent is finished")
}
return err
}
}
@@ -230,7 +237,7 @@ func (client *AgentClient) RunAgent(userId uuid.UUID, imageId uuid.UUID, imageNa
panic(err)
}
toolChoice := "auto"
toolChoice := "any"
request := AgentRequestBody{
Tools: &tools,