Skip to content

Commit

Permalink
Merge branch 'development' into feat/supported-extensible-routes
Browse files Browse the repository at this point in the history
  • Loading branch information
adubovik committed Jul 19, 2024
2 parents 9585418 + 608bd4e commit 4d43678
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
4 changes: 2 additions & 2 deletions aidial_sdk/embeddings/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

from aidial_sdk.chat_completion.request import Attachment
from aidial_sdk.deployment.from_request_mixin import FromRequestDeploymentMixin
from aidial_sdk.pydantic_v1 import StrictFloat, StrictInt, StrictStr
from aidial_sdk.pydantic_v1 import StrictInt, StrictStr
from aidial_sdk.utils.pydantic import ExtraForbidModel


class AzureEmbeddingsRequest(ExtraForbidModel):
model: Optional[StrictStr] = None
input: Union[
StrictStr, List[StrictStr], List[StrictFloat], List[List[StrictFloat]]
StrictStr, List[StrictStr], List[StrictInt], List[List[StrictInt]]
]
encoding_format: Literal["float", "base64"] = "float"
dimensions: Optional[StrictInt] = None
Expand Down
8 changes: 4 additions & 4 deletions aidial_sdk/embeddings/response.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from typing import List, Literal
from typing import List, Literal, Union

from aidial_sdk.utils.pydantic import ExtraForbidModel


class Embedding(ExtraForbidModel):
embedding: List[float]
embedding: Union[str, List[float]]
index: int
object: Literal["embedding"] = "embedding"

Expand All @@ -14,11 +14,11 @@ class Usage(ExtraForbidModel):
total_tokens: int


class CreateEmbeddingResponse(ExtraForbidModel):
class EmbeddingResponse(ExtraForbidModel):
data: List[Embedding]
model: str
object: Literal["list"] = "list"
usage: Usage


Response = CreateEmbeddingResponse
Response = EmbeddingResponse
15 changes: 14 additions & 1 deletion tests/test_embeddings.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,20 @@
app,
deployment,
"embeddings",
{"input": "a", "custom_fields": {"type": "query"}},
{
"input": "a",
"custom_fields": {
"type": "query",
"instruction": "instruction",
},
},
expected_response_1,
),
TestCase(
app,
deployment,
"embeddings",
{"input": [15339]},
expected_response_1,
),
TestCase(
Expand Down

0 comments on commit 4d43678

Please sign in to comment.