Skip to content

Commit 20b0831

Browse files
author
naman-msft
committed
made a bunch of changes and testing ada
1 parent ef8d834 commit 20b0831

File tree

268 files changed

+67028
-25
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

268 files changed

+67028
-25
lines changed

tools/Dockerfile

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,4 @@ ENV AZURE_OPENAI_ENDPOINT="your_endpoint_here"
4444
ENV PATH="/root/.local/bin:/usr/local/bin:/usr/bin:/bin:${PATH}"
4545

4646
# Set the entrypoint
47-
<<<<<<< HEAD
4847
ENTRYPOINT ["python", "ada.py"]
49-
=======
50-
ENTRYPOINT ["python", "ada.py"]
51-
>>>>>>> 3c6f8812b0e40832d0a2fca45ce1d0a66d03e41a

tools/abc.py

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
from pathlib import Path
2+
import sys
3+
import os
4+
import shutil
5+
import re
6+
7+
def check_and_rename_folders():
8+
# Get the directory where the script is located
9+
script_dir = Path(sys.path[0])
10+
11+
# Define the untested folder path
12+
untested_dir = script_dir / "untested"
13+
14+
if not untested_dir.exists():
15+
print(f"Error: Untested directory not found at {untested_dir}")
16+
return
17+
18+
print(f"Checking folders in {untested_dir}")
19+
20+
# Get all subfolders
21+
subfolders = [f for f in untested_dir.iterdir() if f.is_dir()]
22+
23+
if not subfolders:
24+
print("No subfolders found in the untested directory.")
25+
return
26+
27+
print(f"Found {len(subfolders)} subfolders.")
28+
29+
# Process each subfolder
30+
for folder in subfolders:
31+
original_name = folder.name
32+
33+
# Check if folder is empty
34+
files = list(folder.iterdir())
35+
if not files:
36+
print(f"⚠️ Empty folder detected: {original_name}")
37+
continue
38+
39+
# Remove the "..." from folder name if present
40+
if original_name.endswith("..."):
41+
new_name = original_name[:-3] # Remove the trailing "..."
42+
new_folder_path = folder.parent / new_name
43+
44+
try:
45+
# Create temporary folder name to avoid potential conflicts
46+
temp_folder_path = folder.parent / f"temp_{original_name}"
47+
folder.rename(temp_folder_path)
48+
temp_folder_path.rename(new_folder_path)
49+
print(f"✓ Renamed folder: {original_name}{new_name}")
50+
# Update the folder reference to the new path
51+
folder = new_folder_path
52+
except Exception as e:
53+
print(f"✗ Error renaming folder {original_name}: {str(e)}")
54+
continue
55+
56+
# Rename files within the folder to match folder name
57+
for file_path in folder.iterdir():
58+
if file_path.is_file():
59+
file_extension = file_path.suffix
60+
new_file_name = f"{folder.name}{file_extension}"
61+
new_file_path = folder / new_file_name
62+
63+
# Skip if the filename already matches
64+
if file_path.name == new_file_name:
65+
continue
66+
67+
try:
68+
file_path.rename(new_file_path)
69+
print(f" ✓ Renamed file: {file_path.name}{new_file_name}")
70+
except Exception as e:
71+
print(f" ✗ Error renaming file {file_path.name}: {str(e)}")
72+
73+
if __name__ == "__main__":
74+
check_and_rename_folders()
75+
print("Processing complete!")

tools/ada.py

Lines changed: 91 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1577,22 +1577,28 @@ def get_user_feedback(document_path):
15771577
original_content = f.read()
15781578

15791579
# Get text feedback if any
1580-
feedback = input("\n>> Your feedback (or press Enter to keep going): ")
1580+
cli_feedback = input("\n>> Your feedback (or press Enter to keep going): ")
15811581

15821582
# Check if file was modified
15831583
with open(document_path, "r") as f:
15841584
current_content = f.read()
15851585

1586+
# Return a dictionary with both types of feedback
1587+
result = {"cli_feedback": cli_feedback.strip() if cli_feedback.strip() else None}
1588+
15861589
if current_content != original_content:
15871590
print_message("\n✅ Document changes detected and will be incorporated!")
15881591
# Restore original for proper AI processing
15891592
with open(document_path, "w") as f:
15901593
f.write(original_content)
1591-
# Return the edited content as feedback
1592-
return f"I've updated the document. Here is my revised version:\n\n{current_content}"
1593-
1594-
# Always return CLI feedback, even if only text
1595-
return feedback if feedback.strip() else None
1594+
# Include the edited content in the result
1595+
result["doc_edit"] = current_content
1596+
1597+
# Return both types of feedback or None if neither provided
1598+
if result["cli_feedback"] or "doc_edit" in result:
1599+
return result
1600+
else:
1601+
return None
15961602

