File size: 1,323 Bytes
0983a18
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
"""Fix the broken regex escapes in inference.py parse_action function."""

with open(r'd:\Meta Hackathon\adaptive-world-env\inference.py', 'r', encoding='utf-8') as f:
    content = f.read()

# Exact broken strings as they appear in the file (using \n line endings)
OLD1 = r"        match = re.search(r'```(?:json)?\\s*(\\{.*?\\})\\s*```', llm_output, re.DOTALL)"
NEW1 = r"        match = re.search(r'```(?:json)?\s*(\{.*?\})\s*```', llm_output, re.DOTALL)"

OLD2 = r"            raw_match = re.search(r'\\{.*\\}', llm_output, re.DOTALL)"
NEW2 = r"            raw_match = re.search(r'\{.*\}', llm_output, re.DOTALL)"

print("Looking for OLD1:", repr(OLD1))
print("Found:", OLD1 in content)
print()
print("Looking for OLD2:", repr(OLD2))
print("Found:", OLD2 in content)

if OLD1 in content and OLD2 in content:
    content = content.replace(OLD1, NEW1, 1)
    content = content.replace(OLD2, NEW2, 1)
    with open(r'd:\Meta Hackathon\adaptive-world-env\inference.py', 'w', encoding='utf-8') as f:
        f.write(content)
    print("\nSUCCESS: Fixed both regex lines!")
else:
    # Show the actual lines around parse_action
    idx = content.find("def parse_action")
    snippet = content[idx:idx+600]
    print("\nActual content:")
    for i, line in enumerate(snippet.split('\n')):
        print(f"  {i}: {repr(line)}")