Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -3,7 +3,7 @@ import gradio as gr
|
|
3 |
from crewai import Agent, Task, Crew
|
4 |
from langchain_groq import ChatGroq
|
5 |
from langchain_community.tools import DuckDuckGoSearchRun, DuckDuckGoSearchResults
|
6 |
-
from crewai_tools import tool
|
7 |
|
8 |
# Define the DuckDuckGoSearch tool using the decorator for tool registration
|
9 |
@tool('DuckDuckGoSearch')
|
@@ -17,6 +17,12 @@ def search_results(search_query: str):
|
|
17 |
"""Search the web for information and sources on a given topic with links and titles."""
|
18 |
return DuckDuckGoSearchResults().run(search_query)
|
19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
def kickoff_crew(topic: str) -> dict:
|
21 |
"""Kickoff the research process for a given topic using CrewAI components."""
|
22 |
# Retrieve the API key from the environment variables
|
@@ -31,7 +37,7 @@ def kickoff_crew(topic: str) -> dict:
|
|
31 |
researcher = Agent(
|
32 |
role='Researcher',
|
33 |
goal=f'Collect detailed information on {topic}',
|
34 |
-
tools=[search, search_results],
|
35 |
llm=groq_llm,
|
36 |
backstory=(
|
37 |
"As a diligent researcher, you explore the depths of the internet to "
|
@@ -45,21 +51,23 @@ def kickoff_crew(topic: str) -> dict:
|
|
45 |
|
46 |
editor = Agent(
|
47 |
role='Editor',
|
48 |
-
goal='Compile and refine the information into a comprehensive report on {topic}',
|
49 |
llm=groq_llm,
|
50 |
backstory=(
|
51 |
"With a keen eye for detail and a strong command of language, you transform "
|
52 |
"raw data into polished, insightful reports that are both informative and engaging."
|
|
|
53 |
),
|
54 |
allow_delegation=False,
|
55 |
-
max_iter=
|
56 |
verbose=True
|
57 |
)
|
58 |
|
59 |
# Define Tasks
|
60 |
research_task = Task(
|
61 |
description=(
|
62 |
-
"Use DuckDuckGoSearch and DuckDuckGoSearchResults to gather information about {topic}.
|
|
|
63 |
"Compile your findings into an initial draft. "
|
64 |
"Gather all the sources with title and link relevant to the topic. "
|
65 |
"Be sure you don't make up or invent any information."
|
|
|
3 |
from crewai import Agent, Task, Crew
|
4 |
from langchain_groq import ChatGroq
|
5 |
from langchain_community.tools import DuckDuckGoSearchRun, DuckDuckGoSearchResults
|
6 |
+
from crewai_tools import tool, SeleniumScrapingTool
|
7 |
|
8 |
# Define the DuckDuckGoSearch tool using the decorator for tool registration
|
9 |
@tool('DuckDuckGoSearch')
|
|
|
17 |
"""Search the web for information and sources on a given topic with links and titles."""
|
18 |
return DuckDuckGoSearchResults().run(search_query)
|
19 |
|
20 |
+
# Define the WebScrapper tool
|
21 |
+
@tool('WebScrapper')
|
22 |
+
def web_scrapper(url: str):
|
23 |
+
"""Download information from a web page using its URL"""
|
24 |
+
return SeleniumScrapingTool(website_url=url)
|
25 |
+
|
26 |
def kickoff_crew(topic: str) -> dict:
|
27 |
"""Kickoff the research process for a given topic using CrewAI components."""
|
28 |
# Retrieve the API key from the environment variables
|
|
|
37 |
researcher = Agent(
|
38 |
role='Researcher',
|
39 |
goal=f'Collect detailed information on {topic}',
|
40 |
+
tools=[search, search_results, web_scrapper],
|
41 |
llm=groq_llm,
|
42 |
backstory=(
|
43 |
"As a diligent researcher, you explore the depths of the internet to "
|
|
|
51 |
|
52 |
editor = Agent(
|
53 |
role='Editor',
|
54 |
+
goal='Compile and refine the information into a comprehensive and elaborated report on {topic}',
|
55 |
llm=groq_llm,
|
56 |
backstory=(
|
57 |
"With a keen eye for detail and a strong command of language, you transform "
|
58 |
"raw data into polished, insightful reports that are both informative and engaging."
|
59 |
+
"The length of each section shall be at least 3 paragraphs."
|
60 |
),
|
61 |
allow_delegation=False,
|
62 |
+
max_iter=5,
|
63 |
verbose=True
|
64 |
)
|
65 |
|
66 |
# Define Tasks
|
67 |
research_task = Task(
|
68 |
description=(
|
69 |
+
"Use DuckDuckGoSearch and DuckDuckGoSearchResults to gather information about {topic}."
|
70 |
+
"Use WebScrapper to extract information and insights from links or urls."
|
71 |
"Compile your findings into an initial draft. "
|
72 |
"Gather all the sources with title and link relevant to the topic. "
|
73 |
"Be sure you don't make up or invent any information."
|