Update app.py
Browse files
app.py
CHANGED
|
@@ -13,7 +13,7 @@ pipe = pipeline("text-generation", model=model, tokenizer=tokenizer)
|
|
| 13 |
|
| 14 |
def respond(message, history):
|
| 15 |
# 將當前訊息與歷史訊息合併
|
| 16 |
-
|
| 17 |
input_text = message
|
| 18 |
# 獲取模型的回應
|
| 19 |
response = pipe(input_text, max_length=500, truncation=True, num_return_sequences=1)
|
|
@@ -25,7 +25,7 @@ def respond(message, history):
|
|
| 25 |
return reply
|
| 26 |
|
| 27 |
# 設定 Gradio 的聊天界面
|
| 28 |
-
demo = gr.ChatInterface(fn=respond, title="Chat with Qwen(通義千問) 2.5-0.5B", description="與
|
| 29 |
|
| 30 |
if __name__ == "__main__":
|
| 31 |
demo.launch()
|
|
|
|
| 13 |
|
| 14 |
def respond(message, history):
|
| 15 |
# 將當前訊息與歷史訊息合併
|
| 16 |
+
input_text = message if not history else history[-1]["content"] + " " + message
|
| 17 |
input_text = message
|
| 18 |
# 獲取模型的回應
|
| 19 |
response = pipe(input_text, max_length=500, truncation=True, num_return_sequences=1)
|
|
|
|
| 25 |
return reply
|
| 26 |
|
| 27 |
# 設定 Gradio 的聊天界面
|
| 28 |
+
demo = gr.ChatInterface(fn=respond, title="Chat with Qwen(通義千問) 2.5-0.5B", description="與 Qwen2.5-0.5B-Instruct-openvino 聊天!", type='messages')
|
| 29 |
|
| 30 |
if __name__ == "__main__":
|
| 31 |
demo.launch()
|