parent
be46bcf48f
commit
db43acbf7d
@ -1,28 +0,0 @@
|
|||||||
from swarms import HierarchicalSwarm
|
|
||||||
|
|
||||||
swarm = HierarchicalSwarm(
|
|
||||||
openai_api_key="key",
|
|
||||||
model_type="openai",
|
|
||||||
model_id="gpt-4",
|
|
||||||
use_vectorstore=False,
|
|
||||||
use_async=False,
|
|
||||||
human_in_the_loop=False,
|
|
||||||
logging_enabled=False,
|
|
||||||
)
|
|
||||||
|
|
||||||
# run the swarm with an objective
|
|
||||||
result = swarm.run("Design a new car")
|
|
||||||
|
|
||||||
# or huggingface
|
|
||||||
swarm = HierarchicalSwarm(
|
|
||||||
model_type="huggingface",
|
|
||||||
model_id="tiaueu/falcon",
|
|
||||||
use_vectorstore=True,
|
|
||||||
embedding_size=768,
|
|
||||||
use_async=False,
|
|
||||||
human_in_the_loop=True,
|
|
||||||
logging_enabled=False,
|
|
||||||
)
|
|
||||||
|
|
||||||
# Run the swarm with a particular objective
|
|
||||||
result = swarm.run("Write a sci-fi short story")
|
|
@ -1,11 +0,0 @@
|
|||||||
from swarms import Orchestrator, Worker
|
|
||||||
|
|
||||||
# Instantiate the Orchestrator with 10 agents
|
|
||||||
orchestrator = Orchestrator(
|
|
||||||
Worker, agent_list=[Worker] * 10, task_queue=[]
|
|
||||||
)
|
|
||||||
|
|
||||||
# Agent 1 sends a message to Agent 2
|
|
||||||
orchestrator.chat(
|
|
||||||
sender_id=1, receiver_id=2, message="Hello, Agent 2!"
|
|
||||||
)
|
|
@ -1,7 +1,14 @@
|
|||||||
from swarms import swarm
|
from swarms import Agent, OpenAIChat
|
||||||
|
|
||||||
# Use the function
|
## Initialize the workflow
|
||||||
api_key = "APIKEY"
|
agent = Agent(
|
||||||
objective = "What is the capital of the UK?"
|
llm=OpenAIChat(),
|
||||||
result = swarm(api_key, objective)
|
max_loops=1,
|
||||||
print(result) # Prints: "The capital of the UK is London."
|
autosave=True,
|
||||||
|
dashboard=False,
|
||||||
|
streaming_on=True,
|
||||||
|
verbose=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
# Run the workflow on a task
|
||||||
|
agent("Find a chick fil a equivalent in hayes valley")
|
||||||
|
@ -1,19 +0,0 @@
|
|||||||
from swarms import Orchestrator, Worker
|
|
||||||
|
|
||||||
node = Worker(
|
|
||||||
openai_api_key="",
|
|
||||||
ai_name="Optimus Prime",
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
# Instantiate the Orchestrator with 10 agents
|
|
||||||
orchestrator = Orchestrator(
|
|
||||||
node, agent_list=[node] * 10, task_queue=[]
|
|
||||||
)
|
|
||||||
|
|
||||||
# Agent 7 sends a message to Agent 9
|
|
||||||
orchestrator.chat(
|
|
||||||
sender_id=7,
|
|
||||||
receiver_id=9,
|
|
||||||
message="Can you help me with this task?",
|
|
||||||
)
|
|
@ -1,19 +0,0 @@
|
|||||||
from ..swarms import HierarchicalSwarm
|
|
||||||
|
|
||||||
# Retrieve your API key from the environment or replace with your actual key
|
|
||||||
api_key = "sksdsds"
|
|
||||||
|
|
||||||
# Initialize HierarchicalSwarm with your API key
|
|
||||||
swarm = HierarchicalSwarm(openai_api_key=api_key)
|
|
||||||
|
|
||||||
# Define an objective
|
|
||||||
objective = """
|
|
||||||
Please develop and serve a simple community web service.
|
|
||||||
People can signup, login, post, comment.
|
|
||||||
Post and comment should be visible at once.
|
|
||||||
I want it to have neumorphism-style.
|
|
||||||
The ports you can use are 4500 and 6500.
|
|
||||||
"""
|
|
||||||
|
|
||||||
# Run HierarchicalSwarm
|
|
||||||
swarm.run(objective)
|
|
@ -1,16 +0,0 @@
|
|||||||
from swarms import HierarchicalSwarm
|
|
||||||
|
|
||||||
# Retrieve your API key from the environment or replace with your actual key
|
|
||||||
api_key = ""
|
|
||||||
|
|
||||||
# Initialize HierarchicalSwarm with your API key
|
|
||||||
swarm = HierarchicalSwarm(api_key)
|
|
||||||
|
|
||||||
# Define an objective
|
|
||||||
objective = (
|
|
||||||
"Find 20 potential customers for a HierarchicalSwarm based AI"
|
|
||||||
" Agent automation infrastructure"
|
|
||||||
)
|
|
||||||
|
|
||||||
# Run HierarchicalSwarm
|
|
||||||
swarm.run(objective)
|
|
@ -1,19 +0,0 @@
|
|||||||
from swarms import HierarchicalSwarm
|
|
||||||
|
|
||||||
# Retrieve your API key from the environment or replace with your actual key
|
|
||||||
api_key = "sksdsds"
|
|
||||||
|
|
||||||
# Initialize HierarchicalSwarm with your API key
|
|
||||||
swarm = HierarchicalSwarm(openai_api_key=api_key)
|
|
||||||
|
|
||||||
# Define an objective
|
|
||||||
objective = """
|
|
||||||
Please develop and serve a simple web TODO app.
|
|
||||||
The user can list all TODO items and add or delete each TODO item.
|
|
||||||
I want it to have neumorphism-style.
|
|
||||||
The ports you can use are 4500 and 6500.
|
|
||||||
|
|
||||||
"""
|
|
||||||
|
|
||||||
# Run HierarchicalSwarm
|
|
||||||
swarm.run(objective)
|
|
@ -1,19 +0,0 @@
|
|||||||
from swarms.tools.tool import tool
|
|
||||||
from swarms.tools.tool_func_doc_scraper import scrape_tool_func_docs
|
|
||||||
|
|
||||||
|
|
||||||
@tool
|
|
||||||
def search_api(query: str) -> str:
|
|
||||||
"""Search API
|
|
||||||
|
|
||||||
Args:
|
|
||||||
query (str): _description_
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
str: _description_
|
|
||||||
"""
|
|
||||||
print(f"Searching API for {query}")
|
|
||||||
|
|
||||||
|
|
||||||
tool_docs = scrape_tool_func_docs(search_api)
|
|
||||||
print(tool_docs)
|
|
@ -1,7 +0,0 @@
|
|||||||
from swarms.models import OpenAIChat
|
|
||||||
from swarms.structs.workflow import Workflow
|
|
||||||
|
|
||||||
llm = OpenAIChat()
|
|
||||||
|
|
||||||
|
|
||||||
workflow = Workflow(llm)
|
|
@ -1,22 +0,0 @@
|
|||||||
from swarms.tools.tool import tool
|
|
||||||
from swarms.tools.tool_func_doc_scraper import scrape_tool_func_docs
|
|
||||||
|
|
||||||
# Define a tool by decorating a function with the tool decorator and providing a docstring
|
|
||||||
|
|
||||||
|
|
||||||
@tool(return_direct=True)
|
|
||||||
def search_api(query: str):
|
|
||||||
"""Search the web for the query
|
|
||||||
|
|
||||||
Args:
|
|
||||||
query (str): _description_
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
_type_: _description_
|
|
||||||
"""
|
|
||||||
return f"Search results for {query}"
|
|
||||||
|
|
||||||
|
|
||||||
# Scrape the tool func docs to prepare for injection into the agent prompt
|
|
||||||
out = scrape_tool_func_docs(search_api)
|
|
||||||
print(out)
|
|
@ -1,10 +0,0 @@
|
|||||||
from swarms import Workflow
|
|
||||||
from swarms.models import ChatOpenAI
|
|
||||||
|
|
||||||
workflow = Workflow(ChatOpenAI)
|
|
||||||
|
|
||||||
workflow.add("What's the weather in miami")
|
|
||||||
workflow.add("Provide details for {{ parent_output }}")
|
|
||||||
workflow.add("Summarize the above information: {{ parent_output}}")
|
|
||||||
|
|
||||||
workflow.run()
|
|
Loading…
Reference in new issue