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
dd2b5750
Commit
dd2b5750
authored
1 year ago
by
Ismail Ashraq
Browse files
Options
Downloads
Patches
Plain Diff
update tests
parent
c1485309
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_splitters.py
+21
-0
21 additions, 0 deletions
tests/unit/test_splitters.py
with
21 additions
and
0 deletions
tests/unit/test_splitters.py
+
21
−
0
View file @
dd2b5750
import
pytest
import
pytest
from
unittest.mock
import
Mock
from
unittest.mock
import
Mock
from
semantic_router.utils.splitters
import
semantic_splitter
from
semantic_router.utils.splitters
import
semantic_splitter
from
semantic_router.schema
import
Conversation
,
Message
def
test_semantic_splitter_consecutive_similarity_drop
():
def
test_semantic_splitter_consecutive_similarity_drop
():
...
@@ -43,3 +44,23 @@ def test_semantic_splitter_invalid_method():
...
@@ -43,3 +44,23 @@ def test_semantic_splitter_invalid_method():
with
pytest
.
raises
(
ValueError
):
with
pytest
.
raises
(
ValueError
):
semantic_splitter
(
mock_encoder
,
docs
,
threshold
,
split_method
)
semantic_splitter
(
mock_encoder
,
docs
,
threshold
,
split_method
)
def
test_split_by_topic
():
mock_encoder
=
Mock
()
mock_encoder
.
return_value
=
[[
0.5
,
0
],
[
0
,
0.5
]]
messages
=
[
Message
(
role
=
"
User
"
,
content
=
"
What is the latest news?
"
),
Message
(
role
=
"
Bot
"
,
content
=
"
How is the weather today?
"
),
]
conversation
=
Conversation
(
messages
=
messages
)
result
=
conversation
.
split_by_topic
(
encoder
=
mock_encoder
,
threshold
=
0.5
,
split_method
=
"
consecutive_similarity_drop
"
)
assert
result
==
{
"
split 1
"
:
[
"
User: What is the latest news?
"
],
"
split 2
"
:
[
"
Bot: How is the weather today?
"
],
}
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