tmzh commited on
Commit
db20734
1 Parent(s): aedb933

requirements.txt

Browse files
Files changed (2) hide show
  1. app.py +14 -18
  2. requirements.txt +1 -0
app.py CHANGED
@@ -272,6 +272,20 @@ def group_words_callback(words: List[str]) -> List[gr.update]:
272
  print(f"Generated groups: {groups}")
273
  return [gr.update(value=group.words, choices=group.words, info=group.explanation) for group in groups]
274
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
275
 
276
  if __name__ == '__main__':
277
  with gr.Blocks() as demo:
@@ -304,24 +318,6 @@ if __name__ == '__main__':
304
  buttons.append(clue_button)
305
  outputs.append(clue_output)
306
 
307
- def pad_or_truncate(lst, n=4):
308
- # Ensure the length of the list is at most n
309
- truncated_lst = lst[:n]
310
- return truncated_lst + (n - len(truncated_lst)) * [Group(words=[],clue='',explanation='')]
311
-
312
-
313
- def group_words_callback(words):
314
- groups = group_words(words)
315
- groups = pad_or_truncate(groups, 4)
316
- print("Got groups: ", groups, type(groups))
317
- return [gr.update(value=groups[i].words, choices=groups[i].words, info=groups[i].explanation) for i in range(4)]
318
-
319
-
320
-
321
- def generate_clues_callback(group):
322
- print("Generating clues: ", group)
323
- g = generate_clue(group)
324
- return gr.update(value=g.word, info=g.explanation)
325
 
326
 
327
  model = models.transformers("microsoft/Phi-3-mini-4k-instruct",
 
272
  print(f"Generated groups: {groups}")
273
  return [gr.update(value=group.words, choices=group.words, info=group.explanation) for group in groups]
274
 
275
+ def generate_clues_callback(group):
276
+ """
277
+ Callback function to generate a clue for the given words.
278
+
279
+ Args:
280
+ words: a list of words.
281
+
282
+ Returns:
283
+ A gradio update object for the given group input.
284
+ """
285
+ print("Generating clues: ", group)
286
+ g = generate_clue(group)
287
+ return gr.update(value=g.word, info=g.explanation)
288
+
289
 
290
  if __name__ == '__main__':
291
  with gr.Blocks() as demo:
 
318
  buttons.append(clue_button)
319
  outputs.append(clue_output)
320
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
321
 
322
 
323
  model = models.transformers("microsoft/Phi-3-mini-4k-instruct",
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ outlines