@fugood/bricks-project 2.24.0-beta.9 → 2.24.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/compile/action-name-map.ts +38 -0
- package/compile/index.ts +460 -158
- package/compile/util.ts +2 -0
- package/package.json +7 -3
- package/package.json.bak +27 -0
- package/skills/{bricks-project → bricks-ctor}/SKILL.md +2 -2
- package/skills/{bricks-project → bricks-ctor}/rules/animation.md +1 -1
- package/skills/{bricks-project → bricks-ctor}/rules/architecture-patterns.md +7 -0
- package/skills/{bricks-project → bricks-ctor}/rules/buttress.md +10 -7
- package/skills/{bricks-project → bricks-ctor}/rules/data-calculation.md +1 -1
- package/skills/{bricks-project → bricks-ctor}/rules/local-sync.md +2 -2
- package/skills/{bricks-project → bricks-ctor}/rules/media-flow.md +3 -3
- package/skills/{bricks-project → bricks-ctor}/rules/remote-data-bank.md +6 -6
- package/skills/{bricks-project → bricks-ctor}/rules/standby-transition.md +1 -1
- package/skills/bricks-design/LICENSE.txt +180 -0
- package/skills/bricks-design/SKILL.md +66 -0
- package/tools/deploy.ts +66 -12
- package/tools/icons/fa6pro-meta.json +3669 -26125
- package/tools/mcp-server.ts +11 -878
- package/tools/mcp-tools/compile.ts +91 -0
- package/tools/mcp-tools/huggingface.ts +762 -0
- package/tools/mcp-tools/icons.ts +70 -0
- package/tools/mcp-tools/lottie.ts +102 -0
- package/tools/mcp-tools/media.ts +110 -0
- package/tools/postinstall.ts +137 -40
- package/tools/preview-main.mjs +135 -2
- package/tools/preview.ts +41 -2
- package/tools/pull.ts +37 -19
- package/tsconfig.json +16 -0
- package/types/animation.ts +4 -0
- package/types/automation.ts +4 -1
- package/types/brick-base.ts +1 -1
- package/types/bricks/Camera.ts +47 -12
- package/types/bricks/Chart.ts +9 -3
- package/types/bricks/GenerativeMedia.ts +29 -13
- package/types/bricks/Icon.ts +8 -4
- package/types/bricks/Image.ts +9 -5
- package/types/bricks/Items.ts +28 -14
- package/types/bricks/Lottie.ts +14 -6
- package/types/bricks/Maps.ts +15 -7
- package/types/bricks/QrCode.ts +8 -4
- package/types/bricks/Rect.ts +44 -5
- package/types/bricks/RichText.ts +8 -4
- package/types/bricks/Rive.ts +20 -10
- package/types/bricks/Slideshow.ts +19 -9
- package/types/bricks/Svg.ts +7 -3
- package/types/bricks/Text.ts +8 -4
- package/types/bricks/TextInput.ts +22 -12
- package/types/bricks/Video.ts +10 -6
- package/types/bricks/VideoStreaming.ts +7 -3
- package/types/bricks/WebRtcStream.ts +6 -2
- package/types/bricks/WebView.ts +11 -7
- package/types/canvas.ts +2 -0
- package/types/common.ts +15 -8
- 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 +16 -10
- package/types/generators/Assistant.ts +68 -17
- package/types/generators/BleCentral.ts +30 -10
- package/types/generators/BlePeripheral.ts +10 -6
- package/types/generators/CanvasMap.ts +9 -5
- package/types/generators/CastlesPay.ts +14 -6
- package/types/generators/DataBank.ts +43 -8
- package/types/generators/File.ts +108 -29
- package/types/generators/GraphQl.ts +11 -5
- package/types/generators/Http.ts +32 -9
- package/types/generators/HttpServer.ts +22 -14
- package/types/generators/Information.ts +8 -4
- package/types/generators/Intent.ts +14 -4
- package/types/generators/Iterator.ts +14 -10
- package/types/generators/Keyboard.ts +26 -12
- package/types/generators/LlmAnthropicCompat.ts +32 -10
- package/types/generators/LlmAppleBuiltin.ts +24 -9
- package/types/generators/LlmGgml.ts +139 -30
- package/types/generators/LlmMediaTekNeuroPilot.ts +235 -0
- package/types/generators/LlmMlx.ts +227 -0
- package/types/generators/LlmOnnx.ts +33 -13
- package/types/generators/LlmOpenAiCompat.ts +46 -10
- package/types/generators/LlmQualcommAiEngine.ts +44 -12
- package/types/generators/Mcp.ts +374 -33
- package/types/generators/McpServer.ts +57 -18
- package/types/generators/MediaFlow.ts +37 -11
- package/types/generators/MqttBroker.ts +28 -10
- package/types/generators/MqttClient.ts +18 -8
- package/types/generators/Question.ts +12 -8
- package/types/generators/RealtimeTranscription.ts +107 -18
- package/types/generators/RerankerGgml.ts +42 -11
- package/types/generators/SerialPort.ts +17 -9
- package/types/generators/SoundPlayer.ts +9 -3
- package/types/generators/SoundRecorder.ts +23 -8
- package/types/generators/SpeechToTextGgml.ts +51 -17
- package/types/generators/SpeechToTextOnnx.ts +17 -10
- package/types/generators/SpeechToTextPlatform.ts +14 -6
- package/types/generators/SqLite.ts +19 -9
- package/types/generators/Step.ts +8 -4
- package/types/generators/SttAppleBuiltin.ts +21 -8
- package/types/generators/Tcp.ts +12 -8
- package/types/generators/TcpServer.ts +19 -13
- package/types/generators/TextToSpeechAppleBuiltin.ts +20 -7
- package/types/generators/TextToSpeechGgml.ts +28 -10
- package/types/generators/TextToSpeechOnnx.ts +18 -11
- package/types/generators/TextToSpeechOpenAiLike.ts +13 -7
- package/types/generators/ThermalPrinter.ts +12 -8
- package/types/generators/Tick.ts +10 -6
- package/types/generators/Udp.ts +16 -7
- package/types/generators/VadGgml.ts +50 -13
- package/types/generators/VadOnnx.ts +41 -11
- package/types/generators/VadTraditional.ts +27 -12
- package/types/generators/VectorStore.ts +32 -11
- package/types/generators/Watchdog.ts +18 -9
- package/types/generators/WebCrawler.ts +10 -6
- package/types/generators/WebRtc.ts +29 -15
- package/types/generators/WebSocket.ts +10 -6
- package/types/generators/index.ts +2 -0
- package/types/subspace.ts +4 -0
- package/types/system.ts +1 -1
- package/utils/event-props.ts +833 -1022
- package/api/index.ts +0 -1
- package/api/instance.ts +0 -213
- package/types/generators/TextToSpeechApple.ts +0 -113
- package/types/generators/TtsAppleBuiltin.ts +0 -105
- /package/skills/{bricks-project → bricks-ctor}/rules/automations.md +0 -0
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
/* Auto generated by build script
|
|
2
|
+
*
|
|
3
|
+
* On-device LLM inference using MediaTek NeuroPilot native SDK integration on Android
|
|
4
|
+
*/
|
|
5
|
+
import type { SwitchCondInnerStateCurrentCanvas, SwitchCondData, SwitchDef } from '../switch'
|
|
6
|
+
import type { Data, DataLink } from '../data'
|
|
7
|
+
import type {
|
|
8
|
+
Brick,
|
|
9
|
+
Generator,
|
|
10
|
+
EventAction,
|
|
11
|
+
ActionWithDataParams,
|
|
12
|
+
ActionWithParams,
|
|
13
|
+
Action,
|
|
14
|
+
EventProperty,
|
|
15
|
+
} from '../common'
|
|
16
|
+
import type { TemplateEventPropsMap } from '../../utils/event-props'
|
|
17
|
+
|
|
18
|
+
/* Load or validate the NeuroPilot model context */
|
|
19
|
+
export type GeneratorNeuropilotLlmActionLoadModel = ActionWithParams & {
|
|
20
|
+
__actionName: 'GENERATOR_NEUROPILOT_LLM_LOAD_MODEL'
|
|
21
|
+
params?: Array<
|
|
22
|
+
| {
|
|
23
|
+
input: 'runnerPath'
|
|
24
|
+
value?: string | DataLink | EventProperty
|
|
25
|
+
mapping?: string
|
|
26
|
+
}
|
|
27
|
+
| {
|
|
28
|
+
input: 'configPath'
|
|
29
|
+
value?: string | DataLink | EventProperty
|
|
30
|
+
mapping?: string
|
|
31
|
+
}
|
|
32
|
+
| {
|
|
33
|
+
input: 'workingDirectory'
|
|
34
|
+
value?: string | DataLink | EventProperty
|
|
35
|
+
mapping?: string
|
|
36
|
+
}
|
|
37
|
+
| {
|
|
38
|
+
input: 'libraryPaths'
|
|
39
|
+
value?: Array<any> | DataLink | EventProperty
|
|
40
|
+
mapping?: string
|
|
41
|
+
}
|
|
42
|
+
| {
|
|
43
|
+
input: 'daemonHost'
|
|
44
|
+
value?: string | DataLink | EventProperty
|
|
45
|
+
mapping?: string
|
|
46
|
+
}
|
|
47
|
+
| {
|
|
48
|
+
input: 'daemonPort'
|
|
49
|
+
value?: number | DataLink | EventProperty
|
|
50
|
+
mapping?: string
|
|
51
|
+
}
|
|
52
|
+
| {
|
|
53
|
+
input: 'daemonSocketName'
|
|
54
|
+
value?: string | DataLink | EventProperty
|
|
55
|
+
mapping?: string
|
|
56
|
+
}
|
|
57
|
+
| {
|
|
58
|
+
input: 'daemonSocketNamespace'
|
|
59
|
+
value?: string | DataLink | EventProperty
|
|
60
|
+
mapping?: string
|
|
61
|
+
}
|
|
62
|
+
>
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/* Run text generation with the current NeuroPilot context */
|
|
66
|
+
export type GeneratorNeuropilotLlmActionGenerate = ActionWithParams & {
|
|
67
|
+
__actionName: 'GENERATOR_NEUROPILOT_LLM_GENERATE'
|
|
68
|
+
params?: Array<
|
|
69
|
+
| {
|
|
70
|
+
input: 'prompt'
|
|
71
|
+
value?: string | DataLink | EventProperty
|
|
72
|
+
mapping?: string
|
|
73
|
+
}
|
|
74
|
+
| {
|
|
75
|
+
input: 'messages'
|
|
76
|
+
value?: Array<any> | DataLink | EventProperty
|
|
77
|
+
mapping?: string
|
|
78
|
+
}
|
|
79
|
+
| {
|
|
80
|
+
input: 'maxNewTokens'
|
|
81
|
+
value?: number | DataLink | EventProperty
|
|
82
|
+
mapping?: string
|
|
83
|
+
}
|
|
84
|
+
| {
|
|
85
|
+
input: 'preformatter'
|
|
86
|
+
value?: string | DataLink | EventProperty
|
|
87
|
+
mapping?: string
|
|
88
|
+
}
|
|
89
|
+
>
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/* Abort an in-flight NeuroPilot generation request */
|
|
93
|
+
export type GeneratorNeuropilotLlmActionAbortGeneration = Action & {
|
|
94
|
+
__actionName: 'GENERATOR_NEUROPILOT_LLM_ABORT_GENERATION'
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/* Release the current NeuroPilot context */
|
|
98
|
+
export type GeneratorNeuropilotLlmActionReleaseContext = Action & {
|
|
99
|
+
__actionName: 'GENERATOR_NEUROPILOT_LLM_RELEASE_CONTEXT'
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
interface GeneratorNeuropilotLlmDef {
|
|
103
|
+
/*
|
|
104
|
+
Default property:
|
|
105
|
+
{
|
|
106
|
+
"runnerPath": "/data/local/tmp/llm_sdk/main",
|
|
107
|
+
"configPath": "/data/local/tmp/llm_sdk/config_gemma2_2b_instruct.yaml",
|
|
108
|
+
"workingDirectory": "/data/local/tmp/llm_sdk",
|
|
109
|
+
"libraryPaths": [
|
|
110
|
+
"/vendor/lib64",
|
|
111
|
+
"/system_ext/lib64",
|
|
112
|
+
"/vendor/lib",
|
|
113
|
+
"/system_ext/lib"
|
|
114
|
+
],
|
|
115
|
+
"runtimeMode": "auto",
|
|
116
|
+
"preformatter": "GemmaNoInput",
|
|
117
|
+
"maxNewTokens": 128
|
|
118
|
+
}
|
|
119
|
+
*/
|
|
120
|
+
property?: {
|
|
121
|
+
/* Preloadable NeuroPilot model bundle preset */
|
|
122
|
+
modelBundle?:
|
|
123
|
+
| 'Gemma 2 2B Instruct'
|
|
124
|
+
| 'Gemma 2 2B Instruct (Tailpatched)'
|
|
125
|
+
| 'Gemma 2 2B Instruct (Tailpatched MDLA53)'
|
|
126
|
+
| 'Qwen 2.5 0.5B Instruct'
|
|
127
|
+
| 'Qwen 2.5 1.5B Instruct'
|
|
128
|
+
| 'Llama 3 8B Instruct'
|
|
129
|
+
| DataLink
|
|
130
|
+
/* Override base URL for NeuroPilot model bundle downloads */
|
|
131
|
+
modelBaseUrl?: string | DataLink
|
|
132
|
+
/* Validate runner/config paths on generator initialization */
|
|
133
|
+
init?: boolean | DataLink
|
|
134
|
+
/* Runner binary path on device */
|
|
135
|
+
runnerPath?: string | DataLink
|
|
136
|
+
/* YAML config path on device */
|
|
137
|
+
configPath?: string | DataLink
|
|
138
|
+
/* Working directory for the runner process */
|
|
139
|
+
workingDirectory?: string | DataLink
|
|
140
|
+
/* Extra library search paths for the runner process */
|
|
141
|
+
libraryPaths?: Array<string | DataLink> | DataLink
|
|
142
|
+
/* Daemon host for a preloaded NeuroPilot service */
|
|
143
|
+
daemonHost?: string | DataLink
|
|
144
|
+
/* Daemon TCP port for a preloaded NeuroPilot service */
|
|
145
|
+
daemonPort?: number | DataLink
|
|
146
|
+
/* Android local socket name for a privileged NeuroPilot service */
|
|
147
|
+
daemonSocketName?: string | DataLink
|
|
148
|
+
/* Android local socket namespace used by the privileged NeuroPilot service */
|
|
149
|
+
daemonSocketNamespace?: 'abstract' | 'reserved' | 'filesystem' | DataLink
|
|
150
|
+
/* Runtime selection strategy for MediaTek execution */
|
|
151
|
+
runtimeMode?: 'auto' | 'daemon' | 'root-runner' | 'native' | DataLink
|
|
152
|
+
/* Prompt preformatter used by the vendor runner */
|
|
153
|
+
preformatter?:
|
|
154
|
+
| 'AlpacaNoInput'
|
|
155
|
+
| 'OneShotConversation'
|
|
156
|
+
| 'VicunaNoInput'
|
|
157
|
+
| 'QwenNoInput'
|
|
158
|
+
| 'Qwen3NoInput'
|
|
159
|
+
| 'Qwen3NoInputNoThink'
|
|
160
|
+
| 'Llama3NoInput'
|
|
161
|
+
| 'Phi3NoInput'
|
|
162
|
+
| 'MinicpmNoInput'
|
|
163
|
+
| 'MinicpmNoInputZh'
|
|
164
|
+
| 'InternLM2'
|
|
165
|
+
| 'GemmaNoInput'
|
|
166
|
+
| DataLink
|
|
167
|
+
/* Prompt to run */
|
|
168
|
+
prompt?: string | DataLink
|
|
169
|
+
/* Chat messages to flatten into a prompt */
|
|
170
|
+
messages?: Array<DataLink | {}> | DataLink
|
|
171
|
+
/* Maximum tokens requested from the runner */
|
|
172
|
+
maxNewTokens?: number | DataLink
|
|
173
|
+
}
|
|
174
|
+
events?: {
|
|
175
|
+
/* Event triggered when the NeuroPilot context state changes */
|
|
176
|
+
onContextStateChange?: Array<
|
|
177
|
+
EventAction<string & keyof TemplateEventPropsMap['NeuropilotLlm']['onContextStateChange']>
|
|
178
|
+
>
|
|
179
|
+
/* Event triggered when a completion token or partial result is emitted */
|
|
180
|
+
onCompletion?: Array<
|
|
181
|
+
EventAction<string & keyof TemplateEventPropsMap['NeuropilotLlm']['onCompletion']>
|
|
182
|
+
>
|
|
183
|
+
/* Event triggered when generation finishes */
|
|
184
|
+
onCompletionFinished?: Array<
|
|
185
|
+
EventAction<string & keyof TemplateEventPropsMap['NeuropilotLlm']['onCompletionFinished']>
|
|
186
|
+
>
|
|
187
|
+
/* Event triggered when a NeuroPilot error occurs */
|
|
188
|
+
onError?: Array<EventAction<string & keyof TemplateEventPropsMap['NeuropilotLlm']['onError']>>
|
|
189
|
+
}
|
|
190
|
+
outlets?: {
|
|
191
|
+
/* Current NeuroPilot context state */
|
|
192
|
+
contextState?: () => Data<string>
|
|
193
|
+
/* Final generated result text */
|
|
194
|
+
result?: () => Data<string>
|
|
195
|
+
/* Full context returned by the runner */
|
|
196
|
+
fullContext?: () => Data<string>
|
|
197
|
+
/* Last emitted token or chunk */
|
|
198
|
+
lastToken?: () => Data<string>
|
|
199
|
+
/* Raw output captured from the NeuroPilot runner */
|
|
200
|
+
rawOutput?: () => Data<string>
|
|
201
|
+
/* Prompt-phase performance in tokens per second */
|
|
202
|
+
promptTokensPerSec?: () => Data<string>
|
|
203
|
+
/* Generation-phase performance in tokens per second */
|
|
204
|
+
generationTokensPerSec?: () => Data<string>
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/* On-device LLM inference using MediaTek NeuroPilot native SDK integration on Android */
|
|
209
|
+
export type GeneratorNeuropilotLlm = Generator &
|
|
210
|
+
GeneratorNeuropilotLlmDef & {
|
|
211
|
+
templateKey: 'GENERATOR_NEUROPILOT_LLM'
|
|
212
|
+
switches?: Array<
|
|
213
|
+
SwitchDef &
|
|
214
|
+
GeneratorNeuropilotLlmDef & {
|
|
215
|
+
conds?: Array<{
|
|
216
|
+
method: '==' | '!=' | '>' | '<' | '>=' | '<='
|
|
217
|
+
cond:
|
|
218
|
+
| SwitchCondInnerStateCurrentCanvas
|
|
219
|
+
| SwitchCondData
|
|
220
|
+
| {
|
|
221
|
+
__typename: 'SwitchCondInnerStateOutlet'
|
|
222
|
+
outlet:
|
|
223
|
+
| 'contextState'
|
|
224
|
+
| 'result'
|
|
225
|
+
| 'fullContext'
|
|
226
|
+
| 'lastToken'
|
|
227
|
+
| 'rawOutput'
|
|
228
|
+
| 'promptTokensPerSec'
|
|
229
|
+
| 'generationTokensPerSec'
|
|
230
|
+
value: any
|
|
231
|
+
}
|
|
232
|
+
}>
|
|
233
|
+
}
|
|
234
|
+
>
|
|
235
|
+
}
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
/* Auto generated by build script
|
|
2
|
+
*
|
|
3
|
+
* On-device LLM inference using Apple MLX framework on iOS/tvOS
|
|
4
|
+
*
|
|
5
|
+
* ## Features
|
|
6
|
+
* - Powered by MLX (Apple's ML framework optimized for Apple Silicon)
|
|
7
|
+
* - Download models directly from HuggingFace Hub
|
|
8
|
+
* - Streaming token generation
|
|
9
|
+
* - Supports LLM and VLM (Vision Language Models)
|
|
10
|
+
* - Requires iOS 17+ or tvOS 17+
|
|
11
|
+
*/
|
|
12
|
+
import type { SwitchCondInnerStateCurrentCanvas, SwitchCondData, SwitchDef } from '../switch'
|
|
13
|
+
import type { Data, DataLink } from '../data'
|
|
14
|
+
import type {
|
|
15
|
+
Brick,
|
|
16
|
+
Generator,
|
|
17
|
+
EventAction,
|
|
18
|
+
ActionWithDataParams,
|
|
19
|
+
ActionWithParams,
|
|
20
|
+
Action,
|
|
21
|
+
EventProperty,
|
|
22
|
+
} from '../common'
|
|
23
|
+
import type { TemplateEventPropsMap } from '../../utils/event-props'
|
|
24
|
+
|
|
25
|
+
/* Load model */
|
|
26
|
+
export type GeneratorMlxLLMActionLoadModel = ActionWithParams & {
|
|
27
|
+
__actionName: 'GENERATOR_MLX_LLM_LOAD_MODEL'
|
|
28
|
+
params?: Array<
|
|
29
|
+
| {
|
|
30
|
+
input: 'modelId'
|
|
31
|
+
value?: string | DataLink | EventProperty
|
|
32
|
+
mapping?: string
|
|
33
|
+
}
|
|
34
|
+
| {
|
|
35
|
+
input: 'vlm'
|
|
36
|
+
value?: boolean | DataLink | EventProperty
|
|
37
|
+
mapping?: string
|
|
38
|
+
}
|
|
39
|
+
>
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/* Run text completion */
|
|
43
|
+
export type GeneratorMlxLLMActionCompletion = ActionWithParams & {
|
|
44
|
+
__actionName: 'GENERATOR_MLX_LLM_COMPLETION'
|
|
45
|
+
params?: Array<
|
|
46
|
+
| {
|
|
47
|
+
input: 'messages'
|
|
48
|
+
value?: Array<any> | DataLink | EventProperty
|
|
49
|
+
mapping?: string
|
|
50
|
+
}
|
|
51
|
+
| {
|
|
52
|
+
input: 'tools'
|
|
53
|
+
value?: Array<any> | DataLink | EventProperty
|
|
54
|
+
mapping?: string
|
|
55
|
+
}
|
|
56
|
+
| {
|
|
57
|
+
input: 'maxTokens'
|
|
58
|
+
value?: number | DataLink | EventProperty
|
|
59
|
+
mapping?: string
|
|
60
|
+
}
|
|
61
|
+
| {
|
|
62
|
+
input: 'temperature'
|
|
63
|
+
value?: number | DataLink | EventProperty
|
|
64
|
+
mapping?: string
|
|
65
|
+
}
|
|
66
|
+
| {
|
|
67
|
+
input: 'topP'
|
|
68
|
+
value?: number | DataLink | EventProperty
|
|
69
|
+
mapping?: string
|
|
70
|
+
}
|
|
71
|
+
| {
|
|
72
|
+
input: 'repetitionPenalty'
|
|
73
|
+
value?: number | DataLink | EventProperty
|
|
74
|
+
mapping?: string
|
|
75
|
+
}
|
|
76
|
+
>
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/* Stop text completion */
|
|
80
|
+
export type GeneratorMlxLLMActionStopCompletion = Action & {
|
|
81
|
+
__actionName: 'GENERATOR_MLX_LLM_STOP_COMPLETION'
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/* Release model context */
|
|
85
|
+
export type GeneratorMlxLLMActionReleaseContext = Action & {
|
|
86
|
+
__actionName: 'GENERATOR_MLX_LLM_RELEASE_CONTEXT'
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
interface GeneratorMlxLLMDef {
|
|
90
|
+
/*
|
|
91
|
+
Default property:
|
|
92
|
+
{
|
|
93
|
+
"init": false,
|
|
94
|
+
"modelId": "mlx-community/Qwen3-4B-4bit",
|
|
95
|
+
"vlm": false,
|
|
96
|
+
"completionMessages": [
|
|
97
|
+
{
|
|
98
|
+
"role": "system",
|
|
99
|
+
"content": "You are a helpful assistant."
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
"role": "user",
|
|
103
|
+
"content": "Hello"
|
|
104
|
+
}
|
|
105
|
+
],
|
|
106
|
+
"completionMaxTokens": 1024,
|
|
107
|
+
"completionTemperature": 0.6,
|
|
108
|
+
"completionTopP": 1,
|
|
109
|
+
"completionRepetitionContextSize": 20
|
|
110
|
+
}
|
|
111
|
+
*/
|
|
112
|
+
property?: {
|
|
113
|
+
/* Initialize model on generator init */
|
|
114
|
+
init?: boolean | DataLink
|
|
115
|
+
/* HuggingFace model ID or local path to model directory
|
|
116
|
+
e.g. "mlx-community/Qwen3-4B-4bit" */
|
|
117
|
+
modelId?: string | DataLink
|
|
118
|
+
/* Enable Vision Language Model (VLM) mode */
|
|
119
|
+
vlm?: boolean | DataLink
|
|
120
|
+
/* Chat messages (if first message has role 'system', it will be used as system prompt) */
|
|
121
|
+
completionMessages?:
|
|
122
|
+
| Array<
|
|
123
|
+
| DataLink
|
|
124
|
+
| {
|
|
125
|
+
role?: string | DataLink
|
|
126
|
+
content?: string | DataLink
|
|
127
|
+
}
|
|
128
|
+
>
|
|
129
|
+
| DataLink
|
|
130
|
+
/* Maximum tokens to generate */
|
|
131
|
+
completionMaxTokens?: number | DataLink
|
|
132
|
+
/* Temperature (0.0 to 2.0) */
|
|
133
|
+
completionTemperature?: number | DataLink
|
|
134
|
+
/* Top P sampling */
|
|
135
|
+
completionTopP?: number | DataLink
|
|
136
|
+
/* Repetition penalty factor */
|
|
137
|
+
completionRepetitionPenalty?: number | DataLink
|
|
138
|
+
/* Number of tokens to consider for repetition penalty */
|
|
139
|
+
completionRepetitionContextSize?: number | DataLink
|
|
140
|
+
/* Maximum KV cache size (context window). Uses rotating cache to limit memory.
|
|
141
|
+
Smaller values (e.g. 512) use less memory but lower quality.
|
|
142
|
+
Larger values (e.g. 4096) use more memory but better quality.
|
|
143
|
+
Leave empty for unlimited (model default). */
|
|
144
|
+
contextSize?: number | DataLink
|
|
145
|
+
/* Enable thinking mode (model-dependent, e.g. Qwen3).
|
|
146
|
+
When enabled, passes enable_thinking=true to the chat template.
|
|
147
|
+
The model may output reasoning in <think> tags which will be extracted as reasoning_content. */
|
|
148
|
+
completionEnableThinking?: boolean | DataLink
|
|
149
|
+
/* Additional keyword arguments for chat template (object) */
|
|
150
|
+
completionChatTemplateKwargs?: {} | DataLink
|
|
151
|
+
/* Tools for chat mode using OpenAI-compatible function calling format
|
|
152
|
+
Format: Array of objects with {type, function: {name, description, parameters}} structure
|
|
153
|
+
See: https://platform.openai.com/docs/guides/function-calling */
|
|
154
|
+
completionTools?: Array<{} | DataLink> | DataLink
|
|
155
|
+
/* Buttress connection settings for remote inference */
|
|
156
|
+
buttressConnectionSettings?:
|
|
157
|
+
| DataLink
|
|
158
|
+
| {
|
|
159
|
+
enabled?: boolean | DataLink
|
|
160
|
+
url?: string | DataLink
|
|
161
|
+
fallbackType?: 'use-local' | 'no-op' | DataLink
|
|
162
|
+
strategy?: 'prefer-local' | 'prefer-buttress' | 'prefer-best' | DataLink
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
events?: {
|
|
166
|
+
/* Event triggered when context state changes */
|
|
167
|
+
onContextStateChange?: Array<
|
|
168
|
+
EventAction<string & keyof TemplateEventPropsMap['MlxLlm']['onContextStateChange']>
|
|
169
|
+
>
|
|
170
|
+
/* Error event */
|
|
171
|
+
onError?: Array<EventAction<string & keyof TemplateEventPropsMap['MlxLlm']['onError']>>
|
|
172
|
+
/* Completion streaming event (emitted for each token) */
|
|
173
|
+
onCompletion?: Array<
|
|
174
|
+
EventAction<string & keyof TemplateEventPropsMap['MlxLlm']['onCompletion']>
|
|
175
|
+
>
|
|
176
|
+
/* Completion finished event */
|
|
177
|
+
onCompletionFinished?: Array<
|
|
178
|
+
EventAction<string & keyof TemplateEventPropsMap['MlxLlm']['onCompletionFinished']>
|
|
179
|
+
>
|
|
180
|
+
}
|
|
181
|
+
outlets?: {
|
|
182
|
+
/* Context state */
|
|
183
|
+
contextState?: () => Data<string>
|
|
184
|
+
/* Model load progress (0-1) */
|
|
185
|
+
loadProgress?: () => Data<number>
|
|
186
|
+
/* Whether the model is evaluating */
|
|
187
|
+
isEvaluating?: () => Data<boolean>
|
|
188
|
+
/* Completion result */
|
|
189
|
+
completionResult?: () => Data<string>
|
|
190
|
+
/* Last token */
|
|
191
|
+
completionLastToken?: () => Data<string>
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/* On-device LLM inference using Apple MLX framework on iOS/tvOS
|
|
196
|
+
|
|
197
|
+
## Features
|
|
198
|
+
- Powered by MLX (Apple's ML framework optimized for Apple Silicon)
|
|
199
|
+
- Download models directly from HuggingFace Hub
|
|
200
|
+
- Streaming token generation
|
|
201
|
+
- Supports LLM and VLM (Vision Language Models)
|
|
202
|
+
- Requires iOS 17+ or tvOS 17+ */
|
|
203
|
+
export type GeneratorMlxLLM = Generator &
|
|
204
|
+
GeneratorMlxLLMDef & {
|
|
205
|
+
templateKey: 'GENERATOR_MLX_LLM'
|
|
206
|
+
switches?: Array<
|
|
207
|
+
SwitchDef &
|
|
208
|
+
GeneratorMlxLLMDef & {
|
|
209
|
+
conds?: Array<{
|
|
210
|
+
method: '==' | '!=' | '>' | '<' | '>=' | '<='
|
|
211
|
+
cond:
|
|
212
|
+
| SwitchCondInnerStateCurrentCanvas
|
|
213
|
+
| SwitchCondData
|
|
214
|
+
| {
|
|
215
|
+
__typename: 'SwitchCondInnerStateOutlet'
|
|
216
|
+
outlet:
|
|
217
|
+
| 'contextState'
|
|
218
|
+
| 'loadProgress'
|
|
219
|
+
| 'isEvaluating'
|
|
220
|
+
| 'completionResult'
|
|
221
|
+
| 'completionLastToken'
|
|
222
|
+
value: any
|
|
223
|
+
}
|
|
224
|
+
}>
|
|
225
|
+
}
|
|
226
|
+
>
|
|
227
|
+
}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
/* Auto generated by build script
|
|
1
|
+
/* Auto generated by build script
|
|
2
|
+
*
|
|
3
|
+
* Local LLM inference based on [transformers.js](https://huggingface.co/docs/transformers.js)
|
|
4
|
+
* You can use any converted model on HuggingFace.
|
|
5
|
+
*/
|
|
2
6
|
import type { SwitchCondInnerStateCurrentCanvas, SwitchCondData, SwitchDef } from '../switch'
|
|
3
7
|
import type { Data, DataLink } from '../data'
|
|
4
8
|
import type {
|
|
@@ -10,6 +14,7 @@ import type {
|
|
|
10
14
|
Action,
|
|
11
15
|
EventProperty,
|
|
12
16
|
} from '../common'
|
|
17
|
+
import type { TemplateEventPropsMap } from '../../utils/event-props'
|
|
13
18
|
|
|
14
19
|
/* Load the model */
|
|
15
20
|
export type GeneratorOnnxLLMActionLoadModel = Action & {
|
|
@@ -110,7 +115,7 @@ Default property:
|
|
|
110
115
|
audios?: Array<string | DataLink> | DataLink
|
|
111
116
|
/* Tool call parser */
|
|
112
117
|
toolCallParser?: 'llama3_json' | 'mistral' | 'hermes' | 'internlm' | 'phi4' | DataLink
|
|
113
|
-
/* Tools for chat mode using OpenAI-compatible function calling format
|
|
118
|
+
/* Tools for chat mode using OpenAI-compatible function calling format
|
|
114
119
|
Format: Array of objects with {type, function: {name, description, parameters}} structure
|
|
115
120
|
See: https://platform.openai.com/docs/guides/function-calling */
|
|
116
121
|
tools?: Array<{} | DataLink> | DataLink
|
|
@@ -132,12 +137,12 @@ Default property:
|
|
|
132
137
|
numBeams?: number | DataLink
|
|
133
138
|
/* Do sampling */
|
|
134
139
|
doSample?: boolean | DataLink
|
|
135
|
-
/* Executor candidates, descending order of priority
|
|
140
|
+
/* Executor candidates, descending order of priority
|
|
136
141
|
Default will be xnnpack, wasm, cpu */
|
|
137
142
|
executors?:
|
|
138
143
|
| Array<'qnn' | 'dml' | 'nnapi' | 'xnnpack' | 'coreml' | 'cpu' | 'wasm' | 'webgpu' | DataLink>
|
|
139
144
|
| DataLink
|
|
140
|
-
/* Execution mode
|
|
145
|
+
/* Execution mode
|
|
141
146
|
Usually when the model has many branches, setting this option to `parallel` will give you better performance. */
|
|
142
147
|
executionMode?: 'sequential' | 'parallel' | DataLink
|
|
143
148
|
/* QNN backend */
|
|
@@ -149,27 +154,42 @@ Default property:
|
|
|
149
154
|
}
|
|
150
155
|
events?: {
|
|
151
156
|
/* Event triggered when state change */
|
|
152
|
-
onContextStateChange?: Array<
|
|
157
|
+
onContextStateChange?: Array<
|
|
158
|
+
EventAction<string & keyof TemplateEventPropsMap['OnnxLlm']['onContextStateChange']>
|
|
159
|
+
>
|
|
153
160
|
/* Event triggered on get function call request */
|
|
154
|
-
onFunctionCall?: Array<
|
|
161
|
+
onFunctionCall?: Array<
|
|
162
|
+
EventAction<string & keyof TemplateEventPropsMap['OnnxLlm']['onFunctionCall']>
|
|
163
|
+
>
|
|
155
164
|
/* Event triggered on completion finished */
|
|
156
|
-
onCompletionFinished?: Array<
|
|
165
|
+
onCompletionFinished?: Array<
|
|
166
|
+
EventAction<string & keyof TemplateEventPropsMap['OnnxLlm']['onCompletionFinished']>
|
|
167
|
+
>
|
|
157
168
|
/* Event triggered when error occurs */
|
|
158
|
-
onError?: Array<EventAction
|
|
169
|
+
onError?: Array<EventAction<string & keyof TemplateEventPropsMap['OnnxLlm']['onError']>>
|
|
159
170
|
}
|
|
160
171
|
outlets?: {
|
|
161
172
|
/* Context state */
|
|
162
|
-
contextState?: () => Data
|
|
173
|
+
contextState?: () => Data<string>
|
|
163
174
|
/* Generated output */
|
|
164
|
-
generated?: () => Data
|
|
175
|
+
generated?: () => Data<string>
|
|
165
176
|
/* Full result of generation */
|
|
166
|
-
fullResult?: () => Data
|
|
177
|
+
fullResult?: () => Data<string>
|
|
167
178
|
/* Last function call */
|
|
168
|
-
lastFunctionCall?: () => Data
|
|
179
|
+
lastFunctionCall?: () => Data<{
|
|
180
|
+
id?: string
|
|
181
|
+
type?: string
|
|
182
|
+
function?: {
|
|
183
|
+
name?: string
|
|
184
|
+
arguments?: string
|
|
185
|
+
[key: string]: any
|
|
186
|
+
}
|
|
187
|
+
[key: string]: any
|
|
188
|
+
}>
|
|
169
189
|
}
|
|
170
190
|
}
|
|
171
191
|
|
|
172
|
-
/* Local LLM inference based on [transformers.js](https://huggingface.co/docs/transformers.js)
|
|
192
|
+
/* Local LLM inference based on [transformers.js](https://huggingface.co/docs/transformers.js)
|
|
173
193
|
You can use any converted model on HuggingFace. */
|
|
174
194
|
export type GeneratorOnnxLLM = Generator &
|
|
175
195
|
GeneratorOnnxLLMDef & {
|
|
@@ -1,4 +1,17 @@
|
|
|
1
|
-
/* Auto generated by build script
|
|
1
|
+
/* Auto generated by build script
|
|
2
|
+
*
|
|
3
|
+
* LLM inference using OpenAI-compatible API endpoints
|
|
4
|
+
*
|
|
5
|
+
* ## Features
|
|
6
|
+
* - Compatible with OpenAI API format
|
|
7
|
+
* - Supports function calling
|
|
8
|
+
* - Streaming responses
|
|
9
|
+
* - Custom API endpoints, like
|
|
10
|
+
* - OpenAI API: https://platform.openai.com/docs/guides/text?api-mode=chat
|
|
11
|
+
* - Anthropic API: https://docs.anthropic.com/en/api/openai-sdk
|
|
12
|
+
* - Gemini API: https://ai.google.dev/gemini-api/docs/openai
|
|
13
|
+
* - llama.cpp server: https://github.com/ggml-org/llama.cpp/tree/master/tools/server
|
|
14
|
+
*/
|
|
2
15
|
import type { SwitchCondInnerStateCurrentCanvas, SwitchCondData, SwitchDef } from '../switch'
|
|
3
16
|
import type { Data, DataLink } from '../data'
|
|
4
17
|
import type {
|
|
@@ -10,6 +23,7 @@ import type {
|
|
|
10
23
|
Action,
|
|
11
24
|
EventProperty,
|
|
12
25
|
} from '../common'
|
|
26
|
+
import type { TemplateEventPropsMap } from '../../utils/event-props'
|
|
13
27
|
|
|
14
28
|
/* Run text completion */
|
|
15
29
|
export type GeneratorOpenAILLMActionCompletion = ActionWithParams & {
|
|
@@ -122,7 +136,7 @@ Default property:
|
|
|
122
136
|
}
|
|
123
137
|
>
|
|
124
138
|
| DataLink
|
|
125
|
-
/* Tools for chat mode following OpenAI function calling format
|
|
139
|
+
/* Tools for chat mode following OpenAI function calling format
|
|
126
140
|
Format: Array of objects with {type, function: {name, description, parameters}} structure
|
|
127
141
|
See: https://platform.openai.com/docs/guides/function-calling */
|
|
128
142
|
completionTools?: Array<{} | DataLink> | DataLink
|
|
@@ -157,25 +171,47 @@ Default property:
|
|
|
157
171
|
}
|
|
158
172
|
events?: {
|
|
159
173
|
/* Error event */
|
|
160
|
-
onError?: Array<EventAction
|
|
174
|
+
onError?: Array<EventAction<string & keyof TemplateEventPropsMap['OpenaiLlm']['onError']>>
|
|
161
175
|
/* Completion event */
|
|
162
|
-
onCompletion?: Array<
|
|
176
|
+
onCompletion?: Array<
|
|
177
|
+
EventAction<string & keyof TemplateEventPropsMap['OpenaiLlm']['onCompletion']>
|
|
178
|
+
>
|
|
163
179
|
/* Completion finished event */
|
|
164
|
-
onCompletionFinished?: Array<
|
|
180
|
+
onCompletionFinished?: Array<
|
|
181
|
+
EventAction<string & keyof TemplateEventPropsMap['OpenaiLlm']['onCompletionFinished']>
|
|
182
|
+
>
|
|
165
183
|
/* Completion function call event */
|
|
166
|
-
onCompletionFunctionCall?: Array<
|
|
184
|
+
onCompletionFunctionCall?: Array<
|
|
185
|
+
EventAction<string & keyof TemplateEventPropsMap['OpenaiLlm']['onCompletionFunctionCall']>
|
|
186
|
+
>
|
|
167
187
|
}
|
|
168
188
|
outlets?: {
|
|
169
189
|
/* Evaluating outlet */
|
|
170
|
-
isEvaluating?: () => Data
|
|
190
|
+
isEvaluating?: () => Data<boolean>
|
|
171
191
|
/* Completion result outlet */
|
|
172
|
-
completionResult?: () => Data
|
|
192
|
+
completionResult?: () => Data<string>
|
|
173
193
|
/* Completion details outlet */
|
|
174
|
-
completionDetails?: () => Data
|
|
194
|
+
completionDetails?: () => Data<{
|
|
195
|
+
text?: string
|
|
196
|
+
content?: string
|
|
197
|
+
finish_reason?: string
|
|
198
|
+
usage?: { [key: string]: any }
|
|
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
|
+
}>
|
|
175
211
|
}
|
|
176
212
|
}
|
|
177
213
|
|
|
178
|
-
/* LLM inference using OpenAI-compatible API endpoints
|
|
214
|
+
/* LLM inference using OpenAI-compatible API endpoints
|
|
179
215
|
|
|
180
216
|
## Features
|
|
181
217
|
- Compatible with OpenAI API format
|