From 33cecf622ade2502ab24e6eebba59168e9713b92 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 21 Apr 2025 19:29:23 +0200 Subject: [PATCH 1/2] Add exchangerateapi skill using ExchangeRate-API --- skills/exchangerateapi/__init__.py | 7 +++++++ skills/exchangerateapi/base.py | 6 ++++++ skills/exchangerateapi/exchange_rate_api.py | 18 ++++++++++++++++++ skills/exchangerateapi/exchangerateapi.png | Bin 0 -> 2164 bytes skills/exchangerateapi/schema.json | 11 +++++++++++ 5 files changed, 42 insertions(+) create mode 100644 skills/exchangerateapi/__init__.py create mode 100644 skills/exchangerateapi/base.py create mode 100644 skills/exchangerateapi/exchange_rate_api.py create mode 100644 skills/exchangerateapi/exchangerateapi.png create mode 100644 skills/exchangerateapi/schema.json diff --git a/skills/exchangerateapi/__init__.py b/skills/exchangerateapi/__init__.py new file mode 100644 index 00000000..aa273558 --- /dev/null +++ b/skills/exchangerateapi/__init__.py @@ -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"]) + ] diff --git a/skills/exchangerateapi/base.py b/skills/exchangerateapi/base.py new file mode 100644 index 00000000..35ad1359 --- /dev/null +++ b/skills/exchangerateapi/base.py @@ -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.") diff --git a/skills/exchangerateapi/exchange_rate_api.py b/skills/exchangerateapi/exchange_rate_api.py new file mode 100644 index 00000000..78c70f09 --- /dev/null +++ b/skills/exchangerateapi/exchange_rate_api.py @@ -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 diff --git a/skills/exchangerateapi/exchangerateapi.png b/skills/exchangerateapi/exchangerateapi.png new file mode 100644 index 0000000000000000000000000000000000000000..3640feee8072eed28c986c0c8a2e4f58cbe5e9c5 GIT binary patch literal 2164 zcmZ`*`9IW&AC{w-tu04L%NMhgt0ZTR6{W!>*J|a~$W@f|&9csv@FF(fnIu=H6_o@2em?xNONhAG-u%Uxr zGbXIJ@YqC|bWtpdp^^0PYyLa<_aXsaD!I;}1nl6aM1mR)(+Izw#iWWA3V}i%Pbc|M zw#^9}HpILzl45yPlDY$kXyPC~p%4NAMS~!hZ$!4T5D9&W;ibOmp z;5BjqOX4PU2cJkMJCLvj__a7_1!%XKJ6yRuh)Nh1@@_CFLXk+JP!zCe8O$9l z0nY?j3>Ir0yS0JCN~KbXL_($0a#&O%g)9<_WHK3t$0d+SbS6V0m2Pcs+mW{J19U2# zzJ=eG%jKkj0*r2xH_!`dbi%h?Pj08pq@fl#=K!vY+(SRz4km{|Pw<~EMa z<@5=-I09ZOlj4X34wt)4B;ZLznOu%1k+?h_kwPKw?6BCt7m1iJ5HMIwzJR|&r-?)& zDuYgAFj#Chm(LT4#ai9IQ7S5XQT{&OVc89gdigoM^M+FgyOtiCmMz{dvgA5l)UjLQ z(NnPdzg;Xsds)TKq7eI^`!N1297eAtkT96Kd~|+N<1e0PwA|4y&0OXnSxSHONn73f z(7)jO7mRn~E1^Wb+Rdx&w<*9Q7i0A=)x*n=%7e*kF@~NOhqg}HE^%#Jg6;{co;tY+ zJo`f);zvmLC7yPsVW_bwL`cxs5%AQJ(HnfV%)>4BtKXJ@# z_+L5&+BR$CI+vP;a!`AL{L&luOY+5|u5+%@sB;VwvLP_6HORp(a}H%4^YQG02T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INWK}-fJ*0cBO=q6&osf)1tTyGQi=%X$Z3as`u#XY> zFeczc`O5s+ZW!6wX4xLi%=)7XmIiJwT6_85Wa*hUJ&=`r3<-;{!pZNR^|XPwF0}cr z{+0QCM>ceZb-*azHZQsSb0y|g1ZXP)uBxkIGJgm;LyIu%s-67#aRWKR@`owMnURlY zcQiUendLd)KR1fPv?}&!&faHrI4K;{c?SI<-M(&9ynp|%?aY-9)V#PMO3gnJM`_;;} zB<|5x!5dxyuYY-2nDyxQ4)mu8&B5XIFKDEFZq!MKzs)p@P5%Yi5V1i;_+opFgXNjs QZ$icYe4tPF+4$mr0M%=yc>n+a literal 0 HcmV?d00001 diff --git a/skills/exchangerateapi/schema.json b/skills/exchangerateapi/schema.json new file mode 100644 index 00000000..edb2fc9f --- /dev/null +++ b/skills/exchangerateapi/schema.json @@ -0,0 +1,11 @@ +{ + "title": "Currency Conversion Skill Configuration", + "type": "object", + "required": ["api_key"], + "properties": { + "api_key": { + "type": "string", + "description": "Your API key for ExchangeRate-API." + } + } +} From 594823b4391032404c185bd6d088200aa5194d39 Mon Sep 17 00:00:00 2001 From: Olugbue Reginald Chinazom <90420197+0xnald@users.noreply.github.com> Date: Mon, 5 May 2025 13:39:11 +0100 Subject: [PATCH 2/2] Updated schema.json --- skills/exchangerateapi/schema.json | 35 +++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/skills/exchangerateapi/schema.json b/skills/exchangerateapi/schema.json index edb2fc9f..72aba7ac 100644 --- a/skills/exchangerateapi/schema.json +++ b/skills/exchangerateapi/schema.json @@ -1,11 +1,34 @@ { - "title": "Currency Conversion Skill Configuration", + "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", - "required": ["api_key"], + "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": { - "api_key": { - "type": "string", - "description": "Your API key for ExchangeRate-API." + "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"] }