File size: 1,080 Bytes
5684a32
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
37
38
39
40
41
#!/usr/bin/env python3
"""
Data models for RAG system.
Contains Pydantic models for query rewriting, filters, and responses.
"""

from typing import Optional, List
from enum import Enum
from pydantic import BaseModel


class QueryRewrite(BaseModel):
    """Model for query rewriting with expansion."""
    improved_query: str
    expanded_query: Optional[str] = ""


class CatalogResponse(BaseModel):
    """Simplified response for catalog search - no YES/NO validation needed."""
    summary: str


class MaterialType(str, Enum):
    """Enumeration of material types available in the BPL catalog."""
    STILL_IMAGE = "Still image"
    CARTOGRAPHIC = "Cartographic"
    MANUSCRIPT = "Manuscript"
    MOVING_IMAGE = "Moving image"
    NOTATED_MUSIC = "Notated music"
    ARTIFACT = "Artifact"
    AUDIO = "Audio"


class SearchFilters(BaseModel):
    """Search filters for temporal and material type filtering."""
    year_exact: Optional[int] = None
    year_start: Optional[int] = None
    year_end: Optional[int] = None
    material_types: Optional[List[MaterialType]] = None