Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't use same tool in OpenAI & GoogleAI #1101

Open
temamagic opened this issue Jan 10, 2025 · 0 comments
Open

Can't use same tool in OpenAI & GoogleAI #1101

temamagic opened this issue Jan 10, 2025 · 0 comments

Comments

@temamagic
Copy link

I was trying to use same tool for different models, here my tries:

var Tool = llms.Tool{
	Type: tools.ToolTypeFunction,
	Function: &llms.FunctionDefinition{
		Name:        tools.ICal,
		Description: "Send an iCal file to the chat",
		Parameters: map[string]any{
			"type": string(jsonschema.Object),
			"properties": map[string]any{
				"contents": map[string]any{
					"type":        string(jsonschema.String),
					"description": "Contents of the iCal file",
				},
				"file_name": map[string]any{
					"type":        string(jsonschema.String),
					"description": "Name of the iCal file (with .ics extension)",
				},
			},
			"required": []string{"contents", "file_name"},
		},
	},
}
var Tool = llms.Tool{
	Type: tools.ToolTypeFunction,
	Function: &llms.FunctionDefinition{
		Name:        tools.ICal,
		Description: "Send an iCal file to the chat",
		Parameters: jsonschema.Definition{
			Type: jsonschema.Object,
			Properties: map[string]jsonschema.Definition{
				"contents": {
					Type:        jsonschema.String,
					Description: "Contents of the iCal file",
				},
				"file_name": {
					Type:        jsonschema.String,
					Description: "Name of the iCal file (with .ics extension)",
				},
			},
			Required: []string{"contents", "file_name"},
		},
	},
}

tools.ToolTypeFunction - my const "function"

I think we can handle here

params, ok := tool.Function.Parameters.(map[string]any)

Or why we have jsonschema.Definition?

I'll try to figure how i can use same models but still no success

or catch errors like

[ {
  "error" : {
    "code" : 400,
    "message" : "* GenerateContentRequest.tools[7].function_declarations[0].parameters.properties[options].items: missing field.\n",
    "status" : "INVALID_ARGUMENT"
  }
} ]

or

[ {
  "error" : {
    "code" : 400,
    "message" : "* GenerateContentRequest.tools[2].function_declarations[0].parameters.type: must be specified when not using one_of\n* GenerateContentRequest.tools[7].function_declarations[0].parameters.properties[options].items: missing field.\n* GenerateContentRequest.tools[13].function_declarations[0].parameters.type: must be specified when not using one_of\n* GenerateContentRequest.tools[15].function_declarations[0].parameters.type: must be specified when not using one_of\n",
    "status" : "INVALID_ARGUMENT"
  }
} ]

What i'm doing wrong?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant