Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -45,4 +45,25 @@ def respond(message, history, system_message, max_tokens, temperature, top_p):
|
|
| 45 |
stream=True,
|
| 46 |
):
|
| 47 |
token = ""
|
| 48 |
-
if chunk.choices and
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
stream=True,
|
| 46 |
):
|
| 47 |
token = ""
|
| 48 |
+
if chunk.choices and chunk.choices[0].delta and chunk.choices[0].delta.content:
|
| 49 |
+
token = chunk.choices[0].delta.content
|
| 50 |
+
response += token
|
| 51 |
+
yield response
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
chatbot = gr.ChatInterface(
|
| 55 |
+
respond,
|
| 56 |
+
type="messages",
|
| 57 |
+
additional_inputs=[
|
| 58 |
+
gr.Textbox(value=SYSTEM_PROMPT, label="System message"),
|
| 59 |
+
gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
|
| 60 |
+
gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
|
| 61 |
+
gr.Slider(minimum=0.1, maximum=1.0, value=0.95, step=0.05, label="Top-p (nucleus sampling)"),
|
| 62 |
+
],
|
| 63 |
+
)
|
| 64 |
+
|
| 65 |
+
demo = gr.Blocks()
|
| 66 |
+
with demo:
|
| 67 |
+
chatbot.render()
|
| 68 |
+
|
| 69 |
+
app = demo
|