@melaya/runner 1.0.44 → 1.0.46
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/dist/localRagIngest.py +46 -1
- package/localRagIngest.py +46 -1
- package/package.json +1 -1
package/dist/localRagIngest.py
CHANGED
|
@@ -136,12 +136,57 @@ async def _ingest(args) -> int:
|
|
|
136
136
|
# LM Studio exposes an OpenAI-compatible /v1; reuse the OpenAI
|
|
137
137
|
# client pointed at its local endpoint. Dim default = 768 (the
|
|
138
138
|
# FE picker should report the real dim per loaded model).
|
|
139
|
+
# base_url MUST be passed at construction (the OpenAI 1.x
|
|
140
|
+
# AsyncClient bakes the URL into its httpx client during
|
|
141
|
+
# __init__; setting `client.base_url = ...` after the fact is a
|
|
142
|
+
# no-op and the next request resolves an empty hostname →
|
|
143
|
+
# `[Errno 8] nodename nor servname provided`).
|
|
139
144
|
embedder = OpenAITextEmbedding(
|
|
140
145
|
api_key="lmstudio",
|
|
141
146
|
model_name=args.embedder_model,
|
|
142
147
|
dimensions=768,
|
|
148
|
+
base_url="http://localhost:1234/v1",
|
|
143
149
|
)
|
|
144
|
-
|
|
150
|
+
# Diagnostic: surface the URLs the httpx client will actually
|
|
151
|
+
# hit. Prior runs were failing with `[Errno 8] nodename nor
|
|
152
|
+
# servname provided` — the high-level `.base_url` attribute
|
|
153
|
+
# was being set but the underlying httpx client kept the
|
|
154
|
+
# default `api.openai.com` from construction. With the kwarg
|
|
155
|
+
# path these should both be `localhost:1234/v1`.
|
|
156
|
+
try:
|
|
157
|
+
_cb = getattr(embedder.client, "base_url", "?")
|
|
158
|
+
_hb = getattr(getattr(embedder.client, "_client", None), "base_url", "?")
|
|
159
|
+
_emit("lmstudio_init", client_base_url=str(_cb), httpx_base_url=str(_hb))
|
|
160
|
+
except Exception as _exc:
|
|
161
|
+
_emit("lmstudio_init", error=f"{type(_exc).__name__}: {_exc}")
|
|
162
|
+
# Probe the LM Studio HTTP server BEFORE the first embed call
|
|
163
|
+
# so a misconfigured/off server surfaces as one clear error
|
|
164
|
+
# rather than 240 cryptic per-file failures.
|
|
165
|
+
try:
|
|
166
|
+
import urllib.request, json as _json
|
|
167
|
+
with urllib.request.urlopen(
|
|
168
|
+
"http://localhost:1234/v1/models", timeout=3
|
|
169
|
+
) as _r:
|
|
170
|
+
_models = _json.loads(_r.read().decode("utf-8"))
|
|
171
|
+
_names = [m.get("id") for m in _models.get("data", [])]
|
|
172
|
+
_emit("lmstudio_probe", ok=True, models=_names)
|
|
173
|
+
if args.embedder_model not in _names:
|
|
174
|
+
_emit("warning", reason=(
|
|
175
|
+
f"LM Studio is reachable but model "
|
|
176
|
+
f"'{args.embedder_model}' is not loaded. "
|
|
177
|
+
f"Loaded: {_names}"
|
|
178
|
+
))
|
|
179
|
+
except Exception as _exc:
|
|
180
|
+
_emit("lmstudio_probe", ok=False,
|
|
181
|
+
error=f"{type(_exc).__name__}: {_exc}")
|
|
182
|
+
_emit("error", reason=(
|
|
183
|
+
f"Cannot reach LM Studio at http://localhost:1234. "
|
|
184
|
+
f"Make sure the LM Studio app's local server is started "
|
|
185
|
+
f"(Developer → Start Server) and the model "
|
|
186
|
+
f"'{args.embedder_model}' is loaded. Underlying error: "
|
|
187
|
+
f"{type(_exc).__name__}: {_exc}"
|
|
188
|
+
))
|
|
189
|
+
return 6
|
|
145
190
|
# LM Studio's /v1/embeddings rejects the OpenAI-specific
|
|
146
191
|
# `dimensions` kwarg (only OpenAI text-embedding-3 supports
|
|
147
192
|
# output-dim reduction). Strip it before each call so the
|
package/localRagIngest.py
CHANGED
|
@@ -136,12 +136,57 @@ async def _ingest(args) -> int:
|
|
|
136
136
|
# LM Studio exposes an OpenAI-compatible /v1; reuse the OpenAI
|
|
137
137
|
# client pointed at its local endpoint. Dim default = 768 (the
|
|
138
138
|
# FE picker should report the real dim per loaded model).
|
|
139
|
+
# base_url MUST be passed at construction (the OpenAI 1.x
|
|
140
|
+
# AsyncClient bakes the URL into its httpx client during
|
|
141
|
+
# __init__; setting `client.base_url = ...` after the fact is a
|
|
142
|
+
# no-op and the next request resolves an empty hostname →
|
|
143
|
+
# `[Errno 8] nodename nor servname provided`).
|
|
139
144
|
embedder = OpenAITextEmbedding(
|
|
140
145
|
api_key="lmstudio",
|
|
141
146
|
model_name=args.embedder_model,
|
|
142
147
|
dimensions=768,
|
|
148
|
+
base_url="http://localhost:1234/v1",
|
|
143
149
|
)
|
|
144
|
-
|
|
150
|
+
# Diagnostic: surface the URLs the httpx client will actually
|
|
151
|
+
# hit. Prior runs were failing with `[Errno 8] nodename nor
|
|
152
|
+
# servname provided` — the high-level `.base_url` attribute
|
|
153
|
+
# was being set but the underlying httpx client kept the
|
|
154
|
+
# default `api.openai.com` from construction. With the kwarg
|
|
155
|
+
# path these should both be `localhost:1234/v1`.
|
|
156
|
+
try:
|
|
157
|
+
_cb = getattr(embedder.client, "base_url", "?")
|
|
158
|
+
_hb = getattr(getattr(embedder.client, "_client", None), "base_url", "?")
|
|
159
|
+
_emit("lmstudio_init", client_base_url=str(_cb), httpx_base_url=str(_hb))
|
|
160
|
+
except Exception as _exc:
|
|
161
|
+
_emit("lmstudio_init", error=f"{type(_exc).__name__}: {_exc}")
|
|
162
|
+
# Probe the LM Studio HTTP server BEFORE the first embed call
|
|
163
|
+
# so a misconfigured/off server surfaces as one clear error
|
|
164
|
+
# rather than 240 cryptic per-file failures.
|
|
165
|
+
try:
|
|
166
|
+
import urllib.request, json as _json
|
|
167
|
+
with urllib.request.urlopen(
|
|
168
|
+
"http://localhost:1234/v1/models", timeout=3
|
|
169
|
+
) as _r:
|
|
170
|
+
_models = _json.loads(_r.read().decode("utf-8"))
|
|
171
|
+
_names = [m.get("id") for m in _models.get("data", [])]
|
|
172
|
+
_emit("lmstudio_probe", ok=True, models=_names)
|
|
173
|
+
if args.embedder_model not in _names:
|
|
174
|
+
_emit("warning", reason=(
|
|
175
|
+
f"LM Studio is reachable but model "
|
|
176
|
+
f"'{args.embedder_model}' is not loaded. "
|
|
177
|
+
f"Loaded: {_names}"
|
|
178
|
+
))
|
|
179
|
+
except Exception as _exc:
|
|
180
|
+
_emit("lmstudio_probe", ok=False,
|
|
181
|
+
error=f"{type(_exc).__name__}: {_exc}")
|
|
182
|
+
_emit("error", reason=(
|
|
183
|
+
f"Cannot reach LM Studio at http://localhost:1234. "
|
|
184
|
+
f"Make sure the LM Studio app's local server is started "
|
|
185
|
+
f"(Developer → Start Server) and the model "
|
|
186
|
+
f"'{args.embedder_model}' is loaded. Underlying error: "
|
|
187
|
+
f"{type(_exc).__name__}: {_exc}"
|
|
188
|
+
))
|
|
189
|
+
return 6
|
|
145
190
|
# LM Studio's /v1/embeddings rejects the OpenAI-specific
|
|
146
191
|
# `dimensions` kwarg (only OpenAI text-embedding-3 supports
|
|
147
192
|
# output-dim reduction). Strip it before each call so the
|