@fugood/bricks-project 2.24.0-beta.4 → 2.24.0-beta.40

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.
Files changed (125) hide show
  1. package/compile/action-name-map.ts +38 -0
  2. package/compile/index.ts +429 -160
  3. package/compile/util.ts +2 -0
  4. package/package.json +7 -3
  5. package/package.json.bak +27 -0
  6. package/skills/bricks-design/LICENSE.txt +180 -0
  7. package/skills/bricks-design/SKILL.md +66 -0
  8. package/skills/bricks-project/SKILL.md +2 -2
  9. package/skills/bricks-project/rules/animation.md +1 -1
  10. package/skills/bricks-project/rules/architecture-patterns.md +7 -0
  11. package/skills/bricks-project/rules/automations.md +74 -28
  12. package/skills/bricks-project/rules/buttress.md +10 -7
  13. package/skills/bricks-project/rules/data-calculation.md +1 -1
  14. package/skills/bricks-project/rules/local-sync.md +2 -2
  15. package/skills/bricks-project/rules/media-flow.md +3 -3
  16. package/skills/bricks-project/rules/remote-data-bank.md +6 -6
  17. package/skills/bricks-project/rules/standby-transition.md +1 -1
  18. package/tools/deploy.ts +66 -12
  19. package/tools/icons/fa6pro-meta.json +3669 -26125
  20. package/tools/mcp-server.ts +11 -878
  21. package/tools/mcp-tools/compile.ts +91 -0
  22. package/tools/mcp-tools/huggingface.ts +762 -0
  23. package/tools/mcp-tools/icons.ts +70 -0
  24. package/tools/mcp-tools/lottie.ts +102 -0
  25. package/tools/mcp-tools/media.ts +110 -0
  26. package/tools/postinstall.ts +137 -40
  27. package/tools/preview-main.mjs +146 -9
  28. package/tools/preview.ts +30 -2
  29. package/tools/pull.ts +37 -19
  30. package/tsconfig.json +16 -0
  31. package/types/animation.ts +4 -0
  32. package/types/automation.ts +4 -1
  33. package/types/brick-base.ts +1 -1
  34. package/types/bricks/Camera.ts +48 -13
  35. package/types/bricks/Chart.ts +10 -4
  36. package/types/bricks/GenerativeMedia.ts +30 -14
  37. package/types/bricks/Icon.ts +9 -5
  38. package/types/bricks/Image.ts +10 -6
  39. package/types/bricks/Items.ts +29 -15
  40. package/types/bricks/Lottie.ts +15 -7
  41. package/types/bricks/Maps.ts +16 -8
  42. package/types/bricks/QrCode.ts +9 -5
  43. package/types/bricks/Rect.ts +45 -6
  44. package/types/bricks/RichText.ts +9 -5
  45. package/types/bricks/Rive.ts +21 -11
  46. package/types/bricks/Slideshow.ts +20 -10
  47. package/types/bricks/Svg.ts +8 -4
  48. package/types/bricks/Text.ts +9 -5
  49. package/types/bricks/TextInput.ts +23 -13
  50. package/types/bricks/Video.ts +11 -7
  51. package/types/bricks/VideoStreaming.ts +8 -4
  52. package/types/bricks/WebRtcStream.ts +7 -3
  53. package/types/bricks/WebView.ts +12 -8
  54. package/types/canvas.ts +4 -2
  55. package/types/common.ts +19 -12
  56. package/types/data-calc-command.ts +2 -0
  57. package/types/data-calc.ts +1 -0
  58. package/types/data.ts +2 -0
  59. package/types/generators/AlarmClock.ts +17 -11
  60. package/types/generators/Assistant.ts +69 -18
  61. package/types/generators/BleCentral.ts +31 -11
  62. package/types/generators/BlePeripheral.ts +11 -7
  63. package/types/generators/CanvasMap.ts +10 -6
  64. package/types/generators/CastlesPay.ts +15 -7
  65. package/types/generators/DataBank.ts +44 -9
  66. package/types/generators/File.ts +109 -30
  67. package/types/generators/GraphQl.ts +12 -6
  68. package/types/generators/Http.ts +33 -10
  69. package/types/generators/HttpServer.ts +23 -15
  70. package/types/generators/Information.ts +9 -5
  71. package/types/generators/Intent.ts +15 -5
  72. package/types/generators/Iterator.ts +15 -11
  73. package/types/generators/Keyboard.ts +27 -13
  74. package/types/generators/LlmAnthropicCompat.ts +33 -11
  75. package/types/generators/LlmAppleBuiltin.ts +25 -10
  76. package/types/generators/LlmGgml.ts +140 -31
  77. package/types/generators/LlmMediaTekNeuroPilot.ts +235 -0
  78. package/types/generators/LlmMlx.ts +227 -0
  79. package/types/generators/LlmOnnx.ts +34 -14
  80. package/types/generators/LlmOpenAiCompat.ts +47 -11
  81. package/types/generators/LlmQualcommAiEngine.ts +45 -13
  82. package/types/generators/Mcp.ts +375 -34
  83. package/types/generators/McpServer.ts +58 -19
  84. package/types/generators/MediaFlow.ts +38 -12
  85. package/types/generators/MqttBroker.ts +29 -11
  86. package/types/generators/MqttClient.ts +19 -9
  87. package/types/generators/Question.ts +13 -9
  88. package/types/generators/RealtimeTranscription.ts +108 -19
  89. package/types/generators/RerankerGgml.ts +43 -12
  90. package/types/generators/SerialPort.ts +18 -10
  91. package/types/generators/SoundPlayer.ts +10 -4
  92. package/types/generators/SoundRecorder.ts +24 -9
  93. package/types/generators/SpeechToTextGgml.ts +52 -18
  94. package/types/generators/SpeechToTextOnnx.ts +18 -11
  95. package/types/generators/SpeechToTextPlatform.ts +15 -7
  96. package/types/generators/SqLite.ts +20 -10
  97. package/types/generators/Step.ts +9 -5
  98. package/types/generators/SttAppleBuiltin.ts +22 -9
  99. package/types/generators/Tcp.ts +13 -9
  100. package/types/generators/TcpServer.ts +20 -14
  101. package/types/generators/TextToSpeechAppleBuiltin.ts +21 -8
  102. package/types/generators/TextToSpeechGgml.ts +29 -11
  103. package/types/generators/TextToSpeechOnnx.ts +19 -12
  104. package/types/generators/TextToSpeechOpenAiLike.ts +14 -8
  105. package/types/generators/ThermalPrinter.ts +13 -9
  106. package/types/generators/Tick.ts +11 -7
  107. package/types/generators/Udp.ts +17 -8
  108. package/types/generators/VadGgml.ts +51 -14
  109. package/types/generators/VadOnnx.ts +42 -12
  110. package/types/generators/VadTraditional.ts +28 -13
  111. package/types/generators/VectorStore.ts +33 -12
  112. package/types/generators/Watchdog.ts +19 -10
  113. package/types/generators/WebCrawler.ts +11 -7
  114. package/types/generators/WebRtc.ts +30 -16
  115. package/types/generators/WebSocket.ts +11 -7
  116. package/types/generators/index.ts +2 -0
  117. package/types/subspace.ts +3 -0
  118. package/types/system.ts +1 -1
  119. package/utils/calc.ts +12 -8
  120. package/utils/event-props.ts +833 -1022
  121. package/utils/id.ts +4 -0
  122. package/api/index.ts +0 -1
  123. package/api/instance.ts +0 -213
  124. package/types/generators/TextToSpeechApple.ts +0 -113
  125. package/types/generators/TtsAppleBuiltin.ts +0 -105
