Spaces:
Running on Zero
Running on Zero
feat: Implement colored output for thinking tokens
Browse files29 unmodified lines3031323334353637383929 unmodified lines# Todolist## 未完成- [ ] (进行中) 实现调试模式以观察“思考”和“正文” token 的区别。- [ ] (已暂停) 搜索 `huggingface_hub` 文档,确认是否存在用于重启 Space 的 API。## 已完成- [x] 修改 `app.py`,移除 `Ling-flash-2.0` 模型,只保留 `Ring-mini-2.0`。- [x] **(用户决策)** 确认 `Ling-flash-2.0` 模型过大,暂时移除,仅使用 `Ring-mini-2.0`。- [x] 搭建 LangGraph 基础架构并重构 `app.py`。29 unmodified lines303132333435363738394029 unmodified lines# Todolist## 未完成- [ ] (进行中) 为“思考”和“正文” token 实现不同的颜色显示。- [ ] (已暂停) 搜索 `huggingface_hub` 文档,确认是否存在用于重启 Space 的 API。## 已完成- [x] 实现调试模式以观察“思考”和“正文” token 的区别。- [x] 修改 `app.py`,移除 `Ling-flash-2.0` 模型,只保留 `Ring-mini-2.0`。- [x] **(用户决策)** 确认 `Ling-flash-2.0` 模型过大,暂时移除,仅使用 `Ring-mini-2.0`。- [x] 搭建 LangGraph 基础架构并重构 `app.py`。
2 unmodified lines34567891011121314151 unmodified line17181920212223242526272829302 unmodified lines# --- Gradio UI ---with gr.Blocks() as demo:gr.Markdown("# Ling Playground")chatbot = gr.Chatbot()with gr.Row():msg = gr.Textbox()token_debugger = gr.Textbox(label="Token Debugger", interactive=False)clear = gr.ClearButton([msg, chatbot, token_debugger])def user(user_message, history):return "", history + [[user_message, None]]1 unmodified linedef bot(history):user_message = history[-1][0]history[-1][1] = ""raw_token_text = ""for response, new_text in generate_response(user_message, history[:-1]):history[-1][1] = responseraw_token_text += new_textyield history, raw_token_textmsg.submit(user, [msg, chatbot], [msg, chatbot], queue=False).then(bot, chatbot, [chatbot, token_debugger])clear.click(lambda: None, None, chatbot, queue=False)2 unmodified lines3456789101112131 unmodified line15161718192021222324252627282 unmodified lines# --- Gradio UI ---with gr.Blocks(css=".thinking { color: gray; font-style: italic; }") as demo:gr.Markdown("# Ling Playground")chatbot = gr.Chatbot()msg = gr.Textbox()clear = gr.ClearButton([msg, chatbot])def user(user_message, history):return "", history + [[user_message, None]]1 unmodified linedef bot(history):user_message = history[-1][0]history[-1][1] = ""for response in generate_response(user_message, history[:-1]):html_response = response.replace("<think>", "<div class='thinking'>")html_response = html_response.replace("</think>", "</div>")history[-1][1] = html_responseyield historymsg.submit(user, [msg, chatbot], [msg, chatbot], queue=False).then(bot, chatbot, chatbot)clear.click(lambda: None, None, chatbot, queue=False)
61 unmodified lines6263646566676861 unmodified linesresponse = ""for new_text in streamer:response += new_textyield response, new_text# wait for the generation thread to finishthread.join()61 unmodified lines6263646566676861 unmodified linesresponse = ""for new_text in streamer:response += new_textyield response# wait for the generation thread to finishthread.join()
GEMINI.md+2-1
app.py+9-11
comp.py+1-1