ganeshvb003 commited on
Commit
4ffb95c
·
verified ·
1 Parent(s): a5c0648

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -10
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[0]
31
- bot_msg = turn.get("text") if isinstance(turn, dict) else turn[1]
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 Gradio ChatInterface
56
- demo = gr.ChatInterface(
57
- fn=respond,
58
- title="🤖 Free Llama 3.2 CPU Chatbot",
59
- description="Running 24/7/365 for free on Hugging Face Spaces using CPU inference.",
60
- examples=["Explain quantum computing simply.", "Write a short poem about coding."],
61
- theme="soft"
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)