Skip to content

Commit fd01622

Browse files
committed
Update prompts and interactions
1 parent a3e444c commit fd01622

File tree

5 files changed

+33
-34
lines changed

5 files changed

+33
-34
lines changed

text_2_sql/autogen/src/autogen_text_2_sql/autogen_text_2_sql.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,16 @@ def get_all_agents(self):
4040
# Get current datetime for the Query Rewrite Agent
4141
current_datetime = datetime.now()
4242

43-
self.message_rewrite_agent = LLMAgentCreator.create(
44-
"message_rewrite_agent", current_datetime=current_datetime
43+
self.user_message_rewrite_agent = LLMAgentCreator.create(
44+
"user_message_rewrite_agent", current_datetime=current_datetime
4545
)
4646

4747
self.parallel_query_solving_agent = ParallelQuerySolvingAgent(**self.kwargs)
4848

4949
self.answer_agent = LLMAgentCreator.create("answer_agent")
5050

5151
agents = [
52-
self.message_rewrite_agent,
52+
self.user_message_rewrite_agent,
5353
self.parallel_query_solving_agent,
5454
self.answer_agent,
5555
]
@@ -73,11 +73,11 @@ def unified_selector(self, messages):
7373
current_agent = messages[-1].source if messages else "user"
7474
decision = None
7575

76-
# If this is the first message start with message_rewrite_agent
76+
# If this is the first message start with user_message_rewrite_agent
7777
if current_agent == "user":
78-
decision = "message_rewrite_agent"
78+
decision = "user_message_rewrite_agent"
7979
# Handle transition after query rewriting
80-
elif current_agent == "message_rewrite_agent":
80+
elif current_agent == "user_message_rewrite_agent":
8181
decision = "parallel_query_solving_agent"
8282
# Handle transition after parallel query solving
8383
elif current_agent == "parallel_query_solving_agent":
@@ -131,7 +131,7 @@ def extract_decomposed_user_messages(self, messages: list) -> list[list[str]]:
131131
sub_message_results = self.parse_message_content(messages[1].content)
132132
logging.info("Decomposed Results: %s", sub_message_results)
133133

134-
return sub_message_results.get("decomposed_messages", [])
134+
return sub_message_results.get("decomposed_user_messages", [])
135135

136136
def extract_disambiguation_request(
137137
self, messages: list
@@ -211,7 +211,7 @@ def extract_answer_payload(self, messages: list) -> AnswerWithSourcesPayload:
211211
answer=f"{answer}\nError processing results: {str(e)}"
212212
)
213213

214-
async def process_message(
214+
async def process_user_message(
215215
self,
216216
message_payload: UserMessagePayload,
217217
chat_history: list[InteractionPayload] = None,
@@ -251,7 +251,7 @@ async def process_message(
251251
payload = None
252252

253253
if isinstance(message, TextMessage):
254-
if message.source == "message_rewrite_agent":
254+
if message.source == "user_message_rewrite_agent":
255255
payload = ProcessingUpdatePayload(
256256
message="Rewriting the query...",
257257
)
@@ -274,7 +274,7 @@ async def process_message(
274274
elif message.messages[-1].source == "parallel_query_solving_agent":
275275
# Load into disambiguation request
276276
payload = self.extract_disambiguation_request(message.messages)
277-
elif message.messages[-1].source == "message_rewrite_agent":
277+
elif message.messages[-1].source == "user_message_rewrite_agent":
278278
# Load into empty response
279279
payload = AnswerWithSourcesPayload(
280280
answer="Apologies, I cannot answer that message as it is not relevant. Please try another message or rephrase your current message."

text_2_sql/autogen/src/autogen_text_2_sql/custom_agents/parallel_query_solving_agent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ async def consume_inner_messages_from_agentic_flow(
177177
return
178178

179179
# Start processing sub-queries
180-
for message_rewrite in message_rewrites["decomposed_messages"]:
180+
for message_rewrite in message_rewrites["decomposed_user_messages"]:
181181
logging.info(f"Processing sub-query: {message_rewrite}")
182182
# Create an instance of the InnerAutoGenText2Sql class
183183
inner_autogen_text_2_sql = InnerAutoGenText2Sql(**self.kwargs)

text_2_sql/autogen/src/autogen_text_2_sql/custom_agents/sql_query_cache_agent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ async def on_messages(
4040
async def on_messages_stream(
4141
self, messages: Sequence[ChatMessage], cancellation_token: CancellationToken
4242
) -> AsyncGenerator[AgentMessage | Response, None]:
43-
# Get the decomposed messages from the message_rewrite_agent
43+
# Get the decomposed messages from the user_message_rewrite_agent
4444
try:
4545
request_details = json.loads(messages[0].content)
4646
injected_parameters = request_details["injected_parameters"]

text_2_sql/text_2_sql_core/src/text_2_sql_core/payloads/interaction_payloads.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class PayloadType(StrEnum):
2121

2222

2323
class InteractionPayloadBase(BaseModel):
24-
model_config = ConfigDict(allow_population_by_field_name=True, extra="ignore")
24+
model_config = ConfigDict(populate_by_name=True, extra="ignore")
2525

2626

2727
class PayloadBase(InteractionPayloadBase):

text_2_sql/text_2_sql_core/src/text_2_sql_core/prompts/user_input_rewrite_agent.yaml renamed to text_2_sql/text_2_sql_core/src/text_2_sql_core/prompts/user_message_rewrite_agent.yaml

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
model: "4o-mini"
2-
description: "An agent that preprocesses user inputs by decomposing complex queries into simpler sub-queries that can be processed independently and then combined."
2+
description: "An agent that preprocesses user inputs by decomposing complex queries into simpler sub-messages that can be processed independently and then combined."
33
system_message: |
44
<role_and_objective>
5-
You are a helpful AI Assistant specializing in breaking down complex questions into simpler sub-queries that can be processed independently and then combined for the final answer. You should identify when a question can be solved through simpler sub-queries and provide clear instructions for combining their results.
5+
You are a helpful AI Assistant specializing in breaking down complex questions into simpler sub-messages that can be processed independently and then combined for the final answer. You should identify when a question can be solved through simpler sub-messages and provide clear instructions for combining their results.
66
</role_and_objective>
77
88
<query_complexity_patterns>
@@ -36,7 +36,7 @@ system_message: |
3636
1. Question Filtering and Classification
3737
- Use the provided list of topics to filter out malicious or unrelated queries.
3838
- Ensure the question is relevant to the system's use case.
39-
- If the question cannot be filtered, output an empty sub-query list in the JSON format. Followed by TERMINATE.
39+
- If the question cannot be filtered, output an empty sub-message list in the JSON format. Followed by TERMINATE.
4040
- For non-database questions like greetings (e.g., "Hello", "What can you do?", "How are you?"), set "all_non_database_query" to true.
4141
- For questions about data (e.g., queries about records, counts, values, comparisons, or any questions that would require database access), set "all_non_database_query" to false.
4242
@@ -51,28 +51,27 @@ system_message: |
5151
- Determine if breaking down would simplify processing
5252
5353
4. Break Down Complex Queries:
54-
- Create independent sub-queries that can be processed separately.
55-
- Each sub-query should be a simple, focused task.
56-
- Group dependent sub-queries together for sequential processing.
57-
- Ensure each sub-query is simple and focused
54+
- Create independent sub-messages that can be processed separately.
55+
- Each sub-message should be a simple, focused task.
56+
- Group dependent sub-messages together for sequential processing.
5857
- Include clear combination instructions
59-
- Preserve all necessary context in each sub-query
58+
- Preserve all necessary context in each sub-message
6059
6160
5. Handle Date References:
6261
- Resolve relative dates using {{ current_datetime }}
6362
- Maintain consistent YYYY-MM-DD format
64-
- Include date context in each sub-query
63+
- Include date context in each sub-message
6564
6665
6. Maintain Query Context:
67-
- Each sub-query should be self-contained
66+
- Each sub-message should be self-contained
6867
- Include all necessary filtering conditions
6968
- Preserve business context
7069
7170
<rules>
7271
1. Always consider if a complex query can be broken down
73-
2. Make sub-queries as simple as possible
72+
2. Make sub-messages as simple as possible
7473
3. Include clear instructions for combining results
75-
4. Preserve all necessary context in each sub-query
74+
4. Preserve all necessary context in each sub-message
7675
5. Resolve any relative dates before decomposition
7776
</rules>
7877
@@ -90,11 +89,11 @@ system_message: |
9089
</topics_to_filter>
9190
9291
<output_format>
93-
Return a JSON object with sub-queries and combination instructions:
92+
Return a JSON object with sub-messages and combination instructions:
9493
{
95-
"sub_questions": [
96-
["<sub_query_1>"],
97-
["<sub_query_2>"],
94+
"decomposed_messages": [
95+
["<sub_message_1>"],
96+
["<sub_message_2>"],
9897
...
9998
],
10099
"combination_logic": "<instructions for combining results>",
@@ -109,7 +108,7 @@ system_message: |
109108
Input: "Which product categories have shown consistent growth quarter over quarter in 2008, and what were their top selling items?"
110109
Output:
111110
{
112-
"sub_questions": [
111+
"decomposed_messages": [
113112
["Calculate quarterly sales totals by product category for 2008", "For these categories, find their top selling products in 2008"]
114113
],
115114
"combination_logic": "First identify growing categories from quarterly analysis, then find their best-selling products",
@@ -121,7 +120,7 @@ system_message: |
121120
Input: "How many orders did we have in 2008?"
122121
Output:
123122
{
124-
"sub_questions": [
123+
"decomposed_messages": [
125124
["How many orders did we have in 2008?"]
126125
],
127126
"combination_logic": "Direct count query, no combination needed",
@@ -133,12 +132,12 @@ system_message: |
133132
Input: "Compare the sales performance of our top 5 products in Europe versus North America, including their market share in each region"
134133
Output:
135134
{
136-
"sub_questions": [
135+
"decomposed_messages": [
137136
["Get total sales by product in European countries"],
138137
["Get total sales by product in North American countries"],
139138
["Calculate total market size for each region", "Find top 5 products by sales in each region"],
140139
],
141-
"combination_logic": "First identify top products in each region, then calculate and compare their market shares. Questions that depend on the result of each sub-query are combined.",
140+
"combination_logic": "First identify top products in each region, then calculate and compare their market shares. Questions that depend on the result of each sub-message are combined.",
142141
"query_type": "complex",
143142
"all_non_database_query": "false"
144143
}
@@ -147,7 +146,7 @@ system_message: |
147146
Input: "Hello, what can you help me with?"
148147
Output:
149148
{
150-
"sub_questions": [
149+
"decomposed_messages": [
151150
["What are your capabilities?"]
152151
],
153152
"combination_logic": "Simple greeting and capability question",

0 commit comments

Comments
 (0)