Handle execution errors by appending them to the result.
Previously, execution errors were only returned in the refusal field. This update appends errors to the result field if present, ensuring they are included in the tool's output. This change improves visibility and clarity for error reporting.
This commit is contained in:
parent
2737a5b2be
commit
e5a046a70b
10
llm.go
10
llm.go
@ -2,6 +2,7 @@ package go_llm
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/sashabaranov/go-openai"
|
||||
)
|
||||
|
||||
@ -155,10 +156,17 @@ func (t ToolCallResponse) toChatCompletionMessages() []openai.ChatCompletionMess
|
||||
refusal = t.Error.Error()
|
||||
}
|
||||
|
||||
if refusal != "" {
|
||||
if t.Result != "" {
|
||||
t.Result = t.Result + " (error in execution: " + refusal + ")"
|
||||
} else {
|
||||
t.Result = "error in execution:" + refusal
|
||||
}
|
||||
}
|
||||
|
||||
return []openai.ChatCompletionMessage{{
|
||||
Role: openai.ChatMessageRoleTool,
|
||||
Content: t.Result,
|
||||
Refusal: refusal,
|
||||
ToolCallID: t.ID,
|
||||
}}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user