auto-model-router 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/hermes-plugin/__init__.py +17 -1
- package/package.json +1 -1
|
@@ -35,10 +35,23 @@ BASE_URL = f"http://127.0.0.1:{PORT}/v1"
|
|
|
35
35
|
# The router binary, provided by `npm install -g auto-model-router`.
|
|
36
36
|
BIN = "auto-model-router"
|
|
37
37
|
|
|
38
|
+
# The router's config home. Must be SEPARATE from the default (~/.auto-model-router)
|
|
39
|
+
# which omp's embedded router shares: both read the same ledger + config there,
|
|
40
|
+
# so sharing it would leak omp's routing toasts into this harness (and vice versa)
|
|
41
|
+
# and let the two routers fight over conversation state. Use a hermes-owned home.
|
|
42
|
+
_ROUTER_HOME = os.environ.get(
|
|
43
|
+
"AUTO_MODEL_ROUTER_HOME",
|
|
44
|
+
os.path.join(
|
|
45
|
+
os.environ.get("HERMES_HOME", os.path.expanduser("~")), "auto-model-router"
|
|
46
|
+
),
|
|
47
|
+
)
|
|
48
|
+
|
|
38
49
|
|
|
39
50
|
def _router_running() -> bool:
|
|
40
51
|
try:
|
|
41
|
-
with urllib.request.urlopen(
|
|
52
|
+
with urllib.request.urlopen(
|
|
53
|
+
f"http://127.0.0.1:{PORT}/health", timeout=1
|
|
54
|
+
) as resp:
|
|
42
55
|
return resp.status == 200
|
|
43
56
|
except Exception:
|
|
44
57
|
return False
|
|
@@ -53,6 +66,7 @@ def _spawn_router() -> None:
|
|
|
53
66
|
"auto-model-router is not installed or not on PATH. "
|
|
54
67
|
"Run `npm install -g auto-model-router` first."
|
|
55
68
|
)
|
|
69
|
+
env = {**os.environ, "AUTO_MODEL_ROUTER_HOME": _ROUTER_HOME}
|
|
56
70
|
if sys.platform.startswith("win"):
|
|
57
71
|
# npm installs a `.cmd` shim that cannot be exec'd as a bare argv
|
|
58
72
|
# list; shell=True resolves it through the command shell.
|
|
@@ -62,6 +76,7 @@ def _spawn_router() -> None:
|
|
|
62
76
|
stderr=subprocess.DEVNULL,
|
|
63
77
|
shell=True,
|
|
64
78
|
start_new_session=True,
|
|
79
|
+
env=env,
|
|
65
80
|
)
|
|
66
81
|
else:
|
|
67
82
|
subprocess.Popen(
|
|
@@ -69,6 +84,7 @@ def _spawn_router() -> None:
|
|
|
69
84
|
stdout=subprocess.DEVNULL,
|
|
70
85
|
stderr=subprocess.DEVNULL,
|
|
71
86
|
start_new_session=True,
|
|
87
|
+
env=env,
|
|
72
88
|
)
|
|
73
89
|
# Wait for it to come up (bounded).
|
|
74
90
|
for _ in range(50):
|