Skip to content

Commit

Permalink
[NEW TOOLS]
Browse files Browse the repository at this point in the history
  • Loading branch information
kyegomez committed Jan 30, 2025
1 parent c079d5f commit 28a4473
Show file tree
Hide file tree
Showing 13 changed files with 1,184 additions and 6 deletions.
4 changes: 4 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,7 @@ OPENAI_API_KEY=""

# Synthesia API Key
SYNTHESIA_API_KEY=""


# Exa.AI API Key
EXA_API_KEY=""
18 changes: 18 additions & 0 deletions check_solana_address.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from swarms_tools.finance.check_solana_address import (
check_solana_balance,
check_multiple_wallets,
)

print(
check_solana_balance(
"7MaX4muAn8ZQREJxnupm8sgokwFHujgrGfH9Qn81BuEV"
)
)
print(
check_multiple_wallets(
[
"7MaX4muAn8ZQREJxnupm8sgokwFHujgrGfH9Qn81BuEV",
"7MaX4muAn8ZQREJxnupm8sgokwFHujgrGfH9Qn81BuEV",
]
)
)
File renamed without changes.
74 changes: 74 additions & 0 deletions examples/mcs_auto_reply.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import os

from swarm_models import OpenAIChat
from swarms import Agent
from dotenv import load_dotenv
from swarms_tools.social_media.twitter_tool import (
reply_to_mentions_with_agent,
)

load_dotenv()

model_name = "gpt-4o"

model = OpenAIChat(
model_name=model_name,
max_tokens=3000,
openai_api_key=os.getenv("OPENAI_API_KEY"),
)


medical_coder = Agent(
agent_name="Medical Coder",
system_prompt="""
You are a highly experienced and certified medical coder with extensive knowledge of ICD-10 coding guidelines, clinical documentation standards, and compliance regulations. Your responsibility is to ensure precise, compliant, and well-documented coding for all clinical cases.
### Primary Responsibilities:
1. **Review Clinical Documentation**: Analyze all available clinical records, including specialist inputs, physician notes, lab results, imaging reports, and discharge summaries.
2. **Assign Accurate ICD-10 Codes**: Identify and assign appropriate codes for primary diagnoses, secondary conditions, symptoms, and complications.
3. **Ensure Coding Compliance**: Follow the latest ICD-10-CM/PCS coding guidelines, payer-specific requirements, and organizational policies.
4. **Document Code Justification**: Provide clear, evidence-based rationale for each assigned code.
### Detailed Coding Process:
- **Review Specialist Inputs**: Examine all relevant documentation to capture the full scope of the patient's condition and care provided.
- **Identify Diagnoses**: Determine the primary and secondary diagnoses, as well as any symptoms or complications, based on the documentation.
- **Assign ICD-10 Codes**: Select the most accurate and specific ICD-10 codes for each identified diagnosis or condition.
- **Document Supporting Evidence**: Record the documentation source (e.g., lab report, imaging, or physician note) for each code to justify its assignment.
- **Address Queries**: Note and flag any inconsistencies, missing information, or areas requiring clarification from providers.
### Output Requirements:
Your response must be clear, structured, and compliant with professional standards. Use the following format:
1. **Primary Diagnosis Codes**:
- **ICD-10 Code**: [e.g., E11.9]
- **Description**: [e.g., Type 2 diabetes mellitus without complications]
- **Supporting Documentation**: [e.g., Physician's note dated MM/DD/YYYY]
2. **Secondary Diagnosis Codes**:
- **ICD-10 Code**: [Code]
- **Description**: [Description]
- **Order of Clinical Significance**: [Rank or priority]
3. **Symptom Codes**:
- **ICD-10 Code**: [Code]
- **Description**: [Description]
4. **Complication Codes**:
- **ICD-10 Code**: [Code]
- **Description**: [Description]
- **Relevant Documentation**: [Source of information]
5. **Coding Notes**:
- Observations, clarifications, or any potential issues requiring provider input.
### Additional Guidelines:
- Always prioritize specificity and compliance when assigning codes.
- For ambiguous cases, provide a brief note with reasoning and flag for clarification.
- Ensure the output format is clean, consistent, and ready for professional use.
""",
llm=model,
max_loops=1,
dynamic_temperature_enabled=True,
)

print(reply_to_mentions_with_agent(medical_coder))
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "swarms-tools"
version = "0.1.3"
version = "0.1.5"
description = "Paper - Pytorch"
license = "MIT"
authors = ["Kye Gomez <[email protected]>"]
Expand Down
6 changes: 6 additions & 0 deletions swarms_tools/finance/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
fetch_solana_token_pairs,
)
from swarms_tools.finance.macro_tool import fetch_macro_financial_data
from swarms_tools.finance.check_solana_address import (
check_solana_balance,
check_multiple_wallets,
)

