dromerosm commited on
Commit
c458cbf
1 Parent(s): d9e6fe6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -13
app.py CHANGED
@@ -9,7 +9,9 @@ from langchain_cohere import ChatCohere
9
 
10
  from langchain_community.tools import DuckDuckGoSearchRun, DuckDuckGoSearchResults
11
  from crewai_tools import tool, SeleniumScrapingTool, ScrapeWebsiteTool
12
- from duckduckgo_search import DDGS # Asegúrate de tener instalado el paquete duckduckgo_search
 
 
13
 
14
  # Ensure essential environment variables are set
15
  cohere_api_key = os.getenv('COHERE_API_KEY')
@@ -22,19 +24,14 @@ if not groq_api_key:
22
  # Initialize API clients
23
  co = cohere.Client(cohere_api_key)
24
 
25
- # Jina.ai API key
26
- jina_api_key = os.getenv('JINA_API_KEY')
27
-
28
  def fetch_content(url):
29
  try:
30
- response = requests.get(
31
- f"https://r.jina.ai/{url}",
32
- headers={"Authorization": f"Bearer {jina_api_key}"}
33
- )
34
- response.raise_for_status()
35
- return response.text
36
- except requests.exceptions.RequestException as e:
37
- print ("ERROR: " + e)
38
  return f"Error fetching content: {e}"
39
 
40
  # Define the DuckDuckGoSearch tool
@@ -95,7 +92,7 @@ def kickoff_crew(topic: str) -> dict:
95
  try:
96
 
97
  # Initialize the large language models
98
- groq_llm_70b = ChatGroq(temperature=0, groq_api_key=groq_api_key, model_name="llama3-70b-8192")
99
  cohere_llm = ChatCohere(
100
  temperature=0,
101
  cohere_api_key=cohere_api_key,
 
9
 
10
  from langchain_community.tools import DuckDuckGoSearchRun, DuckDuckGoSearchResults
11
  from crewai_tools import tool, SeleniumScrapingTool, ScrapeWebsiteTool
12
+ from duckduckgo_search import DDGS
13
+
14
+ from newspaper import Article
15
 
16
  # Ensure essential environment variables are set
17
  cohere_api_key = os.getenv('COHERE_API_KEY')
 
24
  # Initialize API clients
25
  co = cohere.Client(cohere_api_key)
26
 
 
 
 
27
  def fetch_content(url):
28
  try:
29
+ article = Article(url)
30
+ article.download()
31
+ article.parse()
32
+ return article.text
33
+ except Exception as e:
34
+ print("ERROR: " + str(e))
 
 
35
  return f"Error fetching content: {e}"
36
 
37
  # Define the DuckDuckGoSearch tool
 
92
  try:
93
 
94
  # Initialize the large language models
95
+ groq_llm_70b = ChatGroq(temperature=0, groq_api_key=groq_api_key, model_name="llama-3.1-70b-versatile")
96
  cohere_llm = ChatCohere(
97
  temperature=0,
98
  cohere_api_key=cohere_api_key,