SBK commited on
Commit
0358e00
·
verified ·
1 Parent(s): f5cf2dc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -4
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
- msg.submit(respond, [msg, history, system_prompt], [msg, history, chatbot], stream=True)
 
 
 
 
 
 
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()