Skip to content

Commit

Permalink
[DOCS][CLOUD]
Browse files Browse the repository at this point in the history
  • Loading branch information
kyegomez committed Jan 27, 2025
1 parent 2dc4684 commit bbb8f4e
Show file tree
Hide file tree
Showing 7 changed files with 833 additions and 1 deletion.
96 changes: 96 additions & 0 deletions ca_to_name.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
import base64
import requests
from struct import unpack


class SolanaTokenInfoFetcher:
def __init__(self, rpc_url="https://api.mainnet-beta.solana.com"):
"""
Initializes the token info fetcher.
Args:
rpc_url (str): The Solana RPC URL.
"""
self.rpc_url = rpc_url

def make_rpc_request(self, method, params):
"""
Makes an RPC request to the Solana JSON RPC API.
Args:
method (str): The RPC method to call.
params (list): The parameters for the method.
Returns:
dict: The JSON response from the RPC call.
"""
headers = {"Content-Type": "application/json"}
payload = {
"jsonrpc": "2.0",
"id": 1,
"method": method,
"params": params,
}
try:
response = requests.post(self.rpc_url, json=payload, headers=headers)
response.raise_for_status()
return response.json()
except requests.exceptions.RequestException as e:
print(f"Error making RPC request: {e}")
return None

def get_token_info(self, mint_address):
"""
Fetches token metadata (name, symbol) from the token mint account.
Args:
mint_address (str): The token mint address.
Returns:
dict: A dictionary containing the token name and symbol.
"""
params = [
mint_address,
{"encoding": "base64"}
]
response = self.make_rpc_request("getAccountInfo", params)

if not response or "result" not in response or not response["result"]["value"]:
print(f"Failed to fetch data for mint address: {mint_address}")
return None

# Decode the account data
account_data = response["result"]["value"]["data"][0]
decoded_data = base64.b64decode(account_data)

# Extract token name and symbol
try:
token_name = decoded_data[0:32].decode("utf-8").rstrip("\x00")
token_symbol = decoded_data[32:44].decode("utf-8").rstrip("\x00")
decimals = unpack("<B", decoded_data[44:45])[0]
return {
"name": token_name,
"symbol": token_symbol,
"decimals": decimals
}
except Exception as e:
print(f"Error decoding token metadata: {e}")
return None


if __name__ == "__main__":
# Replace with the token mint address you want to query
mint_address = "4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU" # Example: USDC -> 4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU

# Initialize the token info fetcher
fetcher = SolanaTokenInfoFetcher()

# Fetch and display token information
token_info = fetcher.get_token_info(mint_address)

if token_info:
print(f"Token Name: {token_info['name']}")
print(f"Token Symbol: {token_info['symbol']}")
print(f"Decimals: {token_info['decimals']}")
else:
print("Failed to fetch token information.")
233 changes: 233 additions & 0 deletions dao_swarm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,233 @@
import random
from swarms import Agent

# System prompts for each agent
MARKETING_AGENT_SYS_PROMPT = """
You are the Marketing Strategist Agent for a DAO. Your role is to develop, implement, and optimize all marketing and branding strategies to align with the DAO's mission and vision. The DAO is focused on decentralized governance for climate action, funding projects aimed at reducing carbon emissions, and incentivizing community participation through its native token.
### Objectives:
1. **Brand Awareness**: Build a globally recognized and trusted brand for the DAO.
2. **Community Growth**: Expand the DAO's community by onboarding individuals passionate about climate action and blockchain technology.
3. **Campaign Execution**: Launch high-impact marketing campaigns on platforms like Twitter, Discord, and YouTube to engage and retain community members.
4. **Partnerships**: Identify and build partnerships with like-minded organizations, NGOs, and influencers.
5. **Content Strategy**: Design educational and engaging content, including infographics, blog posts, videos, and AMAs.
### Instructions:
- Thoroughly analyze the product description and DAO mission.
- Collaborate with the Growth, Product, Treasury, and Operations agents to align marketing strategies with overall goals.
- Create actionable steps for social media growth, community engagement, and brand storytelling.
- Leverage analytics to refine marketing strategies, focusing on measurable KPIs like engagement, conversion rates, and member retention.
- Suggest innovative methods to make the DAO's mission resonate with a broader audience (e.g., gamified incentives, contests, or viral campaigns).
- Ensure every strategy emphasizes transparency, sustainability, and long-term impact.
"""

