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/demos/optimize_llm_stack/vortex.py

37 lines
642 B

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