This commit is contained in:
parent
f904c754e2
commit
095311d016
|
|
@ -121,8 +121,12 @@ def chat(
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
result = result_q.get(timeout=0.1)
|
result = result_q.get(timeout=0.1)
|
||||||
|
# ★ 不论 /generate(纯 str)还是 /v1/chat/completions(dict),都转成 {"text": ...}
|
||||||
if isinstance(result, str):
|
if isinstance(result, str):
|
||||||
result = {"text": result}
|
result = {"text": result}
|
||||||
|
elif not isinstance(result, dict) or "text" not in result:
|
||||||
|
result = {"text": str(result)}
|
||||||
|
|
||||||
yield result, log_state
|
yield result, log_state
|
||||||
except Empty:
|
except Empty:
|
||||||
continue
|
continue
|
||||||
|
|
@ -155,7 +159,7 @@ with gr.Blocks(title="调试界面") as demo:
|
||||||
additional_inputs=[max_new, temp, top_p, top_k,
|
additional_inputs=[max_new, temp, top_p, top_k,
|
||||||
rep_pen, pres_pen, stop_txt,
|
rep_pen, pres_pen, stop_txt,
|
||||||
api_choice, log_state],
|
api_choice, log_state],
|
||||||
additional_outputs=[],
|
additional_outputs=[log_state],
|
||||||
type="messages"
|
type="messages"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue