Spaces:
Running
Running
ayan4m1
commited on
Commit
·
692215d
1
Parent(s):
555f172
fix: unable to cache pipelines, thanks gradio
Browse files
app.py
CHANGED
@@ -5,10 +5,6 @@ models = {
|
|
5 |
"MagicPrompt": "pszemraj/distilgpt2-magicprompt-SD",
|
6 |
"Llama-SmolTalk-3.2-1B": "prithivMLmods/Llama-SmolTalk-3.2-1B-Instruct"
|
7 |
}
|
8 |
-
pipelines = {}
|
9 |
-
|
10 |
-
for key, value in models.items():
|
11 |
-
pipelines[key] = pipeline("text-generation", model=value)
|
12 |
|
13 |
def respond(
|
14 |
message,
|
@@ -19,7 +15,7 @@ def respond(
|
|
19 |
top_p: float,
|
20 |
top_k: int
|
21 |
):
|
22 |
-
yield
|
23 |
message,
|
24 |
max_new_tokens=max_new_tokens,
|
25 |
do_sample=True,
|
@@ -34,8 +30,11 @@ For information on how to customize the ChatInterface, peruse the gradio docs: h
|
|
34 |
"""
|
35 |
demo = gr.ChatInterface(
|
36 |
respond,
|
|
|
|
|
37 |
additional_inputs=[
|
38 |
gr.Radio(choices=[models.items()], value="pszemraj/distilgpt2-magicprompt-SD", type="value", label="Model"),
|
|
|
39 |
gr.Slider(minimum=8, maximum=128, value=64, step=8, label="Max new tokens"),
|
40 |
gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
|
41 |
gr.Slider(
|
|
|
5 |
"MagicPrompt": "pszemraj/distilgpt2-magicprompt-SD",
|
6 |
"Llama-SmolTalk-3.2-1B": "prithivMLmods/Llama-SmolTalk-3.2-1B-Instruct"
|
7 |
}
|
|
|
|
|
|
|
|
|
8 |
|
9 |
def respond(
|
10 |
message,
|
|
|
15 |
top_p: float,
|
16 |
top_k: int
|
17 |
):
|
18 |
+
yield pipeline("text-generation", model=model)(
|
19 |
message,
|
20 |
max_new_tokens=max_new_tokens,
|
21 |
do_sample=True,
|
|
|
30 |
"""
|
31 |
demo = gr.ChatInterface(
|
32 |
respond,
|
33 |
+
title="Prompt Enhancer Test",
|
34 |
+
type="messages",
|
35 |
additional_inputs=[
|
36 |
gr.Radio(choices=[models.items()], value="pszemraj/distilgpt2-magicprompt-SD", type="value", label="Model"),
|
37 |
+
# gr.Textbox(value="Enhance the provided text so that it is more vibrant and detailed.", label="System prompt"),
|
38 |
gr.Slider(minimum=8, maximum=128, value=64, step=8, label="Max new tokens"),
|
39 |
gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
|
40 |
gr.Slider(
|