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.
35 lines
779 B
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
|
||
1 year ago
|
import os
|
||
|
from dotenv import load_dotenv
|
||
1 year ago
|
from swarms.models.gpt4_vision_api import GPT4VisionAPI
|
||
1 year ago
|
from swarms.structs import Agent
|
||
|
|
||
1 year ago
|
# Load the environment variables
|
||
1 year ago
|
load_dotenv()
|
||
1 year ago
|
|
||
1 year ago
|
# Get the API key from the environment
|
||
1 year ago
|
api_key = os.environ.get("OPENAI_API_KEY")
|
||
1 year ago
|
|
||
1 year ago
|
# Initialize the language model
|
||
1 year ago
|
llm = GPT4VisionAPI(
|
||
|
openai_api_key=api_key,
|
||
1 year ago
|
max_tokens=500,
|
||
1 year ago
|
)
|
||
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
|
||
1 year ago
|
agent = Agent(
|
||
1 year ago
|
llm=llm,
|
||
1 year ago
|
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
|
||
1 year ago
|
out = agent.run(task=task, img=img)
|
||
|
print(out)
|