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
a96f6b85
Commit
a96f6b85
authored
3 months ago
by
jamescalam
Browse files
Options
Downloads
Patches
Plain Diff
fix: import
parent
805807f8
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
semantic_router/schema.py
+9
-13
9 additions, 13 deletions
semantic_router/schema.py
tests/unit/test_sync.py
+1
-1
1 addition, 1 deletion
tests/unit/test_sync.py
with
10 additions
and
14 deletions
semantic_router/schema.py
+
9
−
13
View file @
a96f6b85
...
...
@@ -412,6 +412,7 @@ class SparseEmbedding(BaseModel):
"""
Sparse embedding interface. Primarily uses numpy operations for faster
operations.
"""
embedding
:
np
.
ndarray
class
Config
:
...
...
@@ -425,36 +426,31 @@ class SparseEmbedding(BaseModel):
"
Column 0 should contain index positions, and column 1 should contain respective values.
"
)
return
cls
(
embedding
=
array
)
@classmethod
def
from_aurelio
(
cls
,
embedding
:
BM25Embedding
):
arr
=
np
.
array
([
embedding
.
indices
,
embedding
.
values
]).
T
return
cls
.
from_array
(
arr
)
@classmethod
def
from_dict
(
cls
,
sparse_dict
:
dict
):
arr
=
np
.
array
([
list
(
sparse_dict
.
keys
()),
list
(
sparse_dict
.
values
())]).
T
return
cls
.
from_array
(
arr
)
def
to_dict
(
self
):
return
{
i
:
v
for
i
,
v
in
zip
(
self
.
embedding
[:,
0
].
astype
(
int
),
self
.
embedding
[:,
1
]
)
i
:
v
for
i
,
v
in
zip
(
self
.
embedding
[:,
0
].
astype
(
int
),
self
.
embedding
[:,
1
])
}
def
to_pinecone
(
self
):
return
{
"
indices
"
:
self
.
embedding
[:,
0
].
astype
(
int
).
tolist
(),
"
values
"
:
self
.
embedding
[:,
1
].
tolist
(),
}
# dictionary interface
def
items
(
self
):
return
[
(
i
,
v
)
for
i
,
v
in
zip
(
self
.
embedding
[:,
0
].
astype
(
int
),
self
.
embedding
[:,
1
]
)
(
i
,
v
)
for
i
,
v
in
zip
(
self
.
embedding
[:,
0
].
astype
(
int
),
self
.
embedding
[:,
1
])
]
This diff is collapsed.
Click to expand it.
tests/unit/test_sync.py
+
1
−
1
View file @
a96f6b85
...
...
@@ -7,7 +7,7 @@ from typing import Optional
from
semantic_router.encoders
import
DenseEncoder
,
CohereEncoder
,
OpenAIEncoder
from
semantic_router.index.pinecone
import
PineconeIndex
from
semantic_router.schema
import
Utterance
from
semantic_router.routers
.base
import
SemanticRouter
from
semantic_router.routers
import
SemanticRouter
from
semantic_router.route
import
Route
from
platform
import
python_version
...
...
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