Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,34 @@ https://github.com/user-attachments/assets/7bc99d61-5c49-4c65-9cf2-36c1c9415559

- **Streaming supported**: Enables real-time streaming of AI responses for low latency applications, with immediate validation of partial outputs. Learn more about [streaming capabilities](https://docs.workflowai.com/python-sdk/agent#streaming).

```python
class ProductInput(BaseModel):
description: str = Field()

class Category(str, enum.Enum):
ELECTRONICS = "Electronics"
CLOTHING = "Clothing"
HOME_GOODS = "Home Goods"
BEAUTY = "Beauty"
SPORTS = "Sports"

class ProductAnalysisOutput(BaseModel):
tags: list[str] = Field(default_factory=list)
summary: str = Field()
category: Category = Field()

@workflowai.agent(id="product-tagger", model=Model.DEEPSEEK_V3_LATEST)
async def product_analyzer(input: ProductInput) -> ProductAnalysisOutput:
"""
Analyze a product description.
"""

async for chunk in product_analyzer.stream(ProductInput(description="....")):
# chunk is a partial ProductAnalysisOutput object. Fields are progressively
# filled, but the object structure respects the type hint even when incomplete.
print(chunk.output)
```

https://github.com/user-attachments/assets/bcb52412-4dcb-45f8-b812-4275824ed543

- **Provider fallback**: Automatically switches to alternative AI providers when the primary provider fails, ensuring high availability and reliability for your AI applications. This feature allows you to define fallback strategies that maintain service continuity even during provider outages or rate limiting.
Expand Down