You're the star of the show now baby!

This commit is contained in:
WhatDidYouExpect 2025-07-16 19:27:12 +02:00
parent d89a086420
commit 4ff0630d66
2 changed files with 23 additions and 3 deletions

View file

@ -34,13 +34,15 @@ def save_memory(memory):
with open(MEMORY_FILE, "w") as f:
json.dump(memory, f, indent=4)
# Train a Markov model using memory and optional additional data
def train_markov_model(memory, additional_data=None):
if not memory:
return None
text = "\n".join(memory)
filtered_memory = [line for line in memory if isinstance(line, str)]
if additional_data:
text += "\n" + "\n".join(additional_data)
filtered_memory.extend(line for line in additional_data if isinstance(line, str))
if not filtered_memory:
return None
text = "\n".join(filtered_memory)
model = markovify.NewlineText(text, state_size=2)
return model