File size: 1,053 Bytes
017e961
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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]