File size: 1,053 Bytes
9d780fe | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | from pydantic import BaseModel, Field
from typing import Any, Dict, List, Optional
class QdrantCfg(BaseModel):
url: str
collection: str
query_filter: Optional[Dict[str, Any]] = None
class ModelSpec(BaseModel):
backend: str = Field(default="st", pattern="^(fastembed|st)$")
name: str = "BAAI/bge-m3"
normalize: bool = True
e5_mode: str = Field(default="auto", pattern="^(auto|query|passage)$")
class SearchRequest(BaseModel):
text: str
top_k: int = Field(default=5, ge=1, le=100)
threshold: float = Field(default=0.0, ge=0.0)
with_payload: bool = True
qdrant: QdrantCfg
model: ModelSpec = ModelSpec()
# ์๋ก ์ถ๊ฐ: ํ๋ฆฌ์
ํ ์ค๋ก ์ ํ ๊ฐ๋ฅ (๋ค์ด์ค๋ฉด preset ์ฐ์ ์ ์ฉ)
preset_id: Optional[str] = None
class Hit(BaseModel):
id: Any
score: float
payload: Optional[Dict[str, Any]] = None
class SearchResponse(BaseModel):
took_ms: int
model: ModelSpec
collection: str
total_candidates: int
hits: List[Hit]
|