@fugood/bricks-project 2.24.0-beta.2 → 2.24.0-beta.21
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/compile/action-name-map.ts +14 -0
- package/compile/index.ts +377 -129
- package/package.json +8 -3
- package/skills/bricks-project/rules/architecture-patterns.md +7 -0
- package/skills/bricks-project/rules/automations.md +74 -28
- package/skills/bricks-project/rules/buttress.md +9 -6
- package/tools/deploy.ts +39 -10
- package/tools/mcp-server.ts +10 -877
- package/tools/mcp-tools/compile.ts +91 -0
- package/tools/mcp-tools/huggingface.ts +762 -0
- package/tools/mcp-tools/icons.ts +60 -0
- package/tools/mcp-tools/lottie.ts +102 -0
- package/tools/mcp-tools/media.ts +110 -0
- package/tools/postinstall.ts +121 -33
- package/tools/preview-main.mjs +12 -8
- package/tools/pull.ts +37 -19
- package/tsconfig.json +16 -0
- package/types/animation.ts +4 -0
- package/types/automation.ts +3 -0
- package/types/brick-base.ts +1 -1
- package/types/bricks/Camera.ts +34 -7
- package/types/bricks/Chart.ts +1 -1
- package/types/bricks/GenerativeMedia.ts +6 -6
- package/types/bricks/Icon.ts +3 -3
- package/types/bricks/Image.ts +4 -4
- package/types/bricks/Items.ts +7 -7
- package/types/bricks/Lottie.ts +4 -4
- package/types/bricks/Maps.ts +4 -4
- package/types/bricks/QrCode.ts +4 -4
- package/types/bricks/Rect.ts +4 -4
- package/types/bricks/RichText.ts +3 -3
- package/types/bricks/Rive.ts +1 -1
- package/types/bricks/Slideshow.ts +4 -4
- package/types/bricks/Svg.ts +3 -3
- package/types/bricks/Text.ts +4 -4
- package/types/bricks/TextInput.ts +11 -7
- package/types/bricks/Video.ts +4 -4
- package/types/bricks/VideoStreaming.ts +3 -3
- package/types/bricks/WebRtcStream.ts +1 -1
- package/types/bricks/WebView.ts +4 -4
- package/types/canvas.ts +4 -2
- package/types/common.ts +9 -4
- package/types/data-calc-command.ts +2 -0
- package/types/data-calc.ts +1 -0
- package/types/data.ts +2 -0
- package/types/generators/AlarmClock.ts +5 -5
- package/types/generators/Assistant.ts +57 -12
- package/types/generators/BleCentral.ts +12 -4
- package/types/generators/BlePeripheral.ts +5 -5
- package/types/generators/CanvasMap.ts +4 -4
- package/types/generators/CastlesPay.ts +3 -3
- package/types/generators/DataBank.ts +31 -4
- package/types/generators/File.ts +63 -14
- package/types/generators/GraphQl.ts +3 -3
- package/types/generators/Http.ts +27 -8
- package/types/generators/HttpServer.ts +9 -9
- package/types/generators/Information.ts +2 -2
- package/types/generators/Intent.ts +8 -2
- package/types/generators/Iterator.ts +6 -6
- package/types/generators/Keyboard.ts +18 -8
- package/types/generators/LlmAnthropicCompat.ts +12 -6
- package/types/generators/LlmAppleBuiltin.ts +6 -6
- package/types/generators/LlmGgml.ts +75 -25
- package/types/generators/LlmMlx.ts +210 -0
- package/types/generators/LlmOnnx.ts +18 -9
- package/types/generators/LlmOpenAiCompat.ts +22 -6
- package/types/generators/LlmQualcommAiEngine.ts +32 -8
- package/types/generators/Mcp.ts +332 -17
- package/types/generators/McpServer.ts +38 -11
- package/types/generators/MediaFlow.ts +26 -8
- package/types/generators/MqttBroker.ts +10 -4
- package/types/generators/MqttClient.ts +11 -5
- package/types/generators/Question.ts +6 -6
- package/types/generators/RealtimeTranscription.ts +70 -11
- package/types/generators/RerankerGgml.ts +23 -9
- package/types/generators/SerialPort.ts +6 -6
- package/types/generators/SoundPlayer.ts +2 -2
- package/types/generators/SoundRecorder.ts +5 -5
- package/types/generators/SpeechToTextGgml.ts +34 -14
- package/types/generators/SpeechToTextOnnx.ts +8 -8
- package/types/generators/SpeechToTextPlatform.ts +4 -4
- package/types/generators/SqLite.ts +10 -6
- package/types/generators/Step.ts +3 -3
- package/types/generators/SttAppleBuiltin.ts +6 -6
- package/types/generators/Tcp.ts +5 -5
- package/types/generators/TcpServer.ts +7 -7
- package/types/generators/TextToSpeechApple.ts +1 -1
- package/types/generators/TextToSpeechAppleBuiltin.ts +5 -5
- package/types/generators/TextToSpeechGgml.ts +8 -8
- package/types/generators/TextToSpeechOnnx.ts +9 -9
- package/types/generators/TextToSpeechOpenAiLike.ts +5 -5
- package/types/generators/ThermalPrinter.ts +6 -6
- package/types/generators/Tick.ts +3 -3
- package/types/generators/Udp.ts +9 -4
- package/types/generators/VadGgml.ts +39 -10
- package/types/generators/VadOnnx.ts +31 -8
- package/types/generators/VadTraditional.ts +15 -9
- package/types/generators/VectorStore.ts +26 -9
- package/types/generators/Watchdog.ts +11 -6
- package/types/generators/WebCrawler.ts +5 -5
- package/types/generators/WebRtc.ts +17 -11
- package/types/generators/WebSocket.ts +5 -5
- package/types/generators/index.ts +1 -0
- package/types/subspace.ts +1 -0
- package/types/system.ts +1 -1
- package/utils/calc.ts +12 -8
- package/utils/event-props.ts +104 -87
- package/utils/id.ts +4 -0
- package/api/index.ts +0 -1
- package/api/instance.ts +0 -213
|
@@ -119,7 +119,7 @@ Default property:
|
|
|
119
119
|
}
|
|
120
120
|
>
|
|
121
121
|
| DataLink
|
|
122
|
-
/* Tools for function calling following Anthropic format
|
|
122
|
+
/* Tools for function calling following Anthropic format
|
|
123
123
|
Format: Array of objects with {name, description, input_schema} structure
|
|
124
124
|
See: https://docs.anthropic.com/en/docs/tool-use */
|
|
125
125
|
completionTools?: Array<{} | DataLink> | DataLink
|
|
@@ -153,15 +153,21 @@ Default property:
|
|
|
153
153
|
}
|
|
154
154
|
outlets?: {
|
|
155
155
|
/* Evaluating outlet */
|
|
156
|
-
isEvaluating?: () => Data
|
|
156
|
+
isEvaluating?: () => Data<boolean>
|
|
157
157
|
/* Completion result outlet */
|
|
158
|
-
completionResult?: () => Data
|
|
158
|
+
completionResult?: () => Data<string>
|
|
159
159
|
/* Completion details outlet */
|
|
160
|
-
completionDetails?: () => Data
|
|
160
|
+
completionDetails?: () => Data<{
|
|
161
|
+
model?: string
|
|
162
|
+
stop_reason?: string
|
|
163
|
+
usage?: { [key: string]: any }
|
|
164
|
+
content?: Array<any>
|
|
165
|
+
[key: string]: any
|
|
166
|
+
}>
|
|
161
167
|
}
|
|
162
168
|
}
|
|
163
169
|
|
|
164
|
-
/* LLM inference using Anthropic-compatible API endpoints
|
|
170
|
+
/* LLM inference using Anthropic-compatible API endpoints
|
|
165
171
|
|
|
166
172
|
## Features
|
|
167
173
|
- Compatible with Anthropic API format
|
|
@@ -171,7 +177,7 @@ Default property:
|
|
|
171
177
|
export type GeneratorAnthropicLLM = Generator &
|
|
172
178
|
GeneratorAnthropicLLMDef & {
|
|
173
179
|
templateKey: 'GENERATOR_ANTHROPIC_LLM'
|
|
174
|
-
switches
|
|
180
|
+
switches?: Array<
|
|
175
181
|
SwitchDef &
|
|
176
182
|
GeneratorAnthropicLLMDef & {
|
|
177
183
|
conds?: Array<{
|
|
@@ -100,17 +100,17 @@ Default property:
|
|
|
100
100
|
}
|
|
101
101
|
outlets?: {
|
|
102
102
|
/* Context state outlet */
|
|
103
|
-
contextState?: () => Data
|
|
103
|
+
contextState?: () => Data<string>
|
|
104
104
|
/* Evaluating outlet */
|
|
105
|
-
isEvaluating?: () => Data
|
|
105
|
+
isEvaluating?: () => Data<boolean>
|
|
106
106
|
/* Completion result outlet */
|
|
107
|
-
completionResult?: () => Data
|
|
107
|
+
completionResult?: () => Data<string>
|
|
108
108
|
/* Last token outlet */
|
|
109
|
-
completionLastToken?: () => Data
|
|
109
|
+
completionLastToken?: () => Data<string>
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
-
/* LLM inference using Apple Intelligence on iOS/tvOS 26+
|
|
113
|
+
/* LLM inference using Apple Intelligence on iOS/tvOS 26+
|
|
114
114
|
|
|
115
115
|
## Features
|
|
116
116
|
- Native Apple Intelligence integration
|
|
@@ -121,7 +121,7 @@ Default property:
|
|
|
121
121
|
export type GeneratorAppleLLM = Generator &
|
|
122
122
|
GeneratorAppleLLMDef & {
|
|
123
123
|
templateKey: 'GENERATOR_APPLE_LLM'
|
|
124
|
-
switches
|
|
124
|
+
switches?: Array<
|
|
125
125
|
SwitchDef &
|
|
126
126
|
GeneratorAppleLLMDef & {
|
|
127
127
|
conds?: Array<{
|
|
@@ -459,10 +459,10 @@ Default property:
|
|
|
459
459
|
}
|
|
460
460
|
*/
|
|
461
461
|
property?: {
|
|
462
|
-
/* Initialize the Llama context on generator initialization
|
|
462
|
+
/* Initialize the Llama context on generator initialization
|
|
463
463
|
Please note that it will take some RAM depending on the model size */
|
|
464
464
|
init?: boolean | DataLink
|
|
465
|
-
/* The URL or path of model
|
|
465
|
+
/* The URL or path of model
|
|
466
466
|
We used GGUF format model, please refer to https://github.com/ggerganov/llama.cpp/tree/master#description */
|
|
467
467
|
modelUrl?: string | DataLink
|
|
468
468
|
/* Hash type of model */
|
|
@@ -477,10 +477,10 @@ Default property:
|
|
|
477
477
|
mmprojHashType?: 'md5' | 'sha256' | 'sha1' | DataLink
|
|
478
478
|
/* Hash of mmproj file (PREVIEW FEATURE) */
|
|
479
479
|
mmprojHash?: string | DataLink
|
|
480
|
-
/* Minimum tokens for image encoding in multimodal (PREVIEW FEATURE)
|
|
480
|
+
/* Minimum tokens for image encoding in multimodal (PREVIEW FEATURE)
|
|
481
481
|
Useful for dynamic resolution models (e.g. Qwen-VL). Default: -1 (auto) */
|
|
482
482
|
imageMinTokens?: number | DataLink
|
|
483
|
-
/* Maximum tokens for image encoding in multimodal (PREVIEW FEATURE)
|
|
483
|
+
/* Maximum tokens for image encoding in multimodal (PREVIEW FEATURE)
|
|
484
484
|
Limit tokens for dynamic resolution models to balance speed vs. detail. Default: -1 (auto) */
|
|
485
485
|
imageMaxTokens?: number | DataLink
|
|
486
486
|
/* Chat Template (Jinja format) to override the default template from model */
|
|
@@ -493,13 +493,13 @@ Default property:
|
|
|
493
493
|
uBatchSize?: number | DataLink
|
|
494
494
|
/* Number of threads */
|
|
495
495
|
maxThreads?: number | DataLink
|
|
496
|
-
/* Accelerator variant (Only for desktop)
|
|
496
|
+
/* Accelerator variant (Only for desktop)
|
|
497
497
|
`default` - CPU / Metal (macOS)
|
|
498
498
|
`vulkan` - Use Vulkan
|
|
499
499
|
`cuda` - Use CUDA
|
|
500
500
|
`snapdragon` - Use OpenCL/Hexagon of Qualcomm Snapdragon */
|
|
501
501
|
accelVariant?: 'default' | 'vulkan' | 'cuda' | 'snapdragon' | DataLink
|
|
502
|
-
/* Devices. For example:
|
|
502
|
+
/* Devices. For example:
|
|
503
503
|
|
|
504
504
|
Metal or CPU for iOS/tvOS/MacOS
|
|
505
505
|
OpenCL or CPU for Android
|
|
@@ -534,7 +534,7 @@ Default property:
|
|
|
534
534
|
transformScriptCode?: string | DataLink
|
|
535
535
|
/* Variables used in Transform Script (object) */
|
|
536
536
|
transformScriptVariables?: {} | DataLink
|
|
537
|
-
/* Session save mode
|
|
537
|
+
/* Session save mode
|
|
538
538
|
`none` - No session saving
|
|
539
539
|
`prompt` - Save session when prompt processed
|
|
540
540
|
`completion` - Save session when completion finished
|
|
@@ -546,7 +546,7 @@ Default property:
|
|
|
546
546
|
sessionRemain?: number | DataLink
|
|
547
547
|
/* TODO:loran_gqarms_norm_epsrope_freq_baserope_freq_scale */
|
|
548
548
|
completionMode?: 'auto' | 'chat' | 'text' | DataLink
|
|
549
|
-
/* Tools for chat mode using OpenAI-compatible function calling format
|
|
549
|
+
/* Tools for chat mode using OpenAI-compatible function calling format
|
|
550
550
|
Format: Array of objects with {type, function: {name, description, parameters}} structure
|
|
551
551
|
See: https://platform.openai.com/docs/guides/function-calling */
|
|
552
552
|
completionTools?: Array<{} | DataLink> | DataLink
|
|
@@ -566,7 +566,7 @@ Default property:
|
|
|
566
566
|
| DataLink
|
|
567
567
|
/* Prompt (text mode) */
|
|
568
568
|
completionPrompt?: string | DataLink
|
|
569
|
-
/* Media paths to be used in the prompt template (PREVIEW FEATURE)
|
|
569
|
+
/* Media paths to be used in the prompt template (PREVIEW FEATURE)
|
|
570
570
|
In prompt, use `<__media__>` for position of media content */
|
|
571
571
|
completionPromptMediaPaths?: Array<string | DataLink> | DataLink
|
|
572
572
|
/* Data to be used in the prompt template (e.g. `Hello ${name}`). Supports nested data, such as `Hello ${user.name}`. */
|
|
@@ -594,7 +594,7 @@ Default property:
|
|
|
594
594
|
completionNow?: string | DataLink
|
|
595
595
|
/* Additional keyword arguments for chat template (object) */
|
|
596
596
|
completionChatTemplateKwargs?: {} | DataLink
|
|
597
|
-
/* Use reasoning format for enhanced response structure
|
|
597
|
+
/* Use reasoning format for enhanced response structure
|
|
598
598
|
`auto` - Auto-determine the reasoning format of the model
|
|
599
599
|
`none` - Disable reasoning format */
|
|
600
600
|
completionUseReasoningFormat?: 'auto' | 'none' | DataLink
|
|
@@ -678,35 +678,85 @@ Default property:
|
|
|
678
678
|
}
|
|
679
679
|
outlets?: {
|
|
680
680
|
/* Context state */
|
|
681
|
-
contextState?: () => Data
|
|
681
|
+
contextState?: () => Data<string>
|
|
682
682
|
/* Context load progress (0-100) */
|
|
683
|
-
contextLoadProgress?: () => Data
|
|
683
|
+
contextLoadProgress?: () => Data<number>
|
|
684
684
|
/* Context details */
|
|
685
|
-
contextDetails?: () => Data
|
|
685
|
+
contextDetails?: () => Data<{
|
|
686
|
+
state?: string
|
|
687
|
+
contextId?: string
|
|
688
|
+
gpu?: string
|
|
689
|
+
reasonNoGPU?: string
|
|
690
|
+
model?: { [key: string]: any }
|
|
691
|
+
isMultimodalEnabled?: boolean
|
|
692
|
+
[key: string]: any
|
|
693
|
+
}>
|
|
686
694
|
/* Session details */
|
|
687
|
-
sessions?: () => Data
|
|
695
|
+
sessions?: () => Data<{
|
|
696
|
+
last_session_id?: string
|
|
697
|
+
sessions?: Array<{
|
|
698
|
+
id?: string
|
|
699
|
+
type?: string
|
|
700
|
+
prompt?: string
|
|
701
|
+
sessionKey?: string
|
|
702
|
+
model_instance_id?: string
|
|
703
|
+
tokens_evaluated?: number
|
|
704
|
+
t?: number
|
|
705
|
+
[key: string]: any
|
|
706
|
+
}>
|
|
707
|
+
last_custom_session_id?: string
|
|
708
|
+
custom_sessions?: Array<{
|
|
709
|
+
id?: string
|
|
710
|
+
type?: string
|
|
711
|
+
prompt?: string
|
|
712
|
+
sessionKey?: string
|
|
713
|
+
model_instance_id?: string
|
|
714
|
+
tokens_evaluated?: number
|
|
715
|
+
t?: number
|
|
716
|
+
[key: string]: any
|
|
717
|
+
}>
|
|
718
|
+
[key: string]: any
|
|
719
|
+
}>
|
|
688
720
|
/* Is evaluating */
|
|
689
|
-
isEvaluating?: () => Data
|
|
721
|
+
isEvaluating?: () => Data<boolean>
|
|
690
722
|
/* Tokenize result */
|
|
691
|
-
tokenizeResult?: () => Data
|
|
723
|
+
tokenizeResult?: () => Data<Array<number>>
|
|
692
724
|
/* Detokenize result */
|
|
693
|
-
detokenizeResult?: () => Data
|
|
725
|
+
detokenizeResult?: () => Data<string>
|
|
694
726
|
/* Last formatted prompt (messages or prompt) */
|
|
695
|
-
completionLastFormattedPrompt?: () => Data
|
|
727
|
+
completionLastFormattedPrompt?: () => Data<string>
|
|
696
728
|
/* Last completion token */
|
|
697
|
-
completionLastToken?: () => Data
|
|
729
|
+
completionLastToken?: () => Data<string>
|
|
698
730
|
/* Completion result */
|
|
699
|
-
completionResult?: () => Data
|
|
731
|
+
completionResult?: () => Data<string>
|
|
700
732
|
/* Reasoning content from model responses */
|
|
701
|
-
completionReasoningContent?: () => Data
|
|
733
|
+
completionReasoningContent?: () => Data<string>
|
|
702
734
|
/* Full context (Prompt + Completion) */
|
|
703
|
-
completionFullContext?: () => Data
|
|
735
|
+
completionFullContext?: () => Data<string>
|
|
704
736
|
/* Inference result details */
|
|
705
|
-
completionResultDetails?: () => Data
|
|
737
|
+
completionResultDetails?: () => Data<{
|
|
738
|
+
prompt?: string
|
|
739
|
+
full_context?: string
|
|
740
|
+
text?: string
|
|
741
|
+
content?: string
|
|
742
|
+
reasoning_content?: string
|
|
743
|
+
token?: string
|
|
744
|
+
tool_calls?: Array<{
|
|
745
|
+
id?: string
|
|
746
|
+
type?: string
|
|
747
|
+
function?: {
|
|
748
|
+
name?: string
|
|
749
|
+
arguments?: string
|
|
750
|
+
[key: string]: any
|
|
751
|
+
}
|
|
752
|
+
[key: string]: any
|
|
753
|
+
}>
|
|
754
|
+
[key: string]: any
|
|
755
|
+
}>
|
|
706
756
|
}
|
|
707
757
|
}
|
|
708
758
|
|
|
709
|
-
/* Local Large Language Model (LLM) inference based on GGML and [llama.cpp](https://github.com/ggerganov/llama.cpp)
|
|
759
|
+
/* Local Large Language Model (LLM) inference based on GGML and [llama.cpp](https://github.com/ggerganov/llama.cpp)
|
|
710
760
|
|
|
711
761
|
## Notice
|
|
712
762
|
- The device RAM must be larger than 8GB
|
|
@@ -720,7 +770,7 @@ Default property:
|
|
|
720
770
|
export type GeneratorLLM = Generator &
|
|
721
771
|
GeneratorLLMDef & {
|
|
722
772
|
templateKey: 'GENERATOR_LLM'
|
|
723
|
-
switches
|
|
773
|
+
switches?: Array<
|
|
724
774
|
SwitchDef &
|
|
725
775
|
GeneratorLLMDef & {
|
|
726
776
|
conds?: Array<{
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
/* Auto generated by build script */
|
|
2
|
+
import type { SwitchCondInnerStateCurrentCanvas, SwitchCondData, SwitchDef } from '../switch'
|
|
3
|
+
import type { Data, DataLink } from '../data'
|
|
4
|
+
import type {
|
|
5
|
+
Brick,
|
|
6
|
+
Generator,
|
|
7
|
+
EventAction,
|
|
8
|
+
ActionWithDataParams,
|
|
9
|
+
ActionWithParams,
|
|
10
|
+
Action,
|
|
11
|
+
EventProperty,
|
|
12
|
+
} from '../common'
|
|
13
|
+
|
|
14
|
+
/* Load model */
|
|
15
|
+
export type GeneratorMlxLLMActionLoadModel = ActionWithParams & {
|
|
16
|
+
__actionName: 'GENERATOR_MLX_LLM_LOAD_MODEL'
|
|
17
|
+
params?: Array<
|
|
18
|
+
| {
|
|
19
|
+
input: 'modelId'
|
|
20
|
+
value?: string | DataLink | EventProperty
|
|
21
|
+
mapping?: string
|
|
22
|
+
}
|
|
23
|
+
| {
|
|
24
|
+
input: 'vlm'
|
|
25
|
+
value?: boolean | DataLink | EventProperty
|
|
26
|
+
mapping?: string
|
|
27
|
+
}
|
|
28
|
+
>
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/* Run text completion */
|
|
32
|
+
export type GeneratorMlxLLMActionCompletion = ActionWithParams & {
|
|
33
|
+
__actionName: 'GENERATOR_MLX_LLM_COMPLETION'
|
|
34
|
+
params?: Array<
|
|
35
|
+
| {
|
|
36
|
+
input: 'messages'
|
|
37
|
+
value?: Array<any> | DataLink | EventProperty
|
|
38
|
+
mapping?: string
|
|
39
|
+
}
|
|
40
|
+
| {
|
|
41
|
+
input: 'tools'
|
|
42
|
+
value?: Array<any> | DataLink | EventProperty
|
|
43
|
+
mapping?: string
|
|
44
|
+
}
|
|
45
|
+
| {
|
|
46
|
+
input: 'maxTokens'
|
|
47
|
+
value?: number | DataLink | EventProperty
|
|
48
|
+
mapping?: string
|
|
49
|
+
}
|
|
50
|
+
| {
|
|
51
|
+
input: 'temperature'
|
|
52
|
+
value?: number | DataLink | EventProperty
|
|
53
|
+
mapping?: string
|
|
54
|
+
}
|
|
55
|
+
| {
|
|
56
|
+
input: 'topP'
|
|
57
|
+
value?: number | DataLink | EventProperty
|
|
58
|
+
mapping?: string
|
|
59
|
+
}
|
|
60
|
+
| {
|
|
61
|
+
input: 'repetitionPenalty'
|
|
62
|
+
value?: number | DataLink | EventProperty
|
|
63
|
+
mapping?: string
|
|
64
|
+
}
|
|
65
|
+
>
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/* Stop text completion */
|
|
69
|
+
export type GeneratorMlxLLMActionStopCompletion = Action & {
|
|
70
|
+
__actionName: 'GENERATOR_MLX_LLM_STOP_COMPLETION'
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/* Release model context */
|
|
74
|
+
export type GeneratorMlxLLMActionReleaseContext = Action & {
|
|
75
|
+
__actionName: 'GENERATOR_MLX_LLM_RELEASE_CONTEXT'
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
interface GeneratorMlxLLMDef {
|
|
79
|
+
/*
|
|
80
|
+
Default property:
|
|
81
|
+
{
|
|
82
|
+
"init": false,
|
|
83
|
+
"modelId": "mlx-community/Qwen3-4B-4bit",
|
|
84
|
+
"vlm": false,
|
|
85
|
+
"completionMessages": [
|
|
86
|
+
{
|
|
87
|
+
"role": "system",
|
|
88
|
+
"content": "You are a helpful assistant."
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
"role": "user",
|
|
92
|
+
"content": "Hello"
|
|
93
|
+
}
|
|
94
|
+
],
|
|
95
|
+
"completionMaxTokens": 1024,
|
|
96
|
+
"completionTemperature": 0.6,
|
|
97
|
+
"completionTopP": 1,
|
|
98
|
+
"completionRepetitionContextSize": 20
|
|
99
|
+
}
|
|
100
|
+
*/
|
|
101
|
+
property?: {
|
|
102
|
+
/* Initialize model on generator init */
|
|
103
|
+
init?: boolean | DataLink
|
|
104
|
+
/* HuggingFace model ID or local path to model directory
|
|
105
|
+
e.g. "mlx-community/Qwen3-4B-4bit" */
|
|
106
|
+
modelId?: string | DataLink
|
|
107
|
+
/* Enable Vision Language Model (VLM) mode */
|
|
108
|
+
vlm?: boolean | DataLink
|
|
109
|
+
/* Chat messages (if first message has role 'system', it will be used as system prompt) */
|
|
110
|
+
completionMessages?:
|
|
111
|
+
| Array<
|
|
112
|
+
| DataLink
|
|
113
|
+
| {
|
|
114
|
+
role?: string | DataLink
|
|
115
|
+
content?: string | DataLink
|
|
116
|
+
}
|
|
117
|
+
>
|
|
118
|
+
| DataLink
|
|
119
|
+
/* Maximum tokens to generate */
|
|
120
|
+
completionMaxTokens?: number | DataLink
|
|
121
|
+
/* Temperature (0.0 to 2.0) */
|
|
122
|
+
completionTemperature?: number | DataLink
|
|
123
|
+
/* Top P sampling */
|
|
124
|
+
completionTopP?: number | DataLink
|
|
125
|
+
/* Repetition penalty factor */
|
|
126
|
+
completionRepetitionPenalty?: number | DataLink
|
|
127
|
+
/* Number of tokens to consider for repetition penalty */
|
|
128
|
+
completionRepetitionContextSize?: number | DataLink
|
|
129
|
+
/* Maximum KV cache size (context window). Uses rotating cache to limit memory.
|
|
130
|
+
Smaller values (e.g. 512) use less memory but lower quality.
|
|
131
|
+
Larger values (e.g. 4096) use more memory but better quality.
|
|
132
|
+
Leave empty for unlimited (model default). */
|
|
133
|
+
contextSize?: number | DataLink
|
|
134
|
+
/* Enable thinking mode (model-dependent, e.g. Qwen3).
|
|
135
|
+
When enabled, passes enable_thinking=true to the chat template.
|
|
136
|
+
The model may output reasoning in <think> tags which will be extracted as reasoning_content. */
|
|
137
|
+
completionEnableThinking?: boolean | DataLink
|
|
138
|
+
/* Additional keyword arguments for chat template (object) */
|
|
139
|
+
completionChatTemplateKwargs?: {} | DataLink
|
|
140
|
+
/* Tools for chat mode using OpenAI-compatible function calling format
|
|
141
|
+
Format: Array of objects with {type, function: {name, description, parameters}} structure
|
|
142
|
+
See: https://platform.openai.com/docs/guides/function-calling */
|
|
143
|
+
completionTools?: Array<{} | DataLink> | DataLink
|
|
144
|
+
/* Buttress connection settings for remote inference */
|
|
145
|
+
buttressConnectionSettings?:
|
|
146
|
+
| DataLink
|
|
147
|
+
| {
|
|
148
|
+
enabled?: boolean | DataLink
|
|
149
|
+
url?: string | DataLink
|
|
150
|
+
fallbackType?: 'use-local' | 'no-op' | DataLink
|
|
151
|
+
strategy?: 'prefer-local' | 'prefer-buttress' | 'prefer-best' | DataLink
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
events?: {
|
|
155
|
+
/* Event triggered when context state changes */
|
|
156
|
+
onContextStateChange?: Array<EventAction>
|
|
157
|
+
/* Error event */
|
|
158
|
+
onError?: Array<EventAction>
|
|
159
|
+
/* Completion streaming event (emitted for each token) */
|
|
160
|
+
onCompletion?: Array<EventAction>
|
|
161
|
+
/* Completion finished event */
|
|
162
|
+
onCompletionFinished?: Array<EventAction>
|
|
163
|
+
}
|
|
164
|
+
outlets?: {
|
|
165
|
+
/* Context state */
|
|
166
|
+
contextState?: () => Data<string>
|
|
167
|
+
/* Model load progress (0-1) */
|
|
168
|
+
loadProgress?: () => Data<number>
|
|
169
|
+
/* Whether the model is evaluating */
|
|
170
|
+
isEvaluating?: () => Data<boolean>
|
|
171
|
+
/* Completion result */
|
|
172
|
+
completionResult?: () => Data<string>
|
|
173
|
+
/* Last token */
|
|
174
|
+
completionLastToken?: () => Data<string>
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/* On-device LLM inference using Apple MLX framework on iOS/tvOS
|
|
179
|
+
|
|
180
|
+
## Features
|
|
181
|
+
- Powered by MLX (Apple's ML framework optimized for Apple Silicon)
|
|
182
|
+
- Download models directly from HuggingFace Hub
|
|
183
|
+
- Streaming token generation
|
|
184
|
+
- Supports LLM and VLM (Vision Language Models)
|
|
185
|
+
- Requires iOS 17+ or tvOS 17+ */
|
|
186
|
+
export type GeneratorMlxLLM = Generator &
|
|
187
|
+
GeneratorMlxLLMDef & {
|
|
188
|
+
templateKey: 'GENERATOR_MLX_LLM'
|
|
189
|
+
switches?: Array<
|
|
190
|
+
SwitchDef &
|
|
191
|
+
GeneratorMlxLLMDef & {
|
|
192
|
+
conds?: Array<{
|
|
193
|
+
method: '==' | '!=' | '>' | '<' | '>=' | '<='
|
|
194
|
+
cond:
|
|
195
|
+
| SwitchCondInnerStateCurrentCanvas
|
|
196
|
+
| SwitchCondData
|
|
197
|
+
| {
|
|
198
|
+
__typename: 'SwitchCondInnerStateOutlet'
|
|
199
|
+
outlet:
|
|
200
|
+
| 'contextState'
|
|
201
|
+
| 'loadProgress'
|
|
202
|
+
| 'isEvaluating'
|
|
203
|
+
| 'completionResult'
|
|
204
|
+
| 'completionLastToken'
|
|
205
|
+
value: any
|
|
206
|
+
}
|
|
207
|
+
}>
|
|
208
|
+
}
|
|
209
|
+
>
|
|
210
|
+
}
|
|
@@ -110,7 +110,7 @@ Default property:
|
|
|
110
110
|
audios?: Array<string | DataLink> | DataLink
|
|
111
111
|
/* Tool call parser */
|
|
112
112
|
toolCallParser?: 'llama3_json' | 'mistral' | 'hermes' | 'internlm' | 'phi4' | DataLink
|
|
113
|
-
/* Tools for chat mode using OpenAI-compatible function calling format
|
|
113
|
+
/* Tools for chat mode using OpenAI-compatible function calling format
|
|
114
114
|
Format: Array of objects with {type, function: {name, description, parameters}} structure
|
|
115
115
|
See: https://platform.openai.com/docs/guides/function-calling */
|
|
116
116
|
tools?: Array<{} | DataLink> | DataLink
|
|
@@ -132,12 +132,12 @@ Default property:
|
|
|
132
132
|
numBeams?: number | DataLink
|
|
133
133
|
/* Do sampling */
|
|
134
134
|
doSample?: boolean | DataLink
|
|
135
|
-
/* Executor candidates, descending order of priority
|
|
135
|
+
/* Executor candidates, descending order of priority
|
|
136
136
|
Default will be xnnpack, wasm, cpu */
|
|
137
137
|
executors?:
|
|
138
138
|
| Array<'qnn' | 'dml' | 'nnapi' | 'xnnpack' | 'coreml' | 'cpu' | 'wasm' | 'webgpu' | DataLink>
|
|
139
139
|
| DataLink
|
|
140
|
-
/* Execution mode
|
|
140
|
+
/* Execution mode
|
|
141
141
|
Usually when the model has many branches, setting this option to `parallel` will give you better performance. */
|
|
142
142
|
executionMode?: 'sequential' | 'parallel' | DataLink
|
|
143
143
|
/* QNN backend */
|
|
@@ -159,22 +159,31 @@ Default property:
|
|
|
159
159
|
}
|
|
160
160
|
outlets?: {
|
|
161
161
|
/* Context state */
|
|
162
|
-
contextState?: () => Data
|
|
162
|
+
contextState?: () => Data<string>
|
|
163
163
|
/* Generated output */
|
|
164
|
-
generated?: () => Data
|
|
164
|
+
generated?: () => Data<string>
|
|
165
165
|
/* Full result of generation */
|
|
166
|
-
fullResult?: () => Data
|
|
166
|
+
fullResult?: () => Data<string>
|
|
167
167
|
/* Last function call */
|
|
168
|
-
lastFunctionCall?: () => Data
|
|
168
|
+
lastFunctionCall?: () => Data<{
|
|
169
|
+
id?: string
|
|
170
|
+
type?: string
|
|
171
|
+
function?: {
|
|
172
|
+
name?: string
|
|
173
|
+
arguments?: string
|
|
174
|
+
[key: string]: any
|
|
175
|
+
}
|
|
176
|
+
[key: string]: any
|
|
177
|
+
}>
|
|
169
178
|
}
|
|
170
179
|
}
|
|
171
180
|
|
|
172
|
-
/* Local LLM inference based on [transformers.js](https://huggingface.co/docs/transformers.js)
|
|
181
|
+
/* Local LLM inference based on [transformers.js](https://huggingface.co/docs/transformers.js)
|
|
173
182
|
You can use any converted model on HuggingFace. */
|
|
174
183
|
export type GeneratorOnnxLLM = Generator &
|
|
175
184
|
GeneratorOnnxLLMDef & {
|
|
176
185
|
templateKey: 'GENERATOR_ONNX_LLM'
|
|
177
|
-
switches
|
|
186
|
+
switches?: Array<
|
|
178
187
|
SwitchDef &
|
|
179
188
|
GeneratorOnnxLLMDef & {
|
|
180
189
|
conds?: Array<{
|
|
@@ -122,7 +122,7 @@ Default property:
|
|
|
122
122
|
}
|
|
123
123
|
>
|
|
124
124
|
| DataLink
|
|
125
|
-
/* Tools for chat mode following OpenAI function calling format
|
|
125
|
+
/* Tools for chat mode following OpenAI function calling format
|
|
126
126
|
Format: Array of objects with {type, function: {name, description, parameters}} structure
|
|
127
127
|
See: https://platform.openai.com/docs/guides/function-calling */
|
|
128
128
|
completionTools?: Array<{} | DataLink> | DataLink
|
|
@@ -167,15 +167,31 @@ Default property:
|
|
|
167
167
|
}
|
|
168
168
|
outlets?: {
|
|
169
169
|
/* Evaluating outlet */
|
|
170
|
-
isEvaluating?: () => Data
|
|
170
|
+
isEvaluating?: () => Data<boolean>
|
|
171
171
|
/* Completion result outlet */
|
|
172
|
-
completionResult?: () => Data
|
|
172
|
+
completionResult?: () => Data<string>
|
|
173
173
|
/* Completion details outlet */
|
|
174
|
-
completionDetails?: () => Data
|
|
174
|
+
completionDetails?: () => Data<{
|
|
175
|
+
text?: string
|
|
176
|
+
content?: string
|
|
177
|
+
finish_reason?: string
|
|
178
|
+
usage?: { [key: string]: any }
|
|
179
|
+
tool_calls?: Array<{
|
|
180
|
+
id?: string
|
|
181
|
+
type?: string
|
|
182
|
+
function?: {
|
|
183
|
+
name?: string
|
|
184
|
+
arguments?: string
|
|
185
|
+
[key: string]: any
|
|
186
|
+
}
|
|
187
|
+
[key: string]: any
|
|
188
|
+
}>
|
|
189
|
+
[key: string]: any
|
|
190
|
+
}>
|
|
175
191
|
}
|
|
176
192
|
}
|
|
177
193
|
|
|
178
|
-
/* LLM inference using OpenAI-compatible API endpoints
|
|
194
|
+
/* LLM inference using OpenAI-compatible API endpoints
|
|
179
195
|
|
|
180
196
|
## Features
|
|
181
197
|
- Compatible with OpenAI API format
|
|
@@ -189,7 +205,7 @@ Default property:
|
|
|
189
205
|
export type GeneratorOpenAILLM = Generator &
|
|
190
206
|
GeneratorOpenAILLMDef & {
|
|
191
207
|
templateKey: 'GENERATOR_OPENAI_LLM'
|
|
192
|
-
switches
|
|
208
|
+
switches?: Array<
|
|
193
209
|
SwitchDef &
|
|
194
210
|
GeneratorOpenAILLMDef & {
|
|
195
211
|
conds?: Array<{
|
|
@@ -108,7 +108,7 @@ Default property:
|
|
|
108
108
|
| DataLink
|
|
109
109
|
/* SOC model */
|
|
110
110
|
socModel?: 'X Elite' | 'X Plus' | '8 Elite' | '8 Gen 3' | 'QCS8550' | DataLink
|
|
111
|
-
/* Custom model base URL
|
|
111
|
+
/* Custom model base URL
|
|
112
112
|
The model should be bundled, for details see https://github.com/mybigday/node-qnn-llm?tab=readme-ov-file#bundled-file */
|
|
113
113
|
customModelUrl?: string | DataLink
|
|
114
114
|
/* Custom model MD5 */
|
|
@@ -142,7 +142,7 @@ Default property:
|
|
|
142
142
|
stopWords?: Array<string | DataLink> | DataLink
|
|
143
143
|
/* Tool call parser */
|
|
144
144
|
toolCallParser?: 'llama3_json' | 'mistral' | 'hermes' | 'internlm' | 'phi4' | DataLink
|
|
145
|
-
/* Tools for chat mode using OpenAI-compatible function calling format
|
|
145
|
+
/* Tools for chat mode using OpenAI-compatible function calling format
|
|
146
146
|
Format: Array of objects with {type, function: {name, description, parameters}} structure
|
|
147
147
|
See: https://platform.openai.com/docs/guides/function-calling */
|
|
148
148
|
tools?: Array<{} | DataLink> | DataLink
|
|
@@ -175,15 +175,39 @@ Default property:
|
|
|
175
175
|
}
|
|
176
176
|
outlets?: {
|
|
177
177
|
/* Context state */
|
|
178
|
-
contextState?: () => Data
|
|
178
|
+
contextState?: () => Data<string>
|
|
179
179
|
/* Generation result */
|
|
180
|
-
result?: () => Data
|
|
180
|
+
result?: () => Data<string>
|
|
181
181
|
/* Full context (Prompt + Generation Result) */
|
|
182
|
-
fullContext?: () => Data
|
|
182
|
+
fullContext?: () => Data<string>
|
|
183
183
|
/* Last function call details */
|
|
184
|
-
lastFunctionCall?: () => Data
|
|
184
|
+
lastFunctionCall?: () => Data<{
|
|
185
|
+
id?: string
|
|
186
|
+
type?: string
|
|
187
|
+
function?: {
|
|
188
|
+
name?: string
|
|
189
|
+
arguments?: string
|
|
190
|
+
[key: string]: any
|
|
191
|
+
}
|
|
192
|
+
[key: string]: any
|
|
193
|
+
}>
|
|
185
194
|
/* Completion details */
|
|
186
|
-
completionDetails?: () => Data
|
|
195
|
+
completionDetails?: () => Data<{
|
|
196
|
+
text?: string
|
|
197
|
+
content?: string
|
|
198
|
+
reasoning_content?: string
|
|
199
|
+
tool_calls?: Array<{
|
|
200
|
+
id?: string
|
|
201
|
+
type?: string
|
|
202
|
+
function?: {
|
|
203
|
+
name?: string
|
|
204
|
+
arguments?: string
|
|
205
|
+
[key: string]: any
|
|
206
|
+
}
|
|
207
|
+
[key: string]: any
|
|
208
|
+
}>
|
|
209
|
+
[key: string]: any
|
|
210
|
+
}>
|
|
187
211
|
}
|
|
188
212
|
}
|
|
189
213
|
|
|
@@ -191,7 +215,7 @@ Default property:
|
|
|
191
215
|
export type GeneratorQnnLlm = Generator &
|
|
192
216
|
GeneratorQnnLlmDef & {
|
|
193
217
|
templateKey: 'GENERATOR_QNN_LLM'
|
|
194
|
-
switches
|
|
218
|
+
switches?: Array<
|
|
195
219
|
SwitchDef &
|
|
196
220
|
GeneratorQnnLlmDef & {
|
|
197
221
|
conds?: Array<{
|