ayan4m1 commited on
Commit
9091051
·
1 Parent(s): 692215d

fix: items not in a list

Browse files
Files changed (1) hide show
  1. app.py +6 -2
app.py CHANGED
@@ -5,6 +5,10 @@ models = {
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,7 +19,7 @@ def respond(
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,
@@ -33,7 +37,7 @@ demo = gr.ChatInterface(
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"),
 
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
  top_p: float,
20
  top_k: int
21
  ):
22
+ yield pipelines[model](
23
  message,
24
  max_new_tokens=max_new_tokens,
25
  do_sample=True,
 
37
  title="Prompt Enhancer Test",
38
  type="messages",
39
  additional_inputs=[
40
+ gr.Radio(choices=[list(models.items())], value="pszemraj/distilgpt2-magicprompt-SD", type="value", label="Model"),
41
  # gr.Textbox(value="Enhance the provided text so that it is more vibrant and detailed.", label="System prompt"),
42
  gr.Slider(minimum=8, maximum=128, value=64, step=8, label="Max new tokens"),
43
  gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),