-
Notifications
You must be signed in to change notification settings - Fork 1.2k
fix: make top_p parameter optional for Azure AI models #347
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -502,9 +502,11 @@ async def handle_websocket_chat(websocket: WebSocket): | |
model_kwargs = { | ||
"model": request.model, | ||
"stream": True, | ||
"temperature": model_config["temperature"], | ||
"top_p": model_config["top_p"] | ||
"temperature": model_config["temperature"] | ||
} | ||
# Only add top_p if it exists in the model config | ||
if "top_p" in model_config: | ||
model_kwargs["top_p"] = model_config["top_p"] | ||
Comment on lines
502
to
+509
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to the change in |
||
|
||
api_kwargs = model.convert_inputs_to_api_kwargs( | ||
input=prompt, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While this change correctly makes
top_p
optional for the Azure provider, it highlights a code duplication issue. The logic for constructingmodel_kwargs
is now identical for theopenrouter
,openai
, andazure
providers. To improve maintainability and adhere to the DRY (Don't Repeat Yourself) principle, consider extracting this common logic into a helper function. This would centralize the logic and make future modifications easier.For example: