prashantmatlani commited on
Commit
be9ab33
Β·
1 Parent(s): f31ad14

history display

Browse files
Files changed (1) hide show
  1. app.py +41 -4
app.py CHANGED
@@ -59,8 +59,12 @@ with gr.Blocks() as demo:
59
 
60
  # --- Center Panel: Main Core Multimodal Chat ---
61
  with gr.Column(scale=3):
62
- chatbot = gr.Chatbot(show_label=False, height=700)
63
 
 
 
 
 
64
  chat_input = gr.Textbox(
65
  interactive=True,
66
  placeholder="Discuss architecture, paste code blocks, or ask CoderG to produce course documentation...",
@@ -74,7 +78,7 @@ with gr.Blocks() as demo:
74
  upload_btn = gr.UploadButton(
75
  "πŸ“Ž Attach Documents/Images",
76
  file_count="multiple",
77
- file_types=[".png", ".jpg", ".jpeg", ".bmp", ".pdf", ".xlsx", ".xls", ".docx", ".md", ".py", ".html", ".cs", ".js", ".json", ".csv", ".zip", ".tar.gz", ".log", ".txt"],
78
  scale=2
79
  )
80
 
@@ -144,6 +148,7 @@ with gr.Blocks() as demo:
144
  history[-1]["content"] = partial_resp
145
  yield history
146
 
 
147
  def handle_save(history, chat_id, session_password):
148
  new_id = save_chat(chat_id, history)
149
  # Keeps sidebar refreshes tied strictly to the current session token authentication context
@@ -151,11 +156,30 @@ with gr.Blocks() as demo:
151
  if [new_id] not in current_list:
152
  current_list.insert(0, [new_id])
153
  return new_id, gr.update(samples=current_list)
 
 
 
 
 
 
 
 
 
 
 
154
 
 
155
  def load_past_chat(selected_list):
156
  chat_id = selected_list[0]
157
  content = get_chat_content(chat_id)
158
  return content, chat_id
 
 
 
 
 
 
 
159
 
160
  def push_authorized(repo_name, commit_msg, files_list):
161
  files = [f.strip() for f in files_list.split(",") if f.strip()]
@@ -199,20 +223,33 @@ with gr.Blocks() as demo:
199
  ).then(
200
  fn=handle_save,
201
  inputs=[chatbot, chat_id_state, user_session_password],
202
- outputs=[chat_id_state, history_list]
 
 
203
  )
204
 
205
  history_list.click(
206
  fn=load_past_chat,
207
  inputs=[history_list],
208
- outputs=[chatbot, chat_id_state]
 
209
  )
210
 
 
211
  new_btn.click(
212
  fn=lambda session_pass: ([], "", [], load_history(user_password=session_pass), "", "_Awaiting local environment staging completion..._"),
213
  inputs=[user_session_password],
214
  outputs=[chatbot, chat_id_state, staged_files_state, history_list, upload_status, output_log]
215
  )
 
 
 
 
 
 
 
 
 
216
 
217
  approve_btn.click(
218
  fn=push_authorized,
 
59
 
60
  # --- Center Panel: Main Core Multimodal Chat ---
61
  with gr.Column(scale=3):
62
+ #chatbot = gr.Chatbot(show_label=False, height=700)
63
 
64
+ active_chat_indicator = gr.Markdown("### πŸ“ Active Session: *New Conversation*")
65
+
66
+ chatbot = gr.Chatbot(show_label=False, height=660) # Tweak height slightly to give header room
67
+
68
  chat_input = gr.Textbox(
69
  interactive=True,
70
  placeholder="Discuss architecture, paste code blocks, or ask CoderG to produce course documentation...",
 
78
  upload_btn = gr.UploadButton(
79
  "πŸ“Ž Attach Documents/Images",
80
  file_count="multiple",
81
+ file_types=[".png", ".jpg", ".jpeg", ".bmp", ".pdf", ".xlsx", ".xls", ".doc", ".docx", ".md", ".py", ".html", ".css", ".js", ".json", ".csv", ".zip", ".tar.gz", ".log", ".txt"],
82
  scale=2
83
  )
84
 
 
148
  history[-1]["content"] = partial_resp
149
  yield history
150
 
151
+ """
152
  def handle_save(history, chat_id, session_password):
153
  new_id = save_chat(chat_id, history)
154
  # Keeps sidebar refreshes tied strictly to the current session token authentication context
 
156
  if [new_id] not in current_list:
157
  current_list.insert(0, [new_id])
158
  return new_id, gr.update(samples=current_list)
159
+ """
160
+ def handle_save(history, chat_id, session_password):
161
+ new_id = save_chat(chat_id, history)
162
+ # Keeps sidebar refreshes tied strictly to the current session token authentication context
163
+ current_list = load_history(user_password=session_password)
164
+ if [new_id] not in current_list:
165
+ current_list.insert(0, [new_id])
166
+
167
+ # We return the new_id, the dataset update, AND we update the indicator view
168
+ # in case a brand new chat just generated its first true cloud file name.
169
+ return new_id, gr.update(samples=current_list), f"### πŸ“ Active Session: `{new_id}`"
170
 
171
+ """
172
  def load_past_chat(selected_list):
173
  chat_id = selected_list[0]
174
  content = get_chat_content(chat_id)
175
  return content, chat_id
176
+ """
177
+ def load_past_chat(selected_list):
178
+ chat_id = selected_list[0]
179
+ content = get_chat_content(chat_id)
180
+ # Returns chat log array, updates chat ID tracking state, and updates the header text
181
+ return content, chat_id, f"### πŸ“ Active Session: `{chat_id}`"
182
+
183
 
184
  def push_authorized(repo_name, commit_msg, files_list):
185
  files = [f.strip() for f in files_list.split(",") if f.strip()]
 
223
  ).then(
224
  fn=handle_save,
225
  inputs=[chatbot, chat_id_state, user_session_password],
226
+ outputs=[chat_id_state, history_list,
227
+ active_chat_indicator] # Updates header text post-save
228
+
229
  )
230
 
231
  history_list.click(
232
  fn=load_past_chat,
233
  inputs=[history_list],
234
+ outputs=[chatbot, chat_id_state,
235
+ active_chat_indicator] # Feeds selected chat ID into header
236
  )
237
 
238
+ """
239
  new_btn.click(
240
  fn=lambda session_pass: ([], "", [], load_history(user_password=session_pass), "", "_Awaiting local environment staging completion..._"),
241
  inputs=[user_session_password],
242
  outputs=[chatbot, chat_id_state, staged_files_state, history_list, upload_status, output_log]
243
  )
244
+ """
245
+ new_btn.click(
246
+ fn=lambda session_pass: (
247
+ [], "", [], load_history(user_password=session_pass), "",
248
+ "_Awaiting local environment staging completion..._", "### πŸ“ Active Session: *New Conversation*"
249
+ ),
250
+ inputs=[user_session_password],
251
+ outputs=[chatbot, chat_id_state, staged_files_state, history_list, upload_status, output_log, active_chat_indicator]
252
+ )
253
 
254
  approve_btn.click(
255
  fn=push_authorized,