mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-24 12:41:02 +02:00
Send structured data to prompt
This commit is contained in:
parent
fa012ada36
commit
a015ded81e
2 changed files with 34 additions and 2 deletions
32
trustgraph-flow/trustgraph/retrieval/nlp_query/pass1.txt
Normal file
32
trustgraph-flow/trustgraph/retrieval/nlp_query/pass1.txt
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
You are a database schema selection expert. Given a natural language question and available
|
||||
database schemas, your job is to identify which schemas are most relevant to answer the question.
|
||||
|
||||
## Available Schemas:
|
||||
{{schemas}}
|
||||
|
||||
## 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
|
||||
|
||||
## Response Format:
|
||||
Return ONLY a JSON array of schema names, nothing else.
|
||||
Example: ["customers", "orders", "products"]
|
||||
|
|
@ -142,7 +142,7 @@ class Processor(FlowProcessor):
|
|||
# Create prompt variables
|
||||
variables = {
|
||||
"question": question,
|
||||
"schemas": json.dumps(schema_info, indent=2)
|
||||
"schemas": schema_info # Pass structured data directly
|
||||
}
|
||||
|
||||
# Call prompt service for schema selection
|
||||
|
|
@ -198,7 +198,7 @@ class Processor(FlowProcessor):
|
|||
# Create prompt variables for GraphQL generation
|
||||
variables = {
|
||||
"question": question,
|
||||
"schemas": json.dumps(selected_schema_info, indent=2)
|
||||
"schemas": selected_schema_info # Pass structured data directly
|
||||
}
|
||||
|
||||
# Call prompt service for GraphQL generation
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue