-
Notifications
You must be signed in to change notification settings - Fork 366
Expand file tree
/
Copy pathdemo.py
More file actions
35 lines (26 loc) · 833 Bytes
/
demo.py
File metadata and controls
35 lines (26 loc) · 833 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from typing import Any
import torch
from .generate import init_history, generate_response
DEMO_PROMPTS = [
"Hello, who are you?",
"What is 2+2? Answer in one sentence.",
"Tell me a one-sentence joke.",
]
def run_demo(model: Any, processor: Any) -> None:
print("=== Demo mode: text-only smoke test ===\n")
for prompt in DEMO_PROMPTS:
history = init_history()
history.append(
{"role": "user", "content": [{"type": "text", "text": prompt}]},
)
with torch.no_grad():
text, _ = generate_response(
model,
processor,
history,
enable_audio=False,
speaker=None,
)
print(f"You: {prompt}")
print(f"Qwen: {text}\n")
print("=== Demo complete ===")