Files
crewAI/tests/test_response_crew.py
Devin AI f7cca439cc refactor: Implement CrewAI Flow for email processing
- Add EmailState model for Flow state management
- Create EmailProcessingFlow class with event-based automation
- Update tools and crews for Flow integration
- Add comprehensive Flow tests
- Implement error handling and state tracking
- Add mock implementations for testing

This implementation uses CrewAI Flow features to create an event-based
email processing system that can analyze emails, research senders,
and generate appropriate responses using specialized AI crews.

Co-Authored-By: Joe Moura <joao@crewai.com>
2024-12-12 16:00:10 +00:00

46 lines
1.3 KiB
Python

"""Test script for response crew functionality"""
from response_crew import ResponseCrew
from email_analysis_crew import EmailAnalysisCrew
import json
def test_response_crew():
"""Test the response crew functionality"""
try:
# First get analysis results
analysis_crew = EmailAnalysisCrew()
analysis_result = analysis_crew.analyze_email("thread_1")
if not analysis_result.get("response_needed", False):
print("No response needed for this thread")
return True
# Initialize response crew
response_crew = ResponseCrew()
print("\nTesting response crew...")
# Draft response
result = response_crew.draft_response("thread_1", analysis_result)
print("\nResponse Results:")
print(f"Thread ID: {result['thread_id']}")
if result.get("error"):
print(f"Error: {result['error']}")
return False
print("\nContent Strategy:")
print(json.dumps(result['strategy_used'], indent=2))
print("\nFinal Response:")
print(json.dumps(result['response'], indent=2))
print("\nAll tests completed successfully!")
return True
except Exception as e:
print(f"Error during testing: {str(e)}")
return False
if __name__ == "__main__":
test_response_crew()