-
Notifications
You must be signed in to change notification settings - Fork 3
docs: enhance README with key features and add flight info extraction example #79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
1b4813a
docs: enhance README with key features and practical example
54a483e
feat: add flight info extraction example and playground screenshot
e0fbc3d
docs: add multimodality support to key features
b61b070
docs: add link to built-in tools documentation
35be1f8
docs: enhance README with more documentation links and improve example
edeaa0d
docs: add link to WorkflowAI Cloud documentation
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| """ | ||
| This example demonstrates how to create a WorkflowAI agent that extracts flight information from emails. | ||
| It showcases: | ||
|
|
||
| 1. Using Pydantic models for structured data extraction | ||
| 2. Extracting specific details like flight numbers, dates, and times | ||
| """ | ||
|
|
||
| import asyncio | ||
| from datetime import datetime | ||
| from enum import Enum | ||
|
|
||
| from pydantic import BaseModel, Field | ||
|
|
||
| import workflowai | ||
| from workflowai import Model | ||
|
|
||
|
|
||
| class EmailInput(BaseModel): | ||
| """Raw email content containing flight booking details. | ||
| This could be a confirmation email, itinerary update, or e-ticket from any airline.""" | ||
| email_content: str | ||
|
|
||
|
|
||
| class FlightInfo(BaseModel): | ||
| """Model for extracted flight information.""" | ||
| class Status(str, Enum): | ||
| """Possible statuses for a flight booking.""" | ||
| CONFIRMED = "Confirmed" | ||
| PENDING = "Pending" | ||
| CANCELLED = "Cancelled" | ||
| DELAYED = "Delayed" | ||
| COMPLETED = "Completed" | ||
|
|
||
| passenger: str | ||
| airline: str | ||
| flight_number: str | ||
| from_airport: str = Field(description="Three-letter IATA airport code for departure") | ||
| to_airport: str = Field(description="Three-letter IATA airport code for arrival") | ||
| departure: datetime | ||
| arrival: datetime | ||
| status: Status | ||
|
|
||
| @workflowai.agent( | ||
| id="flight-info-extractor", | ||
| model=Model.GEMINI_2_0_FLASH_LATEST, | ||
| ) | ||
| async def extract_flight_info(email_input: EmailInput) -> FlightInfo: | ||
| """ | ||
| Extract flight information from an email containing booking details. | ||
| """ | ||
| ... | ||
|
|
||
pierrevalade marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| async def main(): | ||
| email = """ | ||
| Dear Jane Smith, | ||
|
|
||
| Your flight booking has been confirmed. Here are your flight details: | ||
|
|
||
| Flight: UA789 | ||
| From: SFO | ||
| To: JFK | ||
| Departure: 2024-03-25 9:00 AM | ||
| Arrival: 2024-03-25 5:15 PM | ||
| Booking Reference: XYZ789 | ||
|
|
||
| Total Journey Time: 8 hours 15 minutes | ||
| Status: Confirmed | ||
|
|
||
| Thank you for choosing United Airlines! | ||
| """ | ||
| run = await extract_flight_info.run(EmailInput(email_content=email)) | ||
| print(run) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| asyncio.run(main()) | ||
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.