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:
7
llm.go
7
llm.go
@@ -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,
|
||||
}}
|
||||
}
|
||||
|
Reference in New Issue
Block a user