mirror of
https://github.com/vxcontrol/langchaingo.git
synced 2026-07-21 00:45:22 -04:00
Merge branch 'pr/1240' into main-pull-requests
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user