Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: updates semantic version on docs #500

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
100 changes: 68 additions & 32 deletions docs/01-save-load-from-file.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
},
"outputs": [],
"source": [
"!pip install -qU semantic-router"
"!pip install -qU \"semantic-router==0.1.0.dev3\""
]
},
{
Expand All @@ -69,7 +69,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"metadata": {
"id": "U_YPXSNAg6T9",
"outputId": "e6916925-e55c-49e8-e574-5b0cc136d8c2"
Expand All @@ -79,7 +79,7 @@
"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",
"c:\\Users\\Joshu\\OneDrive\\Documents\\Aurelio\\agents-course\\07-pratical-ai\\.venv\\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"
]
}
Expand Down Expand Up @@ -122,7 +122,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 4,
"metadata": {
"id": "BnwbMv1Cg6T_",
"outputId": "383c2dc7-1271-41bd-facf-6db5bd76bc9a"
Expand All @@ -132,15 +132,18 @@
"name": "stderr",
"output_type": "stream",
"text": [
"\u001b[32m2024-05-07 15:03:35 INFO semantic_router.utils.logger local\u001b[0m\n"
"2025-01-06 11:59:56 - semantic_router.utils.logger - WARNING - base.py:356 - _get_index() - No index provided. Using default LocalIndex.\n",
"2025-01-06 11:59:56 - httpx - INFO - _client.py:1025 - _send_single_request() - HTTP Request: POST https://api.cohere.com/v1/embed \"HTTP/1.1 200 OK\"\n",
"2025-01-06 11:59:57 - httpx - INFO - _client.py:1025 - _send_single_request() - HTTP Request: POST https://api.cohere.com/v1/embed \"HTTP/1.1 200 OK\"\n",
"2025-01-06 11:59:57 - semantic_router.utils.logger - WARNING - local.py:148 - _write_config() - No config is written for LocalIndex.\n"
]
}
],
"source": [
"import os\n",
"from getpass import getpass\n",
"from semantic_router import RouteLayer\n",
"from semantic_router.encoders import CohereEncoder\n",
"from semantic_router.routers import SemanticRouter\n",
"\n",
"# dashboard.cohere.ai\n",
"os.environ[\"COHERE_API_KEY\"] = os.getenv(\"COHERE_API_KEY\") or getpass(\n",
Expand All @@ -149,7 +152,7 @@
"\n",
"encoder = CohereEncoder()\n",
"\n",
"rl = RouteLayer(encoder=encoder, routes=routes)"
"rl = SemanticRouter(encoder=encoder, routes=routes, auto_sync=\"local\")"
]
},
{
Expand All @@ -163,19 +166,34 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 5,
"metadata": {
"id": "VlKURQQCg6UB",
"outputId": "98bf19ec-4ba0-4cdc-d232-7629aa5afea2"
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"2025-01-06 12:00:03 - httpx - INFO - _client.py:1025 - _send_single_request() - HTTP Request: POST https://api.cohere.com/v1/embed \"HTTP/1.1 200 OK\"\n",
"2025-01-06 12:00:08 - httpx - INFO - _client.py:1025 - _send_single_request() - HTTP Request: POST https://api.cohere.com/v1/embed \"HTTP/1.1 200 OK\"\n",
"2025-01-06 12:00:42 - httpx - INFO - _client.py:1025 - _send_single_request() - HTTP Request: POST https://api.cohere.com/v1/embed \"HTTP/1.1 200 OK\"\n",
"2025-01-06 12:03:49 - httpx - INFO - _client.py:1025 - _send_single_request() - HTTP Request: POST https://api.cohere.com/v1/embed \"HTTP/1.1 200 OK\"\n",
"2025-01-06 12:03:49 - httpx - INFO - _client.py:1025 - _send_single_request() - HTTP Request: POST https://api.cohere.com/v1/embed \"HTTP/1.1 200 OK\"\n",
"2025-01-06 12:04:00 - httpx - INFO - _client.py:1025 - _send_single_request() - HTTP Request: POST https://api.cohere.com/v1/embed \"HTTP/1.1 200 OK\"\n",
"2025-01-06 12:04:09 - httpx - INFO - _client.py:1025 - _send_single_request() - HTTP Request: POST https://api.cohere.com/v1/embed \"HTTP/1.1 200 OK\"\n",
"2025-01-06 12:04:38 - httpx - INFO - _client.py:1025 - _send_single_request() - HTTP Request: POST https://api.cohere.com/v1/embed \"HTTP/1.1 200 OK\"\n",
"2025-01-06 12:04:38 - httpx - INFO - _client.py:1025 - _send_single_request() - HTTP Request: POST https://api.cohere.com/v1/embed \"HTTP/1.1 200 OK\"\n"
]
},
{
"data": {
"text/plain": [
"RouteChoice(name='politics', function_call=None, similarity_score=None)"
]
},
"execution_count": 4,
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -186,7 +204,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 6,
"metadata": {
"id": "1FUnWyN8g6UB",
"outputId": "697f9937-8739-4e13-93f7-cfbfbbb61a01"
Expand All @@ -198,7 +216,7 @@
"RouteChoice(name='chitchat', function_call=None, similarity_score=None)"
]
},
"execution_count": 5,
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
Expand Down Expand Up @@ -227,7 +245,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 7,
"metadata": {
"id": "jnLwulrCg6UC",
"outputId": "cfd85636-1030-4b00-bebe-9167319e8b62"
Expand All @@ -237,7 +255,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
"\u001b[32m2024-05-07 15:03:37 INFO semantic_router.utils.logger Saving route config to layer.json\u001b[0m\n"
"2025-01-06 12:00:14 - semantic_router.utils.logger - INFO - base.py:211 - to_file() - Saving route config to layer.json\n"
]
}
],
Expand Down Expand Up @@ -265,7 +283,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 8,
"metadata": {
"id": "NRfi40IAg6UE",
"outputId": "29c3f322-59ef-4103-abf9-2184aac5e465"
Expand All @@ -275,7 +293,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"{'encoder_type': 'cohere', 'encoder_name': 'embed-english-v3.0', 'routes': [{'name': 'politics', 'utterances': [\"isn't politics the best thing ever\", \"why don't you tell me about your political opinions\", \"don't you just love the presidentdon't you just hate the president\", \"they're going to destroy this country!\", 'they will save the country!'], 'description': None, 'function_schemas': None, 'llm': None, 'score_threshold': 0.3}, {'name': 'chitchat', 'utterances': [\"how's the weather today?\", 'how are things going?', 'lovely weather today', 'the weather is horrendous', \"let's go to the chippy\"], 'description': None, 'function_schemas': None, 'llm': None, 'score_threshold': 0.3}]}\n"
"{'encoder_type': 'cohere', 'encoder_name': 'embed-english-v3.0', 'routes': [{'name': 'politics', 'utterances': [\"isn't politics the best thing ever\", \"why don't you tell me about your political opinions\", \"don't you just love the presidentdon't you just hate the president\", \"they're going to destroy this country!\", 'they will save the country!'], 'description': None, 'function_schemas': None, 'llm': None, 'score_threshold': 0.3, 'metadata': {}}, {'name': 'chitchat', 'utterances': [\"how's the weather today?\", 'how are things going?', 'lovely weather today', 'the weather is horrendous', \"let's go to the chippy\"], 'description': None, 'function_schemas': None, 'llm': None, 'score_threshold': 0.3, 'metadata': {}}]}\n"
]
}
],
Expand All @@ -299,7 +317,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 9,
"metadata": {
"id": "K40Ig7Gkg6UF",
"outputId": "2ab1eef7-f8d1-4801-ad97-9f436922d0a4"
Expand All @@ -309,13 +327,13 @@
"name": "stderr",
"output_type": "stream",
"text": [
"\u001b[32m2024-05-07 15:03:37 INFO semantic_router.utils.logger Loading route config from layer.json\u001b[0m\n",
"\u001b[32m2024-05-07 15:03:37 INFO semantic_router.utils.logger local\u001b[0m\n"
"2025-01-06 12:00:30 - semantic_router.utils.logger - INFO - base.py:96 - from_file() - Loading route config from layer.json\n",
"2025-01-06 12:00:31 - semantic_router.utils.logger - WARNING - base.py:356 - _get_index() - No index provided. Using default LocalIndex.\n"
]
}
],
"source": [
"rl = RouteLayer.from_json(\"layer.json\")"
"rl = SemanticRouter.from_json(\"layer.json\")"
]
},
{
Expand All @@ -329,7 +347,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 10,
"metadata": {
"id": "Ah9EVIITg6UF",
"outputId": "4ab0af28-b62b-4d18-df9e-3243e0ba56b7"
Expand All @@ -341,7 +359,7 @@
"text": [
"rl.encoder.type='cohere'\n",
"rl.encoder.name='embed-english-v3.0'\n",
"rl.routes=[Route(name='politics', utterances=[\"isn't politics the best thing ever\", \"why don't you tell me about your political opinions\", \"don't you just love the presidentdon't you just hate the president\", \"they're going to destroy this country!\", 'they will save the country!'], description=None, function_schemas=None, llm=None, score_threshold=0.3), Route(name='chitchat', utterances=[\"how's the weather today?\", 'how are things going?', 'lovely weather today', 'the weather is horrendous', \"let's go to the chippy\"], description=None, function_schemas=None, llm=None, score_threshold=0.3)]\n"
"rl.routes=[Route(name='politics', utterances=[\"isn't politics the best thing ever\", \"why don't you tell me about your political opinions\", \"don't you just love the presidentdon't you just hate the president\", \"they're going to destroy this country!\", 'they will save the country!'], description=None, function_schemas=None, llm=None, score_threshold=0.3, metadata={}), Route(name='chitchat', utterances=[\"how's the weather today?\", 'how are things going?', 'lovely weather today', 'the weather is horrendous', \"let's go to the chippy\"], description=None, function_schemas=None, llm=None, score_threshold=0.3, metadata={})]\n"
]
}
],
Expand All @@ -353,6 +371,24 @@
")"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"2025-01-06 12:04:38 - semantic_router.utils.logger - WARNING - base.py:356 - _get_index() - No index provided. Using default LocalIndex.\n",
"2025-01-06 12:04:38 - semantic_router.utils.logger - WARNING - local.py:148 - _write_config() - No config is written for LocalIndex.\n"
]
}
],
"source": [
"new_rl = SemanticRouter(encoder=rl.encoder, routes=rl.routes, auto_sync=\"local\")"
]
},
{
"cell_type": "markdown",
"metadata": {
Expand All @@ -373,7 +409,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 13,
"metadata": {
"id": "RXkJldaxg6UF",
"outputId": "222e6cdb-1c0c-4aff-df3a-062d72137744"
Expand All @@ -385,18 +421,18 @@
"RouteChoice(name='politics', function_call=None, similarity_score=None)"
]
},
"execution_count": 10,
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"rl(\"isn't politics the best thing ever\")"
"new_rl(\"isn't politics the best thing ever\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 14,
"metadata": {
"id": "u07b2W-Jg6UG",
"outputId": "9a07d46a-0b73-4a3b-eb61-b5df49c92b67"
Expand All @@ -408,17 +444,20 @@
"RouteChoice(name='chitchat', function_call=None, similarity_score=None)"
]
},
"execution_count": 11,
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"rl(\"how's the weather today?\")"
"new_rl(\"how's the weather today?\")"
]
}
],
"metadata": {
"colab": {
"provenance": []
},
"kernelspec": {
"display_name": "decision-layer",
"language": "python",
Expand All @@ -434,12 +473,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.4"
},
"colab": {
"provenance": []
"version": "3.12.7"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
}
Loading
Loading