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/example.py

80 lines
1.7 KiB

1 year ago
# import os
# from swarms.swarms.swarms import HierarchicalSwarm
2 years ago
1 year ago
# api_key = os.getenv("OPENAI_API_KEY")
2 years ago
1 year ago
# # Initialize Swarms with your API key
# swarm = HierarchicalSwarm(openai_api_key=api_key)
2 years ago
1 year ago
# # Define an objective
# objective = """
# Please make a web GUI for using HTTP API server.
# The name of it is Swarms.
# You can check the server code at ./main.py.
# The server is served on localhost:8000.
# Users should be able to write text input as 'query' and url array as 'files', and check the response.
# Users input form should be delivered in JSON format.
# I want it to have neumorphism-style. Serve it on port 4500.
2 years ago
1 year ago
# """
2 years ago
1 year ago
# # Run Swarms
# task = swarm.run(objective)
2 years ago
1 year ago
# print(task)
1 year ago
1 year ago
# ######### V2
# from swarms.agents.models.openai import OpenAI
1 year ago
# chat = OpenAI()
# response = chat("Hello World")
# print(response)
1 year ago
# # ############# v3
1 year ago
# import os
# from swarms.workers.vortex_worker import VortexWorkerAgent
1 year ago
# api_key = os.getenv("OPENAI_API_KEY")
1 year ago
# agent = VortexWorkerAgent(openai_api_key=api_key)
1 year ago
# agent.run("Help me find resources about renewable energy.")
1 year ago
################
# from swarms import WorkerNode
1 year ago
# # Your OpenAI API key
# api_key = ""
# # Initialize a WorkerNode with your API key
# node = WorkerNode(api_key)
# # node.create_worker_node()
1 year ago
# # Define an objective
# objective = "Please make a web GUI for using HTTP API server..."
# # Run the task
# task = node.run(objective)
# print(task)
##########
from swarms import Worker
1 year ago
node = Worker(
openai_api_key="",
ai_name="Optimus Prime",
)
1 year ago
task = "What were the winning boston marathon times for the past 5 years (ending in 2022)? Generate a table of the year, name, country of origin, and times."
response = node.run(task)
print(response)