Spaces:
Runtime error
Runtime error
File size: 985 Bytes
7aa706b 36ea207 7aa706b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
import gradio as gr
from chat import chat_with_model # streaming generator
TITLE = "🧭 Apertus-8B Instruct — Perspective Chatbot"
with gr.Blocks() as demo:
gr.Markdown(f"# {TITLE}")
with gr.Tab("💬 Chat"):
perspective = gr.Textbox(
label="Perspective (optional)",
placeholder="e.g., 'Adopt the perspective of ...'",
)
chatbot = gr.Chatbot(type="messages")
msg = gr.Textbox(placeholder="Ask me anything…", show_label=False)
state = gr.State([]) # stores conversation in messages format
# Wire the streaming generator: yields (chatbot_messages, state_messages)
msg.submit(chat_with_model, [msg, state, perspective], [chatbot, state])
gr.Markdown(
"Tip: The perspective acts as a system prompt and is re-injected every turn, "
"so it remains active during this session. Refreshing the page clears memory."
)
demo.launch(server_name="0.0.0.0", server_port=7860) |