make toolbox optional

This commit is contained in:
2024-12-28 20:39:57 -05:00
parent 46a526fd5a
commit dfb768d966
3 changed files with 21 additions and 13 deletions

View File

@@ -3,8 +3,9 @@ package go_llm
import (
"context"
"fmt"
oai "github.com/sashabaranov/go-openai"
"strings"
oai "github.com/sashabaranov/go-openai"
)
type openaiImpl struct {
@@ -57,18 +58,20 @@ func (o openaiImpl) requestToOpenAIRequest(request Request) oai.ChatCompletionRe
res.Messages = append(res.Messages, m)
}
for _, tool := range request.Toolbox.funcs {
res.Tools = append(res.Tools, oai.Tool{
Type: "function",
Function: &oai.FunctionDefinition{
Name: tool.Name,
Description: tool.Description,
Strict: tool.Strict,
Parameters: tool.Parameters.Definition(),
},
})
if request.Toolbox != nil {
for _, tool := range request.Toolbox.funcs {
res.Tools = append(res.Tools, oai.Tool{
Type: "function",
Function: &oai.FunctionDefinition{
Name: tool.Name,
Description: tool.Description,
Strict: tool.Strict,
Parameters: tool.Parameters.Definition(),
},
})
fmt.Println("tool:", tool.Name, tool.Description, tool.Strict, tool.Parameters.Definition())
fmt.Println("tool:", tool.Name, tool.Description, tool.Strict, tool.Parameters.Definition())
}
}
if request.Temperature != nil {