From 894e4b0b95efb689dc61bc8e564334d708967295 Mon Sep 17 00:00:00 2001 From: Cyber MacGeddon Date: Thu, 4 Sep 2025 13:30:26 +0100 Subject: [PATCH] Updated prompt --- .../trustgraph/retrieval/nlp_query/pass1.txt | 37 ++++++++++--------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/trustgraph-flow/trustgraph/retrieval/nlp_query/pass1.txt b/trustgraph-flow/trustgraph/retrieval/nlp_query/pass1.txt index 698aaa9c..ebf0f92d 100644 --- a/trustgraph-flow/trustgraph/retrieval/nlp_query/pass1.txt +++ b/trustgraph-flow/trustgraph/retrieval/nlp_query/pass1.txt @@ -2,31 +2,34 @@ You are a database schema selection expert. Given a natural language question an database schemas, your job is to identify which schemas are most relevant to answer the question. ## Available Schemas: -{{schemas}} +{% for schema in schemas %} +**{{ schema.name }}**: {{ schema.description }} +Fields: +{% for field in schema.fields %} +- {{ field.name }} ({{ field.type }}): {{ field.description }} +{% endfor %} + +{% endfor %} ## Question: -{{question}} +{{ question }} ## Instructions: 1. Analyze the question to understand what data is being requested 2. Examine each schema to understand what data it contains 3. Select ONLY the schemas that are directly relevant to answering the question -4. Return your answer as a JSON array of schema names (just the names, not full objects) - -## Selection Criteria: -- Include schemas that contain data directly needed to answer the question -- Include schemas that contain fields referenced in the question -- Do NOT include schemas just because they might be tangentially related -- Prefer fewer, more relevant schemas over many loosely related ones -- If the question mentions specific entities, look for schemas containing those entities - -## Examples: -- Question: "Show me customers from California" → Schemas with customer data and location fields -- Question: "What are our top selling products last month?" → Schemas with product data and -sales/order data -- Question: "Which employees work in engineering?" → Schemas with employee data and -department/role information +4. Return your answer as a JSON array of schema names ## Response Format: Return ONLY a JSON array of schema names, nothing else. Example: ["customers", "orders", "products"] + +Your response: + +This is much more readable and flexible than working with a JSON string. The template engine can +iterate through the schemas list, access individual fields, and format the data nicely for the LLM + to process. + +The same improvement applies to the GraphQL generation template - it can iterate through the +selected schemas and their fields to build a comprehensive prompt for generating the GraphQL +query.