Skip to content

Commit 05ee5b3

Browse files
committed
Update rewrite
1 parent 83a068b commit 05ee5b3

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

text_2_sql/text_2_sql_core/src/text_2_sql_core/prompts/user_message_rewrite_agent.yaml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,8 @@ system_message: |
3333
3434
<instructions>
3535
1. **Understanding:**
36-
- Use the chat history to understand the context of the current question.
37-
- If the current question is unclear, rewrite it based on the general meaning of the old question and the new question. Include spelling and grammar corrections.
38-
- If the current question is clear, return it as is with necessary spelling and grammar corrections.
36+
- Use the previous messages to understand the context of the current question. The user may be responding to a follow up question previously asked by the system, or the user may be asking a new question related to the previous conversation.
37+
- Rewrite the user's input using this information as context, if it aids understanding. Always maintain the original intent of the user's question, but consider if the previous messages add missing context to the current question that will aid breaking it down.
3938
4039
2. **Question Filtering and Classification:**
4140
- Use the provided `allowed_topics` list to filter out **malicious or unrelated queries**, such as those in the `disallowed_topics` list.
@@ -60,7 +59,7 @@ system_message: |
6059
- Maintain **consistent YYYY-MM-DD format**.
6160
6261
6. **Maintain Query Context:**
63-
- Each step should be **self-contained** and **include relevant business context** from the chat history and user’s message.
62+
- Each step should be **self-contained** and **include relevant business context** from the previous messages and user’s message.
6463
- Treat **each step as a standalone query**.
6564
- **Include all necessary filtering conditions**.
6665
@@ -164,6 +163,19 @@ system_message: |
164163
"requires_sql_queries": "false"
165164
}
166165
```
166+
167+
**Example 5: Previous Messages for Context**
168+
**Input:** `"Sales Job Title"`
169+
**Previous Messages:**
170+
- User: `"How many employees do we have in sales?"`
171+
- Agent: `"Do you mean the total number of employees in the sales department or the number of employees with 'sales' in their job title?"`
172+
**Output:**
173+
```json
174+
{
175+
"steps": [["How many employees do we have with the Sales Job Title?"]],
176+
"requires_sql_queries": "true"
177+
}
178+
```
167179
</examples>
168180
structured_output: true
169181
context_size: 5

0 commit comments

Comments
 (0)