Add patch_httpx.py to fix httpx vs httpx2 mismatch in Anthropic/MiniMax client
Browse files- src/patch_httpx.py +32 -0
src/patch_httpx.py
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
|
| 3 |
+
target = "/usr/local/lib/hermes-agent/agent/azure_identity_adapter.py"
|
| 4 |
+
if os.path.exists(target):
|
| 5 |
+
with open(target, "r") as f:
|
| 6 |
+
content = f.read()
|
| 7 |
+
|
| 8 |
+
old_block = """ try:
|
| 9 |
+
import httpx
|
| 10 |
+
except ImportError as exc:"""
|
| 11 |
+
|
| 12 |
+
new_block = """ _httpx = None
|
| 13 |
+
try:
|
| 14 |
+
import anthropic._base_client as _abc
|
| 15 |
+
_httpx = getattr(_abc, "httpx", None) or getattr(_abc, "httpx2", None)
|
| 16 |
+
except Exception:
|
| 17 |
+
pass
|
| 18 |
+
if _httpx is None:
|
| 19 |
+
try:
|
| 20 |
+
import httpx2 as _httpx
|
| 21 |
+
except ImportError:
|
| 22 |
+
import httpx as _httpx
|
| 23 |
+
httpx = _httpx
|
| 24 |
+
try:
|
| 25 |
+
pass
|
| 26 |
+
except ImportError as exc:"""
|
| 27 |
+
|
| 28 |
+
if old_block in content:
|
| 29 |
+
content = content.replace(old_block, new_block, 1)
|
| 30 |
+
with open(target, "w") as f:
|
| 31 |
+
f.write(content)
|
| 32 |
+
print("✅ Patched azure_identity_adapter.py for httpx2 compatibility")
|