Skip to content

Commit fba6560

Browse files
committed
Merge branch 'pr/1240' into main-pull-requests
2 parents 9e5afe9 + 63ccd37 commit fba6560

1 file changed

Lines changed: 14 additions & 11 deletions

File tree

agents/openai_functions_agent.go

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,21 @@ func NewOpenAIFunctionsAgent(llm llms.Model, tools []tools.Tool, opts ...Option)
4848
}
4949
}
5050

51-
func (o *OpenAIFunctionsAgent) functions() []llms.FunctionDefinition {
52-
res := make([]llms.FunctionDefinition, 0)
51+
func (o *OpenAIFunctionsAgent) tools() []llms.Tool {
52+
res := make([]llms.Tool, 0)
5353
for _, tool := range o.Tools {
54-
res = append(res, llms.FunctionDefinition{
55-
Name: tool.Name(),
56-
Description: tool.Description(),
57-
Parameters: map[string]any{
58-
"properties": map[string]any{
59-
"__arg1": map[string]string{"title": "__arg1", "type": "string"},
54+
res = append(res, llms.Tool{
55+
Type: "function",
56+
Function: &llms.FunctionDefinition{
57+
Name: tool.Name(),
58+
Description: tool.Description(),
59+
Parameters: map[string]any{
60+
"properties": map[string]any{
61+
"__arg1": map[string]string{"title": "__arg1", "type": "string"},
62+
},
63+
"required": []string{"__arg1"},
64+
"type": "object",
6065
},
61-
"required": []string{"__arg1"},
62-
"type": "object",
6366
},
6467
})
6568
}
@@ -146,7 +149,7 @@ func (o *OpenAIFunctionsAgent) Plan(
146149
}
147150

148151
result, err := o.LLM.GenerateContent(ctx, mcList,
149-
llms.WithFunctions(o.functions()), llms.WithStreamingFunc(stream))
152+
llms.WithTools(o.tools()), llms.WithStreamingFunc(stream))
150153
if err != nil {
151154
return nil, nil, err
152155
}

0 commit comments

Comments
 (0)