From 3c1b16ae9af63782da85048343b50d3f777503ab Mon Sep 17 00:00:00 2001 From: Domain Genius <77184176+Miracle395@users.noreply.github.com> Date: Thu, 17 Apr 2025 19:34:45 +0000 Subject: [PATCH 1/4] Add summarize_url skill to fetch and summarize webpages --- skills/summarize/summarize_url.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 skills/summarize/summarize_url.py diff --git a/skills/summarize/summarize_url.py b/skills/summarize/summarize_url.py new file mode 100644 index 00000000..771d3174 --- /dev/null +++ b/skills/summarize/summarize_url.py @@ -0,0 +1,20 @@ +import requests +from bs4 import BeautifulSoup + +def run(url: str, *args, **kwargs): + """Fetch and return the first few sentences from the webpage at the given URL.""" + try: + response = requests.get(url, timeout=10) + response.raise_for_status() + + soup = BeautifulSoup(response.text, "html.parser") + paragraphs = soup.find_all("p") + text = " ".join(p.get_text() for p in paragraphs if len(p.get_text()) > 40) + + if not text: + return "Couldn't find readable content on the page." + + sentences = text.split(". ") + return ". ".join(sentences[:3]) + "." + except Exception as e: + return f"Error: {e}" From 5301750199d21ae433e97154d754dd08130126be Mon Sep 17 00:00:00 2001 From: Domain Genius <77184176+Miracle395@users.noreply.github.com> Date: Mon, 21 Apr 2025 09:29:02 +0000 Subject: [PATCH 2/4] Add skill: Fetch crypto prices --- skills/fetch_prices/fetch_crypto_prices.py | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 skills/fetch_prices/fetch_crypto_prices.py diff --git a/skills/fetch_prices/fetch_crypto_prices.py b/skills/fetch_prices/fetch_crypto_prices.py new file mode 100644 index 00000000..732202eb --- /dev/null +++ b/skills/fetch_prices/fetch_crypto_prices.py @@ -0,0 +1,38 @@ +import requests + +def run(token_name: str = "bitcoin") -> dict: + """ + Fetch the current price and market data for a cryptocurrency using CoinGecko API. + + Args: + token_name (str): The name of the cryptocurrency (e.g., 'bitcoin', 'ethereum'). + + Returns: + dict: A dictionary with price, market cap, and 24h change. + """ + url = f"https://api.coingecko.com/api/v3/simple/price" + params = { + "ids": token_name.lower(), + "vs_currencies": "usd", + "include_market_cap": "true", + "include_24hr_change": "true" + } + + try: + response = requests.get(url, params=params) + response.raise_for_status() + data = response.json() + + if token_name not in data: + return {"error": f"Token '{token_name}' not found on CoinGecko."} + + token_data = data[token_name] + return { + "token": token_name, + "price_usd": token_data["usd"], + "market_cap_usd": token_data.get("usd_market_cap"), + "24h_change_percent": round(token_data.get("usd_24h_change", 0), 2) + } + + except requests.exceptions.RequestException as e: + return {"error": str(e)} From 1c885c747b85df24d6bd06a40996320faa872de7 Mon Sep 17 00:00:00 2001 From: Domain Genius <77184176+Miracle395@users.noreply.github.com> Date: Mon, 21 Apr 2025 09:36:07 +0000 Subject: [PATCH 3/4] Add new skill: Fetch real-time crypto prices from CoinGecko --- skills/fetch_prices/fetch_crypto_prices.py | 35 ++++++++-------------- 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/skills/fetch_prices/fetch_crypto_prices.py b/skills/fetch_prices/fetch_crypto_prices.py index 732202eb..74592e58 100644 --- a/skills/fetch_prices/fetch_crypto_prices.py +++ b/skills/fetch_prices/fetch_crypto_prices.py @@ -2,37 +2,28 @@ def run(token_name: str = "bitcoin") -> dict: """ - Fetch the current price and market data for a cryptocurrency using CoinGecko API. + Fetch real-time price data for a cryptocurrency from the CoinGecko API. Args: - token_name (str): The name of the cryptocurrency (e.g., 'bitcoin', 'ethereum'). + token_name (str): The cryptocurrency ID (e.g., 'bitcoin', 'ethereum'). Returns: - dict: A dictionary with price, market cap, and 24h change. + dict: Dictionary containing token name, USD price, market cap, and 24h change. """ - url = f"https://api.coingecko.com/api/v3/simple/price" - params = { - "ids": token_name.lower(), - "vs_currencies": "usd", - "include_market_cap": "true", - "include_24hr_change": "true" - } - + url = f"https://api.coingecko.com/api/v3/coins/{token_name.lower()}" try: - response = requests.get(url, params=params) + response = requests.get(url) response.raise_for_status() data = response.json() - if token_name not in data: - return {"error": f"Token '{token_name}' not found on CoinGecko."} - - token_data = data[token_name] return { - "token": token_name, - "price_usd": token_data["usd"], - "market_cap_usd": token_data.get("usd_market_cap"), - "24h_change_percent": round(token_data.get("usd_24h_change", 0), 2) + "token": token_name.lower(), + "price_usd": data["market_data"]["current_price"]["usd"], + "market_cap_usd": data["market_data"]["market_cap"]["usd"], + "24h_change_percent": data["market_data"]["price_change_percentage_24h"] } - except requests.exceptions.RequestException as e: - return {"error": str(e)} + except requests.RequestException as e: + return {"error": f"Failed to fetch data: {str(e)}"} + except KeyError: + return {"error": "Unexpected response format. Please check token name."} From 8ff8d3e3598a34a126e704d5fbfae0da20f6e30b Mon Sep 17 00:00:00 2001 From: Domain Genius <77184176+Miracle395@users.noreply.github.com> Date: Mon, 21 Apr 2025 10:50:54 +0100 Subject: [PATCH 4/4] Delete skills/summarize directory --- skills/summarize/summarize_url.py | 20 -------------------- 1 file changed, 20 deletions(-) delete mode 100644 skills/summarize/summarize_url.py diff --git a/skills/summarize/summarize_url.py b/skills/summarize/summarize_url.py deleted file mode 100644 index 771d3174..00000000 --- a/skills/summarize/summarize_url.py +++ /dev/null @@ -1,20 +0,0 @@ -import requests -from bs4 import BeautifulSoup - -def run(url: str, *args, **kwargs): - """Fetch and return the first few sentences from the webpage at the given URL.""" - try: - response = requests.get(url, timeout=10) - response.raise_for_status() - - soup = BeautifulSoup(response.text, "html.parser") - paragraphs = soup.find_all("p") - text = " ".join(p.get_text() for p in paragraphs if len(p.get_text()) > 40) - - if not text: - return "Couldn't find readable content on the page." - - sentences = text.split(". ") - return ". ".join(sentences[:3]) + "." - except Exception as e: - return f"Error: {e}"