prasadpatil25 commited on
Commit
ed2c4de
·
verified ·
1 Parent(s): e5a3c15

Deploy Memory Studio public demo

Browse files
Files changed (2) hide show
  1. local_llm.py +2 -1
  2. memory_studio.py +15 -3
local_llm.py CHANGED
@@ -356,7 +356,8 @@ in the same order.
356
  something to it (crash into, swallow, burst out of, squirt, chase...).
357
  - Add one sound, smell, or feeling to each line. Exaggerate size, colour, and
358
  movement; be absurd.
359
- - Use the exact {noun} in its own line. One or two short sentences per line.
 
360
  - No title, introduction, explanation, or conclusion.
361
 
362
  Words each line must contain:
 
356
  something to it (crash into, swallow, burst out of, squirt, chase...).
357
  - Add one sound, smell, or feeling to each line. Exaggerate size, colour, and
358
  movement; be absurd.
359
+ - Use the exact {noun} in its own line. One or two short sentences per line
360
+ (under 40 words). Never mention a later image before its own line.
361
  - No title, introduction, explanation, or conclusion.
362
 
363
  Words each line must contain:
memory_studio.py CHANGED
@@ -912,6 +912,9 @@ def _add_story_lines(rows: list[list[str]], kind: str) -> None:
912
  row.insert(STORY_LINE_COLUMN, line)
913
 
914
 
 
 
 
915
  def _names_image(label: str, text: str) -> bool:
916
  """True if ``text`` names the image word, allowing a plural (lip/lips)."""
917
  needle = re.escape(" ".join(label.casefold().split()))
@@ -960,20 +963,29 @@ def _resolve_story_lines(
960
  line
961
  and line not in STORY_EXAMPLE_LINES
962
  and _names_image(items[index].label, line)
963
- # A link must also touch the previous picture.
964
  and (index == 0 or _names_image(items[index - 1].label, line))
 
 
 
 
 
 
 
 
965
  ):
966
  lines[index] = line
967
  record[index] = None # keep it like your own line
968
  replaced += 1
969
  notes.append(
970
  f"The local model wrote {replaced} of {len(generated)} story "
971
- "line(s); each one names its own image and the one before it. "
972
  "The rest use the built-in "
973
  "lines. Edit any line, or clear it to get a fresh one."
974
  if replaced
975
  else "The local model's story lines were not usable (each line "
976
- "must name its own image and the one before it), so the built-in "
 
977
  "lines are shown."
978
  )
979
  except LocalModelError as exc:
 
912
  row.insert(STORY_LINE_COLUMN, line)
913
 
914
 
915
+ MAX_STORY_LINE_WORDS = 45
916
+
917
+
918
  def _names_image(label: str, text: str) -> bool:
919
  """True if ``text`` names the image word, allowing a plural (lip/lips)."""
920
  needle = re.escape(" ".join(label.casefold().split()))
 
963
  line
964
  and line not in STORY_EXAMPLE_LINES
965
  and _names_image(items[index].label, line)
966
+ # A link must also touch the previous picture...
967
  and (index == 0 or _names_image(items[index - 1].label, line))
968
+ # ...must not give away the next one before its turn...
969
+ and (
970
+ index + 1 >= len(items)
971
+ or _names_image(items[index].label, items[index + 1].label)
972
+ or not _names_image(items[index + 1].label, line)
973
+ )
974
+ # ...and must stay short enough to read in one breath.
975
+ and len(line.split()) <= MAX_STORY_LINE_WORDS
976
  ):
977
  lines[index] = line
978
  record[index] = None # keep it like your own line
979
  replaced += 1
980
  notes.append(
981
  f"The local model wrote {replaced} of {len(generated)} story "
982
+ "line(s); each one links its own image to the one before it. "
983
  "The rest use the built-in "
984
  "lines. Edit any line, or clear it to get a fresh one."
985
  if replaced
986
  else "The local model's story lines were not usable (each line "
987
+ "must link its own image to the one before it, without giving "
988
+ "away the next one), so the built-in "
989
  "lines are shown."
990
  )
991
  except LocalModelError as exc: