Skip to content

style: format code with Ruff Formatter #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 4 additions & 12 deletions app/crew/crew.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,25 +42,17 @@ def get_research_crew(query: ResearchQuery) -> Crew:
relevancy_agent = get_relevancy_agent(AgentInput(query=query))
research_agent = get_research_agent(AgentInput(query=query, tools=[serper_tool]))
query_agent = get_query_agent(AgentInput(query=query))
retrieval_agent = get_retrieval_agent(
AgentInput(query=query, tools=[serper_tool, qdrant_tool])
)
retrieval_agent = get_retrieval_agent(AgentInput(query=query, tools=[serper_tool, qdrant_tool]))
synthesizer_agent = get_synthesizer_agent(AgentInput(query=query))

# Initialize tasks with assigned agents
question_relevancy_task = get_question_relevancy_task(
TaskInput(relevancy_agent, query)
)
research_approach_task = get_research_approach_creation_task(
TaskInput(research_agent, query, [serper_tool])
)
question_relevancy_task = get_question_relevancy_task(TaskInput(relevancy_agent, query))
research_approach_task = get_research_approach_creation_task(TaskInput(research_agent, query, [serper_tool]))
search_query_task = get_search_query_generation_task(TaskInput(query_agent, query))
rag_retrieval_task = get_rag_retrieval_results_task(
TaskInput(retrieval_agent, query, [qdrant_tool], [search_query_task])
)
web_search_task = get_web_search_results_task(
TaskInput(retrieval_agent, query, [serper_tool], [search_query_task])
)
web_search_task = get_web_search_results_task(TaskInput(retrieval_agent, query, [serper_tool], [search_query_task]))
keep_relevant_data_task = get_keep_relevant_data_task(
TaskInput(relevancy_agent, query, [], [rag_retrieval_task, web_search_task])
)
Expand Down
42 changes: 7 additions & 35 deletions app/crew/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,7 @@

