Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion common/llm_services/base_llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Comment on lines +808 to +813

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: The new exception is broad enough that questions asking for structured counts or lookups on schema entities could still be routed to vectorstore. Tighten it so vectorstore applies only when the requested statistics are explicitly sourced from document text or document analysis, not from graph entities. [possible issue, importance: 4]

Suggested change
## 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`.
## Document analysis exception → `vectorstore`
Use `vectorstore` (or `history` if the question clearly continues a prior answer) only when the question explicitly asks to analyze statistics, trends, evidence, or data contained in documents/text for a document topic:
- 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 for counts, lists, lookups, aggregations, or summaries over graph / vertex / edge / schema entities or relationships.
- Do **not** broaden this exception. If the question could reasonably be a structured graph query, route to `functions`.


Otherwise, route to `vectorstore`.

## Inputs
Expand Down