__all__ = [
"fetch_stock_news",
Expand All @@ -38,4 +42,6 @@
"fetch_latest_token_boosts",
"fetch_solana_token_pairs",
"fetch_macro_financial_data",
"check_solana_balance",
"check_multiple_wallets",
]
142 changes: 142 additions & 0 deletions swarms_tools/finance/check_solana_address.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
import requests
import os


class SolanaWalletBalanceChecker:
def __init__(
self,
api_key: str = os.getenv("HELIUS_API_KEY"),
base_url: str = "https://api.helius.xyz/v0/addresses/",
):
"""
Initializes the Solana wallet balance checker using Hélius API.
Args:
api_key (str): Your Hélius API key.
base_url (str): The base URL for the Hélius API.
"""
self.api_key = api_key
self.base_url = base_url
self.token_mapping = self.load_token_list()

def load_token_list(self) -> dict:
"""
Loads the Solana token list to map mint addresses to token names.
Returns:
dict: A dictionary mapping mint addresses to token names.
"""
url = "https://raw.githubusercontent.com/solana-labs/token-list/main/src/tokens/solana.tokenlist.json"
try:
response = requests.get(url)
response.raise_for_status()
token_list = response.json()["tokens"]
return {
token["address"]: token["symbol"]
for token in token_list
}
except requests.exceptions.RequestException as e:
print(f"Error fetching token list: {e}")
return {}

def get_wallet_balances(self, wallet_address: str) -> dict:
"""
Fetches the SOL and SPL token balances for the given wallet address.
Args:
wallet_address (str): The public key of the wallet.
Returns:
dict: A dictionary containing SOL and SPL token balances.
"""
url = f"{self.base_url}{wallet_address}/balances?api-key={self.api_key}"
try:
response = requests.get(url)
response.raise_for_status() # Ensure the request was successful
return response.json()
except requests.exceptions.RequestException as e:
print(f"Error fetching wallet balances: {e}")
return None

def display_balances(self, wallet_address: str) -> None:
"""
Fetches and displays the SOL and SPL token balances with token names.
Args:
wallet_address (str): The public key of the wallet.
"""
print(f"Fetching balances for wallet: {wallet_address}")
balances_data = self.get_wallet_balances(wallet_address)

if not balances_data:
print("No balance data found or API request failed.")
return

# Display SOL balance
sol_balance = (
balances_data.get("nativeBalance", 0) / 1e9
) # Convert lamports to SOL
print(f"SOL: {sol_balance}")

# Display SPL token balances
tokens = balances_data.get("tokens", [])
if not tokens:
print("No SPL tokens found.")
else:
print("SPL Tokens:")
for token in tokens:
mint = token.get("mint")
amount = token.get("amount", 0)
decimals = token.get("decimals", 0)
balance = amount / (10**decimals)
token_name = self.token_mapping.get(
mint, "Unknown Token"
)
print(f" {token_name} ({mint}): {balance}")


def check_solana_balance(wallet_address: str) -> str:
"""
Checks and returns the SOL and SPL token balances for a given Solana wallet address.
Args:
wallet_address (str): The public key of the Solana wallet.
Returns:
str: A string representation of the SOL and SPL token balances.
Raises:
ValueError: If the wallet_address is not a string.
TypeError: If the wallet_address is not a valid Solana wallet address.
"""
try:
checker = SolanaWalletBalanceChecker(
api_key=os.getenv("HELIUS_API_KEY")
)
balance_info = checker.display_balances(wallet_address)
return str(balance_info)
except Exception as e:
raise TypeError(
f"Invalid wallet_address: {wallet_address}. Error: {e}"
)


def check_multiple_wallets(wallet_addresses: list[str]) -> str:
"""
Checks and returns the SOL and SPL token balances for multiple Solana wallet addresses.
Args:
wallet_addresses (list[str]): A list of public keys of the Solana wallets.
Returns:
list[str]: A list of string representations of the SOL and SPL token balances for each wallet address.
Raises:
ValueError: If any wallet_address in the list is not a string.
TypeError: If any wallet_address in the list is not a valid Solana wallet address.
"""
out = [
check_solana_balance(wallet_address)
for wallet_address in wallet_addresses
]
return str(out)
4 changes: 3 additions & 1 deletion swarms_tools/finance/coingecko_tool.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from typing import Dict, Any
from typing import Any, Dict

import requests
from loguru import logger

from swarms_tools.utils.formatted_string import (
format_object_to_string,
)
Expand Down
Loading

0 comments on commit 28a4473

Please sign in to comment.