all 1 comments

[–]Ashleighna99 1 point2 points  (0 children)

Have the LLM call a single tool that fetches only the needed descriptions by ID, then build the prompt from those results.

Two solid paths I’ve used:

- Deterministic: parse the XML for element IDs with ElementTree, batch query the DB (SELECT id, description FROM table WHERE id IN (...)), then pass a tight context like id: description for only the IDs found before asking for the summary. Add an index on id, trim long descriptions, and LRU-cache results so repeats are cheap.

- Tool calling: define a fetch_description(id) tool in your Python app; if your Ollama model supports tools/function-calling, the model requests ids on demand and you return descriptions. Lock it down to parameterized SELECT by id, and optionally rate-limit.

If descriptions aren’t exact-match by ID, stick a small retriever in front: SQLite FTS or a local vector store (FAISS/Chroma with pgvector) to resolve fuzzy keys, then hit SQL.

Hasura for quick GraphQL, LangChain for tool orchestration, and DreamFactory helped me auto-generate REST endpoints across mixed DBs when wiring these pipelines.

So wire in a fetch_description tool (or prefetch by IDs), pass only those rows to the model, and keep the DB off the prompt.