@traceable(run_type="task")
def get_question_relevancy_task(task_input: TaskInput) -> Task:
output_file = (
task_input.output_file
if task_input.output_file
else Path("out" / "question_relevancy.txt")
)
output_file = task_input.output_file if task_input.output_file else Path("out" / "question_relevancy.txt")
return Task(
agent=task_input.agent,
description=f"Evaluate if the question '{task_input.query.query}' is relevant for research. Consider factors such as clarity, specificity, research potential, and whether it is answerable through research. Flag questions that are too vague, nonsensical, or impossible to research effectively.{task_input.query.context_info}",
Expand All @@ -32,11 +28,7 @@ def get_question_relevancy_task(task_input: TaskInput) -> Task:

@traceable(run_type="task")
def get_research_approach_creation_task(task_input: TaskInput) -> Task:
output_file = (
task_input.output_file
if task_input.output_file
else Path("out" / "research_approach.txt")
)
output_file = task_input.output_file if task_input.output_file else Path("out" / "research_approach.txt")
return Task(
agent=task_input.agent,
description=f"Create a comprehensive research approach for the question: '{task_input.query.query}'. Outline the key areas to investigate, potential sources of information, and methodologies to employ. Consider different angles and perspectives that might provide valuable insights.{task_input.query.context_info}",
Expand All @@ -53,11 +45,7 @@ def get_research_approach_creation_task(task_input: TaskInput) -> Task:

@traceable(run_type="task")
def get_search_query_generation_task(task_input: TaskInput) -> Task:
output_file = (
task_input.output_file
if task_input.output_file
else Path("out" / "search_queries.txt")
)
output_file = task_input.output_file if task_input.output_file else Path("out" / "search_queries.txt")
return Task(
agent=task_input.agent,
description=f"Generate a diverse set of search queries related to the research question: '{task_input.query.query}'. Create at least 5 distinct search queries that will help gather comprehensive information. Queries should target different aspects of the question and use varying keywords to maximize relevant results.{task_input.query.context_info}",
Expand All @@ -74,11 +62,7 @@ def get_search_query_generation_task(task_input: TaskInput) -> Task:

@traceable(run_type="task")
def get_rag_retrieval_results_task(task_input: TaskInput) -> Task:
output_file = (
task_input.output_file
if task_input.output_file
else Path("out" / "rag_retrieval_results.txt")
)
output_file = task_input.output_file if task_input.output_file else Path("out" / "rag_retrieval_results.txt")
return Task(
agent=task_input.agent,
description=f"Using Retrieval Augmented Generation (RAG), retrieve relevant information from the knowledge base to answer the research question: '{task_input.query.query}'. Focus on finding high-quality, accurate information that directly addresses the question and provides context.{task_input.query.context_info}",
Expand All @@ -95,11 +79,7 @@ def get_rag_retrieval_results_task(task_input: TaskInput) -> Task:

@traceable(run_type="task")
def get_web_search_results_task(task_input: TaskInput) -> Task:
output_file = (
task_input.output_file
if task_input.output_file
else Path("out" / "web_search_results.txt")
)
output_file = task_input.output_file if task_input.output_file else Path("out" / "web_search_results.txt")
return Task(
agent=task_input.agent,
description=f"Conduct comprehensive web searches using the generated queries to find the most relevant and up-to-date information related to the research question: '{task_input.query.query.query}'. Focus on authoritative sources, recent publications, and diverse perspectives.{task_input.query.context_info}",
Expand All @@ -116,11 +96,7 @@ def get_web_search_results_task(task_input: TaskInput) -> Task:

@traceable(run_type="task")
def get_keep_relevant_data_task(task_input: TaskInput) -> Task:
output_file = (
task_input.output_file
if task_input.output_file
else Path("out" / "relevant_data.txt")
)
output_file = task_input.output_file if task_input.output_file else Path("out" / "relevant_data.txt")
return Task(
agent=task_input.agent,
description=f"Critically evaluate all gathered information (from RAG and web searches) based on its direct relevance to the research question: '{task_input.query.query.query}'. Apply a strict filter, discarding any information that is tangential, low-quality, or lacks credible sourcing. Retain only the most pertinent and verifiable data points.{task_input.query.context_info}",
Expand All @@ -137,11 +113,7 @@ def get_keep_relevant_data_task(task_input: TaskInput) -> Task:

@traceable(run_type="task")
def get_summarizing_task(task_input: TaskInput) -> Task:
output_file = (
task_input.output_file
if task_input.output_file
else Path("out" / "research_synthesis.txt")
)
output_file = task_input.output_file if task_input.output_file else Path("out" / "research_synthesis.txt")
return Task(
agent=task_input.agent,
description=f"Synthesize the curated, relevant information into a final, comprehensive, and coherent report answering the research question: '{task_input.query.query}'. Integrate the verified data points, ensuring a logical flow and addressing the core aspects of the query. *Crucially, every statement or piece of information presented must be accurately attributed to its source* based on the curated data provided in the context.{task_input.query.context_info}",
Expand Down
8 changes: 2 additions & 6 deletions app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ class AgentInput(BaseModel):
...,
description="The research query to be processed by the agent.",
)
tools: list[BaseTool] | None = Field(
None, description="List of tools available to the agent."
)
tools: list[BaseTool] | None = Field(None, description="List of tools available to the agent.")


class TaskInput(BaseModel):
Expand All @@ -24,9 +22,7 @@ class TaskInput(BaseModel):
...,
description="The research query to be processed by the task.",
)
tools: list[BaseTool] | None = Field(
None, description="List of tools available to the task."
)
tools: list[BaseTool] | None = Field(None, description="List of tools available to the task.")
context: list[Task] | None = Field(
None,
description="List of tasks that are contextually relevant to this task.",
Expand Down
4 changes: 1 addition & 3 deletions app/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ def __eq__(self, other: "ResearchQuery") -> bool:
@computed_field
@property
def context_info(self) -> str:
return (
f"\nAdditional Context: {self.query.context}" if self.query.context else ""
)
return f"\nAdditional Context: {self.query.context}" if self.query.context else ""


class ResearchResponse(BaseModel):
Expand Down
Loading