Skip to content

Commit 0e16c76

Browse files
committed
Merge branch 'pr/1240' into main-pull-requests
2 parents 0fa7e1f + 63ccd37 commit 0e16c76

20 files changed

Lines changed: 447 additions & 351 deletions

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
}

chains/testdata/TestLLMChainWithGoogleAI.httprr

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

llms/googleai/googleai_unit_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ func TestConvertTools(t *testing.T) { //nolint:funlen // comprehensive test //no
363363
}
364364
result, err := convertTools(tools)
365365
assert.Error(t, err)
366-
assert.Contains(t, err.Error(), "expected to find a map of properties")
366+
assert.Contains(t, err.Error(), "object schema must have properties")
367367
assert.Nil(t, result)
368368
})
369369

llms/googleai/testdata/TestGoogleAIBatchEmbedding.httprr

Lines changed: 12 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

llms/googleai/testdata/TestGoogleAICall.httprr

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

llms/googleai/testdata/TestGoogleAICreateEmbedding.httprr

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

llms/googleai/testdata/TestGoogleAIErrorHandling.httprr

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

llms/googleai/testdata/TestGoogleAIGenerateContent.httprr

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

llms/googleai/testdata/TestGoogleAIGenerateContentWithMultipleMessages.httprr

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

llms/googleai/testdata/TestGoogleAIGenerateContentWithSystemMessage.httprr

Lines changed: 15 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)