JohanBeytell commited on
Commit
c81ba21
·
verified ·
1 Parent(s): 1f501e4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -0
app.py CHANGED
@@ -79,6 +79,12 @@ def sample_once(prompt, temperature=1.0, top_k=40, max_new=24):
79
 
80
  # === Generation Function ===
81
  def generate_names(prompt, temperature, top_k, count, retries):
 
 
 
 
 
 
82
  results = []
83
  for _ in range(count):
84
  for attempt in range(retries):
@@ -105,6 +111,14 @@ It will generate names for characters, gods, factions, or places.
105
  - The creators are not responsible for any weirdness it spits out. Use responsibly.
106
  """
107
 
 
 
 
 
 
 
 
 
108
  with gr.Blocks() as demo:
109
  gr.Markdown(description)
110
  with gr.Row():
@@ -120,5 +134,6 @@ with gr.Blocks() as demo:
120
  download = gr.File(label="📥 Export Names as .txt")
121
 
122
  generate_btn.click(fn=generate_names, inputs=[prompt, temperature, top_k, count, retries], outputs=[output, download])
 
123
 
124
  demo.launch()
 
79
 
80
  # === Generation Function ===
81
  def generate_names(prompt, temperature, top_k, count, retries):
82
+ prompt = prompt.strip()
83
+ if not prompt:
84
+ raise gr.Error("Prompt cannot be empty.")
85
+ if len(prompt) > 64:
86
+ raise gr.Error("Prompt is too long. Please keep it under 64 characters.")
87
+
88
  results = []
89
  for _ in range(count):
90
  for attempt in range(retries):
 
111
  - The creators are not responsible for any weirdness it spits out. Use responsibly.
112
  """
113
 
114
+ examples = [
115
+ ["a forgotten warrior king"],
116
+ ["queen of the shattered realm"],
117
+ ["blacksmith of shadows"],
118
+ ["titan of the blazing sky"],
119
+ ["a blade that burns through matter"]
120
+ ]
121
+
122
  with gr.Blocks() as demo:
123
  gr.Markdown(description)
124
  with gr.Row():
 
134
  download = gr.File(label="📥 Export Names as .txt")
135
 
136
  generate_btn.click(fn=generate_names, inputs=[prompt, temperature, top_k, count, retries], outputs=[output, download])
137
+ gr.Examples(examples=examples, inputs=prompt)
138
 
139
  demo.launch()