Local Ai
Beginner question: How to summarize session history instead of sending the entire session JSON to a local Ollama server every time?
Hi. I’m developing my first Python project (been at it a couple weeks). I built a very basic CLI ollama client. When a user sends a prompt I append the message to session['history'], save the sessio
Hi. I’m developing my first Python project (been at it a couple weeks). I built a very basic CLI ollama client. When a user sends a prompt I append the message to session["history"], save the session, then stream the chat to the local Ollama server. Environment: Host: Ollama running on Windows 11; Client: Python 3.11 running on Debian Trixie Here’s a small snippet from my actual code: session["history"].append({"role": "user", "content": user_prompt, "ts": turn_ts}) session["updated_at"] = turn_ts save_session(session_id, session) if not find_by_name(cfg, model): print(f'Configured models do not include "{model}". Use lmConfig to add it or pass a known alias.') sys.exit(1) chunks = stream_chat(client, model, session["history"]) if assistant_reply: session["history"].append({"role": "assistant", "content": assistant_reply, "ts": reply_ts or now_ts()}) save_session(session_id, session) Here are some questions that I had on the back of my mind that I need help with. * What strategies should I consider to avoid sending the whole session every time? I expect issues once sessions get long, though I haven’t tested long sessions yet. * For small projects, where do you recommend to store sessions? Plain JSON files in a sessions/ folder (my current approach) or something else like SQLite? Any tips or code examples would be awesome — I’m still learning. Thanks! submitted by /u/mycorrhizal-hominoid [link] [comments]
Related
- [[project-babel-brief-a-local-ai-telegram-secretary-to-summari|[Project] Babel-Brief: A local AI Telegram secretary to summarize the noise (Python + Ollama API)]]
- Built a personal memory system using Ollama + qwen2.5:7b - queries your entire life history via RAG (AetherMind)
Source: r/ollama | 2026-09-24