Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -231,6 +231,9 @@ def chat_interface(user_input, history, web_search, decoding_strategy, temperatu
|
|
231 |
# Ensure the tokenizer is accessible within the function scope
|
232 |
global tokenizer
|
233 |
|
|
|
|
|
|
|
234 |
# Perform model inference
|
235 |
response = model_inference(
|
236 |
user_prompt=user_input,
|
@@ -243,15 +246,18 @@ def chat_interface(user_input, history, web_search, decoding_strategy, temperatu
|
|
243 |
tokenizer=tokenizer # Pass tokenizer to the model_inference function
|
244 |
)
|
245 |
|
246 |
-
#
|
247 |
-
|
|
|
|
|
|
|
248 |
|
249 |
# Define the Gradio interface components
|
250 |
interface = gr.Interface(
|
251 |
fn=chat_interface,
|
252 |
inputs=[
|
253 |
gr.Textbox(label="User Input", placeholder="Type your message here..."),
|
254 |
-
gr.
|
255 |
gr.Checkbox(label="Perform Web Search"),
|
256 |
gr.Radio(["Greedy", "Top P Sampling"], label="Decoding strategy"),
|
257 |
gr.Slider(minimum=0.0, maximum=2.0, step=0.05, label="Sampling temperature", value=0.5),
|
@@ -259,8 +265,11 @@ interface = gr.Interface(
|
|
259 |
gr.Slider(minimum=0.01, maximum=5.0, step=0.01, label="Repetition penalty", value=1),
|
260 |
gr.Slider(minimum=0.01, maximum=0.99, step=0.01, label="Top P", value=0.9)
|
261 |
],
|
262 |
-
outputs=
|
263 |
-
|
|
|
|
|
|
|
264 |
)
|
265 |
|
266 |
# Launch the Gradio interface
|
|
|
231 |
# Ensure the tokenizer is accessible within the function scope
|
232 |
global tokenizer
|
233 |
|
234 |
+
# Ensure the input is correctly formatted as a dictionary
|
235 |
+
user_input = {"text": user_input}
|
236 |
+
|
237 |
# Perform model inference
|
238 |
response = model_inference(
|
239 |
user_prompt=user_input,
|
|
|
246 |
tokenizer=tokenizer # Pass tokenizer to the model_inference function
|
247 |
)
|
248 |
|
249 |
+
# Update chat history
|
250 |
+
history.append([user_input["text"], response])
|
251 |
+
|
252 |
+
# Return the updated history
|
253 |
+
return history, response
|
254 |
|
255 |
# Define the Gradio interface components
|
256 |
interface = gr.Interface(
|
257 |
fn=chat_interface,
|
258 |
inputs=[
|
259 |
gr.Textbox(label="User Input", placeholder="Type your message here..."),
|
260 |
+
gr.State([], label="Chat History"),
|
261 |
gr.Checkbox(label="Perform Web Search"),
|
262 |
gr.Radio(["Greedy", "Top P Sampling"], label="Decoding strategy"),
|
263 |
gr.Slider(minimum=0.0, maximum=2.0, step=0.05, label="Sampling temperature", value=0.5),
|
|
|
265 |
gr.Slider(minimum=0.01, maximum=5.0, step=0.01, label="Repetition penalty", value=1),
|
266 |
gr.Slider(minimum=0.01, maximum=0.99, step=0.01, label="Top P", value=0.9)
|
267 |
],
|
268 |
+
outputs=[
|
269 |
+
gr.Chatbot(label="Assistant Response"),
|
270 |
+
gr.State([])
|
271 |
+
],
|
272 |
+
live=False
|
273 |
)
|
274 |
|
275 |
# Launch the Gradio interface
|