Update app.py
Browse files
app.py
CHANGED
|
@@ -5,7 +5,6 @@ import asyncio
|
|
| 5 |
import json
|
| 6 |
from datasets import Dataset, DatasetDict, load_dataset, load_from_disk
|
| 7 |
from huggingface_hub import HfApi, HfFolder
|
| 8 |
-
from functools import lru_cache
|
| 9 |
|
| 10 |
# 定義 CSS 樣式
|
| 11 |
custom_css = """
|
|
@@ -96,7 +95,6 @@ except:
|
|
| 96 |
})
|
| 97 |
})
|
| 98 |
|
| 99 |
-
@lru_cache(maxsize=32)
|
| 100 |
async def send_chat_message(user_input):
|
| 101 |
payload = {
|
| 102 |
"inputs": {},
|
|
@@ -216,7 +214,6 @@ with gr.Blocks(css=custom_css) as iface:
|
|
| 216 |
gr.Examples(examples=examples, inputs=user_input)
|
| 217 |
|
| 218 |
with gr.Row():
|
| 219 |
-
# like_button = gr.Button("👍 覺得答案很棒,請按我;或者直接繼續問新問題亦可", elem_id="like_button")
|
| 220 |
dislike_button = gr.Button("👎 覺得答案待改善,請輸入改進建議,再按我送出保存", elem_id="dislike_button")
|
| 221 |
improvement_input = gr.Textbox(label='請輸入改進建議', placeholder='請輸入如何改進模型回應的建議', elem_id="improvement_input")
|
| 222 |
|
|
@@ -233,12 +230,6 @@ with gr.Blocks(css=custom_css) as iface:
|
|
| 233 |
|
| 234 |
submit_button.click(fn=chat, inputs=[user_input, chatbot], outputs=[chatbot, chatbot])
|
| 235 |
|
| 236 |
-
# like_button.click(
|
| 237 |
-
# fn=lambda response, improvement: handle_feedback(response, "like", improvement),
|
| 238 |
-
# inputs=[chatbot, improvement_input],
|
| 239 |
-
# outputs=feedback_output
|
| 240 |
-
# )
|
| 241 |
-
|
| 242 |
dislike_button.click(
|
| 243 |
fn=lambda response, improvement: handle_feedback(response, "dislike", improvement),
|
| 244 |
inputs=[chatbot, improvement_input],
|
|
@@ -247,4 +238,4 @@ with gr.Blocks(css=custom_css) as iface:
|
|
| 247 |
|
| 248 |
show_feedback_button.click(fn=show_feedback, outputs=feedback_display)
|
| 249 |
|
| 250 |
-
iface.launch()
|
|
|
|
| 5 |
import json
|
| 6 |
from datasets import Dataset, DatasetDict, load_dataset, load_from_disk
|
| 7 |
from huggingface_hub import HfApi, HfFolder
|
|
|
|
| 8 |
|
| 9 |
# 定義 CSS 樣式
|
| 10 |
custom_css = """
|
|
|
|
| 95 |
})
|
| 96 |
})
|
| 97 |
|
|
|
|
| 98 |
async def send_chat_message(user_input):
|
| 99 |
payload = {
|
| 100 |
"inputs": {},
|
|
|
|
| 214 |
gr.Examples(examples=examples, inputs=user_input)
|
| 215 |
|
| 216 |
with gr.Row():
|
|
|
|
| 217 |
dislike_button = gr.Button("👎 覺得答案待改善,請輸入改進建議,再按我送出保存", elem_id="dislike_button")
|
| 218 |
improvement_input = gr.Textbox(label='請輸入改進建議', placeholder='請輸入如何改進模型回應的建議', elem_id="improvement_input")
|
| 219 |
|
|
|
|
| 230 |
|
| 231 |
submit_button.click(fn=chat, inputs=[user_input, chatbot], outputs=[chatbot, chatbot])
|
| 232 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 233 |
dislike_button.click(
|
| 234 |
fn=lambda response, improvement: handle_feedback(response, "dislike", improvement),
|
| 235 |
inputs=[chatbot, improvement_input],
|
|
|
|
| 238 |
|
| 239 |
show_feedback_button.click(fn=show_feedback, outputs=feedback_display)
|
| 240 |
|
| 241 |
+
iface.launch()
|