make toolbox optional
This commit is contained in:
27
openai.go
27
openai.go
@@ -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 {
|
||||
|
Reference in New Issue
Block a user