@nemesis-oss/ollama-sdk 1.20.0 → 1.20.1
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/CHANGELOG.md +27 -0
- package/dist/index.cjs +13 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +13 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -230,6 +230,17 @@ interface ModelCapabilities {
|
|
|
230
230
|
*/
|
|
231
231
|
readonly parallelToolCalls: ParallelToolCallBehavior;
|
|
232
232
|
}
|
|
233
|
+
/**
|
|
234
|
+
* Classifies the server behind `baseUrl` from its hostname alone (no network call).
|
|
235
|
+
*
|
|
236
|
+
* - `cloud`: the hosted Ollama Cloud API (`ollama.com`, `*.ollama.com`). This is the only host
|
|
237
|
+
* known to reject structured output (`format`), so only it is refused pre-flight.
|
|
238
|
+
* - `local`: a private-network server — loopback, RFC 1918 / ULA addresses, `*.localhost`,
|
|
239
|
+
* `*.local`, `*.internal`, or a single-label name such as a Docker or Kubernetes service
|
|
240
|
+
* (`http://ollama:11434`).
|
|
241
|
+
* - `unknown`: any other hostname, including self-hosted servers on public domains. Those are
|
|
242
|
+
* not refused for `format`, and they are not assumed to be local either.
|
|
243
|
+
*/
|
|
233
244
|
declare function inferRuntimeMode(baseUrl: string): RuntimeMode;
|
|
234
245
|
/**
|
|
235
246
|
* Scans `/api/show`'s `model_info` for the model's **native** context length
|
package/dist/index.d.ts
CHANGED
|
@@ -230,6 +230,17 @@ interface ModelCapabilities {
|
|
|
230
230
|
*/
|
|
231
231
|
readonly parallelToolCalls: ParallelToolCallBehavior;
|
|
232
232
|
}
|
|
233
|
+
/**
|
|
234
|
+
* Classifies the server behind `baseUrl` from its hostname alone (no network call).
|
|
235
|
+
*
|
|
236
|
+
* - `cloud`: the hosted Ollama Cloud API (`ollama.com`, `*.ollama.com`). This is the only host
|
|
237
|
+
* known to reject structured output (`format`), so only it is refused pre-flight.
|
|
238
|
+
* - `local`: a private-network server — loopback, RFC 1918 / ULA addresses, `*.localhost`,
|
|
239
|
+
* `*.local`, `*.internal`, or a single-label name such as a Docker or Kubernetes service
|
|
240
|
+
* (`http://ollama:11434`).
|
|
241
|
+
* - `unknown`: any other hostname, including self-hosted servers on public domains. Those are
|
|
242
|
+
* not refused for `format`, and they are not assumed to be local either.
|
|
243
|
+
*/
|
|
233
244
|
declare function inferRuntimeMode(baseUrl: string): RuntimeMode;
|
|
234
245
|
/**
|
|
235
246
|
* Scans `/api/show`'s `model_info` for the model's **native** context length
|
package/dist/index.js
CHANGED
|
@@ -1606,16 +1606,23 @@ async function checkEndpointHealth(endpoint, fetchImpl, timeoutMs = 5e3, middlew
|
|
|
1606
1606
|
|
|
1607
1607
|
// src/capabilities/capabilities.ts
|
|
1608
1608
|
function inferRuntimeMode(baseUrl) {
|
|
1609
|
+
let host;
|
|
1609
1610
|
try {
|
|
1610
|
-
|
|
1611
|
-
const host = url.hostname.toLowerCase().replace(/^\[|\]$/g, "");
|
|
1612
|
-
if (host === "localhost" || host === "127.0.0.1" || host === "::1" || host.endsWith(".local") || host.startsWith("192.168.") || host.startsWith("10.")) {
|
|
1613
|
-
return "local";
|
|
1614
|
-
}
|
|
1615
|
-
return "cloud";
|
|
1611
|
+
host = new URL(baseUrl).hostname.toLowerCase().replace(/^\[|\]$/g, "");
|
|
1616
1612
|
} catch {
|
|
1617
1613
|
return "unknown";
|
|
1618
1614
|
}
|
|
1615
|
+
if (host === "ollama.com" || host.endsWith(".ollama.com")) return "cloud";
|
|
1616
|
+
if (isPrivateNetworkHost(host)) return "local";
|
|
1617
|
+
return "unknown";
|
|
1618
|
+
}
|
|
1619
|
+
function isPrivateNetworkHost(host) {
|
|
1620
|
+
if (!host.includes(".") && !host.includes(":")) return true;
|
|
1621
|
+
if (host.endsWith(".localhost") || host.endsWith(".local") || host.endsWith(".internal"))
|
|
1622
|
+
return true;
|
|
1623
|
+
if (host === "::1" || host === "0.0.0.0") return true;
|
|
1624
|
+
if (host.includes(":") && /^f[cd][0-9a-f]{0,2}:/.test(host)) return true;
|
|
1625
|
+
return /^(?:127|10)\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(host) || /^192\.168\.\d{1,3}\.\d{1,3}$/.test(host) || /^172\.(?:1[6-9]|2\d|3[01])\.\d{1,3}\.\d{1,3}$/.test(host);
|
|
1619
1626
|
}
|
|
1620
1627
|
function extractContextLength(modelInfo) {
|
|
1621
1628
|
if (!modelInfo) return void 0;
|