Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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(100, 500, render=False)
|
13 |
+
|
14 |
+
gr.ChatInterface(
|
15 |
+
echo, additional_inputs=[system_prompt, slider], type="messages", save_history=True
|
16 |
+
)
|
17 |
+
|
18 |
+
demo.launch()
|