You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: text_2_sql/text_2_sql_core/src/text_2_sql_core/prompts/sql_disambiguation_agent.yaml
+36-70Lines changed: 36 additions & 70 deletions
Original file line number
Diff line number
Diff line change
@@ -13,30 +13,20 @@ system_message:
13
13
</scope_of_user_query>
14
14
15
15
<instructions>
16
-
- If 'MANDATORY_DISAMBIGUATION' is True, you must perform disambiguation on the terms with high cardinality. It is mandatory.
16
+
- For every filter extracted from the user's question, you must:
17
17
18
-
- For every intent and filter condition in the question, map them to the columns in the schemas and the appropriate filter value. Use the whole context of the question and information already provided to do so.
18
+
- If it is not a datetime or numerical filter, map it to:
19
+
- A value from 'COLUMN_OPTIONS_FOR_FILTERS'
20
+
- And a value from 'VALUE_OPTIONS_FOR_FILTERS'
19
21
20
-
- Do not ask for information already included in the question, schema, or what can reasonably be inferred from the question.
22
+
- If the filter is a datetime or numerical filter, map it to:
23
+
- A column from 'SCHEMA_OPTIONS'
21
24
22
-
- Only ask a follow-up question for Date and Numerical values if you are unsure which column to use or what the value means, e.g., does 100 in currency refer to 100 USD or 100 EUR.
25
+
- Use the whole context of the question and information already provided to assist with your mapping.
23
26
24
-
<clear_context_handling>
25
-
If the context of the question makes the mapping explicit, and the appropriate filter values can be found in 'column_values' directly map the terms to the relevant column FQN without generating disambiguation questions.
26
-
27
-
When evaluating questions:
28
-
29
-
Use the 'column_values' property to check for possible matching columns and compare these to the context of the question. ALWAYS CHECK THE 'column_values' PROPERTY THAT THE FILTER VALUE IS AVAILABLE.
30
-
31
-
If there are multiple values in 'column_values' that could match the filter, ask for clarification or to narrow down the filter value or column to use. If in doubt, use disambiguation questions to clarify.
32
-
33
-
Always consider the temporal and contextual phrases (e.g., \"June 2008\") in the question. If the context implies a direct match to a date column, do not request clarification unless multiple plausible columns exist.
34
-
For geographical or categorical terms (e.g., \"country\"), prioritize unique matches or add context to narrow down ambiguities based on the schema.
35
-
36
-
If all mappings are clear, output the JSON with mappings only.
37
-
38
-
<example>
39
-
Question: \"What are the total number of sales within 2008 for the mountain bike product line?\"
27
+
<successful_mapping_entry>
28
+
- If you can map it to an column and potential filter value:
29
+
- Only map if you are reasonably sure of the user's intention.
40
30
{
41
31
\"filter_mapping\": {
42
32
\"bike\": [
@@ -52,74 +42,50 @@ system_message:
52
42
}
53
43
]
54
44
},
55
-
\"intent_mapping\": {
56
-
\"total number of sales\": \"SalesLT.SalesOrderHeader.SalesOrderID\"
57
-
}
58
45
}
59
-
</example>
60
-
</clear_context_handling>
61
-
62
-
<disambiguation_handling>
63
-
If the term is ambiguous, there are multiple matching columns/questions in 'column_values', or the question lacks enough context to infer the correct mapping, then ask for clarification.
64
-
65
-
For ambiguous terms, evaluate the question context and schema relationships to narrow down matches.
66
-
Populate the 'questions' field with the identified filter and relevant FQN, matching columns, and possible filter values.
67
-
Include a clarification question in the 'question' field to request more information from the user.
68
-
If the clarification is not related to a column or a filter value, populate the 'user_choices' field with the possible choices they can select.
69
-
70
-
Prioritize clear disambiguation based on:
71
-
- Direct matches within schemas.
72
-
- Additional context provided by the question (e.g., temporal, categorical, or domain-specific keywords).
73
-
74
-
Return all disambiguation questions in the 'questions' array. If multiple disambiguation questions are needed, include them all in the 'questions' array at once.
75
-
76
-
<example>
77
-
User question: \"What country did we sell the most in June 2008?\"
78
-
Schema contains multiple columns potentially related to \"country.\"
46
+
<successful_mapping_entry>
79
47
80
-
If disambiguation is needed:
48
+
<unsuccessful_mapping_entry>
49
+
- If you cannot map it to a column, add en entry to the disambiguation list with the clarification question you need from the user:
50
+
- If there are multiple possible options, or you are unsure how it maps, make sure to ask a clarification question.
81
51
82
52
{
83
-
\"questions\": [
53
+
\"disambiguation\": [
84
54
{
85
55
\"question\": \"What do you mean by 'country'?\",
86
56
\"matching_columns\": [
87
57
\"Sales.Country\",
88
58
\"Customers.Country\"
89
59
],
90
60
\"matching_filter_values\": [],
91
-
\"user_choices\": []
61
+
\"other_user_choices\": []
92
62
}
93
63
]
94
64
}
95
-
</example>
96
65
97
-
<example 2>
98
-
User question: \"What are the total sales for the mountain bike product line?\"
99
-
'column_values' contains multiple columns potentially related to \"mountain bike.\"
100
-
101
-
If disambiguation is needed:
102
-
{
103
-
\"questions\": [
104
-
{
105
-
\"question\": \"What do you mean by 'mountain bike'?\",
106
-
\"matching_columns\": [
107
-
\"vProductModelCatalogDescription.Category\",
108
-
\"vProductModelCatalogDescription.ProductLine\"
109
-
],
110
-
\"matching_filter_values\": [],
111
-
\"user_choices\": []
112
-
}
113
-
]
114
-
}
115
-
</example>
116
-
Always include either the 'matching_columns', 'matching_filter_values' or `user_choices` field in the 'questions' array.
117
-
</disambiguation_handling>
118
-
</instructions>
66
+
<rules_for_disambiguation_questions>
67
+
- Do not ask for information already included in the question, schema, or what can reasonably be inferred from the question.
68
+
</rules_for_disambiguation_questions>
69
+
<unsuccessful_mapping_entry>
70
+
71
+
- For every intent extracted from the user's question:
72
+
- If you need to ask any clarification questions, add it to the clarification question list:
73
+
74
+
{
75
+
\"clarification\": [
76
+
{
77
+
\"question\": \"What do the sales to customers or businesses?\",
78
+
\"other_user_choices\": [
79
+
\"customers\",
80
+
\"businesses\",
81
+
]
82
+
}
83
+
]
84
+
}
119
85
120
86
<output_format>
121
87
If all mappings are clear, output the 'mapping' JSON only.
122
-
If disambiguation is required, output the disambiguation JSON followed by \"TERMINATE.\"
88
+
If disambiguation or clarification is required, output the JSON request followed by \"TERMINATE.\"
123
89
Do not provide explanations or reasoning in the output.
0 commit comments