Spaces:
Sleeping
Sleeping
File size: 1,358 Bytes
877bedf | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | """
Email Assistant Agent
This module orchestrates the multi-agent architecture for email processing,
following the pattern from the OpenAI Agents SDK notebook.
"""
from typing import Dict, Any
from tools import process_email_with_handoff_agent
def process_email(email_text: str, api_key: str) -> Dict[str, Any]:
"""
Processes an email using the multi-agent architecture.
Args:
email_text (str): The email content to process
api_key (str): OpenAI API key for authentication
Returns:
Dict[str, Any]: Dictionary containing:
- 'success': Boolean indicating if processing was successful
- 'category': Detected email category
- 'summary': Two-sentence email summary
- 'reply': Suggested professional reply
- 'error': Error message if processing failed
"""
# Validate inputs
if not email_text.strip():
return {
'success': False,
'error': 'Email content cannot be empty. Please provide the email text to process.'
}
if not api_key.strip():
return {
'success': False,
'error': 'OpenAI API key is required. Please enter your API key.'
}
# Use the handoff agent architecture
return process_email_with_handoff_agent(email_text, api_key)
|