Skip to content
Snippets Groups Projects
Unverified Commit 3ea1bbec authored by Luca's avatar Luca Committed by GitHub
Browse files

Update README.md

Changed `decisions` to `routes` because of the changes in the library.
parent 9a2a4b8c
No related branches found
No related tags found
No related merge requests found
...@@ -21,7 +21,7 @@ To get started with _semantic-router_ we install it like so: ...@@ -21,7 +21,7 @@ To get started with _semantic-router_ we install it like so:
pip install -qU semantic-router pip install -qU semantic-router
``` ```
We begin by defining a set of `Decision` objects. These are the decision paths that the semantic router can decide to use, let's try two simple decisions for now — one for talk on _politics_ and another for _chitchat_: We begin by defining a set of `Decision` objects. These are the decision paths that the semantic router can decide to use, let's try two simple routes for now — one for talk on _politics_ and another for _chitchat_:
```python ```python
from semantic_router.schema import Route from semantic_router.schema import Route
...@@ -51,11 +51,11 @@ chitchat = Route( ...@@ -51,11 +51,11 @@ chitchat = Route(
], ],
) )
# we place both of our decisions together into single list # we place both of our routes together into single list
decisions = [politics, chitchat] routes = [politics, chitchat]
``` ```
We have our decisions ready, now we initialize an embedding / encoder model. We currently support a `CohereEncoder` and `OpenAIEncoder` — more encoders will be added soon. To initialize them we do: We have our routes ready, now we initialize an embedding / encoder model. We currently support a `CohereEncoder` and `OpenAIEncoder` — more encoders will be added soon. To initialize them we do:
```python ```python
import os import os
...@@ -70,15 +70,15 @@ os.environ["OPENAI_API_KEY"] = "<YOUR_API_KEY>" ...@@ -70,15 +70,15 @@ os.environ["OPENAI_API_KEY"] = "<YOUR_API_KEY>"
encoder = OpenAIEncoder() encoder = OpenAIEncoder()
``` ```
With our `decisions` and `encoder` defined we now create a `DecisionLayer`. The decision layer handles our semantic decision making. With our `routes` and `encoder` defined we now create a `DecisionLayer`. The decision layer handles our semantic decision making.
```python ```python
from semantic_router.layer import RouteLayer from semantic_router.layer import RouteLayer
dl = RouteLayer(encoder=encoder, decisions=decisions) dl = RouteLayer(encoder=encoder, routes=routes)
``` ```
We can now use our decision layer to make super fast decisions based on user queries. Let's try with two queries that should trigger our decisions: We can now use our decision layer to make super fast decisions based on user queries. Let's try with two queries that should trigger our routes:
```python ```python
dl("don't you love politics?") dl("don't you love politics?")
...@@ -98,7 +98,7 @@ dl("how's the weather today?") ...@@ -98,7 +98,7 @@ dl("how's the weather today?")
[Out]: 'chitchat' [Out]: 'chitchat'
``` ```
We get both decisions correct! Now lets try sending an unrelated query: We get both routes correct! Now lets try sending an unrelated query:
```python ```python
dl("I'm interested in learning about llama 2") dl("I'm interested in learning about llama 2")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment