Send structured data to prompt

This commit is contained in:
Cyber MacGeddon 2025-09-04 13:29:47 +01:00
parent fa012ada36
commit a015ded81e
2 changed files with 34 additions and 2 deletions

View 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"]

View file

@ -142,7 +142,7 @@ class Processor(FlowProcessor):
# Create prompt variables # Create prompt variables
variables = { variables = {
"question": question, "question": question,
"schemas": json.dumps(schema_info, indent=2) "schemas": schema_info # Pass structured data directly
} }
# Call prompt service for schema selection # Call prompt service for schema selection
@ -198,7 +198,7 @@ class Processor(FlowProcessor):
# Create prompt variables for GraphQL generation # Create prompt variables for GraphQL generation
variables = { variables = {
"question": question, "question": question,
"schemas": json.dumps(selected_schema_info, indent=2) "schemas": selected_schema_info # Pass structured data directly
} }
# Call prompt service for GraphQL generation # Call prompt service for GraphQL generation