r/learnpython • • 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

7 comments sorted by

View all comments

1

u/randomman10032 Oct 16 '26

In larger programs, Object Oriented Programming is used in general.

For example, you have both claude and a local model in your code.

What you would want, is make a directory in repository called 'models'.

You make a basemodel, and let all other models extend it. Put shared logic, so what you do for every model in the baseclass.

One tip: try learning Object-Oriented Programming (OOP) to keep your code organized as your project grows.

For example, create a models/ directory and put each model in its own file. You could have a BaseModel class with shared logic (like every model has an 'ask' method, every model has an url, etc..), then let your cloud and local models inherit from it.

models/
├── base_model.py
├── cloud_model.py
└── local_model.py

This way, shared code stays in one place, and each model handles its own specific tasks. It makes your project easier to understand, maintain, and expand.