rwitz commited on
Commit
0668dc0
·
verified ·
1 Parent(s): 139fbcc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -7
app.py CHANGED
@@ -13,14 +13,14 @@ import sqlite3
13
 
14
  from pymongo.mongo_client import MongoClient
15
  from pymongo.server_api import ServerApi
16
- async def direct_regenerate(model, user_input, chatbot):
17
  adapter = next(entry['adapter'] for entry in chatbots_data if entry['original_model'] == model)
18
  temp_state = {
19
  "history": [
20
  [{"role": "user", "content": chatbot[-1][0]}] # Keep the user's last message
21
  ]
22
  }
23
- response = await get_bot_response(adapter, user_input, temp_state, 0)
24
  chatbot[-1] = (chatbot[-1][0], response) # Update only the assistant's response
25
  return "", chatbot
26
  password=os.environ.get("MONGODB")
@@ -242,7 +242,7 @@ def generate_leaderboard(collection):
242
  def refresh_leaderboard():
243
  collection = init_database()
244
  return generate_leaderboard(collection)
245
- async def direct_chat(model, user_input, chatbot):
246
  adapter = next(entry['adapter'] for entry in chatbots_data if entry['original_model'] == model)
247
  temp_state = {
248
  "history": [
@@ -250,7 +250,7 @@ async def direct_chat(model, user_input, chatbot):
250
  [{"role": "user", "content": user_input}]
251
  ]
252
  }
253
- response = await get_bot_response(adapter, user_input, temp_state, 0)
254
  chatbot.append((user_input, response))
255
  return "", chatbot
256
  def reset_direct_chat():
@@ -315,9 +315,8 @@ with gr.Blocks() as demo:
315
 
316
  # ...
317
 
318
- direct_regenerate_btn.click(direct_regenerate, inputs=[model_dropdown, direct_textbox, direct_chatbot], outputs=[direct_textbox, direct_chatbot])
319
- direct_textbox.submit(direct_chat, inputs=[model_dropdown, direct_textbox, direct_chatbot], outputs=[direct_textbox, direct_chatbot])
320
- direct_submit_btn.click(direct_chat, inputs=[model_dropdown, direct_textbox, direct_chatbot], outputs=[direct_textbox, direct_chatbot])
321
  direct_reset_btn.click(reset_direct_chat, None, [direct_textbox, direct_chatbot, model_dropdown])
322
 
323
 
 
13
 
14
  from pymongo.mongo_client import MongoClient
15
  from pymongo.server_api import ServerApi
16
+ async def direct_regenerate(model, user_input, chatbot, character_name, character_description, user_name):
17
  adapter = next(entry['adapter'] for entry in chatbots_data if entry['original_model'] == model)
18
  temp_state = {
19
  "history": [
20
  [{"role": "user", "content": chatbot[-1][0]}] # Keep the user's last message
21
  ]
22
  }
23
+ response = await get_bot_response(adapter, user_input, temp_state, 0, character_name, character_description, user_name)
24
  chatbot[-1] = (chatbot[-1][0], response) # Update only the assistant's response
25
  return "", chatbot
26
  password=os.environ.get("MONGODB")
 
242
  def refresh_leaderboard():
243
  collection = init_database()
244
  return generate_leaderboard(collection)
245
+ async def direct_chat(model, user_input, chatbot, character_name, character_description, user_name):
246
  adapter = next(entry['adapter'] for entry in chatbots_data if entry['original_model'] == model)
247
  temp_state = {
248
  "history": [
 
250
  [{"role": "user", "content": user_input}]
251
  ]
252
  }
253
+ response = await get_bot_response(adapter, user_input, temp_state, 0, character_name, character_description, user_name)
254
  chatbot.append((user_input, response))
255
  return "", chatbot
256
  def reset_direct_chat():
 
315
 
316
  # ...
317
 
318
+ direct_regenerate_btn.click(direct_regenerate, inputs=[model_dropdown, direct_textbox, direct_chatbot, character_name, character_description, user_name], outputs=[direct_textbox, direct_chatbot]) direct_textbox.submit(direct_chat, inputs=[model_dropdown, direct_textbox, direct_chatbot, character_name, character_description, user_name], outputs=[direct_textbox, direct_chatbot])
319
+ direct_submit_btn.click(direct_chat, inputs=[model_dropdown, direct_textbox, direct_chatbot, character_name, character_description, user_name], outputs=[direct_textbox, direct_chatbot])
 
320
  direct_reset_btn.click(reset_direct_chat, None, [direct_textbox, direct_chatbot, model_dropdown])
321
 
322