swarm at 2024-02-10 21:44:58

pull/296/head
Nate 11 months ago
parent 936d94820c
commit 18b0504284

@ -1,32 +1,58 @@
import os
from dotenv import load_dotenv
# Import the OpenAIChat model and the Agent struct
from swarms.models import OpenAIChat
from swarms.models import Gemini
from swarms.structs import Agent
# Load the environment variables
# Load environment variables
load_dotenv()
# Get the API key from the environment
api_key = os.environ.get("OPENAI_API_KEY")
# Initialize the language model
llm = OpenAIChat(
temperature=0.5,
model_name="gpt-4",
openai_api_key=api_key,
max_tokens=1000,
api_key = os.environ.get("GOOGLE_API_KEY")
if not api_key:
raise ValueError("Gemini API key not found. Please set it in your .env file")
# Initialize the first agent (Gemini Pro Vision) for image analysis
agent_analysis = Agent(
llm=Gemini(
temperature=0.8,
model_name="gemini-pro-vision",
gemini_api_key=api_key
),
max_loops=1,
autosave=True,
dashboard=True,
)
## Initialize the workflow
agent = Agent(
llm=llm,
# Initialize the second agent (Gemini Pro) for text-based tasks
agent_instruction = Agent(
llm=Gemini(
temperature=0.8,
model_name="gemini-pro",
gemini_api_key=api_key
),
max_loops=1,
autosave=True,
dashboard=True,
)
# Run the workflow on a task
agent.run("Generate a 10,000 word blog on health and wellness.")
# Task for the first agent: Image Analysis
task_analysis = """
Analyze this logo and summarize its content, then give a structured list of suggested improvements.
"""
img = 'swarmslogobanner.png' # Replace with your image file name
# Run the first agent on the task
analysis_results = agent_analysis.run(task=task_analysis, img=img)
# Task for the second agent: Instructions for a better logo
task_instruction = f"""
Based on the analysis and suggestions for the logo:
{analysis_results}
Generate detailed instructions for creating an improved version of this logo.
"""
# Run the second agent on the task
instruction_results = agent_instruction.run(task=task_instruction)
.
Loading…
Cancel
Save