Skip to content

Commit 1b4813a

Browse files
author
Pierre
committed
docs: enhance README with key features and practical example
1 parent 9f327ee commit 1b4813a

File tree

1 file changed

+119
-4
lines changed

1 file changed

+119
-4
lines changed

README.md

Lines changed: 119 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,132 @@ Official SDK from [WorkflowAI](https://workflowai.com) for Python.
1111

1212
This SDK is designed for Python teams who prefer code-first development. It provides greater control through direct code integration while still leveraging the full power of the WorkflowAI platform, complementing the web-app experience.
1313

14-
## Installation
14+
## Key Features
1515

16-
`workflowai` requires a python >= 3.9.
16+
- **Model-agnostic**: Works with all major AI models including OpenAI, Anthropic, Claude, Google/Gemini, Mistral, Deepseek, with a unified interface that makes switching between providers seamless.
17+
18+
- **Open-source and flexible deployment**: WorkflowAI is fully open-source with flexible deployment options. Run it self-hosted on your own infrastructure for maximum data control, or use the managed WorkflowAI Cloud service for hassle-free updates and automatic scaling.
19+
20+
- **Observability integrated**: Built-in monitoring and logging capabilities that provide insights into your AI workflows, making debugging and optimization straightforward. Learn more about [observability features](https://docs.workflowai.com/concepts/runs).
21+
22+
- **Cost tracking**: Automatically calculates and tracks the cost of each AI model run, providing transparency and helping you manage your AI budget effectively.
23+
24+
- **Type-safe**: Leverages Python's type system to catch errors at development time rather than runtime, ensuring more reliable AI applications.
25+
26+
- **Structured output**: Uses Pydantic models to validate and structure AI responses. WorkflowAI ensures your AI responses always match your defined structure, simplifying integrations, reducing parsing errors, and making your data reliable and ready for use.
27+
28+
- **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).
29+
30+
- **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.
31+
32+
- **Built-in tools**: Comes with powerful built-in tools like web search and web browsing capabilities, allowing your agents to access real-time information from the internet. These tools enable your AI applications to retrieve up-to-date data, research topics, and interact with web content without requiring complex integrations.
33+
34+
- **Custom tools support**: Easily extend your agents' capabilities by creating custom tools tailored to your specific needs. Whether you need to query internal databases, call external APIs, or perform specialized calculations, WorkflowAI's tool framework makes it simple to augment your AI with domain-specific functionality.
35+
36+
- **Integrated with WorkflowAI**: The SDK seamlessly syncs with the WorkflowAI web application, giving you access to a powerful playground where you can edit prompts and compare models side-by-side. This hybrid approach combines the flexibility of code-first development with the visual tools needed for effective prompt engineering and model evaluation.
37+
38+
## Get Started
39+
40+
`workflowai` requires Python 3.9 or higher.
1741

1842
```sh
1943
pip install workflowai
2044
```
2145

22-
## Get Started
46+
Here's a simple example of a WorkflowAI agent that extracts structured flight information from email content:
47+
48+
49+
```python
50+
import asyncio
51+
from datetime import datetime
52+
from enum import Enum
53+
54+
from pydantic import BaseModel, Field
55+
56+
import workflowai
57+
from workflowai import Model
58+
59+
60+
class EmailInput(BaseModel):
61+
email_content: str
62+
63+
class FlightInfo(BaseModel):
64+
class Status(str, Enum):
65+
"""Possible statuses for a flight booking."""
66+
CONFIRMED = "Confirmed"
67+
PENDING = "Pending"
68+
CANCELLED = "Cancelled"
69+
DELAYED = "Delayed"
70+
COMPLETED = "Completed"
71+
72+
passenger: str
73+
airline: str
74+
flight_number: str
75+
from_airport: str = Field(description="Three-letter IATA airport code for departure")
76+
to_airport: str = Field(description="Three-letter IATA airport code for arrival")
77+
departure: datetime
78+
arrival: datetime
79+
status: Status
80+
81+
@workflowai.agent(
82+
id="flight-info-extractor",
83+
model=Model.GEMINI_2_0_FLASH_LATEST,
84+
)
85+
async def extract_flight_info(email_input: EmailInput) -> FlightInfo:
86+
"""
87+
Extract flight information from an email containing booking details.
88+
"""
89+
...
90+
91+
92+
async def main():
93+
email = """
94+
Dear Jane Smith,
95+
96+
Your flight booking has been confirmed. Here are your flight details:
97+
98+
Flight: UA789
99+
From: SFO
100+
To: JFK
101+
Departure: 2024-03-25 9:00 AM
102+
Arrival: 2024-03-25 5:15 PM
103+
Booking Reference: XYZ789
104+
105+
Total Journey Time: 8 hours 15 minutes
106+
Status: Confirmed
107+
108+
Thank you for choosing United Airlines!
109+
"""
110+
run = await extract_flight_info.run(EmailInput(email_content=email))
111+
print(run)
112+
113+
114+
if __name__ == "__main__":
115+
asyncio.run(main())
116+
117+
118+
# Output:
119+
# ==================================================
120+
# {
121+
# "passenger": "Jane Smith",
122+
# "airline": "United Airlines",
123+
# "flight_number": "UA789",
124+
# "from_airport": "SFO",
125+
# "to_airport": "JFK",
126+
# "departure": "2024-03-25T09:00:00",
127+
# "arrival": "2024-03-25T17:15:00",
128+
# "status": "Confirmed"
129+
# }
130+
# ==================================================
131+
# Cost: $ 0.00009
132+
# Latency: 1.18s
133+
# URL: https://workflowai.com/_/agents/flight-info-extractor/runs/0195ee02-bdc3-72b6-0e0b-671f0b22b3dc
134+
```
135+
> **Ready to run!** This example works straight out of the box - no tweaking needed.
136+
137+
Agents built with `workflowai` SDK can be run in the [WorkflowAI web application](https://workflowai.com/_/agents/flight-info-extractor/runs/0195ee02-bdc3-72b6-0e0b-671f0b22b3dc) too.
23138

24-
Follow the steps in our [Getting Started Guide](https://docs.workflowai.com/python-sdk/get-started).
139+
![WorkflowAI Playground](/examples/assets/web/playground-flight-info-extractor.png)
25140

26141
## Documentation
27142

0 commit comments

Comments
 (0)