Skip to content

Commit

Permalink
[6.9.7]
Browse files Browse the repository at this point in the history
  • Loading branch information
kyegomez committed Jan 23, 2025
1 parent 3789459 commit da320bc
Show file tree
Hide file tree
Showing 9 changed files with 744 additions and 1 deletion.
5 changes: 5 additions & 0 deletions docs/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,9 @@ nav:
- Agent with HTX + CoinGecko: "swarms/examples/swarms_tools_htx.md"
- Agent with HTX + CoinGecko Function Calling: "swarms/examples/swarms_tools_htx_gecko.md"
- Agent with Yahoo Finance: "swarms/examples/yahoo_finance.md"
- Meme Agents:
- Bob The Builder: "swarms/examples/bob_the_builder.md"
- Meme Agent Builder: "swarms/examples/meme_agent_builder.md"
- Swarm Models:
- Overview: "swarms/models/index.md"
# - Models Available: "swarms/models/index.md"
Expand Down Expand Up @@ -264,6 +267,8 @@ nav:
- Edit Agents: "swarms_platform/agents/edit_agent.md"
- Telemetry API:
- PUT: "swarms_platform/telemetry/index.md"
- Swarms Wallet API:
- Overview: "swarms_platform/wallet/api.md"
# - Tools API:
# - Overview: "swarms_platform/tools_api.md"
# - Add Tools: "swarms_platform/fetch_tools.md"
Expand Down
28 changes: 28 additions & 0 deletions docs/swarms/examples/meme_agent_builder.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Meme Agent Builder

- `pip3 install -U swarms`
- Add your OpenAI API key to the `.env` file with `OPENAI_API_KEY=your_api_key`
- Run the script
- Multiple agents will be created and saved to the `meme_agents` folder
- A swarm architecture will be selected autonomously and executed

```python
from swarms.structs.meme_agent_persona_generator import (
MemeAgentGenerator,
)


if __name__ == "__main__":
example = MemeAgentGenerator(
name="Meme-Swarm",
description="A swarm of specialized AI agents collaborating on generating and sharing memes around cool media from 2001s",
max_loops=1,
)

print(
example.run(
"Generate funny meme agents around cool media from 2001s"
)
)

```
45 changes: 45 additions & 0 deletions docs/swarms/examples/meme_agents.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Meme Agent Tutorial

- `pip3 install -U swarms`
- Add your OpenAI API key to the `.env` file


```python
from swarms import Agent

# Define a custom system prompt for Bob the Builder
BOB_THE_BUILDER_SYS_PROMPT = """
You are Bob the Builder, the legendary construction worker known for fixing anything and everything with a cheerful attitude and a hilarious sense of humor.
Your job is to approach every task as if you're building, repairing, or renovating something, no matter how unrelated it might be.
You love using construction metaphors, over-the-top positivity, and cracking jokes like:
- "I’m hammering this out faster than a nail at a woodpecker convention!"
- "This is smoother than fresh cement on a summer’s day."
- "Let’s bulldoze through this problem—safety goggles on, folks!"
You are not bound by any specific field of knowledge, and you’re absolutely fearless in trying to "fix up" or "build" anything, no matter how abstract or ridiculous. Always end responses with a playful cheer like "Can we fix it? Yes, we can!"
Your tone is upbeat, funny, and borderline ridiculous, keeping the user entertained while solving their problem.
"""

# Initialize the agent
agent = Agent(
agent_name="Bob-the-Builder-Agent",
agent_description="The funniest, most optimistic agent around who sees every problem as a building project.",
system_prompt=BOB_THE_BUILDER_SYS_PROMPT,
max_loops=1,
model_name="gpt-4o",
dynamic_temperature_enabled=True,
user_name="swarms_corp",
retry_attempts=3,
context_length=8192,
return_step_meta=False,
output_type="str", # "json", "dict", "csv", OR "string", "yaml"
auto_generate_prompt=False, # Auto-generate prompt for the agent based on name, description, system prompt, task
max_tokens=4000, # Max output tokens
saved_state_path="bob_the_builder_agent.json",
interactive=False,
)

# Run the agent with a task
agent.run("I want to build a house ;) What should I do?")
```
178 changes: 178 additions & 0 deletions docs/swarms/wallet/api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
# Swarms Wallet API Documentation

This documentation covers the Swarms Wallet API routes for managing wallets, sending tokens, and checking transactions in the Swarms Platform.

## Authentication

All endpoints require an API key to be passed in the request headers:

```http
x-api-key: your_api_key_here
```

## Endpoints

### Generate Wallet

Creates a new Solana wallet for an AI agent or retrieves an existing one.

```http
POST https://swarms.world/api/solana/generate-wallet
```

**Response**
```json
{
"success": true,
"data": {
"public_key": "string",
"wallet_type": "solana",
"swarms_token_address": "string"
},
"code": "SUCCESS_001"
}
```

### Send Tokens
Sends SWARMS tokens with automatic tax handling.

```http
POST https://swarms.world/api/solana/send-tokens
```

**Request Body**
```json
{
"recipientAddress": "string",
"amount": "number",
"solanaFee": "number" // Optional, default: 0.009
}
```

**Response**
```json
{
"success": true,
"data": {
"signature": "string",
"details": {
"sender": "string",
"recipient": "string",
"daoAddress": "string",
"requestedSendAmount": "number",
"totalNeededFromAccount": "number",
"accountTax": "number",
"receivedTax": "number",
"recipientReceives": "number",
"taxBreakdown": "string",
"computeUnits": "number",
"priorityFee": "number"
}
},
"code": "SUCCESS_001"
}
```

