Spaces:
Runtime error
Runtime error
Update app.py
Browse files18 unmodified lines1920212223242526272829303132333435363738394041424344454647484950512 unmodified lines545556575859606118 unmodified lines)# =========================# CHAT FUNCTION (MODERN FORMAT)# =========================def chat(message, history):# convert Gradio "messages" format safelymessages = []for msg in history:if isinstance(msg, dict):messages.append(msg)messages.append({"role": "user", "content": message})output = llm.create_chat_completion(messages=messages,max_tokens=300,temperature=0.7)response = output["choices"][0]["message"]["content"]history.append({"role": "user", "content": message})history.append({"role": "assistant", "content": response})return "", history# =========================# GRADIO UI# =========================with gr.Blocks() as demo:gr.Markdown("# 🧠 Qwen GGUF AI (Living Legend Build)")2 unmodified linesmsg = gr.Textbox(label="Ask your AI")clear = gr.Button("Clear")msg.submit(chat, [msg, chatbot], [msg, chatbot])clear.click(lambda: [], None, chatbot, queue=False)# =========================18 unmodified lines192021222324252627282930313233343536373839404142434445462 unmodified lines4950515253545556575818 unmodified lines)# =========================# CHAT FUNCTION (GRADIO 4 STYLE)# =========================def chat(message, history):# history is list of dicts in Gradio 4history = history or []history.append({"role": "user", "content": message})output = llm.create_chat_completion(messages=history,max_tokens=300,temperature=0.7)response = output["choices"][0]["message"]["content"]history.append({"role": "assistant", "content": response})return "", history# =========================# GRADIO UI (GRADIO 4)# =========================with gr.Blocks() as demo:gr.Markdown("# 🧠 Qwen GGUF AI (Living Legend Build)")2 unmodified linesmsg = gr.Textbox(label="Ask your AI")clear = gr.Button("Clear")# send messagemsg.submit(chat, [msg, chatbot], [msg, chatbot])# clear chatclear.click(lambda: [], None, chatbot, queue=False)# =========================
app.py+8-11