parent
936d94820c
commit
18b0504284
@ -1,32 +1,58 @@
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
|
from swarms.models import Gemini
|
||||||
# Import the OpenAIChat model and the Agent struct
|
|
||||||
from swarms.models import OpenAIChat
|
|
||||||
from swarms.structs import Agent
|
from swarms.structs import Agent
|
||||||
|
|
||||||
# Load the environment variables
|
# Load environment variables
|
||||||
load_dotenv()
|
load_dotenv()
|
||||||
|
|
||||||
# Get the API key from the environment
|
# Get the API key from the environment
|
||||||
api_key = os.environ.get("OPENAI_API_KEY")
|
api_key = os.environ.get("GOOGLE_API_KEY")
|
||||||
|
if not api_key:
|
||||||
# Initialize the language model
|
raise ValueError("Gemini API key not found. Please set it in your .env file")
|
||||||
llm = OpenAIChat(
|
|
||||||
temperature=0.5,
|
# Initialize the first agent (Gemini Pro Vision) for image analysis
|
||||||
model_name="gpt-4",
|
agent_analysis = Agent(
|
||||||
openai_api_key=api_key,
|
llm=Gemini(
|
||||||
max_tokens=1000,
|
temperature=0.8,
|
||||||
|
model_name="gemini-pro-vision",
|
||||||
|
gemini_api_key=api_key
|
||||||
|
),
|
||||||
|
max_loops=1,
|
||||||
|
autosave=True,
|
||||||
|
dashboard=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
## Initialize the workflow
|
# Initialize the second agent (Gemini Pro) for text-based tasks
|
||||||
agent = Agent(
|
agent_instruction = Agent(
|
||||||
llm=llm,
|
llm=Gemini(
|
||||||
|
temperature=0.8,
|
||||||
|
model_name="gemini-pro",
|
||||||
|
gemini_api_key=api_key
|
||||||
|
),
|
||||||
max_loops=1,
|
max_loops=1,
|
||||||
autosave=True,
|
autosave=True,
|
||||||
dashboard=True,
|
dashboard=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
# Run the workflow on a task
|
# Task for the first agent: Image Analysis
|
||||||
agent.run("Generate a 10,000 word blog on health and wellness.")
|
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…
Reference in new issue