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
362e98ef
Commit
362e98ef
authored
4 months ago
by
jamescalam
Browse files
Options
Downloads
Patches
Plain Diff
fix: router test bug fixes
parent
381e8f5e
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
semantic_router/index/local.py
+17
-2
17 additions, 2 deletions
semantic_router/index/local.py
with
17 additions
and
2 deletions
semantic_router/index/local.py
+
17
−
2
View file @
362e98ef
...
...
@@ -42,8 +42,23 @@ class LocalIndex(BaseIndex):
self
.
routes
=
np
.
concatenate
([
self
.
routes
,
routes_arr
])
self
.
utterances
=
np
.
concatenate
([
self
.
utterances
,
utterances_arr
])
def
_remove_and_sync
(
self
,
routes_to_delete
:
dict
):
logger
.
warning
(
f
"
Sync remove is not implemented for
{
self
.
__class__
.
__name__
}
.
"
)
def
_remove_and_sync
(
self
,
routes_to_delete
:
dict
)
->
np
.
ndarray
:
if
self
.
index
is
None
or
self
.
routes
is
None
or
self
.
utterances
is
None
:
raise
ValueError
(
"
Index, routes, or utterances are not populated.
"
)
# TODO JB: implement routes and utterances as a numpy array
route_utterances
=
np
.
array
([
self
.
routes
,
self
.
utterances
]).
T
# initialize our mask with all true values (ie keep all)
mask
=
np
.
ones
(
len
(
route_utterances
),
dtype
=
bool
)
for
route
,
utterances
in
routes_to_delete
.
items
():
# TODO JB: we should be able to vectorize this?
for
utterance
in
utterances
:
mask
&=
~
((
route_utterances
[:,
0
]
==
route
)
&
(
route_utterances
[:,
1
]
==
utterance
))
# apply the mask to index, routes, and utterances
self
.
index
=
self
.
index
[
mask
]
self
.
routes
=
self
.
routes
[
mask
]
self
.
utterances
=
self
.
utterances
[
mask
]
# return what was removed
return
route_utterances
[
~
mask
]
def
get_utterances
(
self
)
->
List
[
Utterance
]:
"""
...
...
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