@blank-utils/llm 0.1.0 → 0.2.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/dist/backends/transformers.d.ts +62 -0
- package/dist/backends/transformers.d.ts.map +1 -0
- package/dist/backends/webllm.d.ts +70 -0
- package/dist/backends/webllm.d.ts.map +1 -0
- package/dist/core.d.ts +71 -0
- package/dist/core.d.ts.map +1 -0
- package/dist/detect.d.ts +21 -0
- package/dist/detect.d.ts.map +1 -0
- package/dist/helpers.d.ts +35 -0
- package/dist/helpers.d.ts.map +1 -0
- package/dist/{index-mv82xhnr.js → index-yyxm9rp0.js} +4 -4
- package/dist/{index-mv82xhnr.js.map → index-yyxm9rp0.js.map} +2 -2
- package/dist/index.d.ts +27 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +37 -57128
- package/dist/index.js.map +3 -26
- package/dist/react/index.d.ts +310 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +7 -6
- package/dist/react/index.js.map +5 -5
- package/dist/{transformers.web-nb96jrhe.js → transformers.web-1qr6h84s.js} +19 -19
- package/dist/{transformers.web-nb96jrhe.js.map → transformers.web-1qr6h84s.js.map} +2 -2
- package/dist/types.d.ts +178 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +37 -20
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transformers.js Backend Implementation
|
|
3
|
+
* Fallback backend using HuggingFace Transformers.js with ONNX runtime
|
|
4
|
+
*/
|
|
5
|
+
import type { LLMProvider, ChatMessage, GenerateOptions, StreamCallback, LoadProgressCallback, Backend, Device, Quantization } from '../types';
|
|
6
|
+
/**
|
|
7
|
+
* Default model for Transformers.js backend
|
|
8
|
+
* Using Qwen2.5 0.5B as it's well-tested with ONNX
|
|
9
|
+
*/
|
|
10
|
+
export declare const DEFAULT_TRANSFORMERS_MODEL = "onnx-community/Qwen2.5-0.5B-Instruct";
|
|
11
|
+
/**
|
|
12
|
+
* Transformers.js compatible models (must have ONNX weights)
|
|
13
|
+
* These are specifically converted for browser use via transformers.js
|
|
14
|
+
*
|
|
15
|
+
* @see https://huggingface.co/onnx-community for more models
|
|
16
|
+
*/
|
|
17
|
+
export declare const TRANSFORMERS_MODELS: {
|
|
18
|
+
readonly 'qwen-2.5-0.5b': "onnx-community/Qwen2.5-0.5B-Instruct";
|
|
19
|
+
readonly 'qwen-2.5-1.5b': "onnx-community/Qwen2.5-1.5B-Instruct";
|
|
20
|
+
readonly 'qwen-2.5-coder-0.5b': "onnx-community/Qwen2.5-Coder-0.5B-Instruct";
|
|
21
|
+
readonly 'qwen-2.5-coder-1.5b': "onnx-community/Qwen2.5-Coder-1.5B-Instruct";
|
|
22
|
+
readonly 'qwen-3-0.6b': "onnx-community/Qwen3-0.6B-ONNX";
|
|
23
|
+
readonly 'smollm2-135m': "HuggingFaceTB/SmolLM2-135M-Instruct";
|
|
24
|
+
readonly 'smollm2-360m': "HuggingFaceTB/SmolLM2-360M-Instruct";
|
|
25
|
+
readonly 'smollm2-1.7b': "HuggingFaceTB/SmolLM2-1.7B-Instruct";
|
|
26
|
+
readonly 'phi-3-mini': "Xenova/Phi-3-mini-4k-instruct";
|
|
27
|
+
readonly tinyllama: "Xenova/TinyLlama-1.1B-Chat-v1.0";
|
|
28
|
+
};
|
|
29
|
+
export type TransformersModelAlias = keyof typeof TRANSFORMERS_MODELS;
|
|
30
|
+
/**
|
|
31
|
+
* Model size estimates for UI display
|
|
32
|
+
*/
|
|
33
|
+
export declare const TRANSFORMERS_MODEL_SIZES: Record<TransformersModelAlias, string>;
|
|
34
|
+
/**
|
|
35
|
+
* Configuration for TransformersProvider
|
|
36
|
+
*/
|
|
37
|
+
export interface TransformersProviderConfig {
|
|
38
|
+
device?: Device;
|
|
39
|
+
quantization?: Quantization;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Transformers.js provider implementation
|
|
43
|
+
*/
|
|
44
|
+
export declare class TransformersProvider implements LLMProvider {
|
|
45
|
+
readonly backend: Backend;
|
|
46
|
+
private pipeline;
|
|
47
|
+
private currentModel;
|
|
48
|
+
private device;
|
|
49
|
+
private quantization;
|
|
50
|
+
constructor(config?: TransformersProviderConfig);
|
|
51
|
+
get isReady(): boolean;
|
|
52
|
+
get modelId(): string | null;
|
|
53
|
+
load(modelId: string, onProgress?: LoadProgressCallback): Promise<void>;
|
|
54
|
+
chat(messages: ChatMessage[], options?: GenerateOptions): Promise<string>;
|
|
55
|
+
stream(messages: ChatMessage[], onToken: StreamCallback, options?: GenerateOptions): Promise<string>;
|
|
56
|
+
unload(): Promise<void>;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Create a Transformers.js provider instance
|
|
60
|
+
*/
|
|
61
|
+
export declare function createTransformersProvider(config?: TransformersProviderConfig): TransformersProvider;
|
|
62
|
+
//# sourceMappingURL=transformers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transformers.d.ts","sourceRoot":"","sources":["../../src/backends/transformers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACV,WAAW,EACX,WAAW,EACX,eAAe,EACf,cAAc,EACd,oBAAoB,EAEpB,OAAO,EACP,MAAM,EACN,YAAY,EACb,MAAM,UAAU,CAAC;AAKlB;;;GAGG;AACH,eAAO,MAAM,0BAA0B,yCAAyC,CAAC;AAEjF;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;;CAoBtB,CAAC;AAEX,MAAM,MAAM,sBAAsB,GAAG,MAAM,OAAO,mBAAmB,CAAC;AAEtE;;GAEG;AACH,eAAO,MAAM,wBAAwB,EAAE,MAAM,CAAC,sBAAsB,EAAE,MAAM,CAW3E,CAAC;AAkGF;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B;AAED;;GAEG;AACH,qBAAa,oBAAqB,YAAW,WAAW;IACtD,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAkB;IAE3C,OAAO,CAAC,QAAQ,CAAuC;IACvD,OAAO,CAAC,YAAY,CAAuB;IAC3C,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,YAAY,CAAe;gBAEvB,MAAM,GAAE,0BAA+B;IAKnD,IAAI,OAAO,IAAI,OAAO,CAErB;IAED,IAAI,OAAO,IAAI,MAAM,GAAG,IAAI,CAE3B;IAEK,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;IAkDvE,IAAI,CAAC,QAAQ,EAAE,WAAW,EAAE,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC;IAoBzE,MAAM,CACV,QAAQ,EAAE,WAAW,EAAE,EACvB,OAAO,EAAE,cAAc,EACvB,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,MAAM,CAAC;IAgCZ,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;CAI9B;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,MAAM,CAAC,EAAE,0BAA0B,GAAG,oBAAoB,CAEpG"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WebLLM Backend Implementation
|
|
3
|
+
* Primary backend using MLC's WebLLM for high-performance inference
|
|
4
|
+
*/
|
|
5
|
+
import type { LLMProvider, ChatMessage, GenerateOptions, StreamCallback, LoadProgressCallback, Backend } from '../types';
|
|
6
|
+
/**
|
|
7
|
+
* Default model for WebLLM backend
|
|
8
|
+
* Using Phi 3.5 Mini as it's well-tested and reasonably sized
|
|
9
|
+
*/
|
|
10
|
+
export declare const DEFAULT_WEBLLM_MODEL = "Phi-3.5-mini-instruct-q4f16_1-MLC";
|
|
11
|
+
/**
|
|
12
|
+
* Popular WebLLM model options with correct MLC model IDs
|
|
13
|
+
* These IDs must match exactly what's in web-llm's prebuiltAppConfig
|
|
14
|
+
*
|
|
15
|
+
* @see https://github.com/mlc-ai/web-llm/blob/main/src/config.ts
|
|
16
|
+
*/
|
|
17
|
+
export declare const WEBLLM_MODELS: {
|
|
18
|
+
readonly 'llama-3.2-1b': "Llama-3.2-1B-Instruct-q4f16_1-MLC";
|
|
19
|
+
readonly 'llama-3.2-3b': "Llama-3.2-3B-Instruct-q4f16_1-MLC";
|
|
20
|
+
readonly 'llama-3.1-8b': "Llama-3.1-8B-Instruct-q4f16_1-MLC";
|
|
21
|
+
readonly 'llama-3.1-8b-1k': "Llama-3.1-8B-Instruct-q4f16_1-MLC-1k";
|
|
22
|
+
readonly 'phi-3.5-mini': "Phi-3.5-mini-instruct-q4f16_1-MLC";
|
|
23
|
+
readonly 'phi-3.5-mini-1k': "Phi-3.5-mini-instruct-q4f16_1-MLC-1k";
|
|
24
|
+
readonly 'phi-3.5-vision': "Phi-3.5-vision-instruct-q4f16_1-MLC";
|
|
25
|
+
readonly 'qwen-2.5-0.5b': "Qwen2.5-0.5B-Instruct-q4f16_1-MLC";
|
|
26
|
+
readonly 'qwen-2.5-1.5b': "Qwen2.5-1.5B-Instruct-q4f16_1-MLC";
|
|
27
|
+
readonly 'qwen-2.5-3b': "Qwen2.5-3B-Instruct-q4f16_1-MLC";
|
|
28
|
+
readonly 'qwen-2.5-7b': "Qwen2.5-7B-Instruct-q4f16_1-MLC";
|
|
29
|
+
readonly 'qwen-2.5-coder-0.5b': "Qwen2.5-Coder-0.5B-Instruct-q4f16_1-MLC";
|
|
30
|
+
readonly 'qwen-2.5-coder-1.5b': "Qwen2.5-Coder-1.5B-Instruct-q4f16_1-MLC";
|
|
31
|
+
readonly 'qwen-3-0.6b': "Qwen3-0.6B-q4f16_1-MLC";
|
|
32
|
+
readonly 'qwen-3-1.7b': "Qwen3-1.7B-q4f16_1-MLC";
|
|
33
|
+
readonly 'qwen-3-4b': "Qwen3-4B-q4f16_1-MLC";
|
|
34
|
+
readonly 'qwen-3-8b': "Qwen3-8B-q4f16_1-MLC";
|
|
35
|
+
readonly 'gemma-2-2b': "gemma-2-2b-it-q4f16_1-MLC";
|
|
36
|
+
readonly 'gemma-2-2b-1k': "gemma-2-2b-it-q4f16_1-MLC-1k";
|
|
37
|
+
readonly 'gemma-2-9b': "gemma-2-9b-it-q4f16_1-MLC";
|
|
38
|
+
readonly 'smollm2-135m': "SmolLM2-135M-Instruct-q0f16-MLC";
|
|
39
|
+
readonly 'smollm2-360m': "SmolLM2-360M-Instruct-q4f16_1-MLC";
|
|
40
|
+
readonly 'smollm2-1.7b': "SmolLM2-1.7B-Instruct-q4f16_1-MLC";
|
|
41
|
+
readonly 'mistral-7b': "Mistral-7B-Instruct-v0.3-q4f16_1-MLC";
|
|
42
|
+
readonly 'deepseek-r1-qwen-7b': "DeepSeek-R1-Distill-Qwen-7B-q4f16_1-MLC";
|
|
43
|
+
readonly 'deepseek-r1-llama-8b': "DeepSeek-R1-Distill-Llama-8B-q4f16_1-MLC";
|
|
44
|
+
readonly 'hermes-3-llama-3.2-3b': "Hermes-3-Llama-3.2-3B-q4f16_1-MLC";
|
|
45
|
+
readonly 'hermes-3-llama-3.1-8b': "Hermes-3-Llama-3.1-8B-q4f16_1-MLC";
|
|
46
|
+
};
|
|
47
|
+
export type WebLLMModelAlias = keyof typeof WEBLLM_MODELS;
|
|
48
|
+
/**
|
|
49
|
+
* Model size estimates for UI display
|
|
50
|
+
*/
|
|
51
|
+
export declare const WEBLLM_MODEL_SIZES: Record<WebLLMModelAlias, string>;
|
|
52
|
+
/**
|
|
53
|
+
* WebLLM provider implementation
|
|
54
|
+
*/
|
|
55
|
+
export declare class WebLLMProvider implements LLMProvider {
|
|
56
|
+
readonly backend: Backend;
|
|
57
|
+
private engine;
|
|
58
|
+
private currentModel;
|
|
59
|
+
get isReady(): boolean;
|
|
60
|
+
get modelId(): string | null;
|
|
61
|
+
load(modelId: string, onProgress?: LoadProgressCallback): Promise<void>;
|
|
62
|
+
chat(messages: ChatMessage[], options?: GenerateOptions): Promise<string>;
|
|
63
|
+
stream(messages: ChatMessage[], onToken: StreamCallback, options?: GenerateOptions): Promise<string>;
|
|
64
|
+
unload(): Promise<void>;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Create a WebLLM provider instance
|
|
68
|
+
*/
|
|
69
|
+
export declare function createWebLLMProvider(): WebLLMProvider;
|
|
70
|
+
//# sourceMappingURL=webllm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webllm.d.ts","sourceRoot":"","sources":["../../src/backends/webllm.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACV,WAAW,EACX,WAAW,EACX,eAAe,EACf,cAAc,EACd,oBAAoB,EAEpB,OAAO,EACR,MAAM,UAAU,CAAC;AAMlB;;;GAGG;AACH,eAAO,MAAM,oBAAoB,sCAAsC,CAAC;AAExE;;;;;GAKG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgDhB,CAAC;AAEX,MAAM,MAAM,gBAAgB,GAAG,MAAM,OAAO,aAAa,CAAC;AAE1D;;GAEG;AACH,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,gBAAgB,EAAE,MAAM,CA6B/D,CAAC;AAYF;;GAEG;AACH,qBAAa,cAAe,YAAW,WAAW;IAChD,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAY;IAErC,OAAO,CAAC,MAAM,CAA0B;IACxC,OAAO,CAAC,YAAY,CAAuB;IAE3C,IAAI,OAAO,IAAI,OAAO,CAErB;IAED,IAAI,OAAO,IAAI,MAAM,GAAG,IAAI,CAE3B;IAEK,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;IAwBvE,IAAI,CAAC,QAAQ,EAAE,WAAW,EAAE,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC;IAmBzE,MAAM,CACV,QAAQ,EAAE,WAAW,EAAE,EACvB,OAAO,EAAE,cAAc,EACvB,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,MAAM,CAAC;IA8BZ,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;CAO9B;AAED;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,cAAc,CAErD"}
|
package/dist/core.d.ts
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core LLM functionality - Separated from index.ts to avoid circular dependencies
|
|
3
|
+
* with React integration.
|
|
4
|
+
*
|
|
5
|
+
* @module local-llm/core
|
|
6
|
+
*/
|
|
7
|
+
export type { Backend, Device, Quantization, LLMConfig, MessageRole, ChatMessage, StreamCallback, LoadProgress, LoadProgressCallback, GenerateOptions, LLMProvider as LLMProviderInterface, AttachOptions, BrowserCapabilities, } from './types';
|
|
8
|
+
export { checkWebGPU, checkWasm, detectCapabilities, logCapabilities } from './detect';
|
|
9
|
+
export { WebLLMProvider, createWebLLMProvider, DEFAULT_WEBLLM_MODEL, WEBLLM_MODELS, } from './backends/webllm';
|
|
10
|
+
export { TransformersProvider, createTransformersProvider, DEFAULT_TRANSFORMERS_MODEL, TRANSFORMERS_MODELS, } from './backends/transformers';
|
|
11
|
+
export { createOutputStreamer, attachToElements, createChatUI, createLoadingIndicator, } from './helpers';
|
|
12
|
+
import type { LLMConfig, ChatMessage, GenerateOptions, StreamCallback, AttachOptions } from './types';
|
|
13
|
+
/**
|
|
14
|
+
* Main LLM interface with simplified API
|
|
15
|
+
*/
|
|
16
|
+
export interface LocalLLM {
|
|
17
|
+
/**
|
|
18
|
+
* Whether the model is loaded and ready
|
|
19
|
+
*/
|
|
20
|
+
readonly isReady: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* The current model ID
|
|
23
|
+
*/
|
|
24
|
+
readonly modelId: string | null;
|
|
25
|
+
/**
|
|
26
|
+
* The backend being used
|
|
27
|
+
*/
|
|
28
|
+
readonly backend: 'webllm' | 'transformers';
|
|
29
|
+
/**
|
|
30
|
+
* Generate a chat response
|
|
31
|
+
*/
|
|
32
|
+
chat(messages: ChatMessage[] | string, options?: GenerateOptions): Promise<string>;
|
|
33
|
+
/**
|
|
34
|
+
* Generate with streaming output
|
|
35
|
+
*/
|
|
36
|
+
stream(messages: ChatMessage[] | string, onToken: StreamCallback, options?: GenerateOptions): Promise<string>;
|
|
37
|
+
/**
|
|
38
|
+
* Attach to input/output elements for automatic generation
|
|
39
|
+
*/
|
|
40
|
+
attachToInput(inputSelector: string | HTMLInputElement | HTMLTextAreaElement, outputSelector: string | HTMLElement, options?: AttachOptions): () => void;
|
|
41
|
+
/**
|
|
42
|
+
* Unload the model and free resources
|
|
43
|
+
*/
|
|
44
|
+
unload(): Promise<void>;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Create a LocalLLM instance
|
|
48
|
+
*
|
|
49
|
+
* @param config - Configuration options
|
|
50
|
+
* @returns Promise that resolves to a LocalLLM instance once the model is loaded
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```typescript
|
|
54
|
+
* // Simple usage with defaults
|
|
55
|
+
* const llm = await createLLM();
|
|
56
|
+
*
|
|
57
|
+
* // With configuration
|
|
58
|
+
* const llm = await createLLM({
|
|
59
|
+
* model: 'phi-3-mini',
|
|
60
|
+
* backend: 'webllm',
|
|
61
|
+
* systemPrompt: 'You are a helpful assistant.',
|
|
62
|
+
* onLoadProgress: (p) => console.log(p.progress)
|
|
63
|
+
* });
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
export declare function createLLM(config?: LLMConfig): Promise<LocalLLM>;
|
|
67
|
+
/**
|
|
68
|
+
* Quick helper to test if the current browser supports WebGPU
|
|
69
|
+
*/
|
|
70
|
+
export declare function isWebGPUSupported(): Promise<boolean>;
|
|
71
|
+
//# sourceMappingURL=core.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,YAAY,EACV,OAAO,EACP,MAAM,EACN,YAAY,EACZ,SAAS,EACT,WAAW,EACX,WAAW,EACX,cAAc,EACd,YAAY,EACZ,oBAAoB,EACpB,eAAe,EACf,WAAW,IAAI,oBAAoB,EACnC,aAAa,EACb,mBAAmB,GACpB,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAGvF,OAAO,EACL,cAAc,EACd,oBAAoB,EACpB,oBAAoB,EACpB,aAAa,GACd,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,oBAAoB,EACpB,0BAA0B,EAC1B,0BAA0B,EAC1B,mBAAmB,GACpB,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EACL,oBAAoB,EACpB,gBAAgB,EAChB,YAAY,EACZ,sBAAsB,GACvB,MAAM,WAAW,CAAC;AAGnB,OAAO,KAAK,EACV,SAAS,EACT,WAAW,EACX,eAAe,EACf,cAAc,EACd,aAAa,EACd,MAAM,SAAS,CAAC;AAOjB;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAE1B;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAEhC;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,QAAQ,GAAG,cAAc,CAAC;IAE5C;;OAEG;IACH,IAAI,CACF,QAAQ,EAAE,WAAW,EAAE,GAAG,MAAM,EAChC,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,MAAM,CAAC,CAAC;IAEnB;;OAEG;IACH,MAAM,CACJ,QAAQ,EAAE,WAAW,EAAE,GAAG,MAAM,EAChC,OAAO,EAAE,cAAc,EACvB,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,MAAM,CAAC,CAAC;IAEnB;;OAEG;IACH,aAAa,CACX,aAAa,EAAE,MAAM,GAAG,gBAAgB,GAAG,mBAAmB,EAC9D,cAAc,EAAE,MAAM,GAAG,WAAW,EACpC,OAAO,CAAC,EAAE,aAAa,GACtB,MAAM,IAAI,CAAC;IAEd;;OAEG;IACH,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACzB;AAwBD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,SAAS,CAAC,MAAM,GAAE,SAAc,GAAG,OAAO,CAAC,QAAQ,CAAC,CAyFzE;AAED;;GAEG;AACH,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,OAAO,CAAC,CAG1D"}
|
package/dist/detect.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser capability detection utilities
|
|
3
|
+
*/
|
|
4
|
+
import type { BrowserCapabilities } from './types';
|
|
5
|
+
/**
|
|
6
|
+
* Check if WebGPU is available in the current browser
|
|
7
|
+
*/
|
|
8
|
+
export declare function checkWebGPU(): Promise<boolean>;
|
|
9
|
+
/**
|
|
10
|
+
* Check if WebAssembly is available
|
|
11
|
+
*/
|
|
12
|
+
export declare function checkWasm(): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Detect browser capabilities and recommend backend/device
|
|
15
|
+
*/
|
|
16
|
+
export declare function detectCapabilities(): Promise<BrowserCapabilities>;
|
|
17
|
+
/**
|
|
18
|
+
* Log capability detection results to console
|
|
19
|
+
*/
|
|
20
|
+
export declare function logCapabilities(): Promise<BrowserCapabilities>;
|
|
21
|
+
//# sourceMappingURL=detect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detect.d.ts","sourceRoot":"","sources":["../src/detect.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAmB,MAAM,SAAS,CAAC;AAEpE;;GAEG;AACH,wBAAsB,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC,CAapD;AAED;;GAEG;AACH,wBAAgB,SAAS,IAAI,OAAO,CAYnC;AAED;;GAEG;AACH,wBAAsB,kBAAkB,IAAI,OAAO,CAAC,mBAAmB,CAAC,CAuBvE;AAED;;GAEG;AACH,wBAAsB,eAAe,IAAI,OAAO,CAAC,mBAAmB,CAAC,CAUpE"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DOM Helper Utilities
|
|
3
|
+
* Easy integration with HTML input/output elements
|
|
4
|
+
*/
|
|
5
|
+
import type { StreamCallback, AttachOptions } from './types';
|
|
6
|
+
/**
|
|
7
|
+
* Creates a streaming callback that updates an output element
|
|
8
|
+
*/
|
|
9
|
+
export declare function createOutputStreamer(outputSelector: string | HTMLElement, options?: {
|
|
10
|
+
append?: boolean;
|
|
11
|
+
scrollToBottom?: boolean;
|
|
12
|
+
}): StreamCallback;
|
|
13
|
+
/**
|
|
14
|
+
* Attach LLM to input/output elements with automatic handling
|
|
15
|
+
*/
|
|
16
|
+
export declare function attachToElements(inputSelector: string | HTMLInputElement | HTMLTextAreaElement, outputSelector: string | HTMLElement, generateFn: (input: string, onToken: StreamCallback) => Promise<string>, options?: AttachOptions): () => void;
|
|
17
|
+
/**
|
|
18
|
+
* Create a simple chat UI in a container
|
|
19
|
+
*/
|
|
20
|
+
export declare function createChatUI(containerSelector: string | HTMLElement): {
|
|
21
|
+
input: HTMLTextAreaElement;
|
|
22
|
+
output: HTMLDivElement;
|
|
23
|
+
sendButton: HTMLButtonElement;
|
|
24
|
+
cleanup: () => void;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Create a loading indicator
|
|
28
|
+
*/
|
|
29
|
+
export declare function createLoadingIndicator(containerSelector: string | HTMLElement): {
|
|
30
|
+
show: () => void;
|
|
31
|
+
hide: () => void;
|
|
32
|
+
setProgress: (percent: number, status?: string) => void;
|
|
33
|
+
element: HTMLDivElement;
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAgB7D;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,cAAc,EAAE,MAAM,GAAG,WAAW,EACpC,OAAO,CAAC,EAAE;IACR,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B,GACA,cAAc,CAoBhB;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,aAAa,EAAE,MAAM,GAAG,gBAAgB,GAAG,mBAAmB,EAC9D,cAAc,EAAE,MAAM,GAAG,WAAW,EACpC,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,KAAK,OAAO,CAAC,MAAM,CAAC,EACvE,OAAO,CAAC,EAAE,aAAa,GACtB,MAAM,IAAI,CA8DZ;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,iBAAiB,EAAE,MAAM,GAAG,WAAW,GAAG;IACrE,KAAK,EAAE,mBAAmB,CAAC;IAC3B,MAAM,EAAE,cAAc,CAAC;IACvB,UAAU,EAAE,iBAAiB,CAAC;IAC9B,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,CAyBA;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,iBAAiB,EAAE,MAAM,GAAG,WAAW,GAAG;IAC/E,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,WAAW,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACxD,OAAO,EAAE,cAAc,CAAC;CACzB,CAwCA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import"./index-55gkckqf.js";
|
|
2
2
|
|
|
3
|
-
// node_modules
|
|
4
|
-
var __dirname = "/Users/blank/Desktop/CREATE/local-llm/node_modules
|
|
3
|
+
// node_modules/@mlc-ai/web-llm/lib/index.js
|
|
4
|
+
var __dirname = "/Users/blank/Desktop/CREATE/local-llm/node_modules/@mlc-ai/web-llm/lib";
|
|
5
5
|
var require$$3 = "MLC_DUMMY_REQUIRE_VAR";
|
|
6
6
|
var require$$4 = "MLC_DUMMY_REQUIRE_VAR";
|
|
7
7
|
function getDefaultExportFromCjs(x) {
|
|
@@ -20994,5 +20994,5 @@ export {
|
|
|
20994
20994
|
Chat
|
|
20995
20995
|
};
|
|
20996
20996
|
|
|
20997
|
-
//# debugId=
|
|
20998
|
-
//# sourceMappingURL=index-
|
|
20997
|
+
//# debugId=5B043401B07A910764756E2164756E21
|
|
20998
|
+
//# sourceMappingURL=index-yyxm9rp0.js.map
|