cryogenic22 commited on
Commit
cc11bc2
·
verified ·
1 Parent(s): 313e8dd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -9
app.py CHANGED
@@ -20,6 +20,8 @@ def init_session_state():
20
  st.session_state.current_image = None
21
  if 'current_analysis' not in st.session_state:
22
  st.session_state.current_analysis = None
 
 
23
 
24
  def main():
25
  st.set_page_config(
@@ -40,10 +42,7 @@ def main():
40
  init_session_state()
41
 
42
  # Create sidebar and get inputs
43
- upload_option, uploaded_file, patterns, indicators = create_sidebar()
44
-
45
- # Main content area
46
- col1, col2 = st.columns([2, 1])
47
 
48
  # Main content area
49
  col1, col2 = st.columns([2, 1])
@@ -82,12 +81,12 @@ def main():
82
  st.session_state.chat_history.extend(results)
83
 
84
  # Display analyses
85
- for result in results:
86
  analysis_type = result.get('analysis_type', 'Individual')
87
  if analysis_type != 'Individual':
88
  st.subheader(f"{analysis_type} Results")
89
  else:
90
- st.subheader(f"Analysis Results - Chart {len(st.session_state.chat_history)}")
91
  st.write(result['analysis'])
92
 
93
  # Risk warning
@@ -104,7 +103,7 @@ def main():
104
  response = analysis_service.handle_follow_up_question(
105
  follow_up,
106
  st.session_state.current_analysis,
107
- st.session_state.current_image
108
  )
109
  if response:
110
  st.session_state.chat_history.append(response)
@@ -119,10 +118,13 @@ def main():
119
  if save_name and st.session_state.chat_history:
120
  filename = save_chat_history(
121
  st.session_state.chat_history,
122
- st.session_state.current_image,
123
  f"{save_name}.json" if save_name else None
124
  )
125
- st.success(f"Chat saved as {filename}")
 
 
 
126
 
127
  if __name__ == "__main__":
128
  main()
 
20
  st.session_state.current_image = None
21
  if 'current_analysis' not in st.session_state:
22
  st.session_state.current_analysis = None
23
+ if 'current_images' not in st.session_state:
24
+ st.session_state.current_images = []
25
 
26
  def main():
27
  st.set_page_config(
 
42
  init_session_state()
43
 
44
  # Create sidebar and get inputs
45
+ upload_option, uploaded_files, patterns, indicators, comparison_type = create_sidebar()
 
 
 
46
 
47
  # Main content area
48
  col1, col2 = st.columns([2, 1])
 
81
  st.session_state.chat_history.extend(results)
82
 
83
  # Display analyses
84
+ for idx, result in enumerate(results):
85
  analysis_type = result.get('analysis_type', 'Individual')
86
  if analysis_type != 'Individual':
87
  st.subheader(f"{analysis_type} Results")
88
  else:
89
+ st.subheader(f"Analysis Results - Chart {idx + 1}")
90
  st.write(result['analysis'])
91
 
92
  # Risk warning
 
103
  response = analysis_service.handle_follow_up_question(
104
  follow_up,
105
  st.session_state.current_analysis,
106
+ st.session_state.current_images[0] if st.session_state.current_images else None
107
  )
108
  if response:
109
  st.session_state.chat_history.append(response)
 
118
  if save_name and st.session_state.chat_history:
119
  filename = save_chat_history(
120
  st.session_state.chat_history,
121
+ st.session_state.current_images[0] if st.session_state.current_images else None,
122
  f"{save_name}.json" if save_name else None
123
  )
124
+ if filename:
125
+ st.success(f"Chat saved as {filename}")
126
+ else:
127
+ st.info("Chat saved to session state")
128
 
129
  if __name__ == "__main__":
130
  main()