bluenevus commited on
Commit
998c37c
·
1 Parent(s): 49fb757

Update app.py via AI Editor

Browse files
Files changed (1) hide show
  1. app.py +6 -17
app.py CHANGED
@@ -98,7 +98,6 @@ def embed_docs_folder():
98
  text = f.read()
99
  if not text.strip():
100
  continue
101
- # OpenAI recommends chunking long texts; here, we take the first 1000 tokens per doc as a simple approach
102
  chunk = text[:4000]
103
  response = openai.Embedding.create(
104
  input=[chunk],
@@ -239,8 +238,6 @@ def assign_session_id(_):
239
  Output("stream-interval", "disabled"),
240
  Output("stream-interval", "n_intervals"),
241
  Output("chat-name-input", "style"),
242
- Output("chat-window", "children"),
243
- Output("stream-interval", "disabled"),
244
  Input("session-id", "data"),
245
  Input("send-btn", "n_clicks"),
246
  Input("file-upload", "contents"),
@@ -366,9 +363,7 @@ def main_callback(session_id, send_clicks, file_contents, new_chat_clicks, strea
366
  "",
367
  not state.get("streaming", False),
368
  0,
369
- show_chat_name,
370
- chat_cards,
371
- not state.get("streaming", False)
372
  )
373
  # If input box is visible and has a value, save chat history
374
  else:
@@ -403,9 +398,7 @@ def main_callback(session_id, send_clicks, file_contents, new_chat_clicks, strea
403
  error,
404
  not state.get("streaming", False),
405
  0,
406
- show_chat_name,
407
- [],
408
- not state.get("streaming", False)
409
  )
410
 
411
  # Handle polling for streaming
@@ -433,9 +426,7 @@ def main_callback(session_id, send_clicks, file_contents, new_chat_clicks, strea
433
  "",
434
  False,
435
  stream_n+1,
436
- chat_name_style,
437
- chat_cards,
438
- False
439
  )
440
  else:
441
  chat_cards = []
@@ -457,9 +448,7 @@ def main_callback(session_id, send_clicks, file_contents, new_chat_clicks, strea
457
  "",
458
  True,
459
  0,
460
- chat_name_style,
461
- chat_cards,
462
- True
463
  )
464
 
465
  # Default: Build Uploads, Chat History and Chat Window
@@ -481,8 +470,8 @@ def main_callback(session_id, send_clicks, file_contents, new_chat_clicks, strea
481
  if state.get("streaming", False):
482
  if state.get("stream_buffer", ""):
483
  chat_cards.append(chat_message_card(state["stream_buffer"], is_user=False))
484
- return upload_cards, chat_history_items, chat_cards, error, False, 0, chat_name_style, chat_cards, False
485
- return upload_cards, chat_history_items, chat_cards, error, (not state.get("streaming", False)), 0, chat_name_style, chat_cards, True
486
 
487
  @app_flask.after_request
488
  def set_session_cookie(resp):
 
98
  text = f.read()
99
  if not text.strip():
100
  continue
 
101
  chunk = text[:4000]
102
  response = openai.Embedding.create(
103
  input=[chunk],
 
238
  Output("stream-interval", "disabled"),
239
  Output("stream-interval", "n_intervals"),
240
  Output("chat-name-input", "style"),
 
 
241
  Input("session-id", "data"),
242
  Input("send-btn", "n_clicks"),
243
  Input("file-upload", "contents"),
 
363
  "",
364
  not state.get("streaming", False),
365
  0,
366
+ show_chat_name
 
 
367
  )
368
  # If input box is visible and has a value, save chat history
369
  else:
 
398
  error,
399
  not state.get("streaming", False),
400
  0,
401
+ show_chat_name
 
 
402
  )
403
 
404
  # Handle polling for streaming
 
426
  "",
427
  False,
428
  stream_n+1,
429
+ chat_name_style
 
 
430
  )
431
  else:
432
  chat_cards = []
 
448
  "",
449
  True,
450
  0,
451
+ chat_name_style
 
 
452
  )
453
 
454
  # Default: Build Uploads, Chat History and Chat Window
 
470
  if state.get("streaming", False):
471
  if state.get("stream_buffer", ""):
472
  chat_cards.append(chat_message_card(state["stream_buffer"], is_user=False))
473
+ return upload_cards, chat_history_items, chat_cards, error, False, 0, chat_name_style
474
+ return upload_cards, chat_history_items, chat_cards, error, (not state.get("streaming", False)), 0, chat_name_style
475
 
476
  @app_flask.after_request
477
  def set_session_cookie(resp):