Spaces:
Sleeping
Sleeping
Update models.py
Browse files
models.py
CHANGED
@@ -1,72 +1,52 @@
|
|
1 |
-
from typing import List, Optional,
|
2 |
from pydantic import BaseModel, Field
|
3 |
from instructor import Field as InstructorField
|
4 |
|
5 |
class Location(BaseModel):
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
|
11 |
class ZoomRange(BaseModel):
|
12 |
-
|
13 |
-
|
14 |
|
15 |
class StyleConfig(BaseModel):
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
class TemporalZoom(BaseModel):
|
21 |
-
level: Literal["century", "decade", "year"]
|
22 |
-
range: List[int] = Field(..., description="Start and end years")
|
23 |
-
explanation: str
|
24 |
|
25 |
class GeographicalZoom(BaseModel):
|
26 |
-
|
27 |
-
|
28 |
-
explanation: str = ""
|
29 |
-
|
30 |
-
class StyleZoom(BaseModel):
|
31 |
-
level: Literal["movement", "sub_movement", "specific"]
|
32 |
-
options: List[str]
|
33 |
-
explanation: str
|
34 |
|
35 |
class AxisImpact(BaseModel):
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
|
40 |
class TemporalConfig(BaseModel):
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
|
46 |
class GeographicalConfig(BaseModel):
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
|
52 |
class StyleConfig(BaseModel):
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
class Analysis(BaseModel):
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
class ArtResponse(BaseModel):
|
61 |
-
"""Art history exploration response with contextual zoom configurations"""
|
62 |
-
analysis: Analysis
|
63 |
-
axis_configurations: dict[
|
64 |
-
Literal["temporal", "geographical", "style"],
|
65 |
-
TemporalConfig | GeographicalConfig | StyleConfig
|
66 |
-
]
|
67 |
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
pass
|
|
|
1 |
+
from typing import List, Optional, Union
|
2 |
from pydantic import BaseModel, Field
|
3 |
from instructor import Field as InstructorField
|
4 |
|
5 |
class Location(BaseModel):
|
6 |
+
name: str
|
7 |
+
lat: float
|
8 |
+
lon: float
|
9 |
+
relevance: str = Field(description="Why this location matters in the historical context")
|
10 |
|
11 |
class ZoomRange(BaseModel):
|
12 |
+
range: List[int] = Field(description="Start and end years for the time period")
|
13 |
+
explanation: str = Field(description="Historical significance of this time period")
|
14 |
|
15 |
class StyleConfig(BaseModel):
|
16 |
+
level: str = Field(description="Level of style detail (movement/sub_movement/specific)")
|
17 |
+
options: List[str] = Field(description="Available artistic styles for selection")
|
18 |
+
explanation: str = Field(description="Historical context for the artistic styles")
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
class GeographicalZoom(BaseModel):
|
21 |
+
locations: List[Location]
|
22 |
+
explanation: str = Field(description="Significance of these locations")
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
|
24 |
class AxisImpact(BaseModel):
|
25 |
+
temporal: Optional[str] = Field(description="How time period affects this axis")
|
26 |
+
geographical: Optional[str] = Field(description="How location affects this axis")
|
27 |
+
style: Optional[str] = Field(description="How artistic style affects this axis")
|
28 |
|
29 |
class TemporalConfig(BaseModel):
|
30 |
+
component: str = Field(default="st.slider")
|
31 |
+
current_zoom: ZoomRange
|
32 |
+
available_zooms: dict[str, ZoomRange] = Field(description="Available zoom levels (in/out)")
|
33 |
+
impacted_by: AxisImpact
|
34 |
|
35 |
class GeographicalConfig(BaseModel):
|
36 |
+
component: str = Field(default="st.map")
|
37 |
+
current_zoom: GeographicalZoom
|
38 |
+
available_zooms: dict[str, GeographicalZoom] = Field(description="Available zoom levels (in/out)")
|
39 |
+
impacted_by: AxisImpact
|
40 |
|
41 |
class StyleConfig(BaseModel):
|
42 |
+
component: str = Field(default="st.multiselect")
|
43 |
+
current_zoom: StyleConfig
|
44 |
+
|
45 |
class Analysis(BaseModel):
|
46 |
+
query_focus: str = Field(description="Main subject of the query")
|
47 |
+
historical_context: str = Field(description="Brief historical context")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
|
49 |
+
class ArtHistoryResponse(BaseModel):
|
50 |
+
analysis: Analysis
|
51 |
+
axis_configurations: dict[str, Union[TemporalConfig, GeographicalConfig, StyleConfig]] = \
|
52 |
+
Field(description="Configuration for each axis (temporal, geographical, style)")
|
|