From db6cd6012e1255589c87f370345512343488db8f Mon Sep 17 00:00:00 2001 From: Siraj R Aizlewood <siraj@aurelio.ai> Date: Mon, 13 May 2024 18:05:34 +0400 Subject: [PATCH] Tested and then removed debugging notebook. --- docs/10-debugging-discord-issue.ipynb | 163 -------------------------- 1 file changed, 163 deletions(-) delete mode 100644 docs/10-debugging-discord-issue.ipynb diff --git a/docs/10-debugging-discord-issue.ipynb b/docs/10-debugging-discord-issue.ipynb deleted file mode 100644 index 9c781d4a..00000000 --- a/docs/10-debugging-discord-issue.ipynb +++ /dev/null @@ -1,163 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "c:\\Users\\Siraj\\Documents\\Personal\\Work\\Aurelio\\Virtual Environments\\semantic_router_3\\Lib\\site-packages\\tqdm\\auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n", - " from .autonotebook import tqdm as notebook_tqdm\n", - "\u001b[32m2024-05-13 17:10:58 INFO semantic_router.utils.logger local\u001b[0m\n", - "\u001b[32m2024-05-13 17:10:59 INFO semantic_router.utils.logger Extracting function input...\u001b[0m\n", - "\u001b[32m2024-05-13 17:11:01 INFO semantic_router.utils.logger LLM output: {\n", - " \"location\": \"berlin\"\n", - "}\u001b[0m\n", - "\u001b[32m2024-05-13 17:11:01 INFO semantic_router.utils.logger Function inputs: {'location': 'berlin'}\u001b[0m\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "2024-05-13 15:11\n" - ] - } - ], - "source": [ - "import datetime\n", - "import pytz\n", - "from semantic_router.llms.openrouter import OpenRouterLLM\n", - "from semantic_router import Route, RouteLayer\n", - "from semantic_router.encoders import HuggingFaceEncoder\n", - "from semantic_router.utils.function_call import get_schema\n", - "import geonamescache\n", - "\n", - "class Skill:\n", - " def __init__(self):\n", - " self.geocoder = geonamescache.GeonamesCache()\n", - " self.location = self.geocode_location()\n", - " self.route = Route(\n", - " name='time',\n", - " utterances=[\n", - " \"tell me what is the time\",\n", - " \"what is the date \",\n", - " \"time in varshava\",\n", - " \"date\",\n", - " \"what date is it today\",\n", - " \"time in ny\",\n", - " \"what is the time and date in boston\",\n", - " \"time\",\n", - " \"what is the time in makhachkala\",\n", - " \"date time in st petersburg\",\n", - " \"what's the date in vienna\",\n", - " \"date time\"\n", - " ],\n", - " function_schema=get_schema(self.run),\n", - "\n", - " )\n", - "\n", - " self.rl = RouteLayer(\n", - " encoder=HuggingFaceEncoder(),\n", - " routes=[self.route],\n", - " llm=OpenRouterLLM(\n", - " name='mistralai/mistral-7b-instruct:free',\n", - " openrouter_api_key='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'\n", - "\n", - " )\n", - " )\n", - "\n", - " def geocode_location(self, location_name=None):\n", - " if location_name:\n", - " location_name = location_name.title()\n", - " location = list(\n", - " self.geocoder.get_cities_by_name(location_name)[0].values() if self.geocoder.get_cities_by_name(\n", - " location_name) else self.geocoder.get_us_states_by_names(location_name)[\n", - " 0].values() if self.geocoder.get_us_states_by_names(location_name) else\n", - " self.geocoder.get_countries_by_names(location_name)[\n", - " 0].values() if self.geocoder.get_countries_by_names(location_name) else None)[0]\n", - " return location['timezone']\n", - " else:\n", - " return ''\n", - "\n", - " def run(self, location:str=None, day:int=0, hour:int=0, minute:int=0):\n", - " \"\"\"Finds the current time in a specific location.\n", - "\n", - " :param location: The location to find the current time in, should\n", - " be a valid location. Put the place name itself\n", - " like \"rome\", or \"new york\" in the lowercase.\n", - " :type location: str\n", - "\n", - " :param day: The offset in days from the current date.\n", - " Use positive integers for future dates (e.g., day=1 for tomorrow),\n", - " negative integers for past dates (e.g., day=-1 for yesterday),\n", - " and 0 for the current date.\n", - " :type day: int\n", - "\n", - " :param hour: The offset in hours from the current time.\n", - " Use positive integers for future times (e.g., hour=1 for one hour ahead),\n", - " negative integers for past times (e.g., hour=-1 for one hour ago),\n", - " and 0 to maintain the current hour.\n", - " :type hour: int\n", - "\n", - " :param minute: The offset in minutes from the current time.\n", - " Use positive integers for future minutes (e.g., minute=20 for twenty minutes ahead),\n", - " negative integers for past minutes (e.g., minute=-20 for twenty minutes ago),\n", - " and 0 to maintain the current minute.\n", - " :type minute: int\n", - "\n", - " :return: The time in the specified location.\"\"\"\n", - " timezone = self.geocode_location(location)\n", - " if timezone:\n", - " tz = pytz.timezone(timezone)\n", - " else:\n", - " tz = None\n", - "\n", - " current_time = datetime.datetime.now(tz) + datetime.timedelta(days=day)\n", - "\n", - " # Adding hours and minutes to the current time\n", - " current_time += datetime.timedelta(hours=hour, minutes=minute)\n", - "\n", - " # Format the date and time as required\n", - " formatted_time = current_time.strftime(\"%Y-%m-%d %H:%M\")\n", - "\n", - " return formatted_time\n", - "\n", - "s = Skill()\n", - "out = s.rl('time in berlin')\n", - "print(s.run(**out.function_call))" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "semantic_router_3", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.11.4" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} -- GitLab