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.
swarms/playground/agents/multi_modal_auto_agent.py

35 lines
779 B

1 year ago
# Description: This is an example of how to use the Agent class to run a multi-modal workflow
import os
from dotenv import load_dotenv
1 year ago
from swarms.models.gpt4_vision_api import GPT4VisionAPI
from swarms.structs import Agent
1 year ago
# Load the environment variables
load_dotenv()
1 year ago
1 year ago
# Get the API key from the environment
api_key = os.environ.get("OPENAI_API_KEY")
1 year ago
1 year ago
# Initialize the language model
llm = GPT4VisionAPI(
openai_api_key=api_key,
1 year ago
max_tokens=500,
)
1 year ago
1 year ago
# Initialize the language model
1 year ago
task = "What is the color of the object?"
img = "images/swarms.jpeg"
## Initialize the workflow
agent = Agent(
1 year ago
llm=llm,
max_loops="auto",
1 year ago
autosave=True,
dashboard=True,
1 year ago
multi_modal=True,
1 year ago
)
1 year ago
# Run the workflow on a task
out = agent.run(task=task, img=img)
print(out)