Release Notes v0.2.1
Release Notes v0.2.1
π New Feature: Pydantic Support
chak now natively supports Pydantic models for tool parameters and return values, bringing type safety and automatic validation to your LLM tool calls.
β¨ What's New
- Type-Safe Function Parameters: Use Pydantic models as function parameters - automatic JSON β object conversion
- Type-Safe Return Values: Return Pydantic models from tools - automatic object β JSON serialization
- Stateful Objects + Pydantic: Combine state persistence with type safety for complex business logic
- Zero Configuration: Just use Pydantic type hints - no decorators or wrappers needed
π Example
from pydantic import BaseModel, Field
class UserInput(BaseModel):
name: str = Field(description="User's full name")
email: str = Field(description="Email address")
age: int
class UserOutput(BaseModel):
id: int
name: str
status: str = "active"
def create_user(user: UserInput) -> UserOutput:
"""Create a new user"""
return UserOutput(id=123, name=user.name)
conv = chak.Conversation(
"openai/gpt-4o",
tools=[create_user]
)
# LLM automatically validates and converts!
response = await conv.asend("Create user: John Doe, john@example.com, 30")