Skip to content

Commit

Permalink
Merge pull request #21 from aurelio-labs/simonas/embed-all-decisions-…
Browse files Browse the repository at this point in the history
…at-once

Encode all decisions at once
  • Loading branch information
simjak authored Dec 13, 2023
2 parents 4a81de1 + eb7c6f0 commit 4e08122
Show file tree
Hide file tree
Showing 16 changed files with 715 additions and 73 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,19 @@ jobs:
- name: Install dependencies
run: |
poetry install
- name: Install nltk
run: |
pip install nltk
- name: Download nltk data
run: |
python -m nltk.downloader punkt stopwords wordnet
- name: Pytest
run: |
make test
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
file: ./coverage.xml
fail_ci_if_error: true
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ mac.env

# Code coverage history
.coverage
.coverage.*
.pytest_cache
7 changes: 5 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@ repos:
rev: v0.0.290
hooks:
- id: ruff
types_or: [python, pyi, jupyter]

types_or: [ python, pyi, jupyter ]
args: [ --fix ]
- id: ruff-format
types_or: [ python, pyi, jupyter ]


- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ lint lint_diff:
poetry run ruff .

test:
poetry run pytest -vv --cov=semantic_router --cov-report=term-missing --cov-fail-under=100
poetry run pytest -vv -n 20 --cov=semantic_router --cov-report=term-missing --cov-report=xml --cov-fail-under=100
27 changes: 17 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
[![Aurelio AI](https://pbs.twimg.com/profile_banners/1671498317455581184/1696285195/1500x500)](https://aurelio.ai)

# Semantic Router
<p>
<img alt="GitHub Contributors" src="https://img.shields.io/github/contributors/aurelio-labs/semantic-router" />
<img alt="GitHub Last Commit" src="https://img.shields.io/github/last-commit/aurelio-labs/semantic-router" />
<img alt="" src="https://img.shields.io/github/repo-size/aurelio-labs/semantic-router" />
<img alt="GitHub Issues" src="https://img.shields.io/github/issues/aurelio-labs/semantic-router" />
<img alt="GitHub Pull Requests" src="https://img.shields.io/github/issues-pr/aurelio-labs/semantic-router" />
<img alt="Github License" src="https://img.shields.io/badge/License-MIT-yellow.svg" />
</p>

Semantic Router is a superfast decision layer for your LLMs and agents. Rather than waiting for slow LLM generations to make tool-use decisions, we use the magic of semantic vector space to make those decisions — _routing_ our requests using _semantic_ meaning.

Expand All @@ -23,11 +31,10 @@ politics = Decision(
utterances=[
"isn't politics the best thing ever",
"why don't you tell me about your political opinions",
"don't you just love the president"
"don't you just hate the president",
"don't you just love the president" "don't you just hate the president",
"they're going to destroy this country!",
"they will save the country!"
]
"they will save the country!",
],
)

# this could be used as an indicator to our chatbot to switch to a more
Expand All @@ -39,8 +46,8 @@ chitchat = Decision(
"how are things going?",
"lovely weather today",
"the weather is horrendous",
"let's go to the chippy"
]
"let's go to the chippy",
],
)

# we place both of our decisions together into single list
Expand Down Expand Up @@ -97,13 +104,13 @@ dl("I'm interested in learning about llama 2")
```

```
[Out]:
[Out]:
```

In this case, no decision could be made as we had no matches — so our decision layer returned `None`!

## 📚 Resources

| | |
| --- | --- |
| 🏃 [Walkthrough](https://colab.research.google.com/github/aurelio-labs/semantic-router/blob/main/walkthrough.ipynb) | Quickstart Python notebook |
| | |
| --------------------------------------------------------------------------------------------------------------- | -------------------------- |
| 🏃[Walkthrough](https://colab.research.google.com/github/aurelio-labs/semantic-router/blob/main/walkthrough.ipynb) | Quickstart Python notebook |
Loading

0 comments on commit 4e08122

Please sign in to comment.