Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenDAS
dynamo
Commits
d809906e
Unverified
Commit
d809906e
authored
Oct 06, 2025
by
Kris Hung
Committed by
GitHub
Oct 07, 2025
Browse files
feat: Add embedding support to sgl backend (#3427)
Signed-off-by:
krishung5
<
krish@nvidia.com
>
parent
4c888bf4
Changes
21
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
0 deletions
+41
-0
tests/utils/payloads.py
tests/utils/payloads.py
+41
-0
No files found.
tests/utils/payloads.py
View file @
d809906e
...
...
@@ -149,6 +149,47 @@ class CompletionPayload(BasePayload):
return
CompletionPayload
.
extract_text
(
response
)
@
dataclass
class
EmbeddingPayload
(
BasePayload
):
"""Payload for embeddings endpoint."""
endpoint
:
str
=
"/v1/embeddings"
@
staticmethod
def
extract_embeddings
(
response
):
"""
Process embeddings API responses.
"""
response
.
raise_for_status
()
result
=
response
.
json
()
assert
"object"
in
result
,
"Missing 'object' in response"
assert
(
result
[
"object"
]
==
"list"
),
f
"Expected object='list', got
{
result
[
'object'
]
}
"
assert
"data"
in
result
,
"Missing 'data' in response"
assert
len
(
result
[
"data"
])
>
0
,
"Empty data in response"
# Extract embedding vectors and validate structure
embeddings
=
[]
for
item
in
result
[
"data"
]:
assert
"object"
in
item
,
"Missing 'object' in embedding item"
assert
(
item
[
"object"
]
==
"embedding"
),
f
"Expected object='embedding', got
{
item
[
'object'
]
}
"
assert
"embedding"
in
item
,
"Missing 'embedding' vector in item"
assert
isinstance
(
item
[
"embedding"
],
list
),
"Embedding should be a list of floats"
assert
len
(
item
[
"embedding"
])
>
0
,
"Embedding vector should not be empty"
embeddings
.
append
(
item
[
"embedding"
])
# Return a summary string for validation
return
f
"Generated
{
len
(
embeddings
)
}
embeddings with dimension
{
len
(
embeddings
[
0
])
}
"
def
response_handler
(
self
,
response
:
Any
)
->
str
:
return
EmbeddingPayload
.
extract_embeddings
(
response
)
@
dataclass
class
MetricsPayload
(
BasePayload
):
endpoint
:
str
=
"/metrics"
...
...
Prev
1
2
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment