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

fix: add validation for unsupported model settings parameters #869

Conversation

hafsatariq18
Copy link

Fixes #856

This PR adds validation for model settings parameters to prevent silent failures when invalid or unsupported parameters are provided. Previously, passing invalid parameters like "tempural" would not trigger any validation errors.

Changes:

  • Add validate_model_settings function to check for invalid parameters
  • Update merge_model_settings to validate settings before merging
  • Add comprehensive tests for model settings validation
  • Provide clear error messages for invalid parameters

Example usage and error:

model = OpenAIModel(DEPLOYMENT_NAME, openai_client=client)
agent = Agent(model)
result = await agent.run(prompt, result_type=People, model_settings={"tempural": 45})
UserError: Invalid model setting parameter(s): tempural. Valid parameters are: frequency_penalty, logit_bias, max_tokens, parallel_tool_calls, presence_penalty, seed, temperature, timeout, top_p

@github-actions github-actions bot temporarily deployed to deploy-preview February 7, 2025 10:28 Inactive
@github-actions github-actions bot temporarily deployed to deploy-preview February 7, 2025 10:59 Inactive
@github-actions github-actions bot temporarily deployed to deploy-preview February 7, 2025 11:06 Inactive
@hafsatariq18 hafsatariq18 force-pushed the feature/model-settings-validation branch from d5d28e0 to 03cabc9 Compare February 7, 2025 11:10
@github-actions github-actions bot temporarily deployed to deploy-preview February 7, 2025 11:14 Inactive
…iniSafetySettings, remove unnecessary cast calls, fix TypedDict assignment, remove unused import
@github-actions github-actions bot temporarily deployed to deploy-preview February 7, 2025 11:26 Inactive
@hafsatariq18 hafsatariq18 force-pushed the feature/model-settings-validation branch from 2af1b59 to d6e193d Compare February 7, 2025 11:32
@github-actions github-actions bot temporarily deployed to deploy-preview February 7, 2025 11:33 Inactive
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

Successfully merging this pull request may close these issues.

Model Settings does not validate if the parameter name passed is supported by the model or not.
1 participant