Spaces:
Sleeping
Sleeping
Eduardo Alvarez commited on
Commit ·
edac7d1
1
Parent(s): e5c70c3
inital push
Browse files- dummyLLM.py +36 -0
- requirements.txt +1 -0
dummyLLM.py
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import time
|
| 3 |
+
|
| 4 |
+
def simulate_response(prompt, expected_output, words_per_second, history):
|
| 5 |
+
delay = 1.0 / words_per_second if words_per_second > 0 else 0.01
|
| 6 |
+
|
| 7 |
+
# Add user prompt
|
| 8 |
+
history.append((prompt, ""))
|
| 9 |
+
|
| 10 |
+
# Stream simulated response
|
| 11 |
+
output = ""
|
| 12 |
+
for word in expected_output.split():
|
| 13 |
+
output += word + " "
|
| 14 |
+
history[-1] = (prompt, output.strip())
|
| 15 |
+
time.sleep(delay)
|
| 16 |
+
yield history
|
| 17 |
+
|
| 18 |
+
with gr.Blocks(theme="default") as demo:
|
| 19 |
+
gr.Markdown("## 🧠 Simulated Chatbot (LLM Style)", elem_id="title")
|
| 20 |
+
|
| 21 |
+
chatbot = gr.Chatbot(show_label=False, height=800)
|
| 22 |
+
generate_btn = gr.Button("Simulate Chat")
|
| 23 |
+
with gr.Row():
|
| 24 |
+
prompt_input = gr.Textbox(label="User Prompt", placeholder="Type your prompt here")
|
| 25 |
+
response_input = gr.Textbox(label="Expected Output", placeholder="Type simulated response here")
|
| 26 |
+
|
| 27 |
+
wps_slider = gr.Slider(minimum=1, maximum=500, value=5, step=1,
|
| 28 |
+
label="Simulated Words per Second")
|
| 29 |
+
|
| 30 |
+
generate_btn.click(
|
| 31 |
+
simulate_response,
|
| 32 |
+
inputs=[prompt_input, response_input, wps_slider, chatbot],
|
| 33 |
+
outputs=chatbot
|
| 34 |
+
)
|
| 35 |
+
|
| 36 |
+
demo.launch()
|
requirements.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
gradio>=3.0
|