i am trying to deploy my flow on the AMP, and when i using the chat and add my query – it tells me to add all the states of the flow
this is the response that come from the chat
”””Hey! I’m here to help you with contentcreatorflow. Could you please provide me with youtubesearchquery, websiteurl, routerdecision, youtubeurl, summary, toreview, user_input so we can get started?
For your question, you shared a YouTube link about a car. If you want me to find the price and engine details, please confirm if you want me to analyze the video or if you have specific details to provide.”””
and when i am looking in the tracing i see it can’t use the tools correctly, but when iam using the kickoff on my ide terminal everything is working as expected, here is my flow to have an idea
from pydantic import BaseModel
from typing import Optional
from enum import Enum
from crewai.flow.flow import Flow, listen, start, router
from content_creator_flow.crews.router_crew.router_crew import RouterCrew
from content_creator_flow.crews.web_scraper.scraper_crew import ScraperCrew
from content_creator_flow.crews.reviewer_crew.reviewer_crew import ReviewerCrew
from content_creator_flow.crews.youtube_crew.youtube_crew import YoutubeCrew
from content_creator_flow.crews.general_crew.general_crew import GeneralCrew
class ContentCreatorState(BaseModel):
user_input: str = ""
router_decision: str = ""
website_url: Optional[str] = None
youtube_url: Optional[str] = None
youtube_search_query: Optional[str] = None
to_review: Optional[str] = None
summary: Optional[str] = None
class RouterDecision(str, Enum):
WEB_CONTENT = "web_content"
YOUTUBE_CONTENT = "youtube_content"
CONTENT_REVIEW = "content_review"
GENERAL = "general"
class ContentCreatorFlow(Flow[ContentCreatorState]):
@start()
def get_input(self):
print("Getting website URL")
self.state.user_input = "ازيك يا ابو الصحاب؟"
@router(get_input)
def route_request(self):
print("Routing request...")
result = (
RouterCrew()
.crew()
.kickoff(
inputs={"user_input": self.state.user_input}
)
)
try:
router_output = result.pydantic
self.state.router_decision = router_output.router_decision
self.state.website_url = router_output.website_url
try:
self.state.youtube_url = router_output.youtube_content.youtube_url
self.state.youtube_search_query = router_output.youtube_content.search_query
except:
self.state.youtube_url = None
self.state.youtube_search_query = None
self.state.to_review = router_output.to_review
print(f"Router decision: {self.state.router_decision}")
if self.state.router_decision == RouterDecision.WEB_CONTENT:
return "scraper"
if self.state.router_decision == RouterDecision.YOUTUBE_CONTENT:
return "youtube"
if self.state.router_decision == RouterDecision.CONTENT_REVIEW:
return "review"
return "general"
except Exception as e:
print(f"Error processing router output: {str(e)}")
print(f"Raw output: {result}")
return "error"
@listen("scraper")
def scrape_crew(self):
print("Summarizing website...")
result = (
ScraperCrew()
.crew()
.kickoff(inputs={
"website_url": self.state.website_url
})
)
print("Summary generated")
self.state.summary = result
@listen("youtube")
def youtube_crew(self):
print("Summarizing YouTube content...")
result = (
YoutubeCrew()
.crew()
.kickoff(inputs={
"search_query": self.state.youtube_search_query,
"youtube_url": self.state.youtube_url,
})
)
print("Summary generated")
self.state.summary = result
@listen("review")
def review_crew(self):
print("Reviewing content...")
result = (
ReviewerCrew()
.crew()
.kickoff(inputs={
"to_review": self.state.to_review or "No summary available"
})
)
print("Review completed")
self.state.summary = result
@listen("general")
def general_crew(self):
print("Generalizing content...")
result = (
GeneralCrew()
.crew()
.kickoff(inputs={
"user_input": self.state.user_input or "No summary available"
})
)
print("Generalization completed")
self.state.summary = result
def kickoff():
content_creator_flow = ContentCreatorFlow()
content_creator_flow.kickoff()
def plot():
content_creator_flow = ContentCreatorFlow()
content_creator_flow.plot()
if __name__ == "__main__":
kickoff()