checkpoint before simplifying data

This commit is contained in:
2026-01-02 19:09:05 -07:00
parent 1222c4ab5a
commit d71883917c
8 changed files with 293 additions and 77 deletions

View File

@@ -16,24 +16,23 @@ def test_valid_response():
# Create a mock generator
generator = JournalPromptGenerator(config_path=".env")
# Create a valid response with 4 prompts (default num_prompts from settings)
valid_response = {
"newprompt0": "Write about a time when you felt truly at peace.",
"newprompt1": "Describe your ideal morning routine in detail.",
"newprompt2": "What are three things you're grateful for today?",
"newprompt3": "Reflect on a recent challenge and what you learned from it."
}
# Create a valid response with 4 prompts as a list (new format)
valid_response = [
"Write about a time when you felt truly at peace.",
"Describe your ideal morning routine in detail.",
"What are three things you're grateful for today?",
"Reflect on a recent challenge and what you learned from it."
]
# Convert to JSON string
json_response = json.dumps(valid_response)
print("\n=== Test: Valid JSON response ===")
print("\n=== Test: Valid JSON response (list format) ===")
result = generator._parse_ai_response(json_response)
print(f"Number of prompts extracted: {len(result)}")
print(f"Type of result: {type(result)}")
for i, prompt_dict in enumerate(result):
prompt_key = list(prompt_dict.keys())[0]
prompt_text = prompt_dict[prompt_key]
for i, prompt_text in enumerate(result):
print(f"Prompt {i+1}: {prompt_text[:50]}...")
# Test with backticks
@@ -48,6 +47,19 @@ def test_valid_response():
result = generator._parse_ai_response(json_prefix_response)
print(f"Number of prompts extracted: {len(result)}")
# Test fallback for old dictionary format
print("\n=== Test: Fallback for old dictionary format ===")
old_format_response = {
"newprompt0": "Write about a time when you felt truly at peace.",
"newprompt1": "Describe your ideal morning routine in detail.",
"newprompt2": "What are three things you're grateful for today?",
"newprompt3": "Reflect on a recent challenge and what you learned from it."
}
json_old_response = json.dumps(old_format_response)
result = generator._parse_ai_response(json_old_response)
print(f"Number of prompts extracted: {len(result)}")
if __name__ == "__main__":
test_valid_response()