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
681 B
35 lines
681 B
1 year ago
|
import subprocess
|
||
1 year ago
|
import os
|
||
|
from swarms.structs import Agent
|
||
|
from swarms.memory import WeaviateClient
|
||
|
from swarms.utils.phoenix_handler import phoenix_trace_decorator
|
||
|
from swarms.models.vllm import vLLM
|
||
|
from dotenv import load_dotenv
|
||
|
|
||
1 year ago
|
try:
|
||
|
import modal
|
||
|
except ImportError:
|
||
|
print(f"modal not installed, please install it with `pip install modal`")
|
||
|
subprocess.run(["pip", "install", "modal"])
|
||
|
|
||
1 year ago
|
|
||
|
|
||
1 year ago
|
load_dotenv()
|
||
|
|
||
1 year ago
|
# Model
|
||
|
llm = vLLM()
|
||
|
|
||
1 year ago
|
# Modal
|
||
|
stub = modal.Stub(name="swarms")
|
||
1 year ago
|
|
||
|
|
||
|
# Agent
|
||
|
@phoenix_trace_decorator
|
||
1 year ago
|
@stub.function(gpu="any")
|
||
1 year ago
|
def agent(task: str):
|
||
|
agent = Agent(
|
||
|
llm = llm,
|
||
|
max_loops=1,
|
||
|
)
|
||
|
out = agent.run(task=task)
|
||
|
return out
|