-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpatch_fix.py
More file actions
46 lines (35 loc) · 1.25 KB
/
patch_fix.py
File metadata and controls
46 lines (35 loc) · 1.25 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# patch_fix.py
import os
import re
def fix_langchain_adapter():
adapter_path = "/Users/filipdvoran/Developer/mcp-use/mcp_use/adapters/langchain_adapter.py"
# Backup
backup_path = adapter_path + ".backup"
with open(adapter_path, 'r') as f:
content = f.read()
# Vytvor backup
with open(backup_path, 'w') as f:
f.write(content)
print(f"💾 Backup vytvorený: {backup_path}")
# Pridaj Union import ak chýba
if 'from typing import Union' not in content:
# Nájdi existujúci typing import a pridaj Union
if 'from typing import' in content:
content = re.sub(
r'(from typing import[^;\n]*)',
r'\1, Union',
content,
count=1
)
else:
# Pridaj nový import na začiatok
content = "from typing import Union\n" + content
# Oprav union syntax chyby
content = re.sub(r'param_type \| None', 'Union[param_type, type(None)]', content)
content = re.sub(r'(\w+) \| None', r'Union[\1, type(None)]', content)
# Zapíš opravený súbor
with open(adapter_path, 'w') as f:
f.write(content)
print("✅ Súbor opravený!")
if __name__ == "__main__":
fix_langchain_adapter()