diff --git a/docs/encoders/fastembed.ipynb b/docs/encoders/fastembed.ipynb index 3134141e12c32f036865ec0642fb1b64156540a1..800d0e84f975d238b09f995899112a0be1780872 100644 --- a/docs/encoders/fastembed.ipynb +++ b/docs/encoders/fastembed.ipynb @@ -47,7 +47,7 @@ "metadata": {}, "outputs": [], "source": [ - "!pip install -qU \"semantic-router[fastembed]==0.0.20\"" + "!pip install -qU \"semantic-router[fastembed]==0.1.0\"" ] }, { @@ -59,7 +59,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 2, "metadata": {}, "outputs": [], "source": [ @@ -87,7 +87,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 3, "metadata": {}, "outputs": [], "source": [ @@ -114,9 +114,20 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 4, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "Fetching 5 files: 0%| | 0/5 [00:00<?, ?it/s]c:\\Users\\Joshu\\OneDrive\\Documents\\Aurelio\\agents-course\\07-pratical-ai\\.venv\\Lib\\site-packages\\huggingface_hub\\file_download.py:140: UserWarning: `huggingface_hub` cache-system uses symlinks by default to efficiently store duplicated files but your machine does not support them in C:\\Users\\Joshu\\AppData\\Local\\Temp\\fastembed_cache\\models--qdrant--bge-small-en-v1.5-onnx-q. Caching files will still work but in a degraded version that might require more space on your disk. This warning can be disabled by setting the `HF_HUB_DISABLE_SYMLINKS_WARNING` environment variable. For more details, see https://huggingface.co/docs/huggingface_hub/how-to-cache#limitations.\n", + "To support symlinks on Windows, you either need to activate Developer Mode or to run Python as an administrator. In order to activate developer mode, see this article: https://docs.microsoft.com/en-us/windows/apps/get-started/enable-your-device-for-development\n", + " warnings.warn(message)\n", + "Fetching 5 files: 100%|██████████| 5/5 [00:06<00:00, 1.33s/it]\n" + ] + } + ], "source": [ "from semantic_router.encoders import FastEmbedEncoder\n", "\n", @@ -139,21 +150,22 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ - "\u001b[32m2024-01-06 16:53:16 INFO semantic_router.utils.logger Initializing RouteLayer\u001b[0m\n" + "2025-01-07 15:40:59 - semantic_router.utils.logger - WARNING - base.py:356 - _get_index() - No index provided. Using default LocalIndex.\n", + "2025-01-07 15:41:00 - semantic_router.utils.logger - WARNING - local.py:148 - _write_config() - No config is written for LocalIndex.\n" ] } ], "source": [ - "from semantic_router.layer import RouteLayer\n", + "from semantic_router.routers import SemanticRouter\n", "\n", - "rl = RouteLayer(encoder=encoder, routes=routes)" + "rl = SemanticRouter(encoder=encoder, routes=routes, auto_sync=\"local\")" ] }, { @@ -165,16 +177,16 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "RouteChoice(name='politics', function_call=None)" + "RouteChoice(name='politics', function_call=None, similarity_score=None)" ] }, - "execution_count": 5, + "execution_count": 6, "metadata": {}, "output_type": "execute_result" } @@ -185,16 +197,16 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "RouteChoice(name='chitchat', function_call=None)" + "RouteChoice(name='chitchat', function_call=None, similarity_score=None)" ] }, - "execution_count": 6, + "execution_count": 7, "metadata": {}, "output_type": "execute_result" } @@ -212,22 +224,22 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "RouteChoice(name=None, function_call=None)" + "RouteChoice(name=None, function_call=None, similarity_score=None)" ] }, - "execution_count": 7, + "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "rl(\"I'm interested in learning about llama 2\")" + "rl(\"I'm interested in learning about llama 2 mechanics\")" ] }, { @@ -254,7 +266,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.18" + "version": "3.12.7" } }, "nbformat": 4, diff --git a/docs/encoders/google.ipynb b/docs/encoders/google.ipynb index 38da5ea1b1a40408e96d970365da1e6770c07ec1..2dcc8587dadf53d3d46672cd1fb1436d02a45e35 100644 --- a/docs/encoders/google.ipynb +++ b/docs/encoders/google.ipynb @@ -53,7 +53,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "metadata": {}, "outputs": [], "source": [ @@ -81,7 +81,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "metadata": {}, "outputs": [], "source": [ @@ -133,9 +133,9 @@ "metadata": {}, "outputs": [], "source": [ - "from semantic_router.layer import RouteLayer\n", + "from semantic_router.routers import SemanticRouter\n", "\n", - "rl = RouteLayer(encoder=encoder, routes=routes)" + "rl = SemanticRouter(encoder=encoder, routes=routes, auto_sync=\"local\")" ] }, { @@ -203,7 +203,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.8" + "version": "3.12.7" } }, "nbformat": 4, diff --git a/docs/encoders/huggingface-endpoint.ipynb b/docs/encoders/huggingface-endpoint.ipynb index c5714142e5b204f7c88740aeccebe92db1cdf042..30b45ee460614071ba856316b239c5a07e9258af 100644 --- a/docs/encoders/huggingface-endpoint.ipynb +++ b/docs/encoders/huggingface-endpoint.ipynb @@ -41,7 +41,7 @@ "metadata": {}, "outputs": [], "source": [ - "# !pip install -qU semantic-router==0.0.20" + "!pip install -qU \"semantic-router==0.1.0\"" ] }, { @@ -55,16 +55,7 @@ "cell_type": "code", "execution_count": 2, "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "d:\\Program_Installation\\anaconda\\envs\\testenv\\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" - ] - } - ], + "outputs": [], "source": [ "from semantic_router import Route\n", "\n", @@ -3187,9 +3178,9 @@ } ], "source": [ - "from semantic_router.layer import RouteLayer\n", + "from semantic_router.routers import SemanticRouter\n", "\n", - "rl = RouteLayer(encoder=encoder, routes=routes)" + "rl = SemanticRouter(encoder=encoder, routes=routes, auto_sync=\"local\")" ] }, { @@ -3346,7 +3337,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.12.2" + "version": "3.12.7" } }, "nbformat": 4, diff --git a/docs/encoders/huggingface.ipynb b/docs/encoders/huggingface.ipynb index cd553a75d261fee9a2327045c898e03e99351dbf..413a75f4ad38e441fe0983ad8d5d7516c5ed45e5 100644 --- a/docs/encoders/huggingface.ipynb +++ b/docs/encoders/huggingface.ipynb @@ -41,7 +41,7 @@ "metadata": {}, "outputs": [], "source": [ - "!pip install -qU \"semantic-router[local]==0.0.20\"" + "!pip install -qU \"semantic-router[local]==0.1.0\"" ] }, { @@ -570,9 +570,9 @@ } ], "source": [ - "from semantic_router.layer import RouteLayer\n", + "from semantic_router.routers import SemanticRouter\n", "\n", - "rl = RouteLayer(encoder=encoder, routes=routes)" + "rl = SemanticRouter(encoder=encoder, routes=routes, auto_sync=\"local\")" ] }, { @@ -817,7 +817,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.12.2" + "version": "3.12.7" } }, "nbformat": 4, diff --git a/docs/encoders/openai-embed-3.ipynb b/docs/encoders/openai-embed-3.ipynb index 6eaf92fbb7d162ec630ab2b44164073c247aa59f..b9b953aafbf697fb14cc06d6a0cf0b0ae241d7ea 100644 --- a/docs/encoders/openai-embed-3.ipynb +++ b/docs/encoders/openai-embed-3.ipynb @@ -41,7 +41,7 @@ "metadata": {}, "outputs": [], "source": [ - "!pip install -qU semantic-router==0.0.20" + "!pip install -qU semantic-router==0.1.0" ] }, { @@ -53,18 +53,9 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 2, "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "/Users/jamesbriggs/opt/anaconda3/envs/decision-layer/lib/python3.11/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" - ] - } - ], + "outputs": [], "source": [ "from semantic_router import Route\n", "\n", @@ -90,7 +81,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 3, "metadata": {}, "outputs": [], "source": [ @@ -117,7 +108,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 4, "metadata": {}, "outputs": [], "source": [ @@ -143,21 +134,24 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ - "\u001b[32m2024-01-28 12:40:08 INFO semantic_router.utils.logger Initializing RouteLayer\u001b[0m\n" + "2025-01-07 12:31:20 - semantic_router.utils.logger - WARNING - base.py:356 - _get_index() - No index provided. Using default LocalIndex.\n", + "2025-01-07 12:31:20 - httpx - INFO - _client.py:1025 - _send_single_request() - HTTP Request: POST https://api.openai.com/v1/embeddings \"HTTP/1.1 200 OK\"\n", + "2025-01-07 12:31:21 - httpx - INFO - _client.py:1025 - _send_single_request() - HTTP Request: POST https://api.openai.com/v1/embeddings \"HTTP/1.1 200 OK\"\n", + "2025-01-07 12:31:21 - semantic_router.utils.logger - WARNING - local.py:148 - _write_config() - No config is written for LocalIndex.\n" ] } ], "source": [ - "from semantic_router.layer import RouteLayer\n", + "from semantic_router.routers import SemanticRouter\n", "\n", - "rl = RouteLayer(encoder=encoder, routes=routes)" + "rl = SemanticRouter(encoder=encoder, routes=routes, auto_sync=\"local\")" ] }, { @@ -169,22 +163,22 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "(11, 256)" + "256" ] }, - "execution_count": 5, + "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "rl.index.shape" + "rl.index.dimensions" ] }, { @@ -196,16 +190,23 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 8, "metadata": {}, "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2025-01-07 12:32:01 - httpx - INFO - _client.py:1025 - _send_single_request() - HTTP Request: POST https://api.openai.com/v1/embeddings \"HTTP/1.1 200 OK\"\n" + ] + }, { "data": { "text/plain": [ - "RouteChoice(name='politics', function_call=None, similarity_score=None, trigger=None)" + "RouteChoice(name='politics', function_call=None, similarity_score=None)" ] }, - "execution_count": 6, + "execution_count": 8, "metadata": {}, "output_type": "execute_result" } @@ -216,16 +217,23 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 9, "metadata": {}, "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2025-01-07 12:32:05 - httpx - INFO - _client.py:1025 - _send_single_request() - HTTP Request: POST https://api.openai.com/v1/embeddings \"HTTP/1.1 200 OK\"\n" + ] + }, { "data": { "text/plain": [ - "RouteChoice(name='chitchat', function_call=None, similarity_score=None, trigger=None)" + "RouteChoice(name='chitchat', function_call=None, similarity_score=None)" ] }, - "execution_count": 7, + "execution_count": 9, "metadata": {}, "output_type": "execute_result" } @@ -243,16 +251,23 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 10, "metadata": {}, "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2025-01-07 12:32:08 - httpx - INFO - _client.py:1025 - _send_single_request() - HTTP Request: POST https://api.openai.com/v1/embeddings \"HTTP/1.1 200 OK\"\n" + ] + }, { "data": { "text/plain": [ - "RouteChoice(name=None, function_call=None, similarity_score=None, trigger=None)" + "RouteChoice(name=None, function_call=None, similarity_score=None)" ] }, - "execution_count": 8, + "execution_count": 10, "metadata": {}, "output_type": "execute_result" } @@ -292,7 +307,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.5" + "version": "3.12.7" } }, "nbformat": 4,