smoltalk 0.15.3 → 0.17.0
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/README.md +62 -0
- package/dist/clients/anthropic.js +3 -2
- package/dist/clients/baseClient.js +4 -3
- package/dist/clients/google.js +2 -1
- package/dist/clients/llamaCppLoader.js +2 -2
- package/dist/clients/mlx.d.ts +12 -1
- package/dist/clients/mlx.js +23 -0
- package/dist/clients/ollama.d.ts +1 -1
- package/dist/clients/ollama.js +1 -1
- package/dist/clients/openai.d.ts +2 -1
- package/dist/clients/openai.js +5 -3
- package/dist/clients/openaiResponses.js +3 -2
- package/dist/clients/resolveAttachments.js +2 -1
- package/dist/clients/structuredAfterTools.d.ts +36 -0
- package/dist/clients/structuredAfterTools.js +87 -0
- package/dist/clients/validationRetry.d.ts +5 -0
- package/dist/clients/validationRetry.js +24 -0
- package/dist/embed/openai.js +3 -2
- package/dist/files/anthropic.js +2 -2
- package/dist/files/openai.js +2 -2
- package/dist/image/google.js +3 -2
- package/dist/image/openai.js +3 -2
- package/dist/image/openaiCompat.js +3 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/dist/modelRefresh.js +10 -11
- package/dist/models.d.ts +298 -56
- package/dist/models.js +331 -66
- package/dist/platform.browser.d.ts +5 -0
- package/dist/platform.browser.js +13 -0
- package/dist/platform.d.ts +33 -0
- package/dist/platform.js +13 -0
- package/dist/platform.node.d.ts +5 -0
- package/dist/platform.node.js +17 -0
- package/dist/speech/google.js +2 -1
- package/dist/speech/groq.js +1 -0
- package/dist/speech/mlx.js +1 -0
- package/dist/speech/openai.js +1 -1
- package/dist/speech/openaiCompat.js +1 -1
- package/dist/statelogClient.js +2 -1
- package/dist/transcription/google.js +3 -2
- package/dist/transcription/groq.js +1 -0
- package/dist/transcription/openai.js +1 -1
- package/dist/transcription/openaiCompat.js +1 -1
- package/dist/types.d.ts +6 -0
- package/dist/util/attachments.js +2 -1
- package/dist/util/base64.d.ts +17 -0
- package/dist/util/base64.js +59 -0
- package/dist/util/blobRef.js +18 -12
- package/dist/util/fileExtension.d.ts +7 -0
- package/dist/util/fileExtension.js +15 -0
- package/dist/util/provider.d.ts +1 -0
- package/dist/util/provider.js +16 -14
- package/package.json +14 -2
package/dist/modelRefresh.js
CHANGED
|
@@ -2,19 +2,19 @@
|
|
|
2
2
|
* Fetching refreshed model data from a remote or on-disk catalog.
|
|
3
3
|
*
|
|
4
4
|
* Split out of modelData.ts so that module — and therefore models.ts, and
|
|
5
|
-
* therefore the model registry —
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* therefore the model registry — stays pure. This file reaches the platform
|
|
6
|
+
* through #platform: a `file:` URL works on Node and throws in a browser,
|
|
7
|
+
* and `https:` works on both.
|
|
8
8
|
*/
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
9
|
+
import { env, readTextFromFileUrl } from "#platform";
|
|
10
|
+
import { utf8ByteLength } from "./util/base64.js";
|
|
11
11
|
import { parseModelDataBlob } from "./modelData.js";
|
|
12
12
|
import { failure } from "./types/result.js";
|
|
13
13
|
export const DEFAULT_MODEL_DATA_URL = "https://raw.githubusercontent.com/egonSchiele/smoltalk/main/packages/smoltalk/data/model-data.json";
|
|
14
14
|
const MAX_BYTES = 10_000_000;
|
|
15
15
|
const TIMEOUT_MS = 15_000;
|
|
16
16
|
function enforceSizeCap(text) {
|
|
17
|
-
if (
|
|
17
|
+
if (utf8ByteLength(text) > MAX_BYTES) {
|
|
18
18
|
throw new Error(`Model data exceeds the ${MAX_BYTES}-byte cap`);
|
|
19
19
|
}
|
|
20
20
|
return text;
|
|
@@ -24,9 +24,7 @@ function enforceSizeCap(text) {
|
|
|
24
24
|
// integration test). Any other scheme is rejected.
|
|
25
25
|
async function defaultFetcher(url, signal) {
|
|
26
26
|
if (url.startsWith("file://")) {
|
|
27
|
-
|
|
28
|
-
const text = await readFile(path, "utf8");
|
|
29
|
-
return enforceSizeCap(text);
|
|
27
|
+
return enforceSizeCap(await readTextFromFileUrl(url));
|
|
30
28
|
}
|
|
31
29
|
if (url.startsWith("https://")) {
|
|
32
30
|
const res = await fetch(url, { signal });
|
|
@@ -39,8 +37,9 @@ async function defaultFetcher(url, signal) {
|
|
|
39
37
|
}
|
|
40
38
|
export async function refreshModels(opts = {}) {
|
|
41
39
|
let url = DEFAULT_MODEL_DATA_URL;
|
|
42
|
-
|
|
43
|
-
|
|
40
|
+
const fromEnv = env("SMOLTALK_MODEL_DATA_URL");
|
|
41
|
+
if (fromEnv) {
|
|
42
|
+
url = fromEnv;
|
|
44
43
|
}
|
|
45
44
|
if (opts.url) {
|
|
46
45
|
url = opts.url;
|