import os
from datetime import datetime
from pydantic import BaseModel, Field
from crewai.flow.flow import Flow, listen, start
# from tools.tools import listener
from pydantic_types import CalendarDetails
from crews.calendar_utils_crew.calendar_utils_crew import CalendarUtilsCrew
# Define State for the Flow
class EmailProcessingState(BaseModel):
email: str = None
thread_id: str = None
sender: str = None
cc_emails: list = None
# calendar_details: CalendarDetails = None
# processing_complete: bool = False
# Define the Flow class for CalendarUtils
class CalendarSchedulingFlow(Flow[EmailProcessingState]):
@start()
def start_calendar_utils(self):
print("inside start flow...")
crew_inputs = {
"sender_mail": self.state.sender,
"cc_emails": self.state.cc_emails,
"thread_id": self.state.thread_id,
"message": self.state.email
}
print(crew_inputs)
result = CalendarUtilsCrew().crew().kickoff(inputs=crew_inputs)
print(result)
return result
@listen("start_calendar_utils")
def process_calendar_details(self, calendar_output: CalendarDetails):
self.update_state(calendar_details=calendar_output, processing_complete=True)
print('calendar_output',calendar_output)
print("Processed Calendar Details:")
print("Timezone:", calendar_output.timezone)
print("Current Datetime:", calendar_output.current_datetime)
print("Calendar IDs:", calendar_output.calendar_ids)
def kickoff(email_inputs):
print('kickoff........')
print(email_inputs)
calendar_flow = CalendarSchedulingFlow()
calendar_flow.kickoff(email_inputs)
if __name__ == "__main__":
print("Starting Gmail Listener...")
# listener.wait_forever()
email_inputs = {'email': 'Hey gia,\r\nplease book a meeting for 1 hour tomm?\r\n', 'thread_id': '1936fbacfa9ea0c3', 'sender': 'rakshit gupta <guptarakshit2000@gmail.com>', 'cc_emails': [], 'subject': 'book meeting'}
kickoff(email_inputs)
Traceback (most recent call last):
File “/Users/rakshitgupta/Desktop/AGEIA/02 Project/Agiea-experiments/email_flow/main.py”, line 103, in
kickoff(email_inputs)
File “/Users/rakshitgupta/Desktop/AGEIA/02 Project/Agiea-experiments/email_flow/main.py”, line 54, in kickoff
calendar_flow.kickoff(email_inputs)
TypeError: Flow.kickoff() takes 1 positional argument but 2 were given