Spaces:
Runtime error
Runtime error
peter.lin commited on
Commit ·
82ed472
1
Parent(s): 5bd3b89
feat: :sparkles: rearrage the layout of qa
Browse files- webui/qa.py +13 -8
webui/qa.py
CHANGED
|
@@ -37,11 +37,22 @@ def recreate(instruction):
|
|
| 37 |
task = QaTask(instruction=instruction, knowledge=load_vectorstore("example").as_retriever())
|
| 38 |
|
| 39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
with gr.Blocks() as qa_ui:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
with gr.Row():
|
| 42 |
with gr.Column(scale=6):
|
| 43 |
with gr.Row():
|
| 44 |
-
chatbot = gr.Chatbot(height=
|
| 45 |
with gr.Row():
|
| 46 |
msg = gr.Textbox()
|
| 47 |
with gr.Column(scale=1):
|
|
@@ -51,13 +62,7 @@ with gr.Blocks() as qa_ui:
|
|
| 51 |
telemetry = gr.JSON(value="""{"tokens":0}""", label="Telemetry")
|
| 52 |
with gr.Row():
|
| 53 |
docs = gr.JSON(value="""["docs"]""", label="Docs")
|
| 54 |
-
with gr.Row():
|
| 55 |
-
clear = gr.ClearButton([msg, chatbot, session_id, telemetry, docs])
|
| 56 |
-
with gr.Row():
|
| 57 |
-
with gr.Column(scale=6):
|
| 58 |
-
instruction = gr.Textbox(label="Instruction", value=DEFAULT_INSTRUCTION, interactive=False)
|
| 59 |
-
with gr.Column(scale=1):
|
| 60 |
-
apply = gr.Button(value="更换Prompt")
|
| 61 |
|
|
|
|
| 62 |
msg.submit(respond, [msg, chatbot, session_id], [msg, chatbot, session_id, telemetry, docs])
|
| 63 |
apply.click(recreate, [instruction], [])
|
|
|
|
| 37 |
task = QaTask(instruction=instruction, knowledge=load_vectorstore("example").as_retriever())
|
| 38 |
|
| 39 |
|
| 40 |
+
def clear(msg, chatbot, session_id, telemetry, docs):
|
| 41 |
+
return "", "", '', '{"tokens":0}', '["docs"]'
|
| 42 |
+
|
| 43 |
+
|
| 44 |
with gr.Blocks() as qa_ui:
|
| 45 |
+
with gr.Row():
|
| 46 |
+
with gr.Column(scale=6):
|
| 47 |
+
instruction = gr.Textbox(label="Instruction", value=DEFAULT_INSTRUCTION, interactive=False)
|
| 48 |
+
with gr.Column(scale=1):
|
| 49 |
+
apply = gr.Button(value="更换Prompt")
|
| 50 |
+
clear_btn = gr.Button(value="清空")
|
| 51 |
+
|
| 52 |
with gr.Row():
|
| 53 |
with gr.Column(scale=6):
|
| 54 |
with gr.Row():
|
| 55 |
+
chatbot = gr.Chatbot(height=400)
|
| 56 |
with gr.Row():
|
| 57 |
msg = gr.Textbox()
|
| 58 |
with gr.Column(scale=1):
|
|
|
|
| 62 |
telemetry = gr.JSON(value="""{"tokens":0}""", label="Telemetry")
|
| 63 |
with gr.Row():
|
| 64 |
docs = gr.JSON(value="""["docs"]""", label="Docs")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
|
| 66 |
+
clear_btn.click(clear, [msg, chatbot, session_id, telemetry, docs], [msg, chatbot, session_id, telemetry, docs])
|
| 67 |
msg.submit(respond, [msg, chatbot, session_id], [msg, chatbot, session_id, telemetry, docs])
|
| 68 |
apply.click(recreate, [instruction], [])
|