|
|
|
@ -9,9 +9,9 @@ from swarms.prompts.ai_research_team import (
|
|
|
|
|
)
|
|
|
|
|
from swarms.structs import Agent
|
|
|
|
|
from swarms.utils.pdf_to_text import pdf_to_text
|
|
|
|
|
from swarms import rearrange
|
|
|
|
|
|
|
|
|
|
# Base llms
|
|
|
|
|
# Environment variables
|
|
|
|
|
load_dotenv()
|
|
|
|
|
anthropic_api_key = os.getenv("ANTHROPIC_API_KEY")
|
|
|
|
|
openai_api_key = os.getenv("OPENAI_API_KEY")
|
|
|
|
@ -30,6 +30,7 @@ llm2 = Anthropic(
|
|
|
|
|
|
|
|
|
|
# Agents
|
|
|
|
|
paper_summarizer_agent = Agent(
|
|
|
|
|
agent_name = "paper_summarizer_agent",
|
|
|
|
|
llm=llm2,
|
|
|
|
|
sop=PAPER_SUMMARY_ANALYZER,
|
|
|
|
|
max_loops=1,
|
|
|
|
@ -38,6 +39,7 @@ paper_summarizer_agent = Agent(
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
paper_implementor_agent = Agent(
|
|
|
|
|
agent_name = "paper_implementor_agent",
|
|
|
|
|
llm=llm1,
|
|
|
|
|
sop=PAPER_IMPLEMENTOR_AGENT_PROMPT,
|
|
|
|
|
max_loops=1,
|
|
|
|
@ -46,9 +48,28 @@ paper_implementor_agent = Agent(
|
|
|
|
|
code_interpreter=False,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
paper = pdf_to_text(PDF_PATH)
|
|
|
|
|
algorithmic_psuedocode_agent = paper_summarizer_agent.run(
|
|
|
|
|
"Focus on creating the algorithmic pseudocode for the novel"
|
|
|
|
|
f" method in this paper: {paper}"
|
|
|
|
|
pytorch_pseudocode_agent = Agent(
|
|
|
|
|
agent_name = "pytorch_pseudocode_agent",
|
|
|
|
|
llm=llm1,
|
|
|
|
|
sop=PAPER_IMPLEMENTOR_AGENT_PROMPT,
|
|
|
|
|
max_loops=1,
|
|
|
|
|
autosave=True,
|
|
|
|
|
saved_state_path="pytorch_pseudocode_agent.json",
|
|
|
|
|
code_interpreter=False,
|
|
|
|
|
)
|
|
|
|
|
pytorch_code = paper_implementor_agent.run(algorithmic_psuedocode_agent)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
paper = pdf_to_text(PDF_PATH)
|
|
|
|
|
task = f"""
|
|
|
|
|
Focus on creating the algorithmic pseudocode for the novel
|
|
|
|
|
f" method in this paper: {paper}
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
agents = [paper_summarizer_agent, paper_implementor_agent, pytorch_pseudocode_agent]
|
|
|
|
|
|
|
|
|
|
flow = "paper_summarizer_agent -> paper_implementor_agent -> pytorch_pseudocode_agent"
|
|
|
|
|
|
|
|
|
|
swarm = rearrange(agents, flow, task)
|
|
|
|
|
print(swarm)
|
|
|
|
|
|
|
|
|
|