Update app.py
Browse files
app.py
CHANGED
@@ -135,15 +135,16 @@ def upload_attachment(cookie ,organization_id,file_path):
|
|
135 |
|
136 |
|
137 |
|
138 |
-
def request_to_v2(message, cookie, user_id,attachment=None,context=[]):
|
139 |
context = [message]
|
140 |
|
141 |
|
142 |
## 是否加入文件
|
143 |
# Upload attachment if provided
|
144 |
-
|
145 |
attachments = []
|
146 |
if attachment:
|
|
|
147 |
attachment_response = upload_attachment(cookie,user_id,attachment)
|
148 |
if attachment_response:
|
149 |
attachments = [attachment_response]
|
@@ -241,12 +242,13 @@ def request_to_v2(message, cookie, user_id,attachment=None,context=[]):
|
|
241 |
return responses, context
|
242 |
|
243 |
finally:
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
|
|
250 |
|
251 |
print("*-"*100)
|
252 |
|
@@ -278,6 +280,7 @@ with gr.Blocks() as dialog_app:
|
|
278 |
cookies = gr.Textbox(lines=2, label="输入cookies")
|
279 |
user_id = gr.Textbox(lines=2, label="输入user_id/organization_uuid")
|
280 |
file = gr.File(label='请上传知识库文件, 目前支持txt、csv、pdf格式',file_types=['.txt', '.csv', '.pdf'])
|
|
|
281 |
# channel_id = gr.Textbox(lines=2, label="输入channel_id/conversation_uuid")
|
282 |
# chatbot = gr.Chatbot()
|
283 |
with gr.Column(scale=0.6):
|
@@ -290,9 +293,9 @@ with gr.Blocks() as dialog_app:
|
|
290 |
label="输入问题",
|
291 |
placeholder="请输入你的文本,确保已经正确填入cookies、user_id"
|
292 |
)
|
293 |
-
inputs.submit(request_to_v2, [inputs, cookies, user_id,file,state], [chatbot, state])
|
294 |
send = gr.Button("发送请求.....")
|
295 |
-
send.click(request_to_v2, [inputs, cookies, user_id,file,state], [chatbot, state], api_name="xiaolvgpt", show_progress=True)
|
296 |
|
297 |
|
298 |
gr.Markdown("""
|
|
|
135 |
|
136 |
|
137 |
|
138 |
+
def request_to_v2(message, cookie, user_id,attachment=None,delst=True,context=[]):
|
139 |
context = [message]
|
140 |
|
141 |
|
142 |
## 是否加入文件
|
143 |
# Upload attachment if provided
|
144 |
+
|
145 |
attachments = []
|
146 |
if attachment:
|
147 |
+
attachment = attachment.name
|
148 |
attachment_response = upload_attachment(cookie,user_id,attachment)
|
149 |
if attachment_response:
|
150 |
attachments = [attachment_response]
|
|
|
242 |
return responses, context
|
243 |
|
244 |
finally:
|
245 |
+
if delst:
|
246 |
+
time.sleep(random.uniform(1,2))
|
247 |
+
ds = delete_conversation(user_id,channel_id,cookie)
|
248 |
+
if ds:
|
249 |
+
print(f"成功删除")
|
250 |
+
else:
|
251 |
+
print(f"删除失败")
|
252 |
|
253 |
print("*-"*100)
|
254 |
|
|
|
280 |
cookies = gr.Textbox(lines=2, label="输入cookies")
|
281 |
user_id = gr.Textbox(lines=2, label="输入user_id/organization_uuid")
|
282 |
file = gr.File(label='请上传知识库文件, 目前支持txt、csv、pdf格式',file_types=['.txt', '.csv', '.pdf'])
|
283 |
+
delst = gr.Checkbox(label="是", info="在该对话回复后,是否要删除该对话?",value = True)
|
284 |
# channel_id = gr.Textbox(lines=2, label="输入channel_id/conversation_uuid")
|
285 |
# chatbot = gr.Chatbot()
|
286 |
with gr.Column(scale=0.6):
|
|
|
293 |
label="输入问题",
|
294 |
placeholder="请输入你的文本,确保已经正确填入cookies、user_id"
|
295 |
)
|
296 |
+
inputs.submit(request_to_v2, [inputs, cookies, user_id,file,delst,state], [chatbot, state])
|
297 |
send = gr.Button("发送请求.....")
|
298 |
+
send.click(request_to_v2, [inputs, cookies, user_id,file,delst,state], [chatbot, state], api_name="xiaolvgpt", show_progress=True)
|
299 |
|
300 |
|
301 |
gr.Markdown("""
|