From 81da70314ead433593c31b06b73ef88735a3419f Mon Sep 17 00:00:00 2001 From: Prins Kumar Date: Mon, 13 Jul 2026 21:30:13 +0530 Subject: [PATCH] GML-2162: route document statistics analysis to vectorstore Keep mandatory functions routing for graph metadata; add a narrow exception for domain analysis that asks for stats instead of narrative text. --- common/llm_services/base_llm.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/common/llm_services/base_llm.py b/common/llm_services/base_llm.py index 8c12159..f52c8b9 100644 --- a/common/llm_services/base_llm.py +++ b/common/llm_services/base_llm.py @@ -796,14 +796,22 @@ def generate_gsql_prompt(self): - **`functions`**: questions about structured data or operations on structured data. Available entities: {v_types}; relationships: {e_types}. Some "how many documents are there?" style questions can be answered here. ## Mandatory `functions` Routing -Any question about graph database **statistics or metadata** MUST route to `functions`: +Any question about graph database **statistics or metadata** MUST route to `functions`. This section has highest priority: - Counts of vertices / nodes / edges (e.g. "how many edges in the graph"). - Listing or describing vertex / edge types, schema, or graph structure. - Aggregations, totals, or summaries of data in the graph database. - Any question mentioning "graph", "graph db", "graph database", "vertices", "nodes", or "edges" in the context of statistics / counts. +- Structured counts or lookups against schema entities / relationships (e.g. how many X, list Y). These are **database queries, not document lookups** — always route them to `functions`. +## Document analysis exception → `vectorstore` +Use `vectorstore` (or `history` if the question clearly continues a prior answer) only for this case: +- Domain / document analysis that asks for statistics or data **instead of** narrative text or description. +- Examples: "backed by statistics of data instead of just reading from the text/description"; same intent plus a document topic (e.g. product stability trends). +- Do **not** use this exception if the question asks for graph / vertex / edge / schema counts. +- Do **not** broaden this exception. If the question could reasonably be a structured graph query, route to `functions`. + Otherwise, route to `vectorstore`. ## Inputs