Spaces:
Sleeping
Sleeping
| import sys | |
| from crewai import Agent, Crew, Process, Task, LLM | |
| from crewai.project import CrewBase, agent, crew, task | |
| from src.research_agent.tools.tool import search_tool, website_search_tool,pdf_search_tool | |
| import streamlit as st | |
| import os | |
| from dotenv import load_dotenv | |
| load_dotenv() | |
| sys.path.append('..') | |
| class MarketUseCaseCrew: | |
| def llm(self): | |
| return LLM(model="openrouter/google/gemini-2.0-flash-001", base_url="https://openrouter.ai/api/v1", api_key=os.getenv("OPENROUTER_API_KEY")) | |
| def researcher(self) -> Agent: | |
| return Agent( | |
| config=self.agents_config['researcher'], | |
| tools=[search_tool,website_search_tool, pdf_search_tool], # Example of custom tool, loaded on the beginning of file | |
| verbose=True, | |
| llm=self.llm(), | |
| allow_delegation=True, | |
| ) | |
| def design_thinker(self) -> Agent: | |
| return Agent( | |
| config=self.agents_config['design_thinker'], | |
| verbose=True, | |
| tools=[search_tool, website_search_tool], | |
| llm=self.llm(), | |
| allow_delegation=True, | |
| ) | |
| def developer(self) -> Agent: | |
| return Agent( | |
| config=self.agents_config['developer'], | |
| verbose=True, | |
| tools=[search_tool, website_search_tool, pdf_search_tool], | |
| llm=self.llm(), | |
| allow_delegation=True, | |
| ) | |
| def research_task(self) -> Task: | |
| return Task( | |
| config=self.tasks_config['research_task'], | |
| output_file=f'output/researched_data.md', | |
| ) | |
| def design_task(self) -> Task: | |
| return Task( | |
| config=self.tasks_config['design_task'], | |
| output_file=f'output/ideas.md' | |
| ) | |
| def resource_collector(self) -> Task: | |
| return Task( | |
| config=self.tasks_config['resource_collector'], | |
| output_file=f'output/resouce.md' | |
| ) | |
| def crew(self) -> Crew: | |
| """Creates the ResearchAgent crew""" | |
| return Crew( | |
| agents=self.agents, # Automatically created by the @agent decorator | |
| tasks=self.tasks, # Automatically created by the @task decorator | |
| process=Process.sequential, | |
| verbose=True, | |
| # process=Process.hierarchical, # In case you wanna use that instead https://docs.crewai.com/how-to/Hierarchical/ | |
| ) |