@agorapete/wllama 3.5.1-q2.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/.gitmodules +3 -0
- package/.prettierignore +38 -0
- package/AGENTS.md +1 -0
- package/CMakeLists.txt +131 -0
- package/LICENCE +21 -0
- package/README-dev.md +178 -0
- package/README.md +225 -0
- package/README_banner.png +0 -0
- package/assets/screenshot_0.png +0 -0
- package/cpp/generate_glue_prototype.js +115 -0
- package/cpp/glue.hpp +664 -0
- package/cpp/test_glue.cpp +80 -0
- package/cpp/wllama-context.h +1172 -0
- package/cpp/wllama-fs.h +148 -0
- package/cpp/wllama.cpp +187 -0
- package/cpp/wllama.h +6 -0
- package/esm/cache-manager.d.ts +130 -0
- package/esm/debug.d.ts +28 -0
- package/esm/glue/glue.d.ts +22 -0
- package/esm/glue/messages.d.ts +146 -0
- package/esm/huggingface.d.ts +31 -0
- package/esm/index.cjs +3406 -0
- package/esm/index.d.ts +8 -0
- package/esm/index.js +3387 -0
- package/esm/index.min.js +1 -0
- package/esm/index.min.js.map +1 -0
- package/esm/model-manager.d.ts +136 -0
- package/esm/storage/cos.d.ts +36 -0
- package/esm/storage/index.d.ts +33 -0
- package/esm/storage/opfs.d.ts +12 -0
- package/esm/types/oai-compat.d.ts +278 -0
- package/esm/types/types.d.ts +112 -0
- package/esm/utils.d.ts +119 -0
- package/esm/wasm/source-map.d.ts +1 -0
- package/esm/wasm/wllama.wasm +0 -0
- package/esm/wasm-from-cdn.d.ts +8 -0
- package/esm/wllama.d.ts +397 -0
- package/esm/worker.d.ts +92 -0
- package/esm/workers-code/generated.d.ts +4 -0
- package/guides/intro-v2.md +132 -0
- package/guides/intro-v3.1.md +40 -0
- package/guides/intro-v3.md +230 -0
- package/index.ts +1 -0
- package/package.json +71 -0
- package/scripts/bisect_test.sh +33 -0
- package/scripts/build_hf_space.sh +26 -0
- package/scripts/build_source_map.js +269 -0
- package/scripts/build_wasm.sh +19 -0
- package/scripts/build_worker.sh +38 -0
- package/scripts/check_debug_build.js +30 -0
- package/scripts/check_package_size.js +25 -0
- package/scripts/docker-compose.yml +76 -0
- package/scripts/generate_wasm_from_cdn.js +24 -0
- package/scripts/http_server.js +44 -0
- package/scripts/post_build.sh +32 -0
- package/src/cache-manager.ts +358 -0
- package/src/debug.ts +111 -0
- package/src/glue/glue.ts +291 -0
- package/src/glue/messages.ts +773 -0
- package/src/huggingface.ts +151 -0
- package/src/index.ts +8 -0
- package/src/mjs.test.ts +44 -0
- package/src/model-manager.test.ts +200 -0
- package/src/model-manager.ts +359 -0
- package/src/storage/cos.test.ts +83 -0
- package/src/storage/cos.ts +171 -0
- package/src/storage/index.ts +40 -0
- package/src/storage/opfs.ts +119 -0
- package/src/types/oai-compat.ts +342 -0
- package/src/types/types.ts +133 -0
- package/src/utils.test.ts +231 -0
- package/src/utils.ts +403 -0
- package/src/wasm/source-map.ts +7 -0
- package/src/wasm/wllama.js +1 -0
- package/src/wasm/wllama.wasm +0 -0
- package/src/wasm-from-cdn.ts +13 -0
- package/src/wllama.test.ts +392 -0
- package/src/wllama.ts +1138 -0
- package/src/wllama.wgpu.test.ts +62 -0
- package/src/worker.ts +443 -0
- package/src/workers-code/generated.ts +11 -0
- package/src/workers-code/llama-cpp.js +511 -0
- package/src/workers-code/opfs-utils.js +150 -0
- package/tsconfig.build.json +34 -0
- package/tsup.config.ts +23 -0
- package/vitest.config.ts +61 -0
package/tsup.config.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Options } from 'tsup';
|
|
2
|
+
|
|
3
|
+
const baseConfig: Options = {
|
|
4
|
+
entry: ['./index.ts'],
|
|
5
|
+
format: ['cjs', 'esm'],
|
|
6
|
+
outDir: 'esm',
|
|
7
|
+
clean: true,
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
// const nodeConfig: Options = {
|
|
11
|
+
// ...baseConfig,
|
|
12
|
+
// platform: "node",
|
|
13
|
+
// };
|
|
14
|
+
|
|
15
|
+
const browserConfig: Options = {
|
|
16
|
+
...baseConfig,
|
|
17
|
+
platform: 'browser',
|
|
18
|
+
target: 'es2015',
|
|
19
|
+
splitting: false,
|
|
20
|
+
outDir: 'esm',
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export default [browserConfig];
|
package/vitest.config.ts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { defineConfig } from 'vitest/config';
|
|
2
|
+
|
|
3
|
+
const SAFARI = process.env.BROWSER === 'safari';
|
|
4
|
+
const WEBGPU = process.env.WEBGPU === '1';
|
|
5
|
+
const AUTO = process.env.AUTO === '1';
|
|
6
|
+
|
|
7
|
+
const chromeArgsCI = ['disable-gpu', 'no-sandbox', 'disable-setuid-sandbox'];
|
|
8
|
+
const chromeArgsWebGPU = [
|
|
9
|
+
'no-sandbox',
|
|
10
|
+
'disable-setuid-sandbox',
|
|
11
|
+
'enable-unsafe-webgpu',
|
|
12
|
+
'enable-features=WebGPU',
|
|
13
|
+
];
|
|
14
|
+
|
|
15
|
+
export default defineConfig({
|
|
16
|
+
define: {
|
|
17
|
+
__GITHUB_CI__: JSON.stringify(!!process.env.GITHUB_ACTIONS),
|
|
18
|
+
},
|
|
19
|
+
test: {
|
|
20
|
+
...(AUTO ? { watch: false } : {}),
|
|
21
|
+
exclude: [
|
|
22
|
+
'**/node_modules/**',
|
|
23
|
+
'**/esm/**',
|
|
24
|
+
'**/docs/**',
|
|
25
|
+
'**/examples/**',
|
|
26
|
+
...(!WEBGPU ? ['**/src/*.wgpu.test.*'] : []),
|
|
27
|
+
],
|
|
28
|
+
include: WEBGPU ? ['**/src/*.wgpu.test.*'] : ['**/src/**/*.test.*'],
|
|
29
|
+
browser: {
|
|
30
|
+
enabled: true,
|
|
31
|
+
name: process.env.BROWSER ?? 'chromium',
|
|
32
|
+
provider: SAFARI ? 'webdriverio' : 'playwright',
|
|
33
|
+
// https://playwright.dev
|
|
34
|
+
providerOptions: WEBGPU
|
|
35
|
+
? { launch: { args: chromeArgsWebGPU.map((a) => `--${a}`) } }
|
|
36
|
+
: process.env.GITHUB_ACTIONS
|
|
37
|
+
? {
|
|
38
|
+
capabilities: {
|
|
39
|
+
'goog:chromeOptions': {
|
|
40
|
+
args: chromeArgsCI,
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
}
|
|
44
|
+
: SAFARI
|
|
45
|
+
? {
|
|
46
|
+
capabilities: {
|
|
47
|
+
alwaysMatch: { browserName: 'safari' },
|
|
48
|
+
firstMatch: [{}],
|
|
49
|
+
browserName: 'safari',
|
|
50
|
+
},
|
|
51
|
+
}
|
|
52
|
+
: {},
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
server: {
|
|
56
|
+
headers: {
|
|
57
|
+
'Cross-Origin-Embedder-Policy': 'require-corp',
|
|
58
|
+
'Cross-Origin-Opener-Policy': 'same-origin',
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
});
|