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

Validate that all Required function calling parameters exist in the Schema #93

Open
fredsa opened this issue Apr 24, 2024 · 2 comments
Open
Labels
status:triaged Issue/PR triaged to the corresponding sub-team type:feature request New feature request or enhancement

Comments

@fredsa
Copy link
Contributor

fredsa commented Apr 24, 2024

Using github.com/google/generative-ai-go v0.11.0, this code does not complain about the "this_param_does_not_exist" entry in the Required field.

	currencyExchange := &genai.Tool{
		FunctionDeclarations: []*genai.FunctionDeclaration{{
			Name:        "get_exchange_rate",
			Description: "Lookup currency exchange rates by date",
			Parameters: &genai.Schema{
				Type: genai.TypeObject,
				Properties: map[string]*genai.Schema{
					"currency_date": {
						Type: genai.TypeString,
						Description: "A date that must always be in YYYY-MM-DD format" +
							" or the value 'latest' if a time period is not specified",
					},
					"currency_from": {
						Type:        genai.TypeString,
						Description: "Currency to convert from",
					},
					"currency_to": {
						Type:        genai.TypeString,
						Description: "Currency to convert to",
					},
				},
                                 // Note, "this_param_does_not_exist".
				Required: []string{"currency_date", "currency_from", "this_param_does_not_exist"},
			},
		}},
	}

To help developers, it would be immensely valuable to validate the Required field values.

@jba
Copy link
Collaborator

jba commented Apr 25, 2024

Isn't that something the service should do, not the client? The client generally tries to do minimal validation or manipulation of requests to the service.

@fredsa
Copy link
Contributor Author

fredsa commented Apr 25, 2024

That would be fine as well. Though, I suspect it will be easier for the client library / SDK to provide a much more useful message to the developer, though admittedly at the cost of duplicate complexity across all language client libraries / SDKs.

In short, happy to have the validation happen in either place.

@singhniraj08 singhniraj08 added type:feature request New feature request or enhancement status:triaged Issue/PR triaged to the corresponding sub-team labels Apr 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:triaged Issue/PR triaged to the corresponding sub-team type:feature request New feature request or enhancement
Projects
None yet
Development

No branches or pull requests

3 participants