Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Semantic Router
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mirrored_repos
MachineLearning
aurelio-labs
Semantic Router
Commits
8d0a38b4
Commit
8d0a38b4
authored
3 weeks ago
by
James Briggs
Browse files
Options
Downloads
Patches
Plain Diff
chore: lint
parent
15497bc5
Branches
james/litellm
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/integration/test_router_integration.py
+16
-12
16 additions, 12 deletions
tests/integration/test_router_integration.py
with
16 additions
and
12 deletions
tests/integration/test_router_integration.py
+
16
−
12
View file @
8d0a38b4
...
...
@@ -5,29 +5,20 @@ import time
from
datetime
import
datetime
from
functools
import
wraps
from
platform
import
python_version
from
typing
import
Any
,
List
,
Optional
from
unittest.mock
import
mock_open
,
patch
from
typing
import
Optional
import
numpy
as
np
import
pytest
from
semantic_router.encoders
import
(
CohereEncoder
,
DenseEncoder
,
OpenAIEncoder
,
)
from
semantic_router.encoders.base
import
(
AsymmetricDenseMixin
,
AsymmetricSparseMixin
,
SparseEncoder
,
)
from
semantic_router.index.local
import
LocalIndex
from
semantic_router.index.pinecone
import
PineconeIndex
from
semantic_router.index.qdrant
import
QdrantIndex
from
semantic_router.llms
import
BaseLLM
,
OpenAILLM
from
semantic_router.route
import
Route
from
semantic_router.routers
import
HybridRouter
,
RouterConfig
,
SemanticRouter
from
semantic_router.schema
import
RouteChoice
,
SparseEmbedding
from
semantic_router.routers
import
HybridRouter
,
SemanticRouter
from
semantic_router.schema
import
RouteChoice
from
semantic_router.utils.logger
import
logger
PINECONE_SLEEP
=
8
...
...
@@ -150,6 +141,7 @@ def routes():
Route
(
name
=
"
Route 2
"
,
utterances
=
[
"
Goodbye
"
,
"
Bye
"
,
"
Au revoir
"
]),
]
@pytest.fixture
def
routes_2
():
return
[
...
...
@@ -157,6 +149,7 @@ def routes_2():
Route
(
name
=
"
Route 2
"
,
utterances
=
[
"
Hi
"
]),
]
@pytest.fixture
def
routes_3
():
return
[
...
...
@@ -164,6 +157,7 @@ def routes_3():
Route
(
name
=
"
Route 2
"
,
utterances
=
[
"
Asparagus
"
]),
]
@pytest.fixture
def
routes_4
():
return
[
...
...
@@ -171,12 +165,14 @@ def routes_4():
Route
(
name
=
"
Route 2
"
,
utterances
=
[
"
Asparagus
"
]),
]
@pytest.fixture
def
route_single_utterance
():
return
[
Route
(
name
=
"
Route 3
"
,
utterances
=
[
"
Hello
"
]),
]
@pytest.fixture
def
dynamic_routes
():
return
[
...
...
@@ -192,6 +188,7 @@ def dynamic_routes():
),
]
@pytest.fixture
def
test_data
():
return
[
...
...
@@ -202,6 +199,7 @@ def test_data():
(
"
tell me an interesting fact
"
,
None
),
]
def
get_test_indexes
():
indexes
=
[
LocalIndex
]
if
importlib
.
util
.
find_spec
(
"
qdrant_client
"
)
is
not
None
:
...
...
@@ -210,16 +208,19 @@ def get_test_indexes():
indexes
.
append
(
PineconeIndex
)
return
indexes
def
get_test_encoders
():
encoders
=
[
OpenAIEncoder
]
if
importlib
.
util
.
find_spec
(
"
cohere
"
)
is
not
None
:
encoders
.
append
(
CohereEncoder
)
return
encoders
def
get_test_routers
():
routers
=
[
SemanticRouter
,
HybridRouter
]
return
routers
@pytest.mark.parametrize
(
"
index_cls,encoder_cls,router_cls
"
,
[
...
...
@@ -246,9 +247,11 @@ class TestIndexEncoders:
else
:
assert
score_threshold
==
encoder
.
score_threshold
assert
route_layer
.
top_k
==
10
@retry
(
max_retries
=
RETRY_COUNT
,
delay
=
PINECONE_SLEEP
)
def
check_index_populated
():
assert
len
(
route_layer
.
index
)
==
5
check_index_populated
()
assert
(
len
(
set
(
route_layer
.
_get_route_names
()))
...
...
@@ -276,6 +279,7 @@ class TestIndexEncoders:
else
:
assert
score_threshold
==
0.3
@pytest.mark.parametrize
(
"
index_cls,encoder_cls,router_cls
"
,
[
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment