chore: removing unnecessary logging
This commit is contained in:
@ -160,23 +160,6 @@ func (client AgentClient) Request(req *AgentRequestBody) (AgentResponse, error)
|
|||||||
return AgentResponse{}, errors.New("Unsupported. We currently only accept 1 choice from AI.")
|
return AgentResponse{}, errors.New("Unsupported. We currently only accept 1 choice from AI.")
|
||||||
}
|
}
|
||||||
|
|
||||||
msg := agentResponse.Choices[0].Message
|
|
||||||
|
|
||||||
if len(msg.Content) > 0 {
|
|
||||||
client.Log.Debugf("Content: %s", msg.Content)
|
|
||||||
}
|
|
||||||
|
|
||||||
if msg.ToolCalls != nil && len(*msg.ToolCalls) > 0 {
|
|
||||||
client.Log.Debugf("Tool Call: %s", (*msg.ToolCalls)[0].Function.Name)
|
|
||||||
|
|
||||||
prettyJson, err := json.MarshalIndent((*msg.ToolCalls)[0].Function.Arguments, "", " ")
|
|
||||||
if err != nil {
|
|
||||||
return AgentResponse{}, err
|
|
||||||
}
|
|
||||||
|
|
||||||
client.Log.Debugf("Arguments: %s", string(prettyJson))
|
|
||||||
}
|
|
||||||
|
|
||||||
req.Chat.AddAiResponse(agentResponse.Choices[0].Message)
|
req.Chat.AddAiResponse(agentResponse.Choices[0].Message)
|
||||||
|
|
||||||
return agentResponse, nil
|
return agentResponse, nil
|
||||||
@ -184,12 +167,17 @@ func (client AgentClient) Request(req *AgentRequestBody) (AgentResponse, error)
|
|||||||
|
|
||||||
func (client *AgentClient) ToolLoop(info ToolHandlerInfo, req *AgentRequestBody) error {
|
func (client *AgentClient) ToolLoop(info ToolHandlerInfo, req *AgentRequestBody) error {
|
||||||
for {
|
for {
|
||||||
err := client.Process(info, req)
|
response, err := client.Request(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = client.Request(req)
|
if response.Choices[0].FinishReason == "stop" {
|
||||||
|
client.Log.Debug("Agent is finished")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
err = client.Process(info, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -227,7 +215,7 @@ func (client *AgentClient) Process(info ToolHandlerInfo, req *AgentRequestBody)
|
|||||||
client.Reply = toolCall.Function.Arguments
|
client.Reply = toolCall.Function.Arguments
|
||||||
}
|
}
|
||||||
|
|
||||||
client.Log.Debugf("Response: %s", toolResponse.Content)
|
client.Log.Debug("Tool call response", "toolCall", toolCall.Function.Name, "response", toolResponse.Content)
|
||||||
|
|
||||||
req.Chat.AddToolResponse(toolResponse)
|
req.Chat.AddToolResponse(toolResponse)
|
||||||
}
|
}
|
||||||
@ -238,8 +226,11 @@ func (client *AgentClient) Process(info ToolHandlerInfo, req *AgentRequestBody)
|
|||||||
func (client *AgentClient) RunAgent(userId uuid.UUID, imageId uuid.UUID, imageName string, imageData []byte) error {
|
func (client *AgentClient) RunAgent(userId uuid.UUID, imageId uuid.UUID, imageName string, imageData []byte) error {
|
||||||
var tools any
|
var tools any
|
||||||
err := json.Unmarshal([]byte(client.Options.JsonTools), &tools)
|
err := json.Unmarshal([]byte(client.Options.JsonTools), &tools)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
toolChoice := "any"
|
toolChoice := "auto"
|
||||||
|
|
||||||
request := AgentRequestBody{
|
request := AgentRequestBody{
|
||||||
Tools: &tools,
|
Tools: &tools,
|
||||||
@ -258,11 +249,6 @@ func (client *AgentClient) RunAgent(userId uuid.UUID, imageId uuid.UUID, imageNa
|
|||||||
request.Chat.AddSystem(client.Options.SystemPrompt)
|
request.Chat.AddSystem(client.Options.SystemPrompt)
|
||||||
request.Chat.AddImage(imageName, imageData, client.Options.Query)
|
request.Chat.AddImage(imageName, imageData, client.Options.Query)
|
||||||
|
|
||||||
_, err = client.Request(&request)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
toolHandlerInfo := ToolHandlerInfo{
|
toolHandlerInfo := ToolHandlerInfo{
|
||||||
ImageId: imageId,
|
ImageId: imageId,
|
||||||
ImageName: imageName,
|
ImageName: imageName,
|
||||||
|
Reference in New Issue
Block a user