The decision layer library can be used as a super fast decision making layer on top of LLMs. That means that rather than waiting on a slow agent to decide what to do, we can use the magic of semantic vector space to make decisions. Cutting decision making time down from seconds to milliseconds.
The decision layer library can be used as a super fast decision making layer on top of LLMs. That means that rather than waiting on a slow agent to decide what to do, we can use the magic of semantic vector space to make decisions. Cutting decision making time down from seconds to milliseconds.
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
## Getting Started
## Getting Started
%% Cell type:code id: tags:
%% Cell type:code id: tags:
``` python
``` python
!pipinstall-qU \
!pipinstall-qU \
decision-layer
decision-layer
```
```
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
We start by defining a dictionary mapping decisions to example phrases that should trigger those decisions.
We start by defining a dictionary mapping decisions to example phrases that should trigger those decisions.
%% Cell type:code id: tags:
%% Cell type:code id: tags:
``` python
``` python
fromdecision_layer.schemaimportDecision
fromdecision_layer.schemaimportDecision
politics=Decision(
politics=Decision(
name="politics",
name="politics",
utterances=[
utterances=[
"isn't politics the best thing ever",
"isn't politics the best thing ever",
"why don't you tell me about your political opinions",
"why don't you tell me about your political opinions",
"don't you just love the president"
"don't you just love the president"
"don't you just hate the president",
"don't you just hate the president",
"they're going to destroy this country!",
"they're going to destroy this country!",
"they will save the country!"
"they will save the country!"
]
]
)
)
```
```
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
Let's define another for good measure:
Let's define another for good measure:
%% Cell type:code id: tags:
%% Cell type:code id: tags:
``` python
``` python
chitchat=Decision(
chitchat=Decision(
name="chitchat",
name="chitchat",
utterances=[
utterances=[
"how's the weather today?",
"how's the weather today?",
"how are things going?",
"how are things going?",
"lovely weather today",
"lovely weather today",
"the weather is horrendous",
"the weather is horrendous",
"let's go to the chippy"
"let's go to the chippy"
]
]
)
)
decisions=[politics,chitchat]
decisions=[politics,chitchat]
```
```
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
Now we initialize our embedding model (we will add support for Hugging Face):
Now we initialize our embedding model (we will add support for Hugging Face):
Now we define the `DecisionLayer`. When called, the decision layer will consume text (a query) and output the category (`Decision`) it belongs to — for now we can only `_query` and get the most similar `Decision``utterances`.
Now we define the `DecisionLayer`. When called, the decision layer will consume text (a query) and output the category (`Decision`) it belongs to — for now we can only `_query` and get the most similar `Decision``utterances`.