r/learnpython • u/Friendly_Rope_5688 • Oct 16 '26
How should I separate LLM interpretation from memory operations in my Python project?
I've been working on a small Python project that uses an LLM to interpret natural language instructions and manage persistent memories. Right now, it supports remembering, retrieving, updating and forgetting information.
I've been trying to improve the separation between model interpretation and memory operations. I'm still new to Python but I'm interested how I could structure the code better. Feedbacks are appreciated and any flaws I might be overlooking.
GitHub repo: https://github.com/Lionshaft-pixel/ennoic
8
Upvotes
View all comments
3
u/Equivalent_Type6726 Oct 17 '26
For the memory side, give the four operations their own interface. Make a small Memory class with remember, retrieve, update, and forget methods, and keep the LLM calling out to it instead of touching storage directly. You can even swap backends later (a dict for dev, a sqlite database for prod) by just replacing that one class. On the LLM side, build a thin Interpreter that takes raw input, calls the model, turns the response into a structured decision like which memory action to run, and hands it to Memory. That keeps interpretation and storage cleanly separated and makes both sides easy to test on their own. A quick type like a MemoryEntry with a key, content, and timestamp also helps a lot when you start retrieving and updating.