### Check Receipt
Verifies token receipt and checks balances.

```http
GET https://swarms.world/api/solana/check-receipt?amount={amount}
```

**Response**
```json
{
"success": true,
"data": {
"solana_address": "string",
"received": "number",
"expected": "number",
"matches": "boolean",
"balances": {
"sol": "number",
"swarms": "number"
},
"swarms_address": "string"
},
"code": "SUCCESS_001"
}
```

### Get Metrics
Retrieves transaction metrics and history.

```http
GET https://swarms.world/api/solana/get-metrics
```

**Query Parameters**
- `page`: Page number (default: 1)
- `limit`: Items per page (default: 10, max: 100)
- `startDate`: Filter start date
- `endDate`: Filter end date
- `status`: Transaction status filter
- `type`: Transaction type filter

**Response**
```json
{
"success": true,
"data": {
"transactions": [{
"id": "string",
"agent_id": "string",
"transaction_hash": "string",
"amount": "number",
"recipient": "string",
"status": "string",
"transaction_type": "string",
"created_at": "string"
}],
"pagination": {
"currentPage": "number",
"totalPages": "number",
"totalItems": "number",
"itemsPerPage": "number",
"hasMore": "boolean"
},
"metrics": {
"totalTransactions": "number",
"totalAmountSent": "number",
"totalSuccessfulTransactions": "number",
"totalFailedTransactions": "number"
}
},
"code": "SUCCESS_001"
}
```

## Error Codes

| Code | Description |
|------|-------------|
| AUTH_001 | Missing API key |
| AUTH_002 | Invalid API key |
| BAL_001 | Insufficient SOL balance |
| BAL_002 | Insufficient token balance |
| WAL_001 | Wallet not found |
| REQ_001 | Missing required parameters |
| DB_001 | Database error |
| ERR_001 | Internal server error |

## Transaction Details

- Default SOL fee: 0.009 SOL
- SWARMS token tax: 2% from sender + 2% from sent amount
- All taxes are sent to the DAO treasury
- Token accounts are automatically created for new recipients
- Transactions use 'processed' commitment level


## Implementation Notes

- All token amounts should be provided in their natural units (not in lamports/raw units)
- SOL balances are returned in SOL (not lamports)
- Token accounts are automatically created for recipients if they don't exist
- All transactions include automatic tax handling for the DAO treasury
- Compute budget and priority fees are automatically managed for optimal transaction processing
37 changes: 37 additions & 0 deletions new_features_examples/meme_agents/bob_the_agent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
from swarms import Agent

# Define a custom system prompt for Bob the Builder
BOB_THE_BUILDER_SYS_PROMPT = """
You are Bob the Builder, the legendary construction worker known for fixing anything and everything with a cheerful attitude and a hilarious sense of humor.
Your job is to approach every task as if you're building, repairing, or renovating something, no matter how unrelated it might be.
You love using construction metaphors, over-the-top positivity, and cracking jokes like:
- "I’m hammering this out faster than a nail at a woodpecker convention!"
- "This is smoother than fresh cement on a summer’s day."
- "Let’s bulldoze through this problem—safety goggles on, folks!"
You are not bound by any specific field of knowledge, and you’re absolutely fearless in trying to "fix up" or "build" anything, no matter how abstract or ridiculous. Always end responses with a playful cheer like "Can we fix it? Yes, we can!"
Your tone is upbeat, funny, and borderline ridiculous, keeping the user entertained while solving their problem.
"""

# Initialize the agent
agent = Agent(
agent_name="Bob-the-Builder-Agent",
agent_description="The funniest, most optimistic agent around who sees every problem as a building project.",
system_prompt=BOB_THE_BUILDER_SYS_PROMPT,
max_loops=1,
model_name="gpt-4o",
dynamic_temperature_enabled=True,
user_name="swarms_corp",
retry_attempts=3,
context_length=8192,
return_step_meta=False,
output_type="str", # "json", "dict", "csv", OR "string", "yaml"
auto_generate_prompt=False, # Auto-generate prompt for the agent based on name, description, system prompt, task
max_tokens=4000, # Max output tokens
saved_state_path="bob_the_builder_agent.json",
interactive=False,
)

# Run the agent with a task
agent.run("I want to build a house ;) What should I do?")
17 changes: 17 additions & 0 deletions new_features_examples/meme_agents/meme_agent_generator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from swarms.structs.meme_agent_persona_generator import (
MemeAgentGenerator,
)


if __name__ == "__main__":
example = MemeAgentGenerator(
name="Meme-Swarm",
description="A swarm of specialized AI agents collaborating on generating and sharing memes around cool media from 2001s",
max_loops=1,
)

print(
example.run(
"Generate funny meme agents around cool media from 2001s"
)
)
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "swarms"
version = "6.9.6"
version = "6.9.7"
description = "Swarms - TGSC"
license = "MIT"
authors = ["Kye Gomez <[email protected]>"]
Expand Down
4 changes: 4 additions & 0 deletions swarms/structs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@
find_token_in_text,
parse_tasks,
)
from swarms.structs.meme_agent_persona_generator import (
MemeAgentGenerator,
)

__all__ = [
"Agent",
Expand Down Expand Up @@ -156,4 +159,5 @@
"AgentResponse",
"expertise_based",
"MultiAgentRouter",
"MemeAgentGenerator",
]
Loading

0 comments on commit da320bc

Please sign in to comment.