Spaces:
Sleeping
Sleeping
File size: 2,197 Bytes
d31d865 |
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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
from typing import List, Optional, Literal
from pydantic import BaseModel, Field
from instructor import Field as InstructorField
class Location(BaseModel):
name: str
lat: float
lon: float
relevance: str
class ZoomRange(BaseModel):
range: List[int] = Field(..., description="Start and end years")
explanation: str
class StyleConfig(BaseModel):
level: str
options: List[str] = Field(..., description="Available style options")
explanation: str
class TemporalZoom(BaseModel):
level: Literal["century", "decade", "year"]
range: List[int] = Field(..., description="Start and end years")
explanation: str
class GeographicalZoom(BaseModel):
level: Literal["continent", "country", "city"]
locations: List[Location]
explanation: str = ""
class StyleZoom(BaseModel):
level: Literal["movement", "sub_movement", "specific"]
options: List[str]
explanation: str
class AxisImpact(BaseModel):
geographical: Optional[str] = None
temporal: Optional[str] = None
style: Optional[str] = None
class TemporalConfig(BaseModel):
component: Literal["st.slider"]
current_zoom: TemporalZoom
available_zooms: dict[Literal["in", "out"], ZoomRange]
impacted_by: AxisImpact
class GeographicalConfig(BaseModel):
component: Literal["st.map"]
current_zoom: GeographicalZoom
available_zooms: dict[Literal["in", "out"], dict[Literal["locations", "explanation"], str | List[Location]]]
impacted_by: AxisImpact
class StyleConfig(BaseModel):
component: Literal["st.multiselect", "st.selectbox"]
current_zoom: StyleZoom
class Analysis(BaseModel):
query_focus: str
historical_context: str
class ArtResponse(BaseModel):
"""Art history exploration response with contextual zoom configurations"""
analysis: Analysis
axis_configurations: dict[
Literal["temporal", "geographical", "style"],
TemporalConfig | GeographicalConfig | StyleConfig
]
@classmethod
def from_llm(cls, query: str, current_zoom_states: dict) -> "ArtResponse":
"""Factory method to create response from LLM output"""
# This would be implemented with instructor
pass |