@@ -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 &lt;think&gt; 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,32 +154,47 @@ Default property:
149
154
  }
150
155
  events?: {
151
156
  /* Event triggered when state change */
152
- onContextStateChange?: Array<EventAction>
157
+ onContextStateChange?: Array<
158
+ EventAction<string & keyof TemplateEventPropsMap['OnnxLlm']['onContextStateChange']>
159
+ >
153
160
  /* Event triggered on get function call request */
154
- onFunctionCall?: Array<EventAction>
161
+ onFunctionCall?: Array<
162
+ EventAction<string & keyof TemplateEventPropsMap['OnnxLlm']['onFunctionCall']>
163
+ >
155
164
  /* Event triggered on completion finished */
156
- onCompletionFinished?: Array<EventAction>
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 & {
176
196
  templateKey: 'GENERATOR_ONNX_LLM'
177
- switches: Array<
197
+ switches?: Array<
178
198
  SwitchDef &
179
199
  GeneratorOnnxLLMDef & {
180
200
  conds?: Array<{
@@ -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<EventAction>
176
+ onCompletion?: Array<
177
+ EventAction<string & keyof TemplateEventPropsMap['OpenaiLlm']['onCompletion']>
178
+ >
163
179
  /* Completion finished event */
164
- onCompletionFinished?: Array<EventAction>
180
+ onCompletionFinished?: Array<
181
+ EventAction<string & keyof TemplateEventPropsMap['OpenaiLlm']['onCompletionFinished']>
182
+ >
165
183
  /* Completion function call event */
166
- onCompletionFunctionCall?: Array<EventAction>
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
@@ -189,7 +225,7 @@ Default property:
189
225
  export type GeneratorOpenAILLM = Generator &
190
226
  GeneratorOpenAILLMDef & {
191
227
  templateKey: 'GENERATOR_OPENAI_LLM'
192
- switches: Array<
228
+ switches?: Array<
193
229
  SwitchDef &
194
230
  GeneratorOpenAILLMDef & {
195
231
  conds?: Array<{
@@ -1,4 +1,7 @@
1
- /* Auto generated by build script */
1
+ /* Auto generated by build script
2
+ *
3
+ * Local LLM inference using Qualcomm AI Engine
4
+ */
2
5
  import type { SwitchCondInnerStateCurrentCanvas, SwitchCondData, SwitchDef } from '../switch'
3
6
  import type { Data, DataLink } from '../data'
4
7
  import type {
@@ -10,6 +13,7 @@ import type {
10
13
  Action,
11
14
  EventProperty,
12
15
  } from '../common'
16
+ import type { TemplateEventPropsMap } from '../../utils/event-props'
13
17
 
14
18
  /* Load the model */
15
19
  export type GeneratorQnnLlmActionLoadModel = Action & {
@@ -108,7 +112,7 @@ Default property:
108
112
  | DataLink
109
113
  /* SOC model */
110
114
  socModel?: 'X Elite' | 'X Plus' | '8 Elite' | '8 Gen 3' | 'QCS8550' | DataLink
111
- /* Custom model base URL
115
+ /* Custom model base URL
112
116
  The model should be bundled, for details see https://github.com/mybigday/node-qnn-llm?tab=readme-ov-file#bundled-file */
113
117
  customModelUrl?: string | DataLink
114
118
  /* Custom model MD5 */
@@ -142,7 +146,7 @@ Default property:
142
146
  stopWords?: Array<string | DataLink> | DataLink
143
147
  /* Tool call parser */
144
148
  toolCallParser?: 'llama3_json' | 'mistral' | 'hermes' | 'internlm' | 'phi4' | DataLink
145
- /* Tools for chat mode using OpenAI-compatible function calling format
149
+ /* Tools for chat mode using OpenAI-compatible function calling format
146
150
  Format: Array of objects with {type, function: {name, description, parameters}} structure
147
151
  See: https://platform.openai.com/docs/guides/function-calling */
148
152
  tools?: Array<{} | DataLink> | DataLink
@@ -165,25 +169,53 @@ Default property:
165
169
  }
166
170
  events?: {
167
171
  /* Event triggered when context state changes */
168
- onContextStateChange?: Array<EventAction>
172
+ onContextStateChange?: Array<
173
+ EventAction<string & keyof TemplateEventPropsMap['QnnLlm']['onContextStateChange']>
174
+ >
169
175
  /* Event triggered when generate is done */
170
- onGenerate?: Array<EventAction>
176
+ onGenerate?: Array<EventAction<string & keyof TemplateEventPropsMap['QnnLlm']['onGenerate']>>
171
177
  /* Event triggered on get function call request */
172
- onFunctionCall?: Array<EventAction>
178
+ onFunctionCall?: Array<
179
+ EventAction<string & keyof TemplateEventPropsMap['QnnLlm']['onFunctionCall']>
180
+ >
173
181
  /* Event triggered when error occurs */
174
- onError?: Array<EventAction>
182
+ onError?: Array<EventAction<string & keyof TemplateEventPropsMap['QnnLlm']['onError']>>
175
183
  }
176
184
  outlets?: {
177
185
  /* Context state */
178
- contextState?: () => Data
186
+ contextState?: () => Data<string>
179
187
  /* Generation result */
180
- result?: () => Data
188
+ result?: () => Data<string>
181
189
  /* Full context (Prompt + Generation Result) */
182
- fullContext?: () => Data
190
+ fullContext?: () => Data<string>
183
191
  /* Last function call details */
184
- lastFunctionCall?: () => Data
192
+ lastFunctionCall?: () => Data<{
193
+ id?: string
194
+ type?: string
195
+ function?: {
196
+ name?: string
197
+ arguments?: string
198
+ [key: string]: any
199
+ }
200
+ [key: string]: any
201
+ }>
185
202
  /* Completion details */
186
- completionDetails?: () => Data
203
+ completionDetails?: () => Data<{
204
+ text?: string
205
+ content?: string
206
+ reasoning_content?: string
207
+ tool_calls?: Array<{
208
+ id?: string
209
+ type?: string
210
+ function?: {
211
+ name?: string
212
+ arguments?: string
213
+ [key: string]: any
214
+ }
215
+ [key: string]: any
216
+ }>
217
+ [key: string]: any
218
+ }>
187
219
  }
188
220
  }
189
221
 
@@ -191,7 +223,7 @@ Default property:
191
223
  export type GeneratorQnnLlm = Generator &
192
224
  GeneratorQnnLlmDef & {
193
225
  templateKey: 'GENERATOR_QNN_LLM'
194
- switches: Array<
226
+ switches?: Array<
195
227
  SwitchDef &
196
228
  GeneratorQnnLlmDef & {
197
229
  conds?: Array<{