pull/415/head
Kye 10 months ago
parent 9ec439a695
commit b679ae9521

@ -2,7 +2,7 @@
<div align="center">
A modular framework that enables you to Build, Deploy, and Scale Reliable Autonomous Agents. Get started now below.
Orchestrate swarms of agents for production-grade applications.
[![GitHub issues](https://img.shields.io/github/issues/kyegomez/swarms)](https://github.com/kyegomez/swarms/issues) [![GitHub forks](https://img.shields.io/github/forks/kyegomez/swarms)](https://github.com/kyegomez/swarms/network) [![GitHub stars](https://img.shields.io/github/stars/kyegomez/swarms)](https://github.com/kyegomez/swarms/stargazers) [![GitHub license](https://img.shields.io/github/license/kyegomez/swarms)](https://github.com/kyegomez/swarms/blob/main/LICENSE)[![GitHub star chart](https://img.shields.io/github/stars/kyegomez/swarms?style=social)](https://star-history.com/#kyegomez/swarms)[![Dependency Status](https://img.shields.io/librariesio/github/kyegomez/swarms)](https://libraries.io/github/kyegomez/swarms) [![Downloads](https://static.pepy.tech/badge/swarms/month)](https://pepy.tech/project/swarms)
@ -15,7 +15,7 @@ A modular framework that enables you to Build, Deploy, and Scale Reliable Autono
----
## Installation
## Install
`pip3 install -U swarms`
---

@ -52,7 +52,7 @@ This tier encompasses moderate enhancements to existing features, as well as the
| Reward | Description |
|------------------------|--------------------------------------------------------------|
| Cash Reward | $301 - $500 |
| Cash Reward | $301 - $++ |
| Stock Reward | 25+ |
This tier is reserved for truly exceptional contributions that have the potential to revolutionize the Swarms ecosystem. Major feature additions, innovative architectural improvements, and groundbreaking new projects fall under this category. Developers who contribute at this level will be recognized as thought leaders and pioneers in their respective fields.

@ -0,0 +1,74 @@
from swarms.structs.message_pool import MessagePool
from swarms import Agent, OpenAIChat
from swarms.memory.chroma_db import ChromaDB
# Agents
agent1 = Agent(
llm=OpenAIChat(system_prompt="You are a Minecraft player. What's your favorite building style?"),
agent_name="Steve",
agent_description="A Minecraft player agent",
long_term_memory=ChromaDB(),
max_steps=1,
)
agent2 = Agent(
llm=OpenAIChat(system_prompt="You are a Minecraft builder. What's your most impressive creation?"),
agent_name="Bob",
agent_description="A Minecraft builder agent",
long_term_memory=ChromaDB(),
max_steps=1,
)
agent3 = Agent(
llm=OpenAIChat(system_prompt="You are a Minecraft explorer. What's the most interesting place you've discovered?"),
agent_name="Alex",
agent_description="A Minecraft explorer agent",
long_term_memory=ChromaDB(),
max_steps=1,
)
agent4 = Agent(
llm=OpenAIChat(system_prompt="You are a Minecraft adventurer. What's the most dangerous situation you've been in?"),
agent_name="Ender",
agent_description="A Minecraft adventurer agent",
long_term_memory=ChromaDB(),
max_steps=1,
)
moderator = Agent(
llm=OpenAIChat(system_prompt="You are a Minecraft moderator. How do you handle conflicts between players?"),
agent_name="Admin",
agent_description="A Minecraft moderator agent",
long_term_memory=ChromaDB(),
max_steps=1,
)
# Create a message pool
pool = MessagePool(
moderator=moderator,
agents=[agent1, agent2, agent3, agent4],
turns=4,
show_names=True,
autosave=True,
)
# Add a message to the pool
pool.add(
agent=agent1,
content="Hello, agent2!",
turn=1,
)
# Get all messages
out = pool.get_all_messages()
print(out)
# Get visible messages
messages = pool.get_visible_messages(agent=agent1, turn=1)
print(messages)
# Get visible messages
# pool.query("Hello, agent2!")

@ -1,5 +1,7 @@
# from swarms.telemetry.main import Telemetry # noqa: E402, F403
from swarms.telemetry.bootup import bootup # noqa: E402, F403
import os
os.environ["WANDB_SILENT"] = "true"
bootup()

@ -99,7 +99,7 @@ class ChromaDB:
name=output_dir,
metadata={"hnsw:space": metric},
embedding_function=self.embedding_function,
data_loader=self.data_loader,
# data_loader=self.data_loader,
*args,
**kwargs,
)

@ -37,7 +37,6 @@ from swarms.structs.schemas import (
TaskRequestBody,
)
from swarms.structs.sequential_workflow import SequentialWorkflow
from swarms.structs.stackoverflow_swarm import StackOverflowSwarm
from swarms.structs.step import Step
from swarms.structs.swarm_net import SwarmNetwork
from swarms.structs.swarming_architectures import (
@ -135,7 +134,6 @@ __all__ = [
"parse_code_completion",
"majority_voting",
"MajorityVoting",
"StackOverflowSwarm",
"synchronized_queue",
"TaskQueueBase",
"MultiProcessingWorkflow",

@ -1,7 +1,7 @@
import yaml
import json
import asyncio
from abc import ABC, abstractmethod
from abc import ABC
from concurrent.futures import ThreadPoolExecutor, as_completed
from typing import Any, Callable, Dict, List, Optional, Sequence
from swarms.utils.loguru_logger import logger
@ -463,7 +463,7 @@ class AbstractSwarm(ABC):
)
return list(responses)
@abstractmethod
# @abstractmethod
def add_swarm_entry(self, swarm):
"""
Add the information of a joined Swarm to the registry.

@ -3,7 +3,6 @@ from time import time_ns
from typing import Callable, List, Optional, Sequence, Union
from swarms.structs.agent import Agent
from swarms.structs.base_swarm import BaseSwarm
from swarms.utils.loguru_logger import logger
@ -43,7 +42,7 @@ def msg_hash(
)
class MessagePool(BaseSwarm):
class MessagePool:
"""
A class representing a message pool for agents in a swarm.
@ -203,12 +202,12 @@ class MessagePool(BaseSwarm):
visible_messages.append(message)
return visible_messages
def query(self, query: str):
"""
Query a message from the messages list and then pass it to the moderator
"""
return [
(mod, content)
for mod, content in self.messages
if mod == self.moderator
]
# def query(self, query: str):
# """
# Query a message from the messages list and then pass it to the moderator
# """
# return [
# (mod, content)
# for mod, content, _ in self.messages # Add an underscore to ignore the rest of the elements
# if query in content
# ]

@ -18,7 +18,6 @@ from swarms.utils.download_weights_from_url import (
from swarms.utils.exponential_backoff import ExponentialBackoffMixin
from swarms.utils.file_processing import (
load_json,
parse_tagged_output,
sanitize_file_path,
zip_workspace,
create_file_in_folder,
@ -97,7 +96,6 @@ __all__ = [
"dataframe_to_text",
"zip_workspace",
"sanitize_file_path",
"parse_tagged_output",
"load_json",
"csv_to_dataframe",
"dataframe_to_strings",

@ -15,3 +15,21 @@ def base_model_schema_to_json(model: BaseModel):
str: The JSON schema of the base model as a formatted JSON string.
"""
return json.dumps(model.model_json_schema(), indent=2)
def extract_json_from_str(response: str):
"""
Extracts a JSON object from a string.
Args:
response (str): The string containing the JSON object.
Returns:
dict: The extracted JSON object.
Raises:
ValueError: If the string does not contain a valid JSON object.
"""
json_start = response.index("{")
json_end = response.rfind("}")
return json.loads(response[json_start : json_end + 1])

Loading…
Cancel
Save