working baseline
This commit is contained in:
80
test_prompt_logic.py
Normal file
80
test_prompt_logic.py
Normal file
@@ -0,0 +1,80 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Test script to verify the prompt numbering logic.
|
||||
"""
|
||||
|
||||
import json
|
||||
from datetime import datetime
|
||||
|
||||
def test_renumbering():
|
||||
"""Test the renumbering logic."""
|
||||
|
||||
# Create a sample historic prompts list
|
||||
historic_prompts = []
|
||||
for i in range(60):
|
||||
historic_prompts.append({
|
||||
f"prompt{i:02d}": f"Old prompt {i}"
|
||||
})
|
||||
|
||||
print(f"Original prompts: {len(historic_prompts)}")
|
||||
print(f"First prompt key: {list(historic_prompts[0].keys())[0]}")
|
||||
print(f"Last prompt key: {list(historic_prompts[-1].keys())[0]}")
|
||||
|
||||
# Simulate adding 6 new prompts (as the current code would create them)
|
||||
new_prompts = []
|
||||
for i in range(6):
|
||||
new_prompts.append({
|
||||
f"prompt{len(historic_prompts) + i:02d}": f"New prompt {i}"
|
||||
})
|
||||
|
||||
print(f"\nNew prompts to add: {len(new_prompts)}")
|
||||
for i, prompt in enumerate(new_prompts):
|
||||
print(f" New prompt {i}: {list(prompt.keys())[0]}")
|
||||
|
||||
# Prepend new prompts (reverse to maintain order)
|
||||
for prompt in reversed(new_prompts):
|
||||
historic_prompts.insert(0, prompt)
|
||||
|
||||
print(f"\nAfter prepending: {len(historic_prompts)} prompts")
|
||||
print(f"First 3 prompts keys:")
|
||||
for i in range(3):
|
||||
print(f" {i}: {list(historic_prompts[i].keys())[0]}")
|
||||
|
||||
# Renumber all prompts
|
||||
renumbered_prompts = []
|
||||
for i, prompt_dict in enumerate(historic_prompts):
|
||||
prompt_key = list(prompt_dict.keys())[0]
|
||||
prompt_text = prompt_dict[prompt_key]
|
||||
|
||||
new_prompt_key = f"prompt{i:02d}"
|
||||
renumbered_prompts.append({
|
||||
new_prompt_key: prompt_text
|
||||
})
|
||||
|
||||
print(f"\nAfter renumbering: {len(renumbered_prompts)} prompts")
|
||||
print(f"First 10 prompts keys:")
|
||||
for i in range(10):
|
||||
print(f" prompt{i:02d}: {list(renumbered_prompts[i].keys())[0]} = {renumbered_prompts[i][f'prompt{i:02d}'][:30]}...")
|
||||
|
||||
# Keep only first 60
|
||||
if len(renumbered_prompts) > 60:
|
||||
renumbered_prompts = renumbered_prompts[:60]
|
||||
|
||||
print(f"\nAfter keeping only first 60: {len(renumbered_prompts)} prompts")
|
||||
print(f"First prompt: {list(renumbered_prompts[0].keys())[0]} = {renumbered_prompts[0]['prompt00'][:30]}...")
|
||||
print(f"Last prompt: {list(renumbered_prompts[-1].keys())[0]} = {renumbered_prompts[-1]['prompt59'][:30]}...")
|
||||
|
||||
# Verify the range
|
||||
for i in range(60):
|
||||
expected_key = f"prompt{i:02d}"
|
||||
actual_key = list(renumbered_prompts[i].keys())[0]
|
||||
if expected_key != actual_key:
|
||||
print(f"ERROR: Expected {expected_key}, got {actual_key}")
|
||||
return False
|
||||
|
||||
print("\n✅ All tests passed! Prompt numbering is correct.")
|
||||
return True
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_renumbering()
|
||||
|
||||
Reference in New Issue
Block a user