Spaces:
Sleeping
Sleeping
Upload multi_agent_workflow.py
Browse files- multi_agent_workflow.py +89 -0
multi_agent_workflow.py
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import requests
|
| 2 |
+
import pandas as pd
|
| 3 |
+
|
| 4 |
+
# Set your SerpAPI key
|
| 5 |
+
API_KEY = "533b5ecf4f322a3e1fb6c6341fc922267805add7e804f7783949a17175ed2f69"
|
| 6 |
+
BASE_URL = "https://serpapi.com/search"
|
| 7 |
+
|
| 8 |
+
def research_company(company_name):
|
| 9 |
+
"""Search for company information using SerpAPI."""
|
| 10 |
+
params = {
|
| 11 |
+
"engine": "google",
|
| 12 |
+
"q": f"{company_name} company overview",
|
| 13 |
+
"api_key": API_KEY,
|
| 14 |
+
"num": 10 # Number of results to return
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
# Perform the search using SerpAPI
|
| 18 |
+
response = requests.get(BASE_URL, params=params)
|
| 19 |
+
|
| 20 |
+
if response.status_code == 200:
|
| 21 |
+
data = response.json()
|
| 22 |
+
|
| 23 |
+
# Extracting relevant information
|
| 24 |
+
results = []
|
| 25 |
+
for item in data.get("organic_results", []):
|
| 26 |
+
title = item.get("title")
|
| 27 |
+
link = item.get("link")
|
| 28 |
+
snippet = item.get("snippet")
|
| 29 |
+
results.append({"Title": title, "Link": link, "Snippet": snippet})
|
| 30 |
+
|
| 31 |
+
return results
|
| 32 |
+
else:
|
| 33 |
+
print(f"Error fetching data: {response.status_code}")
|
| 34 |
+
return None
|
| 35 |
+
|
| 36 |
+
def identify_key_offerings():
|
| 37 |
+
"""Identify key offerings and focus areas."""
|
| 38 |
+
key_offerings = [
|
| 39 |
+
"Consulting Services",
|
| 40 |
+
"Audit Services",
|
| 41 |
+
"Tax Advisory",
|
| 42 |
+
"Risk Management",
|
| 43 |
+
"Financial Advisory",
|
| 44 |
+
"Technology Implementation"
|
| 45 |
+
]
|
| 46 |
+
|
| 47 |
+
focus_areas = [
|
| 48 |
+
"Operations",
|
| 49 |
+
"Supply Chain Management",
|
| 50 |
+
"Customer Experience",
|
| 51 |
+
"Digital Transformation",
|
| 52 |
+
"Sustainability",
|
| 53 |
+
"Cybersecurity"
|
| 54 |
+
]
|
| 55 |
+
|
| 56 |
+
return key_offerings, focus_areas
|
| 57 |
+
|
| 58 |
+
def save_results_to_csv(results, company_name):
|
| 59 |
+
"""Save research results to a CSV file."""
|
| 60 |
+
df = pd.DataFrame(results)
|
| 61 |
+
filename = f"{company_name}_research_results.csv"
|
| 62 |
+
df.to_csv(filename, index=False)
|
| 63 |
+
print(f"Results saved to {filename}")
|
| 64 |
+
return filename
|
| 65 |
+
|
| 66 |
+
if __name__ == "__main__":
|
| 67 |
+
company_name = "Deloitte"
|
| 68 |
+
|
| 69 |
+
print(f"Researching {company_name}...")
|
| 70 |
+
results = research_company(company_name)
|
| 71 |
+
|
| 72 |
+
if results:
|
| 73 |
+
print(f"\nResearch results for {company_name}:")
|
| 74 |
+
for i, item in enumerate(results):
|
| 75 |
+
print(f"{i + 1}: {item['Title']} - {item['Link']}")
|
| 76 |
+
print(f"Snippet: {item['Snippet']}\n")
|
| 77 |
+
|
| 78 |
+
key_offerings, focus_areas = identify_key_offerings()
|
| 79 |
+
|
| 80 |
+
print(f"\nKey Offerings of {company_name}:")
|
| 81 |
+
for offering in key_offerings:
|
| 82 |
+
print(f"- {offering}")
|
| 83 |
+
|
| 84 |
+
print(f"\nStrategic Focus Areas of {company_name}:")
|
| 85 |
+
for area in focus_areas:
|
| 86 |
+
print(f"- {area}")
|
| 87 |
+
|
| 88 |
+
# Save results to CSV
|
| 89 |
+
save_results_to_csv(results, company_name)
|