Skip to content

Commit 1dff7b0

Browse files
committed
wip
1 parent 1706559 commit 1dff7b0

File tree

2 files changed

+16
-17
lines changed

2 files changed

+16
-17
lines changed

runner/app/routes/embeddings.py

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,14 @@
55
from fastapi import APIRouter, Depends, status
66
from fastapi.responses import JSONResponse
77
from fastapi.security import HTTPAuthorizationCredentials, HTTPBearer
8-
from pydantic import BaseModel, Field
98
from app.dependencies import get_pipeline
109
from app.pipelines.base import Pipeline
1110
from app.routes.utils import HTTPError, http_error
11+
from app.routes.utils import EmbeddingRequest, EmbeddingResponse
1212

1313
router = APIRouter()
1414
logger = logging.getLogger(__name__)
1515

16-
17-
class EmbeddingRequest(BaseModel):
18-
input: Union[str, List[str]] = Field(..., description="Text to embed")
19-
model: str = Field("", description="Model to use")
20-
instruction: Optional[str] = Field(
21-
None, description="Instruction for instructor models")
22-
normalize: bool = Field(True, description="Whether to normalize embeddings")
23-
24-
25-
class EmbeddingResponse(BaseModel):
26-
object: str
27-
data: List[Dict[str, Union[List[float], int]]]
28-
model: str
29-
usage: Dict[str, int]
30-
31-
3216
RESPONSES = {
3317
status.HTTP_200_OK: {"model": EmbeddingResponse},
3418
status.HTTP_400_BAD_REQUEST: {"model": HTTPError},

runner/app/routes/utils.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,21 @@ class LLMResponse(BaseModel):
9595
created: int
9696

9797

98+
class EmbeddingRequest(BaseModel):
99+
input: Union[str, List[str]] = Field(..., description="Text to embed")
100+
model: str = Field("", description="Model to use")
101+
instruction: Optional[str] = Field(
102+
None, description="Instruction for instructor models")
103+
normalize: bool = Field(True, description="Whether to normalize embeddings")
104+
105+
106+
class EmbeddingResponse(BaseModel):
107+
object: str
108+
data: List[Dict[str, Union[List[float], int]]]
109+
model: str
110+
usage: Dict[str, int]
111+
112+
98113
class ImageToTextResponse(BaseModel):
99114
"""Response model for text generation."""
100115

0 commit comments

Comments
 (0)