pull/233/head
Kye 1 year ago
parent 6e42d5424d
commit 4e47528b35

@ -73,15 +73,17 @@ out = agent.run("Generate a 10,000 word blog on health and wellness.")
- Integrate Agent's with various LLMs and Multi-Modality Models - Integrate Agent's with various LLMs and Multi-Modality Models
```python ```python
from swarms.models import OpenAIChat, BioGPT, Anthropic import os
from swarms.models import OpenAIChat
from swarms.structs import Agent from swarms.structs import Agent
from swarms.structs.sequential_workflow import SequentialWorkflow from swarms.structs.sequential_workflow import SequentialWorkflow
from dotenv import load_dotenv
load_dotenv()
# Load the environment variables
api_key = os.getenv("OPENAI_API_KEY")
# Example usage
api_key = (
"" # Your actual API key here
)
# Initialize the language agent # Initialize the language agent
llm = OpenAIChat( llm = OpenAIChat(
@ -90,32 +92,28 @@ llm = OpenAIChat(
max_tokens=3000, max_tokens=3000,
) )
biochat = BioGPT()
# Use Anthropic
anthropic = Anthropic()
# Initialize the agent with the language agent # Initialize the agent with the language agent
agent1 = Agent(llm=llm, max_loops=1, dashboard=False) agent1 = Agent(llm=llm, max_loops=1)
# Create another agent for a different task # Create another agent for a different task
agent2 = Agent(llm=llm, max_loops=1, dashboard=False) agent2 = Agent(llm=llm, max_loops=1)
# Create another agent for a different task # Create another agent for a different task
agent3 = Agent(llm=biochat, max_loops=1, dashboard=False) agent3 = Agent(llm=llm, max_loops=1)
# agent4 = Agent(llm=anthropic, max_loops="auto")
# Create the workflow # Create the workflow
workflow = SequentialWorkflow(max_loops=1) workflow = SequentialWorkflow(max_loops=1)
# Add tasks to the workflow # Add tasks to the workflow
workflow.add("Generate a 10,000 word blog on health and wellness.", agent1) workflow.add(
agent1, "Generate a 10,000 word blog on health and wellness.",
)
# Suppose the next task takes the output of the first task as input # Suppose the next task takes the output of the first task as input
workflow.add("Summarize the generated blog", agent2) workflow.add(
agent2, "Summarize the generated blog",
workflow.add("Create a references sheet of materials for the curriculm", agent3) )
# Run the workflow # Run the workflow
workflow.run() workflow.run()
@ -124,6 +122,7 @@ workflow.run()
for task in workflow.tasks: for task in workflow.tasks:
print(f"Task: {task.description}, Result: {task.result}") print(f"Task: {task.description}, Result: {task.result}")
``` ```
## `Multi Modal Autonomous Agents` ## `Multi Modal Autonomous Agents`

Loading…
Cancel
Save