hsuwill000 commited on
Commit
2ab439f
Β·
verified Β·
1 Parent(s): 2f6898e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -4
app.py CHANGED
@@ -22,16 +22,20 @@ def generate_response(prompt):
22
  try:
23
  generated = pipe.generate([prompt], max_length=1024)
24
  tokenpersec=f'{generated.perf_metrics.get_throughput().mean:.2f}'
 
25
  match = re.search(r"<think>(.*?)</think>(.*)", generated, re.DOTALL)
26
-
 
27
  if match:
28
  thinking = match.group(1).strip()
29
  content = match.group(2).strip()
30
  else:
31
  thinking = "ζ¨‘εž‹ζ²’ζœ‰ζδΎ›ζ€θ€ƒιŽη¨‹"
32
  content = generated # ζˆ–θ€… generated.text, 取決於 generated η‰©δ»Άηš„ε±¬ζ€§
33
-
34
  return tokenpersec, thinking, content
 
 
35
  except Exception as e:
36
  return "η™Όη”ŸιŒ―θͺ€", "η™Όη”ŸιŒ―θͺ€", f"η”Ÿζˆε›žζ‡‰ζ™‚η™Όη”ŸιŒ―θͺ€οΌš{e}"
37
 
@@ -42,8 +46,9 @@ demo = gr.Interface(
42
  inputs=gr.Textbox(lines=5, label="θΌΈε…₯提瀺 (Prompt)"),
43
  outputs=[
44
  gr.Textbox(label="tokens/sec"),
45
- gr.Textbox(label="ζ€θ€ƒιŽη¨‹"),
46
- gr.Textbox(label="ζœ€η΅‚ε›žζ‡‰")
 
47
  ],
48
  title="Qwen3-0.6B-int4-ov ",
49
  description="εŸΊζ–Ό Qwen3-0.6B-int4-ov ζŽ¨η†ζ‡‰η”¨οΌŒζ”―ζ΄ζ€θ€ƒιŽη¨‹εˆ†ι›’θˆ‡ GUI。"
 
22
  try:
23
  generated = pipe.generate([prompt], max_length=1024)
24
  tokenpersec=f'{generated.perf_metrics.get_throughput().mean:.2f}'
25
+ '''
26
  match = re.search(r"<think>(.*?)</think>(.*)", generated, re.DOTALL)
27
+ thinking = ""
28
+ content = ""
29
  if match:
30
  thinking = match.group(1).strip()
31
  content = match.group(2).strip()
32
  else:
33
  thinking = "ζ¨‘εž‹ζ²’ζœ‰ζδΎ›ζ€θ€ƒιŽη¨‹"
34
  content = generated # ζˆ–θ€… generated.text, 取決於 generated η‰©δ»Άηš„ε±¬ζ€§
35
+
36
  return tokenpersec, thinking, content
37
+ '''
38
+ return tokenpersec, generated
39
  except Exception as e:
40
  return "η™Όη”ŸιŒ―θͺ€", "η™Όη”ŸιŒ―θͺ€", f"η”Ÿζˆε›žζ‡‰ζ™‚η™Όη”ŸιŒ―θͺ€οΌš{e}"
41
 
 
46
  inputs=gr.Textbox(lines=5, label="θΌΈε…₯提瀺 (Prompt)"),
47
  outputs=[
48
  gr.Textbox(label="tokens/sec"),
49
+ #gr.Textbox(label="ζ€θ€ƒιŽη¨‹"),
50
+ #gr.Textbox(label="ζœ€η΅‚ε›žζ‡‰")
51
+ gr.Textbox(label="ε›žζ‡‰")
52
  ],
53
  title="Qwen3-0.6B-int4-ov ",
54
  description="εŸΊζ–Ό Qwen3-0.6B-int4-ov ζŽ¨η†ζ‡‰η”¨οΌŒζ”―ζ΄ζ€θ€ƒιŽη¨‹εˆ†ι›’θˆ‡ GUI。"