Change function result type from string to any

Updated the return type of functions and related code from `string` to `any` to improve flexibility and support more diverse outputs. Adjusted function implementations, signatures, and handling of results accordingly.
This commit is contained in:
2025-03-25 23:53:09 -04:00
parent 5ba42056ad
commit 82feb7d8b4
4 changed files with 18 additions and 14 deletions

7
llm.go
View File

@@ -2,6 +2,7 @@ package go_llm
import (
"context"
"fmt"
"github.com/sashabaranov/go-openai"
)
@@ -142,7 +143,7 @@ func (t ToolCall) toChatCompletionMessages() []openai.ChatCompletionMessage {
type ToolCallResponse struct {
ID string
Result string
Result any
Error error
}
@@ -167,7 +168,7 @@ func (t ToolCallResponse) toChatCompletionMessages() []openai.ChatCompletionMess
if refusal != "" {
if t.Result != "" {
t.Result = t.Result + " (error in execution: " + refusal + ")"
t.Result = fmt.Sprint(t.Result) + " (error in execution: " + refusal + ")"
} else {
t.Result = "error in execution:" + refusal
}
@@ -175,7 +176,7 @@ func (t ToolCallResponse) toChatCompletionMessages() []openai.ChatCompletionMess
return []openai.ChatCompletionMessage{{
Role: openai.ChatMessageRoleTool,
Content: t.Result,
Content: fmt.Sprint(t.Result),
ToolCallID: t.ID,
}}
}