Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,22 +1,18 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
max_tokens_slider = gr.inputs.Slider(minimum=10, maximum=100, default=50, label="Max Tokens")
|
| 13 |
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
title="Chat Bot",
|
| 20 |
-
description="Type your message and adjust the sliders for temperature and max tokens.",
|
| 21 |
-
theme="compact"
|
| 22 |
-
).launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import time
|
| 3 |
|
| 4 |
+
def echo(message, history, system_prompt, tokens):
|
| 5 |
+
response = f"System prompt: {system_prompt}\n Message: {message}."
|
| 6 |
+
for i in range(min(len(response), int(tokens))):
|
| 7 |
+
time.sleep(0.05)
|
| 8 |
+
yield response[: i+1]
|
| 9 |
|
| 10 |
+
with gr.Blocks() as demo:
|
| 11 |
+
system_prompt = gr.Textbox("You are helpful AI.", label="System Prompt")
|
| 12 |
+
slider = gr.Slider(10, 100, render=False)
|
|
|
|
| 13 |
|
| 14 |
+
gr.ChatInterface(
|
| 15 |
+
echo, additional_inputs=[system_prompt, slider]
|
| 16 |
+
)
|
| 17 |
+
|
| 18 |
+
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|