cosco commited on
Commit
2930d96
·
verified ·
1 Parent(s): 7f6079a

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -13
app.py CHANGED
@@ -63,8 +63,8 @@ class Model_center:
63
  self,
64
  question: str,
65
  chat_history: list = [],
66
- model: str = "zhipuai",
67
- embedding: str = "zhipuai",
68
  temperature: float = 0.0,
69
  top_k: int = 4,
70
  history_len: int = 3,
@@ -98,8 +98,8 @@ class Model_center:
98
  self,
99
  question: str,
100
  chat_history: list = [],
101
- model: str = "zhipuai",
102
- embedding="zhipuai",
103
  temperature: float = 0.0,
104
  top_k: int = 4,
105
  file_path: str = DEFAULT_DB_PATH,
@@ -218,8 +218,8 @@ with block as demo:
218
 
219
  with gr.Row():
220
  # 创建提交按钮。
221
- # db_with_his_btn = gr.Button("Chat db with history")
222
- # db_wo_his_btn = gr.Button("Chat db without history")
223
  llm_btn = gr.Button("Chat with llm")
224
  with gr.Row():
225
  # 创建一个清除按钮,用于清除聊天机器人组件的内容。
@@ -275,13 +275,18 @@ with block as demo:
275
  # 设置初始化向量数据库按钮的点击事件。当点击时,调用 create_db_info 函数,并传入用户的文件和希望使用的 Embedding 模型。
276
  init_db.click(create_db_info, inputs=[file, embeddings], outputs=[msg])
277
 
278
- # # 设置按钮的点击事件。当点击时,调用上面定义的 chat_qa_chain_self_answer 函数,并传入用户的消息和聊天历史记录,然后更新文本框和聊天机器人组件。
279
- # db_with_his_btn.click(model_center.chat_qa_chain_self_answer, inputs=[
280
- # msg, chatbot, llm, embeddings, temperature, top_k, history_len],
281
- # outputs=[msg, chatbot])
282
- # # 设置按钮的点击事件。当点击时,调用上面定义的 qa_chain_self_answer 函数,并传入用户的消息和聊天历史记录,然后更新文本框和聊天机器人组件。
283
- # db_wo_his_btn.click(model_center.qa_chain_self_answer, inputs=[
284
- # msg, chatbot, llm, embeddings, temperature, top_k], outputs=[msg, chatbot])
 
 
 
 
 
285
  # 设置按钮的点击事件。当点击时,调用上面定义的 respond 函数,并传入用户的消息和聊天历史记录,然后更新文本框和聊天机器人组件。
286
  llm_btn.click(
287
  respond,
 
63
  self,
64
  question: str,
65
  chat_history: list = [],
66
+ model: str = "glm-4",
67
+ embedding: str = "embedding-2",
68
  temperature: float = 0.0,
69
  top_k: int = 4,
70
  history_len: int = 3,
 
98
  self,
99
  question: str,
100
  chat_history: list = [],
101
+ model: str = "glm-4",
102
+ embedding="embedding-2",
103
  temperature: float = 0.0,
104
  top_k: int = 4,
105
  file_path: str = DEFAULT_DB_PATH,
 
218
 
219
  with gr.Row():
220
  # 创建提交按钮。
221
+ db_with_his_btn = gr.Button("Chat db with history")
222
+ db_wo_his_btn = gr.Button("Chat db without history")
223
  llm_btn = gr.Button("Chat with llm")
224
  with gr.Row():
225
  # 创建一个清除按钮,用于清除聊天机器人组件的内容。
 
275
  # 设置初始化向量数据库按钮的点击事件。当点击时,调用 create_db_info 函数,并传入用户的文件和希望使用的 Embedding 模型。
276
  init_db.click(create_db_info, inputs=[file, embeddings], outputs=[msg])
277
 
278
+ # 设置按钮的点击事件。当点击时,调用上面定义的 chat_qa_chain_self_answer 函数,并传入用户的消息和聊天历史记录,然后更新文本框和聊天机器人组件。
279
+ db_with_his_btn.click(
280
+ model_center.chat_qa_chain_self_answer,
281
+ inputs=[msg, chatbot, llm, embeddings, temperature, top_k, history_len],
282
+ outputs=[msg, chatbot],
283
+ )
284
+ # 设置按钮的点击事件。当点击时,调用上面定义的 qa_chain_self_answer 函数,并传入用户的消息和聊天历史记录,然后更新文本框和聊天机器人组件。
285
+ db_wo_his_btn.click(
286
+ model_center.qa_chain_self_answer,
287
+ inputs=[msg, chatbot, llm, embeddings, temperature, top_k],
288
+ outputs=[msg, chatbot],
289
+ )
290
  # 设置按钮的点击事件。当点击时,调用上面定义的 respond 函数,并传入用户的消息和聊天历史记录,然后更新文本框和聊天机器人组件。
291
  llm_btn.click(
292
  respond,