Skip to content

Commit 135cc9f

Browse files
author
naman-msft
committed
testing ada
1 parent dd8a768 commit 135cc9f

File tree

6 files changed

+164
-35
lines changed

6 files changed

+164
-35
lines changed

tools/ada.py

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1589,8 +1589,8 @@ def get_user_feedback(document_path):
15891589
if current_content != original_content:
15901590
print_message("\n✅ Document changes detected and will be incorporated!")
15911591
# Restore original for proper AI processing
1592-
with open(document_path, "w") as f:
1593-
f.write(original_content)
1592+
# with open(document_path, "w") as f:
1593+
# f.write(original_content)
15941594
# Include the edited content in the result
15951595
result["doc_edit"] = current_content
15961596

@@ -2317,82 +2317,82 @@ def main():
23172317
cli_text = feedback["cli_feedback"]
23182318

23192319
# Special handling for code block type changes
2320-
original_blocks = re.findall(r'```(\w+)', output_file_content)
2321-
revised_blocks = re.findall(r'```(\w+)', revised_content)
2320+
original_blocks = re.findall(r'```(\w+)', output_file_content) # output_file_content is LLM's previous output
2321+
revised_blocks = re.findall(r'```(\w+)', revised_content) # revised_content is user's direct edit
23222322

2323-
# If user changed code block types, make this very explicit in the prompt
23242323
block_changes = ""
23252324
if original_blocks != revised_blocks:
2326-
block_changes = "\n\nIMPORTANT: The user has changed code block types which MUST be preserved exactly as edited:\n"
2325+
block_changes = "\n\nIMPORTANT: The user has changed code block types which MUST be preserved exactly as edited when you update your previous response:\n"
23272326
for i in range(min(len(original_blocks), len(revised_blocks))):
23282327
if original_blocks[i] != revised_blocks[i]:
23292328
block_changes += f"- Changed '```{original_blocks[i]}' to '```{revised_blocks[i]}'\n"
23302329

23312330
# Compute the diff for context
23322331
diff = '\n'.join(difflib.unified_diff(
2333-
output_file_content.splitlines(),
2334-
revised_content.splitlines(),
2332+
output_file_content.splitlines(), # LLM's previous output
2333+
revised_content.splitlines(), # User's direct edit
23352334
fromfile='before.md',
23362335
tofile='after.md',
23372336
lineterm=''
23382337
))
23392338

23402339
# Combine both types of feedback in the prompt
23412340
feedback_prompt = (
2342-
"The user has provided two types of feedback:\n\n"
2343-
"1. DOCUMENT EDITS: They've directly edited the document. Here is the unified diff between the previous and revised version:\n\n"
2341+
"The user has provided two types of feedback on your previous output:\n\n"
2342+
"1. DOCUMENT EDITS: They've directly edited your previous output. Here is the unified diff showing their changes:\n\n"
23442343
f"{diff}\n\n"
23452344
f"{block_changes}"
23462345
"2. ADDITIONAL COMMENTS: They've also provided these additional instructions:"
23472346
f"\n\n{cli_text}\n\n"
2348-
"Incorporate BOTH the document edits AND the additional instructions into the document "
2347+
"Incorporate BOTH the document edits (apply them to your previous output as shown in the diff) AND the additional instructions into an updated document. "
23492348
"STRICTLY follow these user edits - preserve ALL formatting changes EXACTLY as made by the user, "
23502349
"especially changes to code block types (like bash→shell). "
23512350
"DO NOT revert any user edits when creating the updated document. "
23522351
"Ensure all Exec Doc requirements and formatting rules are still met while maintaining the user's exact changes. "
23532352
"ONLY GIVE THE UPDATED DOC, NOTHING ELSE."
23542353
)
23552354

2356-
# Start with the user's edited version as a base
23572355
output_file_content = revised_content
2356+
# REMOVED: output_file_content = revised_content
23582357

23592358
elif doc_edited:
23602359
# Only document edits
2361-
revised_content = feedback["doc_edit"]
2360+
revised_content = feedback["doc_edit"] # User's direct edit
23622361

23632362
# Special handling for code block type changes
2364-
original_blocks = re.findall(r'```(\w+)', output_file_content)
2365-
revised_blocks = re.findall(r'```(\w+)', revised_content)
2363+
original_blocks = re.findall(r'```(\w+)', output_file_content) # output_file_content is LLM's previous output
2364+
revised_blocks = re.findall(r'```(\w+)', revised_content) # revised_content is user's direct edit
23662365

2367-
# If user changed code block types, make this very explicit in the prompt
23682366
block_changes = ""
23692367
if original_blocks != revised_blocks:
2370-
block_changes = "\n\nIMPORTANT: The user has changed code block types which MUST be preserved exactly as edited:\n"
2368+
block_changes = "\n\nIMPORTANT: The user has changed code block types which MUST be preserved exactly as edited when you update your previous response:\n"
23712369
for i in range(min(len(original_blocks), len(revised_blocks))):
23722370
if original_blocks[i] != revised_blocks[i]:
23732371
block_changes += f"- Changed '```{original_blocks[i]}' to '```{revised_blocks[i]}'\n"
23742372

23752373

23762374
diff = '\n'.join(difflib.unified_diff(
2377-
output_file_content.splitlines(),
2378-
revised_content.splitlines(),
2375+
output_file_content.splitlines(), # LLM's previous output
2376+
revised_content.splitlines(), # User's direct edit
23792377
fromfile='before.md',
23802378
tofile='after.md',
23812379
lineterm=''
23822380
))
23832381
feedback_prompt = (
2384-
"The user has directly edited the document. "
2385-
"Here is the unified diff between the previous and revised version:\n\n"
2382+
"The user has directly edited your previous output. "
2383+
"Here is the unified diff showing their changes:\n\n"
23862384
f"{diff}\n\n"
23872385
f"{block_changes}"
2388-
"STRICTLY follow these user edits - preserve ALL formatting changes EXACTLY as made by the user, "
2386+
"STRICTLY follow these user edits - preserve ALL formatting changes EXACTLY as made by the user "
2387+
"when updating your previous output (as shown in the diff). "
23892388
"especially changes to code block types (like bash→shell). "
23902389
"DO NOT revert any user edits when creating the updated document. "
23912390
"Ensure all Exec Doc requirements and formatting rules are still met while maintaining the user's exact changes. "
23922391
"ONLY GIVE THE UPDATED DOC, NOTHING ELSE."
23932392
)
2393+
# REMOVED: output_file_content = revised_content
23942394
output_file_content = revised_content
2395-
2395+
23962396
elif cli_feedback_provided:
23972397
# Only CLI feedback
23982398
cli_text = feedback["cli_feedback"]

0 commit comments

Comments
 (0)