Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -36,15 +36,24 @@ def respond(
|
|
36 |
)
|
37 |
|
38 |
for chunk in stream:
|
39 |
-
|
40 |
-
|
41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
|
43 |
# Create the Gradio interface
|
44 |
demo = gr.ChatInterface(
|
45 |
respond,
|
46 |
additional_inputs=[
|
47 |
-
gr.Textbox(value="
|
48 |
gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
|
49 |
gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
|
50 |
gr.Slider(
|
|
|
36 |
)
|
37 |
|
38 |
for chunk in stream:
|
39 |
+
# Extract content from the chunk
|
40 |
+
if 'choices' in chunk and len(chunk['choices']) > 0:
|
41 |
+
if 'text' in chunk['choices'][0]:
|
42 |
+
content = chunk['choices'][0]['text']
|
43 |
+
elif 'delta' in chunk['choices'][0] and 'content' in chunk['choices'][0]['delta']:
|
44 |
+
content = chunk['choices'][0]['delta']['content']
|
45 |
+
else:
|
46 |
+
continue
|
47 |
+
|
48 |
+
if content is not None:
|
49 |
+
response += content
|
50 |
+
yield response
|
51 |
|
52 |
# Create the Gradio interface
|
53 |
demo = gr.ChatInterface(
|
54 |
respond,
|
55 |
additional_inputs=[
|
56 |
+
gr.Textbox(value="(Answer on the language of the user)", label="System prompt"),
|
57 |
gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
|
58 |
gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
|
59 |
gr.Slider(
|