Update app.py
Browse files
app.py
CHANGED
|
@@ -24,7 +24,6 @@ Your job is to help users understand what Saptarshi has done, what he's good at,
|
|
| 24 |
Your goal is to represent him truthfully and make his work accessible and understandable to potential collaborators or employers, without overselling or faking.
|
| 25 |
"""
|
| 26 |
|
| 27 |
-
|
| 28 |
BLOCKED_KEYWORDS = ["kill", "harm", "violence", "bomb", "suicide"] # simple guardrail
|
| 29 |
MAX_TOKENS = 512
|
| 30 |
|
|
@@ -66,7 +65,7 @@ def generate_response(history, system_prompt):
|
|
| 66 |
with gr.Blocks() as demo:
|
| 67 |
gr.Markdown("## 🧠 Chat with SBK LLM")
|
| 68 |
system_prompt = gr.Textbox(label="System Prompt", value=SYSTEM_PROMPT, lines=2)
|
| 69 |
-
chatbot = gr.Chatbot()
|
| 70 |
msg = gr.Textbox(label="Your Message", placeholder="Ask me anything...", lines=1)
|
| 71 |
clear = gr.Button("Clear")
|
| 72 |
|
|
@@ -76,7 +75,13 @@ with gr.Blocks() as demo:
|
|
| 76 |
history = history + [[user_message, ""]]
|
| 77 |
return "", history, generate_response(history, system_prompt)
|
| 78 |
|
| 79 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
clear.click(lambda: ([], "", ""), outputs=[chatbot, msg, history])
|
| 81 |
|
| 82 |
-
demo.launch()
|
|
|
|
| 24 |
Your goal is to represent him truthfully and make his work accessible and understandable to potential collaborators or employers, without overselling or faking.
|
| 25 |
"""
|
| 26 |
|
|
|
|
| 27 |
BLOCKED_KEYWORDS = ["kill", "harm", "violence", "bomb", "suicide"] # simple guardrail
|
| 28 |
MAX_TOKENS = 512
|
| 29 |
|
|
|
|
| 65 |
with gr.Blocks() as demo:
|
| 66 |
gr.Markdown("## 🧠 Chat with SBK LLM")
|
| 67 |
system_prompt = gr.Textbox(label="System Prompt", value=SYSTEM_PROMPT, lines=2)
|
| 68 |
+
chatbot = gr.Chatbot(format="messages") # Updated to use the new format
|
| 69 |
msg = gr.Textbox(label="Your Message", placeholder="Ask me anything...", lines=1)
|
| 70 |
clear = gr.Button("Clear")
|
| 71 |
|
|
|
|
| 75 |
history = history + [[user_message, ""]]
|
| 76 |
return "", history, generate_response(history, system_prompt)
|
| 77 |
|
| 78 |
+
# Updated submit handler without stream parameter
|
| 79 |
+
msg.submit(
|
| 80 |
+
respond,
|
| 81 |
+
[msg, history, system_prompt],
|
| 82 |
+
[msg, history, chatbot],
|
| 83 |
+
queue=False
|
| 84 |
+
)
|
| 85 |
clear.click(lambda: ([], "", ""), outputs=[chatbot, msg, history])
|
| 86 |
|
| 87 |
+
demo.queue().launch()
|