|
| 1 | +# Email Data Extraction with OpenAI Agents SDK |
| 2 | + |
| 3 | +This example demonstrates how to use the OpenAI Agents SDK with RagaAI Catalyst to extract structured information from emails. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +The application uses OpenAI's Agents SDK to parse unstructured email text and extract key information such as: |
| 8 | +- Email subject and sender details |
| 9 | +- Main discussion points |
| 10 | +- Meeting information (date, time, location) |
| 11 | +- Action items and tasks with assignees |
| 12 | +- Next steps |
| 13 | + |
| 14 | +The extracted data is structured using Pydantic models for easy manipulation and validation. |
| 15 | + |
| 16 | +## Requirements |
| 17 | + |
| 18 | +- Python 3.8+ |
| 19 | +- OpenAI API key |
| 20 | +- RagaAI Catalyst credentials |
| 21 | + |
| 22 | +## Installation |
| 23 | + |
| 24 | +1. Clone the repository |
| 25 | +2. Install the required dependencies: |
| 26 | +```bash |
| 27 | +pip install -r requirements.txt |
| 28 | +``` |
| 29 | +3. Copy [sample.env](cci:7://file:///Users/ragaai_user/work/ragaai-catalyst/examples/openai_agents_sdk/sample.env:0:0-0:0) to [.env](cci:7://file:///Users/ragaai_user/work/ragaai-catalyst/examples/openai_agents_sdk/sample.env:0:0-0:0) and fill in your API keys: |
| 30 | +```bash |
| 31 | +cp sample.env .env |
| 32 | +``` |
| 33 | + |
| 34 | +## Environment Variables |
| 35 | + |
| 36 | +Configure the following environment variables in your [.env](cci:7://file:///Users/ragaai_user/work/ragaai-catalyst/examples/openai_agents_sdk/sample.env:0:0-0:0) file: |
| 37 | + |
| 38 | +- `OPENAI_API_KEY`: Your OpenAI API key |
| 39 | +- `CATALYST_ACCESS_KEY`: Your RagaAI Catalyst access key |
| 40 | +- `CATALYST_SECRET_KEY`: Your RagaAI Catalyst secret key |
| 41 | +- `CATALYST_BASE_URL`: RagaAI Catalyst base URL |
| 42 | +- `PROJECT_NAME`: Name for your project in RagaAI Catalyst (default: 'email-extraction') |
| 43 | +- `DATASET_NAME`: Name for your dataset in RagaAI Catalyst (default: 'email-data') |
| 44 | + |
| 45 | +## Usage |
| 46 | + |
| 47 | +Run the example script: |
| 48 | + |
| 49 | +```bash |
| 50 | +python data_extraction_email.py |
| 51 | +``` |
| 52 | +The script will: |
| 53 | + |
| 54 | +1. Initialize the RagaAI Catalyst client for tracing |
| 55 | +2. Set up an OpenAI Agent with appropriate instructions |
| 56 | +3. Process a sample email to extract structured data |
| 57 | +4. Display the extracted information |
| 58 | + |
| 59 | +## Customization |
| 60 | + |
| 61 | +You can modify the `sample_email` variable in the script to process different emails, or adapt the code to read emails from files or an API. |
| 62 | + |
| 63 | +The Pydantic models (`Person`, `Meeting`, `Task`, `EmailData`) can be extended to capture additional information as needed. |
| 64 | + |
| 65 | +## Integration with RagaAI Catalyst |
| 66 | + |
| 67 | +This example integrates with RagaAI Catalyst for tracing and monitoring agent interactions. The integration helps with: |
| 68 | + |
| 69 | +- Tracking agent performance |
| 70 | +- Debugging complex agent workflows |
| 71 | +- Collecting data for future improvements |
0 commit comments