langchaingo icon indicating copy to clipboard operation
langchaingo copied to clipboard

Only the first tool is recognized

Open pilsnerbeer opened this issue 1 year ago • 0 comments

I have defined several tools:


var availableTools = []llms.Tool{
	{
		Type: "function",
		Function: &llms.FunctionDefinition{
			Name:        "writeToFile",
			Description: "Write text content to a local file",
			Parameters: map[string]any{
				"type": "object",
				"properties": map[string]any{
					"fileName": map[string]any{
						"type":        "string",
						"description": "The name of the file to write to (including extension)",
					},
					"content": map[string]any{
						"type":        "string",
						"description": "The text content to write to the file",
					},
				},
				"required": []string{"fileName", "content"},
			},
		},
	},
	{
		Type: "function",
		Function: &llms.FunctionDefinition{
			Name:        "readFromFile",
			Description: "Read text content from a local file specified by the name of the file",
			Parameters: map[string]any{
				"type": "object",
				"properties": map[string]any{
					"fileName": map[string]any{
						"type":        "string",
						"description": "The full name of the file to read from (including extension)",
					},
				},
				"required": []string{"fileName"},
			},
		},
	}, .... etc

Add tools with .WithTools func:


choices, err := client.GenerateContent(context.Background(), historyWithBinary, llms.WithTools(availableTools))

Expected result:

  • AI can utilize All tools.

Actual result:

  • Always only the first tool is recognized.
  • AI has no recollection and knows nothing about the other tools

pilsnerbeer avatar Jul 20 '24 19:07 pilsnerbeer