15971603
def get_content_from_url(url):
15981604
"""Extract content from a URL."""
@@ -1696,7 +1702,6 @@ def requires_aks_cluster(doc_path):
16961702
]
16971703
)
16981704
answer = response.choices[0].message.content.strip().lower()
1699-
print(answer)
17001705
return answer.startswith("y")
17011706
else:
17021707
# If 'az aks create' is present, assume AKS cluster is not a prerequisite
@@ -2296,42 +2301,107 @@ def main():
22962301
False
22972302
)
22982303
all_iterations_data.append(iteration_data)
2299-
2304+
23002305
if 'interactive_mode' in locals() and interactive_mode:
23012306
feedback = get_user_feedback(iteration_file)
23022307
if feedback:
23032308
print_message("\nIncorporating your feedback for the next attempt...")
2304-
2305-
# If the user edited the doc, feedback will start with "I've updated the document..."
2306-
if feedback.startswith("I've updated the document. Here is my revised version:"):
2307-
# Extract the revised content
2308-
revised_content = feedback.split("Here is my revised version:", 1)[1].strip()
2309-
# Compute the diff between previous and revised content
2309+
2310+
doc_edited = "doc_edit" in feedback
2311+
cli_feedback_provided = feedback.get("cli_feedback")
2312+
2313+
# Build the feedback prompt based on what the user provided
2314+
if doc_edited and cli_feedback_provided:
2315+
# User provided both types of feedback
2316+
revised_content = feedback["doc_edit"]
2317+
cli_text = feedback["cli_feedback"]
2318+
2319+
# 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)
2322+
2323+
# If user changed code block types, make this very explicit in the prompt
2324+
block_changes = ""
2325+
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"
2327+
for i in range(min(len(original_blocks), len(revised_blocks))):
2328+
if original_blocks[i] != revised_blocks[i]:
2329+
block_changes += f"- Changed '```{original_blocks[i]}' to '```{revised_blocks[i]}'\n"
2330+
2331+
# Compute the diff for context
2332+
diff = '\n'.join(difflib.unified_diff(
2333+
output_file_content.splitlines(),
2334+
revised_content.splitlines(),
2335+
fromfile='before.md',
2336+
tofile='after.md',
2337+
lineterm=''
2338+
))
2339+
2340+
# Combine both types of feedback in the prompt
2341+
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"
2344+
f"{diff}\n\n"
2345+
f"{block_changes}"
2346+
"2. ADDITIONAL COMMENTS: They've also provided these additional instructions:"
2347+
f"\n\n{cli_text}\n\n"
2348+
"Incorporate BOTH the document edits AND the additional instructions into the document "
2349+
"STRICTLY follow these user edits - preserve ALL formatting changes EXACTLY as made by the user, "
2350+
"especially changes to code block types (like bash→shell). "
2351+
"DO NOT revert any user edits when creating the updated document. "
2352+
"Ensure all Exec Doc requirements and formatting rules are still met while maintaining the user's exact changes. "
2353+
"ONLY GIVE THE UPDATED DOC, NOTHING ELSE."
2354+
)
2355+
2356+
# Start with the user's edited version as a base
2357+
output_file_content = revised_content
2358+
2359+
elif doc_edited:
2360+
# Only document edits
2361+
revised_content = feedback["doc_edit"]
2362+
2363+
# 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)
2366+
2367+
# If user changed code block types, make this very explicit in the prompt
2368+
block_changes = ""
2369+
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"
2371+
for i in range(min(len(original_blocks), len(revised_blocks))):
2372+
if original_blocks[i] != revised_blocks[i]:
2373+
block_changes += f"- Changed '```{original_blocks[i]}' to '```{revised_blocks[i]}'\n"
2374+
2375+
23102376
diff = '\n'.join(difflib.unified_diff(
23112377
output_file_content.splitlines(),
23122378
revised_content.splitlines(),
23132379
fromfile='before.md',
23142380
tofile='after.md',
23152381
lineterm=''
23162382
))
2317-
# Use the diff as context for the LLM
23182383
feedback_prompt = (
23192384
"The user has directly edited the document. "
23202385
"Here is the unified diff between the previous and revised version:\n\n"
23212386
f"{diff}\n\n"
2322-
"Update the document to incorporate these changes, ensuring all Exec Doc requirements and formatting rules are still met. "
2387+
f"{block_changes}"
2388+
"STRICTLY follow these user edits - preserve ALL formatting changes EXACTLY as made by the user, "
2389+
"especially changes to code block types (like bash→shell). "
2390+
"DO NOT revert any user edits when creating the updated document. "
2391+
"Ensure all Exec Doc requirements and formatting rules are still met while maintaining the user's exact changes. "
23232392
"ONLY GIVE THE UPDATED DOC, NOTHING ELSE."
23242393
)
2325-
# Use the revised content as the new output_file_content for next run
23262394
output_file_content = revised_content
2327-
else:
2328-
# CLI feedback: pass as explicit instruction
2395+
2396+
elif cli_feedback_provided:
2397+
# Only CLI feedback
2398+
cli_text = feedback["cli_feedback"]
23292399
feedback_prompt = (
23302400
"Please incorporate the following feedback into the document while maintaining all Exec Doc requirements and formatting rules:\n\n"
2331-
f"{feedback}\n\n"
2401+
f"{cli_text}\n\n"
23322402
"ONLY GIVE THE UPDATED DOC, NOTHING ELSE."
23332403
)
2334-
2404+
23352405
# Call the LLM with feedback context
23362406
response = client.chat.completions.create(
23372407
model=deployment_name,

tools/configmap.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: nginx-config
5+
data:
6+
welcome-message: "Hello from configmap"

tools/deployment.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: nginx-demo
5+
spec:
6+
replicas: 1
7+
selector:
8+
matchLabels:
9+
app: nginx-demo
10+
template:
11+
metadata:
12+
labels:
13+
app: nginx-demo
14+
spec:
15+
containers:
16+
- name: nginx
17+
image: nginx:1.21.6
18+
ports:
19+
- containerPort: 80

0 commit comments

Comments
 (0)