Merge branch 'pr/1240' into main-pull-requests

This commit is contained in:
Dmitry Ng
2025-05-06 21:10:58 +03:00
+14 -11
View File
@@ -48,18 +48,21 @@ func NewOpenAIFunctionsAgent(llm llms.Model, tools []tools.Tool, opts ...Option)
}
}
func (o *OpenAIFunctionsAgent) functions() []llms.FunctionDefinition {
res := make([]llms.FunctionDefinition, 0)
func (o *OpenAIFunctionsAgent) tools() []llms.Tool {
res := make([]llms.Tool, 0)
for _, tool := range o.Tools {
res = append(res, llms.FunctionDefinition{
Name: tool.Name(),
Description: tool.Description(),
Parameters: map[string]any{
"properties": map[string]any{
"__arg1": map[string]string{"title": "__arg1", "type": "string"},
res = append(res, llms.Tool{
Type: "function",
Function: &llms.FunctionDefinition{
Name: tool.Name(),
Description: tool.Description(),
Parameters: map[string]any{
"properties": map[string]any{
"__arg1": map[string]string{"title": "__arg1", "type": "string"},
},
"required": []string{"__arg1"},
"type": "object",
},
"required": []string{"__arg1"},
"type": "object",
},
})
}
@@ -146,7 +149,7 @@ func (o *OpenAIFunctionsAgent) Plan(
}
result, err := o.LLM.GenerateContent(ctx, mcList,
llms.WithFunctions(o.functions()), llms.WithStreamingFunc(stream))
llms.WithTools(o.tools()), llms.WithStreamingFunc(stream))
if err != nil {
return nil, nil, err
}