Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -42,10 +42,19 @@ def respond(message, history, system_message, max_tokens, temperature, top_p):
|
|
42 |
)
|
43 |
|
44 |
output = ""
|
|
|
45 |
for chunk in stream:
|
46 |
print("[DEBUG] chunk:", chunk)
|
47 |
delta = chunk.choices[0].delta
|
48 |
if delta:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
# 安全取得 content
|
50 |
if delta.content:
|
51 |
output += delta.content
|
|
|
42 |
)
|
43 |
|
44 |
output = ""
|
45 |
+
first_chunk_processed = False
|
46 |
for chunk in stream:
|
47 |
print("[DEBUG] chunk:", chunk)
|
48 |
delta = chunk.choices[0].delta
|
49 |
if delta:
|
50 |
+
# 忽略第一次出現的特定內容
|
51 |
+
if not first_chunk_processed:
|
52 |
+
first_chunk_processed = True
|
53 |
+
# 檢查並跳過不需要的內容
|
54 |
+
if hasattr(delta, 'content') and delta.content:
|
55 |
+
if delta.content in ['<|channel|>', 'analysis']:
|
56 |
+
continue
|
57 |
+
|
58 |
# 安全取得 content
|
59 |
if delta.content:
|
60 |
output += delta.content
|