SpreadSheetSwarm manages thousands of agents concurrently for efficient task processing. It supports one-to-many task distribution, scalability, and autosaving results. Initialized with a name, description, agents, and settings, the run method executes tasks and returns a dictionary of agent outputs.
SpreadSheetSwarm manages thousands of agents concurrently for efficient task processing. It supports one-to-many task distribution, scalability, and autosaving results. Initialized with a name, description, agents, and settings, the run method executes tasks and returns a dictionary of agent outputs.
Get onboarded now with the creator and lead maintainer of Swarms, Kye Gomez, who will show you how to get started with the installation, usage examples, and starting to build your custom use case! [CLICK HERE](https://cal.com/swarms/swarms-onboarding-session)
Get onboarded now with the creator and lead maintainer of Swarms, Kye Gomez, who will show you how to get started with the installation, usage examples, and starting to build your custom use case! [CLICK HERE](https://cal.com/swarms/swarms-onboarding-session)
---
---
## Documentation
## Documentation
Documentation is located here at: [docs.swarms.world](https://docs.swarms.world)
Documentation is located here at: [docs.swarms.world](https://docs.swarms.world)
-----
-----
## Folder Structure
The swarms package has been meticulously crafted for extreme usability and understanding,the swarms package is split up into various modules such as `swarms.agents` that holds pre-built agents, `swarms.structs` that holds a vast array of structures like `Agent` and multi agent structures. The package is split into various modules, with the most important being `structs`, `tools`, and `agents`.
```sh
├── __init__.py
├── agents/
├── artifacts/
├── client/
├── cli/
├── prompts/
├── schemas/
├── structs/
├── telemetry/
├── tools/
└── utils/
```
----
## 🫶 Contributions:
## 🫶 Contributions:
The easiest way to contribute is to pick any issue with the `good first issue` tag 💪. Read the Contributing guidelines [here](/CONTRIBUTING.md). Bug Report? [File here](https://github.com/swarms/gateway/issues) | Feature Request? [File here](https://github.com/swarms/gateway/issues)
The easiest way to contribute is to pick any issue with the `good first issue` tag 💪. Read the Contributing guidelines [here](/CONTRIBUTING.md). Bug Report? [File here](https://github.com/swarms/gateway/issues) | Feature Request? [File here](https://github.com/swarms/gateway/issues)
@ -2067,17 +2051,20 @@ Swarms is an open-source project, and contributions are VERY welcome. If you wan
----
----
## Community
### Connect With Us
| Platform | Link | Description |
|----------|------|-------------|
| 📚 Documentation | [docs.swarms.world](https://docs.swarms.world) | Official documentation and guides |
| 📝 Blog | [Medium](https://medium.com/@kyeg) | Latest updates and technical articles |
| 💬 Discord | [Join Discord](https://discord.gg/jM3Z6M9uMq) | Live chat and community support |
A tool is a Python function designed to perform specific tasks, with clear type annotations and comprehensive docstrings. Below are examples of tools to help you get started.
A tool is a Python function designed to perform specific tasks with clear type annotations and comprehensive docstrings. Below are examples of financial tools to help you get started.
# Rules
## Rules
To create a tool in the Swarms environment, follow these rules:
To create a tool in the Swarms environment, follow these rules:
@ -25,561 +25,515 @@ To create a tool in the Swarms environment, follow these rules:
- The function's input must be a string.
- The function's input must be a string.
- The function's output must be a string.
- The function's output must be a string.
## Example Financial Tools
### Example Tools
### Example 1: Fetch Stock Price from Yahoo Finance
def calculate_compound_interest(principal, rate, time, n):
# Calculates compound interest.
principal = float(principal)
rate = float(rate)
time = float(time)
n = int(n)
if principal <0orrate<0ortime<0orn<0:
raise ValueError("Inputs must be non-negative.")
amount = principal * (1 + rate / n) ** (n * time)
return f"The amount after {time} years is {amount:.2f}"
```
**Issues with Incorrect Implementation:**
- No type annotations for arguments and return value.
- Missing comprehensive docstring.
- Input types are not enforced as strings.
By following these rules and using the examples provided, you can create robust and well-documented tools in the Swarms environment. Ensure that all functions include proper type annotations, comprehensive docstrings, and that both input and output types are strings.
#### Example Tool 4: Reverse a String
**Functionality**: Reverses a given string.
```python
def reverse_string(s: str) -> str:
"""
Reverses a given string.
Args:
s (str): The string to reverse.
Returns:
str: The reversed string.
Raises:
TypeError: If the input is not a string.
"""
try:
if not isinstance(s, str):
raise TypeError("Input must be a string.")
return s[::-1]
except TypeError as e:
print(f"Type Error: {e}")
raise
```
#### Example Tool 5: Check Palindrome
**Functionality**: Checks if a given string is a palindrome.
```python
def is_palindrome(s: str) -> str:
"""
Checks if a given string is a palindrome.
Args:
s (str): The string to check.
Returns:
str: A message indicating whether the string is a palindrome or not.
By following the examples provided, you can create your own tools to perform various tasks in the Swarms environment. Ensure each function includes type annotations, comprehensive docstrings, and appropriate error handling to make your tools robust and easy to use.
## Integrating Tools into an Agent
To integrate tools into an agent, simply pass callable functions with proper type annotations and documentation into the agent class.
## Integrate tools into Agent
To integrate tools into an agent, you'd simply just pass in a callable function with types and documentation into the agent class.
```python
```python
from swarms import Agent
# Initialize the financial analysis agent
from swarms import Agent, OpenAIChat # ChromaDB
import subprocess
# Model
llm = OpenAIChat(
temperature=0.1,
)
# Tools
def terminal(
code: str,
):
"""
Run code in the terminal.
Args:
code (str): The code to run in the terminal.
Returns:
str: The output of the code.
"""
out = subprocess.run(
code, shell=True, capture_output=True, text=True
).stdout
return str(out)
def browser(query: str):
"""
Search the query in the browser with the `browser` tool.
agent.run("Create a new file for a plan to take over the world.")
response = agent("Analyze the current price of Apple stock and Bitcoin, then calculate the performance of a $10,000 investment in each over the past 2 years.")
print(response)
```
```
## Complete Financial Analysis Example
## Example 2
```python
```python
import yfinance as yf
import os
import requests
import requests
from swarms import Agent
from swarms import Agent
from swarm_models import OpenAIChat
# Get the OpenAI API key from the environment variable
def get_stock_price(symbol: str) -> str:
api_key = os.getenv("OPENAI_API_KEY")
"""
Fetches the current stock price from Yahoo Finance.
# Create an instance of the OpenAIChat class
Args:
model = OpenAIChat(
symbol (str): The stock symbol (e.g., "AAPL", "TSLA", "NVDA").