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
0586c670
Unverified
Commit
0586c670
authored
6 months ago
by
Siraj R Aizlewood
Browse files
Options
Downloads
Patches
Plain Diff
More pytests.
parent
0866dccd
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/unit/test_layer.py
+31
-0
31 additions, 0 deletions
tests/unit/test_layer.py
with
31 additions
and
0 deletions
tests/unit/test_layer.py
+
31
−
0
View file @
0586c670
...
@@ -811,6 +811,36 @@ class TestRouteLayer:
...
@@ -811,6 +811,36 @@ class TestRouteLayer:
):
):
route_layer
.
_refresh_routes
()
route_layer
.
_refresh_routes
()
def
test_update_threshold
(
self
,
openai_encoder
,
routes
,
index_cls
):
index
=
init_index
(
index_cls
)
route_layer
=
RouteLayer
(
encoder
=
openai_encoder
,
routes
=
routes
,
index
=
index
)
route_name
=
"
Route 1
"
new_threshold
=
0.8
route_layer
.
update
(
name
=
route_name
,
threshold
=
new_threshold
)
updated_route
=
route_layer
.
get
(
route_name
)
assert
updated_route
.
score_threshold
==
new_threshold
,
f
"
Expected threshold to be updated to
{
new_threshold
}
, but got
{
updated_route
.
score_threshold
}
"
def
test_update_non_existent_route
(
self
,
openai_encoder
,
routes
,
index_cls
):
index
=
init_index
(
index_cls
)
route_layer
=
RouteLayer
(
encoder
=
openai_encoder
,
routes
=
routes
,
index
=
index
)
non_existent_route
=
"
Non-existent Route
"
with
pytest
.
raises
(
ValueError
,
match
=
f
"
Route
'
{
non_existent_route
}
'
not found. Nothing updated.
"
):
route_layer
.
update
(
name
=
non_existent_route
,
threshold
=
0.7
)
def
test_update_without_parameters
(
self
,
openai_encoder
,
routes
,
index_cls
):
index
=
init_index
(
index_cls
)
route_layer
=
RouteLayer
(
encoder
=
openai_encoder
,
routes
=
routes
,
index
=
index
)
with
pytest
.
raises
(
ValueError
,
match
=
"
At least one of
'
threshold
'
or
'
utterances
'
must be provided.
"
):
route_layer
.
update
(
name
=
"
Route 1
"
)
def
test_update_utterances_not_implemented
(
self
,
openai_encoder
,
routes
,
index_cls
):
index
=
init_index
(
index_cls
)
route_layer
=
RouteLayer
(
encoder
=
openai_encoder
,
routes
=
routes
,
index
=
index
)
with
pytest
.
raises
(
NotImplementedError
,
match
=
"
The update method cannot be used for updating utterances yet.
"
):
route_layer
.
update
(
name
=
"
Route 1
"
,
utterances
=
[
"
New utterance
"
])
class
TestLayerFit
:
class
TestLayerFit
:
def
test_eval
(
self
,
openai_encoder
,
routes
,
test_data
):
def
test_eval
(
self
,
openai_encoder
,
routes
,
test_data
):
...
@@ -948,3 +978,4 @@ class TestLayerConfig:
...
@@ -948,3 +978,4 @@ class TestLayerConfig:
elif
agg
==
"
max
"
:
elif
agg
==
"
max
"
:
assert
classification
==
"
Route 3
"
assert
classification
==
"
Route 3
"
assert
score
==
[
0.1
,
1.0
]
assert
score
==
[
0.1
,
1.0
]
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