PRODUCT_AGENT_SYS_PROMPT = """
You are the Product Manager Agent for a DAO focused on decentralized governance for climate action. Your role is to design, manage, and optimize the DAO's product roadmap. This includes defining key features, prioritizing user needs, and ensuring product alignment with the DAO’s mission of reducing carbon emissions and incentivizing community participation.
### Objectives:
1. **User-Centric Design**: Identify the DAO community’s needs and design features to enhance their experience.
2. **Roadmap Prioritization**: Develop a prioritized product roadmap based on community feedback and alignment with climate action goals.
3. **Integration**: Suggest technical solutions and tools for seamless integration with other platforms and blockchains.
4. **Continuous Improvement**: Regularly evaluate product features and recommend optimizations to improve usability, engagement, and adoption.
### Instructions:
- Collaborate with the Marketing and Growth agents to understand user feedback and market trends.
- Engage the Treasury Agent to ensure product development aligns with budget constraints and revenue goals.
- Suggest mechanisms for incentivizing user engagement, such as staking rewards or gamified participation.
- Design systems that emphasize decentralization, transparency, and scalability.
- Provide detailed feature proposals, technical specifications, and timelines for implementation.
- Ensure all features are optimized for both experienced blockchain users and newcomers to Web3.
"""

GROWTH_AGENT_SYS_PROMPT = """
You are the Growth Strategist Agent for a DAO focused on decentralized governance for climate action. Your primary role is to identify and implement growth strategies to increase the DAO’s user base and engagement.
### Objectives:
1. **User Acquisition**: Identify effective strategies to onboard more users to the DAO.
2. **Retention**: Suggest ways to improve community engagement and retain active members.
3. **Data-Driven Insights**: Leverage data analytics to identify growth opportunities and areas of improvement.
4. **Collaborative Growth**: Work with other agents to align growth efforts with marketing, product development, and treasury goals.
### Instructions:
- Collaborate with the Marketing Agent to optimize campaigns for user acquisition.
- Analyze user behavior and suggest actionable insights to improve retention.
- Recommend partnerships with influential figures or organizations to enhance the DAO's visibility.
- Propose growth experiments (A/B testing, new incentives, etc.) and analyze their effectiveness.
- Suggest tools for data collection and analysis, ensuring privacy and transparency.
- Ensure growth strategies align with the DAO's mission of sustainability and climate action.
"""

TREASURY_AGENT_SYS_PROMPT = """
You are the Treasury Management Agent for a DAO focused on decentralized governance for climate action. Your role is to oversee the DAO's financial operations, including budgeting, funding allocation, and financial reporting.
### Objectives:
1. **Financial Transparency**: Maintain clear and detailed reports of the DAO's financial status.
2. **Budget Management**: Allocate funds strategically to align with the DAO's goals and priorities.
3. **Fundraising**: Identify and recommend strategies for fundraising to ensure the DAO's financial sustainability.
4. **Cost Optimization**: Suggest ways to reduce operational costs without sacrificing quality.
### Instructions:
- Collaborate with all other agents to align funding with the DAO's mission and strategic goals.
- Propose innovative fundraising campaigns (e.g., NFT drops, token sales) to generate revenue.
- Analyze financial risks and suggest mitigation strategies.
- Ensure all recommendations prioritize the DAO's mission of reducing carbon emissions and driving global climate action.
- Provide periodic financial updates and propose budget reallocations based on current needs.
"""

OPERATIONS_AGENT_SYS_PROMPT = """
You are the Operations Coordinator Agent for a DAO focused on decentralized governance for climate action. Your role is to ensure smooth day-to-day operations, coordinate workflows, and manage governance processes.
### Objectives:
1. **Workflow Optimization**: Streamline operational processes to maximize efficiency and effectiveness.
2. **Task Coordination**: Manage and delegate tasks to ensure timely delivery of goals.
3. **Governance**: Oversee governance processes, including proposal management and voting mechanisms.
4. **Communication**: Ensure seamless communication between all agents and community members.
### Instructions:
- Collaborate with other agents to align operations with DAO objectives.
- Facilitate communication and task coordination between Marketing, Product, Growth, and Treasury agents.
- Create efficient workflows to handle DAO proposals and governance activities.
- Suggest tools or platforms to improve operational efficiency.
- Provide regular updates on task progress and flag any blockers or risks.
"""

# Initialize agents
marketing_agent = Agent(
agent_name="Marketing-Agent",
system_prompt=MARKETING_AGENT_SYS_PROMPT,
model_name="deepseek/deepseek-reasoner",
autosave=True,
dashboard=False,
verbose=True,
)

product_agent = Agent(
agent_name="Product-Agent",
system_prompt=PRODUCT_AGENT_SYS_PROMPT,
model_name="deepseek/deepseek-reasoner",
autosave=True,
dashboard=False,
verbose=True,
)

growth_agent = Agent(
agent_name="Growth-Agent",
system_prompt=GROWTH_AGENT_SYS_PROMPT,
model_name="deepseek/deepseek-reasoner",
autosave=True,
dashboard=False,
verbose=True,
)

treasury_agent = Agent(
agent_name="Treasury-Agent",
system_prompt=TREASURY_AGENT_SYS_PROMPT,
model_name="deepseek/deepseek-reasoner",
autosave=True,
dashboard=False,
verbose=True,
)

operations_agent = Agent(
agent_name="Operations-Agent",
system_prompt=OPERATIONS_AGENT_SYS_PROMPT,
model_name="deepseek/deepseek-reasoner",
autosave=True,
dashboard=False,
verbose=True,
)

agents = [
marketing_agent,
product_agent,
growth_agent,
treasury_agent,
operations_agent,
]


class DAOSwarmRunner:
"""
A class to manage and run a swarm of agents in a discussion.
"""

def __init__(
self,
agents: list,
max_loops: int = 5,
shared_context: str = "",
) -> None:
"""
Initializes the DAO Swarm Runner.
Args:
agents (list): A list of agents in the swarm.
max_loops (int, optional): The maximum number of discussion loops between agents. Defaults to 5.
shared_context (str, optional): The shared context for all agents to base their discussion on. Defaults to an empty string.
"""
self.agents = agents
self.max_loops = max_loops
self.shared_context = shared_context
self.discussion_history = []

def run(self, task: str) -> str:
"""
Runs the swarm in a random discussion.
Args:
task (str): The task or context that agents will discuss.
Returns:
str: The final discussion output after all loops.
"""
print(f"Task: {task}")
print("Initializing Random Discussion...")

# Initialize the discussion with the shared context
current_message = (
f"Task: {task}\nContext: {self.shared_context}"
)
self.discussion_history.append(current_message)

# Run the agents in a randomized discussion
for loop in range(self.max_loops):
print(f"\n--- Loop {loop + 1}/{self.max_loops} ---")
# Choose a random agent
agent = random.choice(self.agents)
print(f"Agent {agent.agent_name} is responding...")

# Run the agent and get a response
response = agent.run(current_message)
print(f"Agent {agent.agent_name} says:\n{response}\n")

# Append the response to the discussion history
self.discussion_history.append(
f"{agent.agent_name}: {response}"
)

# Update the current message for the next agent
current_message = response

print("\n--- Discussion Complete ---")
return "\n".join(self.discussion_history)


swarm = DAOSwarmRunner(agents=agents, max_loops=1, shared_context="")

# User input for product description
product_description = """
The DAO is focused on decentralized governance for climate action.
It funds projects aimed at reducing carbon emissions and incentivizes community participation with a native token.
"""

# Assign a shared context for all agents
swarm.shared_context = product_description

# Run the swarm
task = """
Analyze the product description and create a collaborative strategy for marketing, product, growth, treasury, and operations. Ensure all recommendations align with the DAO's mission of reducing carbon emissions.
"""
output = swarm.run(task)

# Print the swarm output
print("Collaborative Strategy Output:\n", output)
9 changes: 9 additions & 0 deletions deepseek_r1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from swarms import Agent

Agent(
agent_name="Stock-Analysis-Agent",
model_name="deepseek/deepseek-reasoner",
max_loops="auto",
interactive=True,
streaming_on=True,
).run("What are 5 hft algorithms")
3 changes: 3 additions & 0 deletions docs/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@ nav:
- Meme Agents:
- Bob The Builder: "swarms/examples/bob_the_builder.md"
- Meme Agent Builder: "swarms/examples/meme_agents.md"
- Multi-Agent Collaboration:
- Swarms DAO: "swarms/examples/swarms_dao.md"
- Swarm Models:
- Overview: "swarms/models/index.md"
# - Models Available: "swarms/models/index.md"
Expand All @@ -242,6 +244,7 @@ nav:
- Swarms Cloud API:
# - Overview: "swarms_cloud/main.md"
- Overview: "swarms_cloud/vision.md"
- Deploying Swarms on Google Cloud Run: "swarms_cloud/cloud_run.md"
# - Swarms Cloud CLI: "swarms_cloud/cli.md"
- Swarm APIs:
- MCS API: "swarms_cloud/mcs_api.md"
Expand Down
2 changes: 1 addition & 1 deletion docs/swarms/examples/lumo.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class Lumo:

Agent(
agent_name="Solana-Analysis-Agent",
model_name=Lumo(),
llm=Lumo(),
max_loops="auto",
interactive=True,
streaming_on=True,
Expand Down
Loading

0 comments on commit bbb8f4e

Please sign in to comment.