You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
121 lines
3.3 KiB
121 lines
3.3 KiB
2 months ago
|
import os
|
||
|
from dotenv import load_dotenv
|
||
|
from swarms import Agent
|
||
|
from swarm_models import OpenAIChat
|
||
|
from swarms.structs.swarm_router import SwarmRouter
|
||
|
|
||
|
load_dotenv()
|
||
|
|
||
|
# Get the OpenAI API key from the environment variable
|
||
|
api_key = os.getenv("GROQ_API_KEY")
|
||
|
|
||
|
# Model
|
||
|
model = OpenAIChat(
|
||
|
openai_api_base="https://api.groq.com/openai/v1",
|
||
|
openai_api_key=api_key,
|
||
|
model_name="llama-3.1-70b-versatile",
|
||
|
temperature=0.1,
|
||
|
)
|
||
|
|
||
|
|
||
|
# Initialize specialized agents
|
||
|
data_extractor_agent = Agent(
|
||
|
agent_name="Data-Extractor",
|
||
2 months ago
|
system_prompt="You are a data extraction specialist. Extract relevant information from provided content.",
|
||
2 months ago
|
llm=model,
|
||
|
max_loops=1,
|
||
|
autosave=True,
|
||
|
verbose=True,
|
||
|
dynamic_temperature_enabled=True,
|
||
|
saved_state_path="data_extractor_agent.json",
|
||
|
user_name="pe_firm",
|
||
|
retry_attempts=1,
|
||
|
context_length=200000,
|
||
|
output_type="string",
|
||
|
)
|
||
|
|
||
|
summarizer_agent = Agent(
|
||
|
agent_name="Document-Summarizer",
|
||
2 months ago
|
system_prompt="You are a document summarization specialist. Provide clear and concise summaries.",
|
||
2 months ago
|
llm=model,
|
||
|
max_loops=1,
|
||
|
autosave=True,
|
||
|
verbose=True,
|
||
|
dynamic_temperature_enabled=True,
|
||
|
saved_state_path="summarizer_agent.json",
|
||
|
user_name="pe_firm",
|
||
|
retry_attempts=1,
|
||
|
context_length=200000,
|
||
|
output_type="string",
|
||
|
)
|
||
|
|
||
|
financial_analyst_agent = Agent(
|
||
|
agent_name="Financial-Analyst",
|
||
2 months ago
|
system_prompt="You are a financial analysis specialist. Analyze financial aspects of content.",
|
||
2 months ago
|
llm=model,
|
||
|
max_loops=1,
|
||
|
autosave=True,
|
||
|
verbose=True,
|
||
|
dynamic_temperature_enabled=True,
|
||
|
saved_state_path="financial_analyst_agent.json",
|
||
|
user_name="pe_firm",
|
||
|
retry_attempts=1,
|
||
|
context_length=200000,
|
||
|
output_type="string",
|
||
|
)
|
||
|
|
||
|
market_analyst_agent = Agent(
|
||
|
agent_name="Market-Analyst",
|
||
2 months ago
|
system_prompt="You are a market analysis specialist. Analyze market-related aspects.",
|
||
2 months ago
|
llm=model,
|
||
|
max_loops=1,
|
||
|
autosave=True,
|
||
|
verbose=True,
|
||
|
dynamic_temperature_enabled=True,
|
||
|
saved_state_path="market_analyst_agent.json",
|
||
|
user_name="pe_firm",
|
||
|
retry_attempts=1,
|
||
|
context_length=200000,
|
||
|
output_type="string",
|
||
|
)
|
||
|
|
||
|
operational_analyst_agent = Agent(
|
||
|
agent_name="Operational-Analyst",
|
||
2 months ago
|
system_prompt="You are an operational analysis specialist. Analyze operational aspects.",
|
||
2 months ago
|
llm=model,
|
||
|
max_loops=1,
|
||
|
autosave=True,
|
||
|
verbose=True,
|
||
|
dynamic_temperature_enabled=True,
|
||
|
saved_state_path="operational_analyst_agent.json",
|
||
|
user_name="pe_firm",
|
||
|
retry_attempts=1,
|
||
|
context_length=200000,
|
||
|
output_type="string",
|
||
|
)
|
||
|
|
||
|
# Initialize the SwarmRouter
|
||
|
router = SwarmRouter(
|
||
|
name="pe-document-analysis-swarm",
|
||
|
description="Analyze documents for private equity due diligence and investment decision-making",
|
||
|
max_loops=1,
|
||
|
agents=[
|
||
|
data_extractor_agent,
|
||
|
summarizer_agent,
|
||
2 months ago
|
financial_analyst_agent,
|
||
|
market_analyst_agent,
|
||
|
operational_analyst_agent,
|
||
2 months ago
|
],
|
||
2 months ago
|
swarm_type="SequentialWorkflow", # or "SequentialWorkflow" or "ConcurrentWorkflow" or
|
||
|
auto_generate_prompts=True,
|
||
|
output_type="all",
|
||
2 months ago
|
)
|
||
|
|
||
|
# Example usage
|
||
|
if __name__ == "__main__":
|
||
|
# Run a comprehensive private equity document analysis task
|
||
|
result = router.run(
|
||
|
"Where is the best place to find template term sheets for series A startups. Provide links and references"
|
||
|
)
|
||
|
print(result)
|