Update app.py
Browse files
app.py
CHANGED
|
@@ -32,7 +32,7 @@ def generate_response(message, history, system_prompt, temperature, top_p, top_k
|
|
| 32 |
inputs = tokenizer(prompt, return_tensors="pt")
|
| 33 |
streamer = TextIteratorStreamer(tokenizer, skip_prompt=True, skip_special_tokens=False)
|
| 34 |
|
| 35 |
-
|
| 36 |
inputs,
|
| 37 |
streamer=streamer,
|
| 38 |
max_new_tokens=int(max_tokens),
|
|
@@ -40,9 +40,7 @@ def generate_response(message, history, system_prompt, temperature, top_p, top_k
|
|
| 40 |
temperature=float(temperature) if temperature > 0.0 else 1.0,
|
| 41 |
top_p=float(top_p),
|
| 42 |
top_k=int(top_k)
|
| 43 |
-
|
| 44 |
)
|
| 45 |
-
|
| 46 |
|
| 47 |
thread = Thread(target=model.generate, kwargs=generation_kwargs)
|
| 48 |
thread.start()
|
|
@@ -59,7 +57,6 @@ with gr.Blocks() as demo:
|
|
| 59 |
with gr.Row():
|
| 60 |
# Left Workspace Column: Chat Layout
|
| 61 |
with gr.Column(scale=3):
|
| 62 |
-
# FIXED: Removed type="messages" since it is default and unsupported as a kwarg in Gradio 6
|
| 63 |
chatbot = gr.Chatbot(height=500)
|
| 64 |
msg_input = gr.Textbox(placeholder="Enter reasoning prompt...", label="Your Message")
|
| 65 |
with gr.Row():
|
|
@@ -95,7 +92,7 @@ with gr.Blocks() as demo:
|
|
| 95 |
yield history
|
| 96 |
|
| 97 |
# Event Wiring Flow
|
| 98 |
-
|
| 99 |
user_side_submit, [msg_input, chatbot], [msg_input, chatbot], queue=False
|
| 100 |
).then(
|
| 101 |
bot_side_inference,
|
|
|
|
| 32 |
inputs = tokenizer(prompt, return_tensors="pt")
|
| 33 |
streamer = TextIteratorStreamer(tokenizer, skip_prompt=True, skip_special_tokens=False)
|
| 34 |
|
| 35 |
+
generation_kwargs = dict(
|
| 36 |
inputs,
|
| 37 |
streamer=streamer,
|
| 38 |
max_new_tokens=int(max_tokens),
|
|
|
|
| 40 |
temperature=float(temperature) if temperature > 0.0 else 1.0,
|
| 41 |
top_p=float(top_p),
|
| 42 |
top_k=int(top_k)
|
|
|
|
| 43 |
)
|
|
|
|
| 44 |
|
| 45 |
thread = Thread(target=model.generate, kwargs=generation_kwargs)
|
| 46 |
thread.start()
|
|
|
|
| 57 |
with gr.Row():
|
| 58 |
# Left Workspace Column: Chat Layout
|
| 59 |
with gr.Column(scale=3):
|
|
|
|
| 60 |
chatbot = gr.Chatbot(height=500)
|
| 61 |
msg_input = gr.Textbox(placeholder="Enter reasoning prompt...", label="Your Message")
|
| 62 |
with gr.Row():
|
|
|
|
| 92 |
yield history
|
| 93 |
|
| 94 |
# Event Wiring Flow
|
| 95 |
+
msg_input.submit(
|
| 96 |
user_side_submit, [msg_input, chatbot], [msg_input, chatbot], queue=False
|
| 97 |
).then(
|
| 98 |
bot_side_inference,
|