InnovisionLLC commited on
Commit
3d3d911
·
1 Parent(s): 84a6f8a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -63
app.py CHANGED
@@ -500,7 +500,7 @@ class DeKCIBChatEngine:
500
 
501
 
502
  print(f"Initializing memory for conversation {conversation_id}")
503
- print(self.chat_store)
504
 
505
  self.memory = ChatMemoryBuffer.from_defaults(
506
  token_limit=3000,
@@ -876,12 +876,7 @@ class ChatbotUI:
876
  value=next(iter(self.vector_stores.keys()), None)
877
 
878
  )
879
- with gr.Column(scale=1):
880
- status_indicator = gr.HTML(
881
- value='<div style="text-align:center; padding:8px; border-radius:4px; background-color:#f0f0f0; margin-top:18px;">✓ Ready</div>',
882
- elem_id="status_indicator"
883
- )
884
-
885
  # Main content with sidebar and chat area
886
  with gr.Row():
887
  # Left sidebar for conversation history
@@ -911,10 +906,7 @@ class ChatbotUI:
911
  )
912
 
913
  with gr.Row():
914
- msg = gr.Textbox(label="Query", scale=5)
915
- clear_btn = gr.Button("Clear Session", scale=1)
916
-
917
-
918
 
919
 
920
  def get_auth_id(oauth_token: gr.OAuthToken | None) -> str:
@@ -1129,6 +1121,12 @@ class ChatbotUI:
1129
  yield llm_name, vector_store_name, update_conversation_history, chat_history
1130
 
1131
 
 
 
 
 
 
 
1132
  demo.load(
1133
  get_auth_id,
1134
  inputs=None,
@@ -1137,6 +1135,10 @@ class ChatbotUI:
1137
  create_session,
1138
  [user_id],
1139
  [llm_dropdown, vector_dropdown, conversation_history, chatbot]
 
 
 
 
1140
  )
1141
 
1142
 
@@ -1281,58 +1283,6 @@ class ChatbotUI:
1281
  [conversation_history, chatbot]
1282
  )
1283
 
1284
-
1285
- # def clear_chatbot(user_id):
1286
- # print("user_id")
1287
- # return []
1288
-
1289
- # user_id_dropdown.change(
1290
- # clear_chatbot,
1291
- # [user_id_dropdown],
1292
- # [chatbot]
1293
- # )
1294
-
1295
- # # Load selected conversation from Dataset click
1296
- # # def load_clicked_conversation(evt: gr.SelectData, user_id, session_state):
1297
- # # if not user_id or not evt.index:
1298
- # # return [], session_state
1299
-
1300
- # # # Get all conversations for this user
1301
- # # conversations = get_user_conversations(user_id)
1302
-
1303
- # # # Check if we have enough conversations
1304
- # # if not conversations or evt.index >= len(conversations):
1305
- # # return [], session_state
1306
-
1307
- # # # Get the clicked conversation ID
1308
- # # selected_conv_id = conversations[evt.index][0] # Get the conversation ID from the tuple
1309
-
1310
- # # # Load the conversation
1311
- # # chat_store, chat_history = load_conversation(user_id, selected_conv_id)
1312
-
1313
- # # if chat_store:
1314
- # # # Update session state with loaded conversation
1315
- # # if not session_state:
1316
- # # session_state = {}
1317
-
1318
- # # session_state["user_id"] = user_id
1319
- # # session_state["session_id"] = user_id
1320
- # # session_state["conversation_id"] = selected_conv_id
1321
- # # session_state["chat_store"] = chat_store
1322
- # # session_state["total_score"] = 0.0
1323
- # # session_state["answer_count"] = 0
1324
-
1325
- # # return chat_history, session_state
1326
- # # else:
1327
- # # return [], session_state
1328
-
1329
- # # Setup conversation history click handler
1330
- # conversation_history.select(
1331
- # load_clicked_conversation,
1332
- # [user_id_dropdown, session_state],
1333
- # [chatbot, session_state]
1334
- # )
1335
-
1336
  # Create new conversation button should only clear the chat area, but not create a new conversation yet
1337
  def prepare_new_chat():
1338
  print("prepare_new_chat")
 
500
 
501
 
502
  print(f"Initializing memory for conversation {conversation_id}")
503
+
504
 
505
  self.memory = ChatMemoryBuffer.from_defaults(
506
  token_limit=3000,
 
876
  value=next(iter(self.vector_stores.keys()), None)
877
 
878
  )
879
+
 
 
 
 
 
880
  # Main content with sidebar and chat area
881
  with gr.Row():
882
  # Left sidebar for conversation history
 
906
  )
907
 
908
  with gr.Row():
909
+ msg = gr.Textbox(label="Ask me anything", placeholder="Log in to start chatting", interactive=False)
 
 
 
910
 
911
 
912
  def get_auth_id(oauth_token: gr.OAuthToken | None) -> str:
 
1121
  yield llm_name, vector_store_name, update_conversation_history, chat_history
1122
 
1123
 
1124
+ def activate_chat(user_id):
1125
+ if user_id is None:
1126
+ return gr.update(placeholder="Log in to start chatting", interactive=False)
1127
+ return gr.update(placeholder="",interactive=True)
1128
+
1129
+
1130
  demo.load(
1131
  get_auth_id,
1132
  inputs=None,
 
1135
  create_session,
1136
  [user_id],
1137
  [llm_dropdown, vector_dropdown, conversation_history, chatbot]
1138
+ ).success(
1139
+ activate_chat,
1140
+ [user_id],
1141
+ [msg]
1142
  )
1143
 
1144
 
 
1283
  [conversation_history, chatbot]
1284
  )
1285
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1286
  # Create new conversation button should only clear the chat area, but not create a new conversation yet
1287
  def prepare_new_chat():
1288
  print("prepare_new_chat")