Skip to content

Commit

Permalink
Merge pull request #17 from ai-cookbook/dev
Browse files Browse the repository at this point in the history
Refactor FunctionTool model to use default factory for parameters and…
  • Loading branch information
all-mute authored Dec 30, 2024
2 parents 13d8ef4 + a45baaf commit 975fd7a
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion app/yandex/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,15 @@ def check_only_one_field(cls, values):
class FunctionTool(BaseModel):
name: str
description: str = Field(default="")
parameters: Dict[str, Any] = Field(default={})
parameters: Dict[str, Any] = Field(default_factory=dict)

@model_validator(mode='after')
def set_empty_defaults(cls, values):
if values.description is None:
values.description = ""
if values.parameters is None:
values.parameters = {}
return values

class Tool(BaseModel):
function: FunctionTool
Expand Down

0 comments on commit 975fd7a

Please sign in to comment.