Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
kyriediculous committed Dec 28, 2024
1 parent ed1413c commit 7987601
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 17 deletions.
18 changes: 1 addition & 17 deletions runner/app/routes/embeddings.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,14 @@
from fastapi import APIRouter, Depends, status
from fastapi.responses import JSONResponse
from fastapi.security import HTTPAuthorizationCredentials, HTTPBearer
from pydantic import BaseModel, Field
from app.dependencies import get_pipeline
from app.pipelines.base import Pipeline
from app.routes.utils import HTTPError, http_error
from app.routes.utils import EmbeddingRequest, EmbeddingResponse

router = APIRouter()
logger = logging.getLogger(__name__)


class EmbeddingRequest(BaseModel):
input: Union[str, List[str]] = Field(..., description="Text to embed")
model: str = Field("", description="Model to use")
instruction: Optional[str] = Field(
None, description="Instruction for instructor models")
normalize: bool = Field(True, description="Whether to normalize embeddings")


class EmbeddingResponse(BaseModel):
object: str
data: List[Dict[str, Union[List[float], int]]]
model: str
usage: Dict[str, int]


RESPONSES = {
status.HTTP_200_OK: {"model": EmbeddingResponse},
status.HTTP_400_BAD_REQUEST: {"model": HTTPError},
Expand Down
15 changes: 15 additions & 0 deletions runner/app/routes/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,21 @@ class LLMResponse(BaseModel):
created: int


class EmbeddingRequest(BaseModel):
input: Union[str, List[str]] = Field(..., description="Text to embed")
model: str = Field("", description="Model to use")
instruction: Optional[str] = Field(
None, description="Instruction for instructor models")
normalize: bool = Field(True, description="Whether to normalize embeddings")


class EmbeddingResponse(BaseModel):
object: str
data: List[Dict[str, Union[List[float], int]]]
model: str
usage: Dict[str, int]


class ImageToTextResponse(BaseModel):
"""Response model for text generation."""

Expand Down

0 comments on commit 7987601

Please sign in to comment.