Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions skills/exchangerateapi/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# skills/currency_conversion/__init__.py
from .exchange_rate_api import ExchangeRateAPISkill

def get_skills(config):
return [
ExchangeRateAPISkill(api_key=config["api_key"])
]
6 changes: 6 additions & 0 deletions skills/exchangerateapi/base.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# skills/currency_conversion/base.py
from intentkit.skills.base_skill import BaseSkill

class CurrencyConversionSkill(BaseSkill):
def convert(self, amount: float, from_currency: str, to_currency: str) -> float:
raise NotImplementedError("This method must be implemented by subclasses.")
18 changes: 18 additions & 0 deletions skills/exchangerateapi/exchange_rate_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# skills/currency_conversion/exchange_rate_api.py
import requests
from .base import CurrencyConversionSkill

class ExchangeRateAPISkill(CurrencyConversionSkill):
def __init__(self, api_key: str):
self.api_key = api_key

def convert(self, amount: float, from_currency: str, to_currency: str) -> float:
url = f"https://v6.exchangerate-api.com/v6/{self.api_key}/pair/{from_currency}/{to_currency}"
response = requests.get(url)
data = response.json()

if response.status_code != 200 or 'conversion_rate' not in data:
raise ValueError("Failed to retrieve conversion rate.")

rate = data['conversion_rate']
return amount * rate
Binary file added skills/exchangerateapi/exchangerateapi.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions skills/exchangerateapi/schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"title": "Currency Conversion Skills",
"description": "Convert between any two currencies (e.g., USD to EUR, BTC to NGN) using the ExchangeRate-API.",
"x-icon": "https://ai.service.crestal.dev/skills/exchangerateapi/exchangerateapi.png",
"x-api-key": "required",
"properties": {
"enabled": {
"type": "boolean",
"title": "Enabled",
"description": "Whether this skill category is enabled",
"default": false
},
"states": {
"type": "object",
"properties": {
"convert_currency": {
"type": "string",
"enum": ["disabled", "public", "private"],
"x-enum-title": [
"Disabled",
"Agent Owner + All Users",
"Agent Owner Only"
],
"description": "Convert one currency to another using real-time exchange rates.",
"default": "disabled"
}
},
"description": "Skill states: enable or restrict access to individual conversion tasks."
}
},
"required": ["states", "enabled"]
}