Skip to content

Commit 287eb40

Browse files
committed
feat: added dimensions to request parameter of the embeddings endpoint
1 parent aa2e00e commit 287eb40

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

open/text/embeddings/server/app.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ class CreateEmbeddingRequest(BaseModel):
5151
model: Optional[str] = Field(
5252
description="The model to use for generating embeddings.", default=None)
5353
input: Union[str, List[str]] = Field(description="The input to embed.")
54+
dimensions: Optional[int] = Field(
55+
description="The number of dimensions the resulting output embeddings should have.",
56+
default=None)
5457
user: Optional[str] = Field(default=None)
5558

5659
model_config = {
@@ -167,9 +170,9 @@ async def create_embedding(
167170
):
168171
if pydantic.__version__ > '2.0.0':
169172
return await run_in_threadpool(
170-
_create_embedding, **request.model_dump(exclude={"user", "model", "model_config"})
173+
_create_embedding, **request.model_dump(exclude={"user", "model", "model_config", "dimensions"})
171174
)
172175
else:
173176
return await run_in_threadpool(
174-
_create_embedding, **request.dict(exclude={"user", "model", "model_config"})
177+
_create_embedding, **request.dict(exclude={"user", "model", "model_config", "dimensions"})
175178
)

text.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"input": [
33
"\n\n### Instructions:\nWhat is the capital of France?\n\n### Response:\n"
4-
]
4+
],
5+
"dimensions": 256
56
}

0 commit comments

Comments
 (0)