Download components/Event_ai/crew.py from Sench729/EventHub: direct link, hf CLI and curl.
- Browser
- Download file 2.11 kB
-
https://huggingface.co/spaces/Sench729/EventHub/resolve/main/components/Event_ai/crew.py
- Command line
-
hf download hf://spaces/Sench729/EventHub/components/Event_ai/crew.py
-
curl -L -o crew.py https://huggingface.co/spaces/Sench729/EventHub/resolve/main/components/Event_ai/crew.py
2.11 kB
| from typing import List | |
| from crewai import Agent, Crew, Process, Task, LLM | |
| from crewai.project import CrewBase, agent, task, crew | |
| from crewai_tools import SerperDevTool, ScrapeWebsiteTool | |
| from pydantic import BaseModel, Field | |
| from dotenv import load_dotenv | |
| _ = load_dotenv() | |
| llm = LLM( | |
| model="gemini/gemini-2.0-flash", | |
| temperature=0.7, | |
| ) | |
| class EventProposal(BaseModel): | |
| title: str = Field(..., description="The event title") | |
| description: str = Field(..., description="Event description, max 200 words") | |
| tags: List[str] = Field(..., description="List of 5 suggested tags") | |
| class EventProposals(BaseModel): | |
| proposals: List[EventProposal] = Field(..., description="List of event proposals") | |
| class EventContentCrew: | |
| """Crew for generating and validating event proposals""" | |
| agents_config = "config/agents.yaml" | |
| tasks_config = "config/tasks.yaml" | |
| def event_generator(self) -> Agent: | |
| return Agent( | |
| config=self.agents_config["event_generator"], | |
| llm=llm, | |
| inject_date=True, | |
| tools=[ | |
| SerperDevTool() | |
| ] | |
| ) | |
| def event_validator(self) -> Agent: | |
| return Agent( | |
| config=self.agents_config["event_validator"], | |
| llm=llm, | |
| inject_date=True, | |
| ) | |
| def generate_event_content(self) -> Task: | |
| return Task( | |
| config=self.tasks_config["generate_event_content"], | |
| agent=self.event_generator(), | |
| output_json=EventProposals | |
| ) | |
| def validate_event_content(self) -> Task: | |
| return Task( | |
| config=self.tasks_config["validate_event_content"], | |
| agent=self.event_validator(), | |
| output_json=EventProposals | |
| ) | |
| def eventcrew(self) -> Crew: | |
| """Creates the event crew""" | |
| return Crew( | |
| agents=self.agents, | |
| tasks=self.tasks, | |
| process=Process.sequential, | |
| verbose=True, | |
| planning=False, | |
| max_rpm=3, | |
| ) | |