Tool default values aren't detected when BaseModel is supplied
Here's a minimal example where the default for `b` isn't respected.
```python
from chatlas import Tool
from pydantic import BaseModel, Field
class AddParams(BaseModel):
"""Add two numbers together."""
a: int = Field(description="The first number to add.")
b: int = Field(description="The second number to add.")
def add(a, b=1) -> int:
return a + b
tool = Tool.from_func(add, model=AddParams)
func = tool.schema["function"]
params = func.get("parameters", {})
props = params["properties"]
assert props["b"]["default"] == 1
```
Note that this isn't an issue if either:
1. The `default` is supplied to `Field`
2. The `AddParams` model isn't supplied.
关闭于 2026-01-02 0 条评论