-
Notifications
You must be signed in to change notification settings - Fork 137
Open
Description
📝 Description
Right now, FireForm reads and calculates the layout of a PDF form from scratch every single time it runs. If a fire department fills out the exact same "Incident Report" 100 times a day, our system wastes time and processing power re-reading the same blank form 100 times.
💡 Rationale
We should save (or "cache") the blank form in the system's memory the very first time we see it. The next 99 times, FireForm will skip the slow hard-drive reading process and load the form instantly from memory. This will make the system much faster and allow it to handle more forms at once.
🛠️ Proposed solution
We can do this by adding a simple memory dictionary to our PDF filler code.
- Create the Cache: Add a dictionary (
self._template_cache = {}) inside theFillerclass to store the raw bytes of the PDFs. - Update PDF Loading: In the
fill_formfunction, check if the PDF is already in the cache.- If it's new, read the file from the hard drive and save it to the cache.
- If it's already saved, load it instantly using
PdfReader(fdata=...).
- Reset LLM Memory: Ensure
self._jsonis reset to an empty dictionary{}at the start ofmain_loopinsrc/llm.py. This prevents older answers from crashing the system when doing multiple fast runs.
✅ Acceptance Criteria
- The "Double Run" Test: If we send the exact same form to the system twice in a row, the terminal prints
[LOG] Template Cache Hit!on the second run. - No Crashes: The system successfully processes the second run without throwing an
AttributeErroror memory state bug. - Speed: The second run finishes noticeably faster than the first run because it skips reading the file from the disk.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels