mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
Python: Fix falsy values being filtered out in ChatOptions.to_provider_settings (#787)
* Python: Fix temperature=0 filtered out in chat options * fix failing tests --------- Co-authored-by: Chris <66376200+crickman@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
Unverified
parent
5e5761b288
commit
4c80e7017d
@@ -1870,10 +1870,17 @@ class ChatOptions(AFBaseModel):
|
||||
# No tool choice if no tools are defined
|
||||
if self.tools is None or len(self.tools) == 0:
|
||||
default_exclude.add("tool_choice")
|
||||
# No metadata and logit bias if they are empty
|
||||
# Prevents 400 error
|
||||
if not self.logit_bias:
|
||||
default_exclude.add("logit_bias")
|
||||
if not self.metadata:
|
||||
default_exclude.add("metadata")
|
||||
|
||||
merged_exclude = default_exclude if exclude is None else default_exclude | set(exclude)
|
||||
|
||||
settings = self.model_dump(exclude_none=True, by_alias=by_alias, exclude=merged_exclude)
|
||||
settings = {k: v for k, v in settings.items() if v}
|
||||
settings = {k: v for k, v in settings.items() if v is not None}
|
||||
settings.update(self.additional_properties)
|
||||
for key in merged_exclude:
|
||||
settings.pop(key, None)
|
||||
|
||||
Reference in New Issue
Block a user