Skip to content

Commit

Permalink
Merge pull request #44 from aurelio-labs/james/public-release-prep
Browse files Browse the repository at this point in the history
updated docs and versions
  • Loading branch information
jamescalam authored Dec 28, 2023
2 parents 1f42ab2 + 81b4367 commit 8367af8
Show file tree
Hide file tree
Showing 6 changed files with 1,015 additions and 56 deletions.
93 changes: 76 additions & 17 deletions docs/00_introduction.ipynb → docs/00-introduction.ipynb
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/aurelio-ai/semantic-router/blob/main/docs/00-introduction.ipynb) [![Open nbviewer](https://raw.githubusercontent.com/pinecone-io/examples/master/assets/nbviewer-shield.svg)](https://nbviewer.org/github/aurelio-ai/semantic-router/blob/main/docs/00-introduction.ipynb)"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -34,7 +41,14 @@
"metadata": {},
"outputs": [],
"source": [
"!pip install -qU semantic-router==0.0.13"
"!pip install -qU semantic-router==0.0.14"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"_**⚠️ If using Google Colab, install the prerequisites and then restart the notebook before continuing**_"
]
},
{
Expand All @@ -46,11 +60,11 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"from semantic_router.schema import Route\n",
"from semantic_router import Route\n",
"\n",
"politics = Route(\n",
" name=\"politics\",\n",
Expand All @@ -73,7 +87,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -100,19 +114,23 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"from getpass import getpass\n",
"from semantic_router.encoders import CohereEncoder\n",
"from semantic_router.encoders import CohereEncoder, OpenAIEncoder\n",
"\n",
"os.environ[\"COHERE_API_KEY\"] = os.getenv(\"COHERE_API_KEY\") or getpass(\n",
" \"Enter Cohere API Key: \"\n",
"# os.environ[\"COHERE_API_KEY\"] = os.getenv(\"COHERE_API_KEY\") or getpass(\n",
"# \"Enter Cohere API Key: \"\n",
"# )\n",
"os.environ[\"OPENAI_API_KEY\"] = os.getenv(\"OPENAI_API_KEY\") or getpass(\n",
" \"Enter OpenAI API Key: \"\n",
")\n",
"\n",
"encoder = CohereEncoder()"
"# encoder = CohereEncoder()\n",
"encoder = OpenAIEncoder()"
]
},
{
Expand All @@ -124,9 +142,17 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 6,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"\u001b[32m2023-12-28 19:14:34 INFO semantic_router.utils.logger Initializing RouteLayer\u001b[0m\n"
]
}
],
"source": [
"from semantic_router.layer import RouteLayer\n",
"\n",
Expand All @@ -142,18 +168,40 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 7,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"RouteChoice(name='politics', function_call=None)"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"dl(\"don't you love politics?\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 8,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"RouteChoice(name='chitchat', function_call=None)"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"dl(\"how's the weather today?\")"
]
Expand All @@ -167,9 +215,20 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 9,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"RouteChoice(name=None, function_call=None)"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"dl(\"I'm interested in learning about llama 2\")"
]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/aurelio-ai/semantic-router/blob/main/docs/01-save-load-from-file.ipynb) [![Open nbviewer](https://raw.githubusercontent.com/pinecone-io/examples/master/assets/nbviewer-shield.svg)](https://nbviewer.org/github/aurelio-ai/semantic-router/blob/main/docs/01-save-load-from-file.ipynb)"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -29,7 +36,14 @@
"metadata": {},
"outputs": [],
"source": [
"!pip install -qU semantic-router==0.0.13"
"!pip install -qU semantic-router==0.0.14"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"_**⚠️ If using Google Colab, install the prerequisites and then restart the notebook before continuing**_"
]
},
{
Expand Down Expand Up @@ -97,15 +111,26 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 4,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"\u001b[32m2023-12-28 19:16:54 INFO semantic_router.utils.logger Initializing RouteLayer\u001b[0m\n"
]
}
],
"source": [
"import os\n",
"from getpass import getpass\n",
"from semantic_router import RouteLayer\n",
"\n",
"# dashboard.cohere.ai\n",
"os.environ[\"COHERE_API_KEY\"] = \"<YOUR_API_KEY>\"\n",
"os.environ[\"COHERE_API_KEY\"] = os.getenv(\"COHERE_API_KEY\") or getpass(\n",
" \"Enter Cohere API Key: \"\n",
")\n",
"\n",
"layer = RouteLayer(routes=routes)"
]
Expand All @@ -119,14 +144,14 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"\u001b[32m2023-12-26 23:38:56 INFO semantic_router.utils.logger Saving route config to layer.json\u001b[0m\n"
"\u001b[32m2023-12-28 19:17:03 INFO semantic_router.utils.logger Saving route config to layer.json\u001b[0m\n"
]
}
],
Expand All @@ -150,7 +175,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 6,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -179,14 +204,15 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 7,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"\u001b[32m2023-12-26 23:38:56 INFO semantic_router.utils.logger Loading route config from layer.json\u001b[0m\n"
"\u001b[32m2023-12-28 19:17:08 INFO semantic_router.utils.logger Loading route config from layer.json\u001b[0m\n",
"\u001b[32m2023-12-28 19:17:08 INFO semantic_router.utils.logger Initializing RouteLayer\u001b[0m\n"
]
}
],
Expand All @@ -203,22 +229,23 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"RouteLayer(encoder=Encoder(type=<EncoderType.COHERE: 'cohere'>, name='embed-english-v3.0', model=CohereEncoder(name='embed-english-v3.0', type='cohere', client=<cohere.client.Client object at 0x12e40d510>)), 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_schema=None), 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_schema=None)])"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
"name": "stdout",
"output_type": "stream",
"text": [
"layer.encoder.type='cohere'\n",
"layer.encoder.name='embed-english-v3.0'\n",
"layer.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_schema=None), 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_schema=None)]\n"
]
}
],
"source": [
"layer"
"print(f\"\"\"{layer.encoder.type=}\n",
"{layer.encoder.name=}\n",
"{layer.routes=}\"\"\")"
]
},
{
Expand Down
Loading

0 comments on commit 8367af8

Please sign in to comment.