This commit is contained in:
parent
d4823afc81
commit
08e5939764
25
meta_ui.py
25
meta_ui.py
|
|
@ -149,7 +149,7 @@ def chat(
|
|||
# threading.Thread(target=worker).start()
|
||||
thread = threading.Thread(target=worker, daemon=True)
|
||||
thread.start()
|
||||
yield "⏳ 正在生成中...", log_state
|
||||
# yield "⏳ 正在生成中...", log_state
|
||||
|
||||
|
||||
while True:
|
||||
|
|
@ -169,24 +169,15 @@ def chat(
|
|||
elif not isinstance(result, dict) or "text" not in result:
|
||||
result = {"text": str(result)}
|
||||
|
||||
yield result, log_state # 第一次真正把模型回复丢给前端
|
||||
# yield result, log_state # 第一次真正把模型回复丢给前端
|
||||
if api_suffix == "/v1/chat/completions":
|
||||
history.append({"role": "assistant", "content": result["text"]})
|
||||
yield result["text"], history
|
||||
else:
|
||||
yield result["text"], log_state
|
||||
|
||||
return # ← 把旧的 break 换成 return
|
||||
|
||||
# while True:
|
||||
# try:
|
||||
# result = result_q.get(timeout=0.1)
|
||||
# # ★ 不论 /generate(纯 str)还是 /v1/completions(dict),都转成 {"text": ...}
|
||||
# if isinstance(result, str):
|
||||
# result = {"text": result}
|
||||
# elif not isinstance(result, dict) or "text" not in result:
|
||||
# result = {"text": str(result)}
|
||||
|
||||
# yield result, log_state
|
||||
# break
|
||||
# except Empty:
|
||||
# continue
|
||||
|
||||
|
||||
# ────────────────── Gradio UI ──────────────────
|
||||
with gr.Blocks(title="调试界面") as demo:
|
||||
gr.Markdown(f"## 💬 调试界面 \n权重 **{MODEL_PATH.name}**")
|
||||
|
|
|
|||
Loading…
Reference in New Issue