Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -27,8 +27,8 @@ def respond(message, chat_history):
|
|
| 27 |
# Inject chat history so the bot remembers the conversation context
|
| 28 |
for turn in chat_history:
|
| 29 |
# Check if history is structured as objects or dicts (Gradio 6 style)
|
| 30 |
-
user_msg = turn.get("text") if isinstance(turn, dict) else turn
|
| 31 |
-
bot_msg = turn.get("text") if isinstance(turn, dict) else turn
|
| 32 |
|
| 33 |
if user_msg:
|
| 34 |
formatted_prompt += f"<|start_header_id|>user<|end_header_id|>\n{user_msg}<|eot_id|>"
|
|
@@ -52,14 +52,14 @@ def respond(message, chat_history):
|
|
| 52 |
token_accumulator += token_text
|
| 53 |
yield token_accumulator
|
| 54 |
|
| 55 |
-
# 4. Create the web dashboard layout using
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
)
|
| 63 |
|
| 64 |
if __name__ == "__main__":
|
| 65 |
demo.launch(server_name="0.0.0.0", server_port=7860)
|
|
|
|
| 27 |
# Inject chat history so the bot remembers the conversation context
|
| 28 |
for turn in chat_history:
|
| 29 |
# Check if history is structured as objects or dicts (Gradio 6 style)
|
| 30 |
+
user_msg = turn.get("text") if isinstance(turn, dict) else turn
|
| 31 |
+
bot_msg = turn.get("text") if isinstance(turn, dict) else turn
|
| 32 |
|
| 33 |
if user_msg:
|
| 34 |
formatted_prompt += f"<|start_header_id|>user<|end_header_id|>\n{user_msg}<|eot_id|>"
|
|
|
|
| 52 |
token_accumulator += token_text
|
| 53 |
yield token_accumulator
|
| 54 |
|
| 55 |
+
# 4. Create the web dashboard layout using a global theme block wrapper
|
| 56 |
+
with gr.Blocks(theme="soft") as demo:
|
| 57 |
+
gr.ChatInterface(
|
| 58 |
+
fn=respond,
|
| 59 |
+
title="🤖 Free Llama 3.2 CPU Chatbot",
|
| 60 |
+
description="Running 24/7/365 for free on Hugging Face Spaces using CPU inference.",
|
| 61 |
+
examples=["Explain quantum computing simply.", "Write a short poem about coding."]
|
| 62 |
+
)
|
| 63 |
|
| 64 |
if __name__ == "__main__":
|
| 65 |
demo.launch(server_name="0.0.0.0", server_port=7860)
|