GitHub Actions commited on
Commit
e82be7a
·
1 Parent(s): 61bd74f

Deploy 5a96418

Browse files
Files changed (1) hide show
  1. app.py +10 -4
app.py CHANGED
@@ -3,16 +3,22 @@
3
  # Model is loaded from /app/model_cache (baked into the Docker image at build time).
4
 
5
  from contextlib import asynccontextmanager
6
- from typing import Any
7
 
8
- import numpy as np
9
  from fastapi import FastAPI
10
- from pydantic import BaseModel
11
  from sentence_transformers import SentenceTransformer
12
 
 
 
 
 
 
13
 
14
  class EmbedRequest(BaseModel):
15
- texts: list[str]
 
 
16
 
17
 
18
  class EmbedResponse(BaseModel):
 
3
  # Model is loaded from /app/model_cache (baked into the Docker image at build time).
4
 
5
  from contextlib import asynccontextmanager
6
+ from typing import Annotated, Any
7
 
 
8
  from fastapi import FastAPI
9
+ from pydantic import BaseModel, Field
10
  from sentence_transformers import SentenceTransformer
11
 
12
+ # 64 texts * 2000 chars = 128KB max payload — keeps the free-tier Space under
13
+ # its 16GB RAM limit even with the largest expected retrieval batch (top-20).
14
+ _MAX_TEXTS = 64
15
+ _MAX_TEXT_LEN = 2000
16
+
17
 
18
  class EmbedRequest(BaseModel):
19
+ texts: list[Annotated[str, Field(max_length=_MAX_TEXT_LEN)]] = Field(
20
+ ..., max_length=_MAX_TEXTS
21
+ )
22
 
23
 
24
  class EmbedResponse(BaseModel):