baconnier commited on
Commit
c4a31ce
·
verified ·
1 Parent(s): 1413b3a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -174
app.py CHANGED
@@ -4,135 +4,8 @@ import gradio as gr
4
  import json
5
  import plotly.graph_objects as go
6
 
7
- CONTEXTUAL_ZOOM_PROMPT = """
8
- You are an expert art historian specializing in interactive exploration. Analyze the query and generate contextually aware zoom configurations with explanations.
9
 
10
- ###Input###
11
- User Query: {user_query}
12
- Current Zoom States: {
13
- "temporal": {"level": "", "selection": ""},
14
- "geographical": {"level": "", "selection": ""},
15
- "style": {"level": "", "selection": ""},
16
- "subject": {"level": "", "selection": ""}
17
- }
18
-
19
- ###Output Format###
20
- {
21
- "analysis": {
22
- "query_focus": "main subject",
23
- "historical_context": "brief explanation"
24
- },
25
- "axis_configurations": {
26
- "temporal": {
27
- "component": "st.slider",
28
- "current_zoom": {
29
- "level": "century/decade/year",
30
- "range": [start, end],
31
- "explanation": "Why this time range is relevant"
32
- },
33
- "available_zooms": {
34
- "in": {
35
- "range": [narrower_start, narrower_end],
36
- "explanation": "What focusing here reveals"
37
- },
38
- "out": {
39
- "range": [broader_start, broader_end],
40
- "explanation": "Broader historical context"
41
- }
42
- },
43
- "impacted_by": {
44
- "geographical": "how location affects timeframe",
45
- "style": "how style affects timeframe"
46
- }
47
- },
48
- "geographical": {
49
- "component": "st.map",
50
- "current_zoom": {
51
- "level": "continent/country/city",
52
- "locations": [
53
- {
54
- "name": "",
55
- "lat": 0,
56
- "lon": 0,
57
- "relevance": "why this location matters"
58
- }
59
- ]
60
- },
61
- "available_zooms": {
62
- "in": {
63
- "locations": ["more specific locations"],
64
- "explanation": "What focusing here reveals"
65
- },
66
- "out": {
67
- "locations": ["broader regions"],
68
- "explanation": "Broader geographical context"
69
- }
70
- },
71
- "impacted_by": {
72
- "temporal": "how time period affects locations",
73
- "style": "how style affects locations"
74
- }
75
- },
76
- "style": {
77
- "component": "st.multiselect" if current_zoom == "broad" else "st.selectbox",
78
- "current_zoom": {
79
- "level": "movement/sub_movement/specific",
80
- "options": ["list of styles"],
81
- "explanation": "Style context for this period/location"
82
- }
83
- }
84
- },
85
- "streamlit_adaptations": {
86
- "recommended_components": {
87
- "component_name": "reason for recommendation based on zoom level",
88
- "configuration": {}
89
- }
90
- }
91
- }
92
-
93
- ###Example for "paint during napoleon war"###
94
- {
95
- "temporal": {
96
- "component": "st.slider",
97
- "current_zoom": {
98
- "level": "period",
99
- "range": [1799, 1815],
100
- "explanation": "Napoleon's reign as First Consul and Emperor"
101
- },
102
- "available_zooms": {
103
- "in": {
104
- "range": [1812, 1815],
105
- "explanation": "Focus on final campaigns and artistic responses"
106
- }
107
- }
108
- },
109
- "geographical": {
110
- "component": "st.map",
111
- "current_zoom": {
112
- "level": "continent",
113
- "locations": [
114
- {
115
- "name": "France",
116
- "relevance": "Center of Napoleonic art production"
117
- },
118
- {
119
- "name": "Spain",
120
- "relevance": "Goya's war paintings perspective"
121
- }
122
- ]
123
- }
124
- }
125
- }
126
-
127
- ###Requirements###
128
- 1. Explain zoom level changes and their historical significance
129
- 2. Adapt Streamlit components based on zoom level
130
- 3. Show relationships between different axes
131
- 4. Provide historical context for available selections
132
- 5. Consider how selections affect other axes
133
- 6. Include relevant historical explanations for each zoom level
134
-
135
- Generate only the JSON response, maintaining strict JSON format."""
136
 
137
  class ArtExplorer:
138
  def __init__(self):
@@ -205,52 +78,7 @@ class ArtExplorer:
205
  return self.get_default_response()
206
 
207
  def get_default_response(self):
208
- return {
209
- "analysis": {
210
- "query_focus": "Default focus",
211
- "historical_context": "Default historical context"
212
- },
213
- "axis_configurations": {
214
- "temporal": {
215
- "component": "st.slider",
216
- "current_zoom": {
217
- "level": "century",
218
- "range": [1700, 2000],
219
- "explanation": "Default time range"
220
- },
221
- "available_zooms": {
222
- "in": {
223
- "range": [1800, 1900],
224
- "explanation": "Zoom in to see more detail"
225
- },
226
- "out": {
227
- "range": [1500, 2024],
228
- "explanation": "Broader historical context"
229
- }
230
- }
231
- },
232
- "geographical": {
233
- "current_zoom": {
234
- "level": "continent",
235
- "locations": [
236
- {
237
- "name": "Paris",
238
- "lat": 48.8566,
239
- "lon": 2.3522,
240
- "relevance": "Default location"
241
- }
242
- ]
243
- }
244
- },
245
- "style": {
246
- "current_zoom": {
247
- "level": "movement",
248
- "options": ["Classical", "Modern"],
249
- "explanation": "Default art movements"
250
- }
251
- }
252
- }
253
- }
254
 
255
  def create_interface(self):
256
  with gr.Blocks() as demo:
 
4
  import json
5
  import plotly.graph_objects as go
6
 
7
+ from variables import *
 
8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
 
10
  class ArtExplorer:
11
  def __init__(self):
 
78
  return self.get_default_response()
79
 
80
  def get_default_response(self):
81
+ return CONTEXTUAL_ZOOM_default_response
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
82
 
83
  def create_interface(self):
84
  with gr.Blocks() as demo: