baconnier commited on
Commit
eed158d
·
verified ·
1 Parent(s): d31d865

Update models.py

Browse files
Files changed (1) hide show
  1. models.py +32 -52
models.py CHANGED
@@ -1,72 +1,52 @@
1
- from typing import List, Optional, Literal
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
10
 
11
  class ZoomRange(BaseModel):
12
- range: List[int] = Field(..., description="Start and end years")
13
- explanation: str
14
 
15
  class StyleConfig(BaseModel):
16
- level: str
17
- options: List[str] = Field(..., description="Available style options")
18
- explanation: str
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
- level: Literal["continent", "country", "city"]
27
- locations: List[Location]
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
- geographical: Optional[str] = None
37
- temporal: Optional[str] = None
38
- style: Optional[str] = None
39
 
40
  class TemporalConfig(BaseModel):
41
- component: Literal["st.slider"]
42
- current_zoom: TemporalZoom
43
- available_zooms: dict[Literal["in", "out"], ZoomRange]
44
- impacted_by: AxisImpact
45
 
46
  class GeographicalConfig(BaseModel):
47
- component: Literal["st.map"]
48
- current_zoom: GeographicalZoom
49
- available_zooms: dict[Literal["in", "out"], dict[Literal["locations", "explanation"], str | List[Location]]]
50
- impacted_by: AxisImpact
51
 
52
  class StyleConfig(BaseModel):
53
- component: Literal["st.multiselect", "st.selectbox"]
54
- current_zoom: StyleZoom
55
-
56
  class Analysis(BaseModel):
57
- query_focus: str
58
- historical_context: str
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
- @classmethod
69
- def from_llm(cls, query: str, current_zoom_states: dict) -> "ArtResponse":
70
- """Factory method to create response from LLM output"""
71
- # This would be implemented with instructor
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)")