I guess a different approach would be alternating between generation and summarization to keep the AI on topic.
GENERATE:
Use a prompt starting with:
- Overall summary - The story so far
- Medium Term Summary - A summary of recent events
- Short Term Summary - A summary of the last completion
It gets harder as you move forward if you don’t want to blow through the token limitations.
You’d have to set budgets for prompts/completions I guess the limit for davinci is what 2048 tokens right?
For example:
500 tokens for The overall summary
150 tokens for the Medium Term (optional)
398 tokens for Short Term summary
200 tokens for any structural wrapping needed (e.g. character list, setting description)
800 tokens for completion (that should give you 2 pages of a book? maybe?)
This budget will likely have to be a little flexible because "The overall summary will grow as you progress, so I’d keep a buffer for it, but I think in the early stages you could get away with longer completions.
Store the full completion as book pages .
SUMMARIZATION
- Summarize the returned completion add to “Short Term Summary”
- Summarize the “Short Term Summary” Add to the bottom of the Medium Term Summary (remove the top), and to the overall summary.
This would be a fun and relatively quick python script to write.