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.
|
|
|
import os
|
|
|
|
import subprocess
|
|
|
|
|
|
|
|
from dotenv import load_dotenv
|
|
|
|
|
|
|
|
from swarms.models import OpenAIChat
|
|
|
|
from swarms.structs import Agent
|
|
|
|
from swarms.utils.phoenix_handler import phoenix_trace_decorator
|
|
|
|
|
|
|
|
import modal
|
|
|
|
|
|
|
|
load_dotenv()
|
|
|
|
|
|
|
|
# Model
|
|
|
|
llm = OpenAIChat(
|
|
|
|
openai_api_key=os.getenv("OPENAI_API_KEY"),
|
|
|
|
model_name="gpt-4",
|
|
|
|
max_tokens=4000,
|
|
|
|
)
|
|
|
|
|
|
|
|
# Modal
|
|
|
|
stub = modal.Stub(name="swarms")
|
|
|
|
|
|
|
|
|
|
|
|
# Agent
|
|
|
|
@phoenix_trace_decorator(
|
|
|
|
"This function is an agent and is traced by Phoenix."
|
|
|
|
)
|
|
|
|
@stub.function(gpu="any")
|
|
|
|
def agent(task: str):
|
|
|
|
agent = Agent(
|
|
|
|
llm=llm,
|
|
|
|
max_loops=1,
|
|
|
|
)
|
|
|
|
out = agent.run(task=task)
|
|
|
|
return out
|