Spaces:
Sleeping
Sleeping
Update phase1_agents.py
Browse files- phase1_agents.py +16 -6
phase1_agents.py
CHANGED
|
@@ -5,6 +5,9 @@ from phi.tools.duckduckgo import DuckDuckGo
|
|
| 5 |
from phi.model.openai import OpenAIChat
|
| 6 |
from pydantic import BaseModel, Field
|
| 7 |
from fastapi import UploadFile
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
# Load environment variables (API keys, etc.)
|
| 10 |
from dotenv import load_dotenv
|
|
@@ -31,7 +34,7 @@ def search_company(company_name: str) -> dict:
|
|
| 31 |
""" Searches for detailed company information using web search. """
|
| 32 |
query = f"Find details for {company_name}, including its official website, mission, services, and AI-related initiatives. Include sources."
|
| 33 |
response = company_search_agent.print_response(query)
|
| 34 |
-
return {"company_name": company_name, "details": response}
|
| 35 |
|
| 36 |
|
| 37 |
##############################
|
|
@@ -45,10 +48,17 @@ firecrawl_agent = Agent(
|
|
| 45 |
markdown=True,
|
| 46 |
)
|
| 47 |
|
| 48 |
-
def scrape_website(url
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
|
| 53 |
|
| 54 |
##############################
|
|
@@ -66,7 +76,7 @@ text_processing_agent = Agent(
|
|
| 66 |
def process_company_description(text: str) -> dict:
|
| 67 |
""" Summarizes the user-provided company description. """
|
| 68 |
response = text_processing_agent.print_response(f"Summarize the following description: {text}. Focus on mission, key services, industry, and AI potential.")
|
| 69 |
-
return {"user_description": text, "summary": response}
|
| 70 |
|
| 71 |
|
| 72 |
##############################
|
|
|
|
| 5 |
from phi.model.openai import OpenAIChat
|
| 6 |
from pydantic import BaseModel, Field
|
| 7 |
from fastapi import UploadFile
|
| 8 |
+
from rich.live import Live
|
| 9 |
+
from rich.console import Console
|
| 10 |
+
from rich.errors import LiveError
|
| 11 |
|
| 12 |
# Load environment variables (API keys, etc.)
|
| 13 |
from dotenv import load_dotenv
|
|
|
|
| 34 |
""" Searches for detailed company information using web search. """
|
| 35 |
query = f"Find details for {company_name}, including its official website, mission, services, and AI-related initiatives. Include sources."
|
| 36 |
response = company_search_agent.print_response(query)
|
| 37 |
+
return {"company_name": company_name, "details": response.content}
|
| 38 |
|
| 39 |
|
| 40 |
##############################
|
|
|
|
| 48 |
markdown=True,
|
| 49 |
)
|
| 50 |
|
| 51 |
+
def scrape_website(url):
|
| 52 |
+
try:
|
| 53 |
+
console = Console()
|
| 54 |
+
with Live(console=console, refresh_per_second=10) as live_log:
|
| 55 |
+
response = firecrawl_agent.print_response(f"Extract business details from {url}, including mission, services, and AI-related information.")
|
| 56 |
+
except LiveError:
|
| 57 |
+
# If Live() is already active, print a simple log instead
|
| 58 |
+
response = firecrawl_agent.print_response(f"Extract business details from {url}, including mission, services, and AI-related information.")
|
| 59 |
+
|
| 60 |
+
return response.content
|
| 61 |
+
|
| 62 |
|
| 63 |
|
| 64 |
##############################
|
|
|
|
| 76 |
def process_company_description(text: str) -> dict:
|
| 77 |
""" Summarizes the user-provided company description. """
|
| 78 |
response = text_processing_agent.print_response(f"Summarize the following description: {text}. Focus on mission, key services, industry, and AI potential.")
|
| 79 |
+
return {"user_description": text, "summary": response.content}
|
| 80 |
|
| 81 |
|
| 82 |
##############################
|