Update app.py
Browse files
app.py
CHANGED
@@ -11,10 +11,10 @@ tokenizer = AutoTokenizer.from_pretrained(model_id)
|
|
11 |
# 建立生成管道
|
12 |
pipe = pipeline("text-generation", model=model, tokenizer=tokenizer)
|
13 |
|
14 |
-
def respond(message
|
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)
|
20 |
reply = response[0]['generated_text']
|
@@ -22,7 +22,7 @@ def respond(message, history):
|
|
22 |
# 返回新的消息格式
|
23 |
print(reply)
|
24 |
return reply
|
25 |
-
|
26 |
# 設定 Gradio 的聊天界面
|
27 |
demo = gr.ChatInterface(fn=respond, title="Chat with Qwen(通義千問) 2.5-0.5B", description="與 HelloSun/Qwen2.5-0.5B-Instruct-openvino 聊天!", type='messages')
|
28 |
|
|
|
11 |
# 建立生成管道
|
12 |
pipe = pipeline("text-generation", model=model, tokenizer=tokenizer)
|
13 |
|
14 |
+
def respond(message):
|
15 |
+
# 直接使用當前訊息作為輸入
|
|
|
16 |
input_text = message
|
17 |
+
|
18 |
# 獲取模型的回應
|
19 |
response = pipe(input_text, max_length=500, truncation=True, num_return_sequences=1)
|
20 |
reply = response[0]['generated_text']
|
|
|
22 |
# 返回新的消息格式
|
23 |
print(reply)
|
24 |
return reply
|
25 |
+
|
26 |
# 設定 Gradio 的聊天界面
|
27 |
demo = gr.ChatInterface(fn=respond, title="Chat with Qwen(通義千問) 2.5-0.5B", description="與 HelloSun/Qwen2.5-0.5B-Instruct-openvino 聊天!", type='messages')
|
28 |
|