Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -54,21 +54,22 @@ def generate_response(user_input):
|
|
| 54 |
|
| 55 |
# εε»ΊGradioηι’
|
| 56 |
def chat_interface(user_input, history):
|
| 57 |
-
global chat_history
|
| 58 |
response = generate_response(user_input)
|
| 59 |
-
history.append(
|
|
|
|
| 60 |
return "", history
|
| 61 |
|
| 62 |
iface = gr.Blocks()
|
| 63 |
|
| 64 |
with iface:
|
| 65 |
gr.Markdown("# ι«ηεηε©ζ\nιζ―δΈεεΊζΌ MediaTek-Research/Breeze-7B-Instruct-v1_0 樑εηι«ηεηε©ζγ")
|
| 66 |
-
chatbot = gr.Chatbot()
|
| 67 |
with gr.Row():
|
| 68 |
txt = gr.Textbox(
|
| 69 |
show_label=False,
|
| 70 |
placeholder="θ«θΌΈε
₯δ½ ηει‘...",
|
| 71 |
-
|
|
|
|
| 72 |
txt.submit(chat_interface, [txt, chatbot], [txt, chatbot])
|
| 73 |
|
| 74 |
# ε―ε¨Gradioηι’εΉΆε
±δΊ«ιΎζ₯
|
|
|
|
| 54 |
|
| 55 |
# εε»ΊGradioηι’
|
| 56 |
def chat_interface(user_input, history):
|
|
|
|
| 57 |
response = generate_response(user_input)
|
| 58 |
+
history.append({"role": "user", "content": user_input})
|
| 59 |
+
history.append({"role": "assistant", "content": response})
|
| 60 |
return "", history
|
| 61 |
|
| 62 |
iface = gr.Blocks()
|
| 63 |
|
| 64 |
with iface:
|
| 65 |
gr.Markdown("# ι«ηεηε©ζ\nιζ―δΈεεΊζΌ MediaTek-Research/Breeze-7B-Instruct-v1_0 樑εηι«ηεηε©ζγ")
|
| 66 |
+
chatbot = gr.Chatbot(type="messages") # δ½Ώη¨OpenAIι£ζ Όηεε
Έζ ΌεΌ
|
| 67 |
with gr.Row():
|
| 68 |
txt = gr.Textbox(
|
| 69 |
show_label=False,
|
| 70 |
placeholder="θ«θΌΈε
₯δ½ ηει‘...",
|
| 71 |
+
lines=1,
|
| 72 |
+
)
|
| 73 |
txt.submit(chat_interface, [txt, chatbot], [txt, chatbot])
|
| 74 |
|
| 75 |
# ε―ε¨Gradioηι’εΉΆε
±δΊ«ιΎζ₯
|