@fugood/bricks-ctor 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.
- package/compile/action-name-map.ts +988 -0
- package/compile/index.ts +1245 -0
- package/compile/util.ts +358 -0
- package/index.ts +6 -0
- package/package.json +28 -0
- package/skills/bricks-design/LICENSE.txt +180 -0
- package/skills/bricks-design/SKILL.md +66 -0
- package/skills/bricks-project/SKILL.md +32 -0
- package/skills/bricks-project/rules/animation.md +159 -0
- package/skills/bricks-project/rules/architecture-patterns.md +69 -0
- package/skills/bricks-project/rules/automations.md +221 -0
- package/skills/bricks-project/rules/buttress.md +156 -0
- package/skills/bricks-project/rules/data-calculation.md +208 -0
- package/skills/bricks-project/rules/local-sync.md +129 -0
- package/skills/bricks-project/rules/media-flow.md +158 -0
- package/skills/bricks-project/rules/remote-data-bank.md +196 -0
- package/skills/bricks-project/rules/standby-transition.md +124 -0
- package/skills/rive-marketplace/SKILL.md +99 -0
- package/tools/deploy.ts +151 -0
- package/tools/icons/.gitattributes +1 -0
- package/tools/icons/fa6pro-glyphmap.json +4686 -0
- package/tools/icons/fa6pro-meta.json +3671 -0
- package/tools/mcp-server.ts +28 -0
- 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 +229 -0
- package/tools/preview-main.mjs +293 -0
- package/tools/preview.ts +143 -0
- package/tools/pull.ts +116 -0
- package/tsconfig.json +16 -0
- package/types/animation.ts +100 -0
- package/types/automation.ts +235 -0
- package/types/brick-base.ts +80 -0
- package/types/bricks/Camera.ts +246 -0
- package/types/bricks/Chart.ts +372 -0
- package/types/bricks/GenerativeMedia.ts +276 -0
- package/types/bricks/Icon.ts +98 -0
- package/types/bricks/Image.ts +114 -0
- package/types/bricks/Items.ts +476 -0
- package/types/bricks/Lottie.ts +168 -0
- package/types/bricks/Maps.ts +262 -0
- package/types/bricks/QrCode.ts +117 -0
- package/types/bricks/Rect.ts +150 -0
- package/types/bricks/RichText.ts +128 -0
- package/types/bricks/Rive.ts +220 -0
- package/types/bricks/Slideshow.ts +201 -0
- package/types/bricks/Svg.ts +99 -0
- package/types/bricks/Text.ts +148 -0
- package/types/bricks/TextInput.ts +242 -0
- package/types/bricks/Video.ts +175 -0
- package/types/bricks/VideoStreaming.ts +112 -0
- package/types/bricks/WebRtcStream.ts +65 -0
- package/types/bricks/WebView.ts +168 -0
- package/types/bricks/index.ts +21 -0
- package/types/canvas.ts +82 -0
- package/types/common.ts +144 -0
- package/types/data-calc-command.ts +7005 -0
- package/types/data-calc-script.ts +21 -0
- package/types/data-calc.ts +11 -0
- package/types/data.ts +95 -0
- package/types/generators/AlarmClock.ts +110 -0
- package/types/generators/Assistant.ts +621 -0
- package/types/generators/BleCentral.ts +247 -0
- package/types/generators/BlePeripheral.ts +208 -0
- package/types/generators/CanvasMap.ts +74 -0
- package/types/generators/CastlesPay.ts +87 -0
- package/types/generators/DataBank.ts +160 -0
- package/types/generators/File.ts +432 -0
- package/types/generators/GraphQl.ts +132 -0
- package/types/generators/Http.ts +222 -0
- package/types/generators/HttpServer.ts +176 -0
- package/types/generators/Information.ts +103 -0
- package/types/generators/Intent.ts +168 -0
- package/types/generators/Iterator.ts +108 -0
- package/types/generators/Keyboard.ts +105 -0
- package/types/generators/LlmAnthropicCompat.ts +212 -0
- package/types/generators/LlmAppleBuiltin.ts +159 -0
- package/types/generators/LlmGgml.ts +861 -0
- package/types/generators/LlmMediaTekNeuroPilot.ts +235 -0
- package/types/generators/LlmMlx.ts +227 -0
- package/types/generators/LlmOnnx.ts +213 -0
- package/types/generators/LlmOpenAiCompat.ts +244 -0
- package/types/generators/LlmQualcommAiEngine.ts +247 -0
- package/types/generators/Mcp.ts +637 -0
- package/types/generators/McpServer.ts +289 -0
- package/types/generators/MediaFlow.ts +170 -0
- package/types/generators/MqttBroker.ts +141 -0
- package/types/generators/MqttClient.ts +141 -0
- package/types/generators/Question.ts +408 -0
- package/types/generators/RealtimeTranscription.ts +279 -0
- package/types/generators/RerankerGgml.ts +191 -0
- package/types/generators/SerialPort.ts +151 -0
- package/types/generators/SoundPlayer.ts +94 -0
- package/types/generators/SoundRecorder.ts +130 -0
- package/types/generators/SpeechToTextGgml.ts +415 -0
- package/types/generators/SpeechToTextOnnx.ts +236 -0
- package/types/generators/SpeechToTextPlatform.ts +85 -0
- package/types/generators/SqLite.ts +159 -0
- package/types/generators/Step.ts +107 -0
- package/types/generators/SttAppleBuiltin.ts +130 -0
- package/types/generators/Tcp.ts +126 -0
- package/types/generators/TcpServer.ts +147 -0
- package/types/generators/TextToSpeechAppleBuiltin.ts +127 -0
- package/types/generators/TextToSpeechGgml.ts +221 -0
- package/types/generators/TextToSpeechOnnx.ts +178 -0
- package/types/generators/TextToSpeechOpenAiLike.ts +121 -0
- package/types/generators/ThermalPrinter.ts +191 -0
- package/types/generators/Tick.ts +83 -0
- package/types/generators/Udp.ts +120 -0
- package/types/generators/VadGgml.ts +250 -0
- package/types/generators/VadOnnx.ts +231 -0
- package/types/generators/VadTraditional.ts +138 -0
- package/types/generators/VectorStore.ts +257 -0
- package/types/generators/Watchdog.ts +107 -0
- package/types/generators/WebCrawler.ts +103 -0
- package/types/generators/WebRtc.ts +181 -0
- package/types/generators/WebSocket.ts +148 -0
- package/types/generators/index.ts +57 -0
- package/types/index.ts +13 -0
- package/types/subspace.ts +59 -0
- package/types/switch.ts +51 -0
- package/types/system.ts +707 -0
- package/utils/calc.ts +126 -0
- package/utils/data.ts +497 -0
- package/utils/event-props.ts +836 -0
- package/utils/id.ts +80 -0
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
/* Auto generated by build script
|
|
2
|
+
*
|
|
3
|
+
* Realtime speech-to-text transcription using Whisper and VAD with live audio streaming
|
|
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
|
+
/* Start realtime transcription */
|
|
19
|
+
export type GeneratorRealtimeTranscriptionActionStart = Action & {
|
|
20
|
+
__actionName: 'GENERATOR_REALTIME_TRANSCRIPTION_START'
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/* Stop realtime transcription */
|
|
24
|
+
export type GeneratorRealtimeTranscriptionActionStop = Action & {
|
|
25
|
+
__actionName: 'GENERATOR_REALTIME_TRANSCRIPTION_STOP'
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/* Force move to next slice */
|
|
29
|
+
export type GeneratorRealtimeTranscriptionActionNextSlice = Action & {
|
|
30
|
+
__actionName: 'GENERATOR_REALTIME_TRANSCRIPTION_NEXT_SLICE'
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/* Reset transcriber state */
|
|
34
|
+
export type GeneratorRealtimeTranscriptionActionReset = Action & {
|
|
35
|
+
__actionName: 'GENERATOR_REALTIME_TRANSCRIPTION_RESET'
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/* List available microphone devices (Web / Desktop only) */
|
|
39
|
+
export type GeneratorRealtimeTranscriptionActionListDevices = Action & {
|
|
40
|
+
__actionName: 'GENERATOR_REALTIME_TRANSCRIPTION_LIST_DEVICES'
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
interface GeneratorRealtimeTranscriptionDef {
|
|
44
|
+
/*
|
|
45
|
+
Default property:
|
|
46
|
+
{
|
|
47
|
+
"sttLivePolicy": "only-in-use",
|
|
48
|
+
"vadInferenceLivePolicy": "only-in-use",
|
|
49
|
+
"vadEnabled": true,
|
|
50
|
+
"audioSliceSec": 30,
|
|
51
|
+
"audioMinSec": 1,
|
|
52
|
+
"maxSlicesInMemory": 5,
|
|
53
|
+
"transcribeProcessingPauseMs": 500,
|
|
54
|
+
"initTranscribeAfterMs": 500,
|
|
55
|
+
"vadStrategy": "use-preset",
|
|
56
|
+
"vadPreset": "default",
|
|
57
|
+
"initialPrompt": "",
|
|
58
|
+
"promptPreviousSlices": false,
|
|
59
|
+
"saveAudio": true,
|
|
60
|
+
"testMode": false,
|
|
61
|
+
"testPlaybackSpeed": 1,
|
|
62
|
+
"testChunkDurationMs": 100,
|
|
63
|
+
"testLoop": false,
|
|
64
|
+
"beginTranscribeEnabled": false,
|
|
65
|
+
"beginTranscribeScript": "\/\* Global variable: inputs = { sliceIndex, duration, vadEvent, variables } \*\/\nreturn true"
|
|
66
|
+
}
|
|
67
|
+
*/
|
|
68
|
+
property?: {
|
|
69
|
+
/* Specifies the device ID to use for audio input.
|
|
70
|
+
Web / Desktop: device ID string from enumerateDevices
|
|
71
|
+
Android: audio source name - DEFAULT, MIC, VOICE_UPLINK, VOICE_DOWNLINK, VOICE_CALL, CAMCORDER, VOICE_RECOGNITION, VOICE_COMMUNICATION, UNPROCESSED */
|
|
72
|
+
deviceId?: string | DataLink
|
|
73
|
+
/* STT Generator for Whisper context */
|
|
74
|
+
sttGeneratorId?: string | DataLink | (() => Generator)
|
|
75
|
+
/* STT Live Policy. If the policy is `only-in-use`, the STT context will be released when not in use. */
|
|
76
|
+
sttLivePolicy?: 'only-in-use' | 'manual' | DataLink
|
|
77
|
+
/* VAD Inference Generator for voice activity detection */
|
|
78
|
+
vadInferenceGeneratorId?: string | DataLink | (() => Generator)
|
|
79
|
+
/* VAD Inference Live Policy. If the policy is `only-in-use`, the VAD Inference context will be released when not in use. */
|
|
80
|
+
vadInferenceLivePolicy?: 'only-in-use' | 'manual' | DataLink
|
|
81
|
+
/* Enable VAD (Voice Activity Detection) */
|
|
82
|
+
vadEnabled?: boolean | DataLink
|
|
83
|
+
/* Audio slice duration in seconds */
|
|
84
|
+
audioSliceSec?: number | DataLink
|
|
85
|
+
/* Minimum audio duration to start transcription in seconds */
|
|
86
|
+
audioMinSec?: number | DataLink
|
|
87
|
+
/* Maximum number of slices to keep in memory */
|
|
88
|
+
maxSlicesInMemory?: number | DataLink
|
|
89
|
+
/* Transcribe processing interval in milliseconds */
|
|
90
|
+
transcribeProcessingPauseMs?: number | DataLink
|
|
91
|
+
/* Transcribe processing init after pause in milliseconds */
|
|
92
|
+
initTranscribeAfterMs?: number | DataLink
|
|
93
|
+
/* VAD Strategy */
|
|
94
|
+
vadStrategy?: 'use-preset' | 'use-generator-options' | DataLink
|
|
95
|
+
/* VAD preset configuration */
|
|
96
|
+
vadPreset?:
|
|
97
|
+
| 'default'
|
|
98
|
+
| 'sensitive'
|
|
99
|
+
| 'very-sensitive'
|
|
100
|
+
| 'conservative'
|
|
101
|
+
| 'very-conservative'
|
|
102
|
+
| 'continuous-speech'
|
|
103
|
+
| 'meeting'
|
|
104
|
+
| 'noisy-environment'
|
|
105
|
+
| DataLink
|
|
106
|
+
/* Initial prompt for transcription */
|
|
107
|
+
initialPrompt?: string | DataLink
|
|
108
|
+
/* Include previous slices in prompt */
|
|
109
|
+
promptPreviousSlices?: boolean | DataLink
|
|
110
|
+
/* Enable audio output saving (auto-generates file path) */
|
|
111
|
+
saveAudio?: boolean | DataLink
|
|
112
|
+
/* Use test mode with file simulation */
|
|
113
|
+
testMode?: boolean | DataLink
|
|
114
|
+
/* Test audio file path for simulation */
|
|
115
|
+
testFilePath?: string | DataLink
|
|
116
|
+
/* Test audio file hash */
|
|
117
|
+
testFileHash?: string | DataLink
|
|
118
|
+
/* Test audio file hash type */
|
|
119
|
+
testFileHashType?: string | DataLink
|
|
120
|
+
/* Test playback speed */
|
|
121
|
+
testPlaybackSpeed?: number | DataLink
|
|
122
|
+
/* Test chunk duration in milliseconds */
|
|
123
|
+
testChunkDurationMs?: number | DataLink
|
|
124
|
+
/* Loop test audio file */
|
|
125
|
+
testLoop?: boolean | DataLink
|
|
126
|
+
/* Enable Begin Transcribe Script to determine transcription */
|
|
127
|
+
beginTranscribeEnabled?: boolean | DataLink
|
|
128
|
+
/* Script to determine whether to proceed with transcription */
|
|
129
|
+
beginTranscribeScript?: string | DataLink
|
|
130
|
+
/* Data to be used in Begin Transcribe Script (object) */
|
|
131
|
+
beginTranscribeScriptData?: {} | DataLink
|
|
132
|
+
}
|
|
133
|
+
events?: {
|
|
134
|
+
/* Event triggered when transcription starts, processes, or ends */
|
|
135
|
+
onTranscribe?: Array<
|
|
136
|
+
EventAction<string & keyof TemplateEventPropsMap['RealtimeTranscription']['onTranscribe']>
|
|
137
|
+
>
|
|
138
|
+
/* Event triggered on VAD (Voice Activity Detection) events */
|
|
139
|
+
onVad?: Array<
|
|
140
|
+
EventAction<string & keyof TemplateEventPropsMap['RealtimeTranscription']['onVad']>
|
|
141
|
+
>
|
|
142
|
+
/* Event triggered when error occurs */
|
|
143
|
+
onError?: Array<
|
|
144
|
+
EventAction<string & keyof TemplateEventPropsMap['RealtimeTranscription']['onError']>
|
|
145
|
+
>
|
|
146
|
+
/* Event triggered when status changes */
|
|
147
|
+
onStatusChange?: Array<
|
|
148
|
+
EventAction<string & keyof TemplateEventPropsMap['RealtimeTranscription']['onStatusChange']>
|
|
149
|
+
>
|
|
150
|
+
/* Event triggered when statistics update */
|
|
151
|
+
onStatsUpdate?: Array<
|
|
152
|
+
EventAction<string & keyof TemplateEventPropsMap['RealtimeTranscription']['onStatsUpdate']>
|
|
153
|
+
>
|
|
154
|
+
/* Event triggered when slice transcription is stabilized */
|
|
155
|
+
onStabilized?: Array<
|
|
156
|
+
EventAction<string & keyof TemplateEventPropsMap['RealtimeTranscription']['onStabilized']>
|
|
157
|
+
>
|
|
158
|
+
/* Event triggered when transcription ends */
|
|
159
|
+
onEnd?: Array<
|
|
160
|
+
EventAction<string & keyof TemplateEventPropsMap['RealtimeTranscription']['onEnd']>
|
|
161
|
+
>
|
|
162
|
+
}
|
|
163
|
+
outlets?: {
|
|
164
|
+
/* Is realtime transcription currently active */
|
|
165
|
+
isActive?: () => Data<boolean>
|
|
166
|
+
/* Is currently transcribing audio */
|
|
167
|
+
isTranscribing?: () => Data<boolean>
|
|
168
|
+
/* Current transcription results */
|
|
169
|
+
results?: () => Data<
|
|
170
|
+
Array<{
|
|
171
|
+
transcribeEvent?: {
|
|
172
|
+
type?: string
|
|
173
|
+
sliceIndex?: number
|
|
174
|
+
isCapturing?: boolean
|
|
175
|
+
data?: {
|
|
176
|
+
result?: string
|
|
177
|
+
[key: string]: any
|
|
178
|
+
}
|
|
179
|
+
vadEvent?: {
|
|
180
|
+
type?: string
|
|
181
|
+
confidence?: number
|
|
182
|
+
duration?: number
|
|
183
|
+
sliceIndex?: number
|
|
184
|
+
timestamp?: number
|
|
185
|
+
[key: string]: any
|
|
186
|
+
}
|
|
187
|
+
[key: string]: any
|
|
188
|
+
}
|
|
189
|
+
vadEvent?: {
|
|
190
|
+
type?: string
|
|
191
|
+
confidence?: number
|
|
192
|
+
duration?: number
|
|
193
|
+
sliceIndex?: number
|
|
194
|
+
timestamp?: number
|
|
195
|
+
[key: string]: any
|
|
196
|
+
}
|
|
197
|
+
[key: string]: any
|
|
198
|
+
}>
|
|
199
|
+
>
|
|
200
|
+
/* Current transcription result text */
|
|
201
|
+
resultText?: () => Data<string>
|
|
202
|
+
/* Last stabilized transcription result segment */
|
|
203
|
+
lastStabilizedSegment?: () => Data<string>
|
|
204
|
+
/* Current statistics */
|
|
205
|
+
statistics?: () => Data<{
|
|
206
|
+
type?: string
|
|
207
|
+
timestamp?: number
|
|
208
|
+
data?: { [key: string]: any }
|
|
209
|
+
[key: string]: any
|
|
210
|
+
}>
|
|
211
|
+
/* Latest transcribe event */
|
|
212
|
+
lastTranscribeEvent?: () => Data<{
|
|
213
|
+
type?: string
|
|
214
|
+
sliceIndex?: number
|
|
215
|
+
isCapturing?: boolean
|
|
216
|
+
data?: {
|
|
217
|
+
result?: string
|
|
218
|
+
[key: string]: any
|
|
219
|
+
}
|
|
220
|
+
vadEvent?: {
|
|
221
|
+
type?: string
|
|
222
|
+
confidence?: number
|
|
223
|
+
duration?: number
|
|
224
|
+
sliceIndex?: number
|
|
225
|
+
timestamp?: number
|
|
226
|
+
[key: string]: any
|
|
227
|
+
}
|
|
228
|
+
[key: string]: any
|
|
229
|
+
}>
|
|
230
|
+
/* Latest VAD event */
|
|
231
|
+
lastVadEvent?: () => Data<{
|
|
232
|
+
type?: string
|
|
233
|
+
confidence?: number
|
|
234
|
+
duration?: number
|
|
235
|
+
sliceIndex?: number
|
|
236
|
+
timestamp?: number
|
|
237
|
+
[key: string]: any
|
|
238
|
+
}>
|
|
239
|
+
/* Stabilized transcription text from completed slices */
|
|
240
|
+
stabilizedText?: () => Data<string>
|
|
241
|
+
/* Audio output file path (auto-generated when saving audio) */
|
|
242
|
+
audioOutputPath?: () => Data<string>
|
|
243
|
+
/* Available microphone devices (Web / Desktop only) */
|
|
244
|
+
devices?: () => Data<Array<any>>
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/* Realtime speech-to-text transcription using Whisper and VAD with live audio streaming */
|
|
249
|
+
export type GeneratorRealtimeTranscription = Generator &
|
|
250
|
+
GeneratorRealtimeTranscriptionDef & {
|
|
251
|
+
templateKey: 'GENERATOR_REALTIME_TRANSCRIPTION'
|
|
252
|
+
switches?: Array<
|
|
253
|
+
SwitchDef &
|
|
254
|
+
GeneratorRealtimeTranscriptionDef & {
|
|
255
|
+
conds?: Array<{
|
|
256
|
+
method: '==' | '!=' | '>' | '<' | '>=' | '<='
|
|
257
|
+
cond:
|
|
258
|
+
| SwitchCondInnerStateCurrentCanvas
|
|
259
|
+
| SwitchCondData
|
|
260
|
+
| {
|
|
261
|
+
__typename: 'SwitchCondInnerStateOutlet'
|
|
262
|
+
outlet:
|
|
263
|
+
| 'isActive'
|
|
264
|
+
| 'isTranscribing'
|
|
265
|
+
| 'results'
|
|
266
|
+
| 'resultText'
|
|
267
|
+
| 'lastStabilizedSegment'
|
|
268
|
+
| 'statistics'
|
|
269
|
+
| 'lastTranscribeEvent'
|
|
270
|
+
| 'lastVadEvent'
|
|
271
|
+
| 'stabilizedText'
|
|
272
|
+
| 'audioOutputPath'
|
|
273
|
+
| 'devices'
|
|
274
|
+
value: any
|
|
275
|
+
}
|
|
276
|
+
}>
|
|
277
|
+
}
|
|
278
|
+
>
|
|
279
|
+
}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
/* Auto generated by build script
|
|
2
|
+
*
|
|
3
|
+
* Local rerank based on GGML and [llama.cpp](https://github.com/ggerganov/llama.cpp)
|
|
4
|
+
*
|
|
5
|
+
* ## Notice
|
|
6
|
+
* - The device RAM must be larger than 8GB
|
|
7
|
+
* - iOS: Recommended use M1+ / A17+ chip device. Supported GPU acceleration by Metal.
|
|
8
|
+
* - macOS: Recommended use M1+ chip device. Supported GPU acceleration by Metal.
|
|
9
|
+
* - Android: Recommended use Android 13+ system.
|
|
10
|
+
* - Supported GPU acceleration by OpenCL, currently only for Qualcomm Adreno 700+ GPUs, other GPUs are not supported.
|
|
11
|
+
* - Supported Hexagon NPU for Qualcomm Snapdragon 8 Gen 2+ GPUs.
|
|
12
|
+
* - Linux / Windows
|
|
13
|
+
* - Supported GPU acceleration, you can choose `vulkan` or `cuda` backend in Accel Variant property
|
|
14
|
+
* - Supported Hexagon NPU for Qualcomm Dragonwing IQ9 series+ (Linux)
|
|
15
|
+
*/
|
|
16
|
+
import type { SwitchCondInnerStateCurrentCanvas, SwitchCondData, SwitchDef } from '../switch'
|
|
17
|
+
import type { Data, DataLink } from '../data'
|
|
18
|
+
import type {
|
|
19
|
+
Brick,
|
|
20
|
+
Generator,
|
|
21
|
+
EventAction,
|
|
22
|
+
ActionWithDataParams,
|
|
23
|
+
ActionWithParams,
|
|
24
|
+
Action,
|
|
25
|
+
EventProperty,
|
|
26
|
+
} from '../common'
|
|
27
|
+
import type { TemplateEventPropsMap } from '../../utils/event-props'
|
|
28
|
+
|
|
29
|
+
/* Load the model */
|
|
30
|
+
export type GeneratorRerankerActionLoadModel = Action & {
|
|
31
|
+
__actionName: 'GENERATOR_RERANKER_LOAD_MODEL'
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/* Rerank documents based on query relevance */
|
|
35
|
+
export type GeneratorRerankerActionRerank = ActionWithParams & {
|
|
36
|
+
__actionName: 'GENERATOR_RERANKER_RERANK'
|
|
37
|
+
params?: Array<
|
|
38
|
+
| {
|
|
39
|
+
input: 'query'
|
|
40
|
+
value?: string | DataLink | EventProperty
|
|
41
|
+
mapping?: string
|
|
42
|
+
}
|
|
43
|
+
| {
|
|
44
|
+
input: 'documents'
|
|
45
|
+
value?: Array<any> | DataLink | EventProperty
|
|
46
|
+
mapping?: string
|
|
47
|
+
}
|
|
48
|
+
>
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/* Release context */
|
|
52
|
+
export type GeneratorRerankerActionReleaseContext = Action & {
|
|
53
|
+
__actionName: 'GENERATOR_RERANKER_RELEASE_CONTEXT'
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
interface GeneratorRerankerDef {
|
|
57
|
+
/*
|
|
58
|
+
Default property:
|
|
59
|
+
{
|
|
60
|
+
"init": false,
|
|
61
|
+
"contextSize": 512,
|
|
62
|
+
"batchSize": 512,
|
|
63
|
+
"uBatchSize": 512,
|
|
64
|
+
"accelVariant": "default",
|
|
65
|
+
"mainGpu": 0,
|
|
66
|
+
"gpuLayers": 0,
|
|
67
|
+
"useMlock": true,
|
|
68
|
+
"useMmap": true,
|
|
69
|
+
"normalize": 1
|
|
70
|
+
}
|
|
71
|
+
*/
|
|
72
|
+
property?: {
|
|
73
|
+
/* Initialize the Reranker context on generator initialization */
|
|
74
|
+
init?: boolean | DataLink
|
|
75
|
+
/* The URL or path of reranker model (GGUF format) */
|
|
76
|
+
modelUrl?: string | DataLink
|
|
77
|
+
/* Hash of reranker model */
|
|
78
|
+
modelHash?: string | DataLink
|
|
79
|
+
/* Hash type of reranker model */
|
|
80
|
+
modelHashType?: 'md5' | 'sha256' | 'sha1' | DataLink
|
|
81
|
+
/* Context size (0 ~ 4096) (Default to 512) */
|
|
82
|
+
contextSize?: number | DataLink
|
|
83
|
+
/* Logical batch size for processing (default: 512) */
|
|
84
|
+
batchSize?: number | DataLink
|
|
85
|
+
/* Physical maximum batch size (default: 512) */
|
|
86
|
+
uBatchSize?: number | DataLink
|
|
87
|
+
/* GGML accelerator variant (Only for desktop)
|
|
88
|
+
`default` - CPU / Metal (macOS)
|
|
89
|
+
`vulkan` - Use Vulkan
|
|
90
|
+
`cuda` - Use CUDA
|
|
91
|
+
`snapdragon` - Use OpenCL/Hexagon of Qualcomm Snapdragon */
|
|
92
|
+
accelVariant?: 'default' | 'vulkan' | 'cuda' | 'snapdragon' | DataLink
|
|
93
|
+
/* Devices. For example:
|
|
94
|
+
|
|
95
|
+
Metal or CPU for iOS/tvOS/MacOS
|
|
96
|
+
OpenCL or CPU for Android
|
|
97
|
+
- Add `HTP0`, `HTP1`, `...` for OpenCL/Hexagon devices (Use HTP* for all HTP devices)
|
|
98
|
+
For Desktop, you may want to include/exclude GPUs */
|
|
99
|
+
devices?: Array<string | DataLink> | DataLink
|
|
100
|
+
/* Main GPU index (default: 0) */
|
|
101
|
+
mainGpu?: number | DataLink
|
|
102
|
+
/* Number of layers to store in VRAM (default: 0) */
|
|
103
|
+
gpuLayers?: number | DataLink
|
|
104
|
+
/* Maximum number of threads to use (default: auto) */
|
|
105
|
+
maxThreads?: number | DataLink
|
|
106
|
+
/* Use mlock to keep model in memory (default: true) */
|
|
107
|
+
useMlock?: boolean | DataLink
|
|
108
|
+
/* Use mmap for model loading (default: true) */
|
|
109
|
+
useMmap?: boolean | DataLink
|
|
110
|
+
/* Query text for reranking */
|
|
111
|
+
query?: string | DataLink
|
|
112
|
+
/* Array of documents to rerank */
|
|
113
|
+
documents?: Array<string | DataLink> | DataLink
|
|
114
|
+
/* Normalize reranking scores (default: from model config) */
|
|
115
|
+
normalize?: number | DataLink | boolean | DataLink | DataLink
|
|
116
|
+
/* Maximum number of documents to return (default: unlimited) */
|
|
117
|
+
topK?: number | DataLink
|
|
118
|
+
}
|
|
119
|
+
events?: {
|
|
120
|
+
/* Event triggered when the reranker context state changes (loading, ready, error, released) */
|
|
121
|
+
onContextStateChange?: Array<
|
|
122
|
+
EventAction<string & keyof TemplateEventPropsMap['Reranker']['onContextStateChange']>
|
|
123
|
+
>
|
|
124
|
+
/* Event triggered when an error occurs during reranker operations */
|
|
125
|
+
onError?: Array<EventAction<string & keyof TemplateEventPropsMap['Reranker']['onError']>>
|
|
126
|
+
}
|
|
127
|
+
outlets?: {
|
|
128
|
+
/* Current state of the reranker context (loading, ready, error, released) */
|
|
129
|
+
contextState?: () => Data<string>
|
|
130
|
+
/* Loading progress of the reranker model (0-100) */
|
|
131
|
+
contextLoadProgress?: () => Data<number>
|
|
132
|
+
/* Detailed information about the reranker context including instance ID and processing status */
|
|
133
|
+
contextDetails?: () => Data<{
|
|
134
|
+
state?: string
|
|
135
|
+
contextId?: string
|
|
136
|
+
gpu?: string
|
|
137
|
+
reasonNoGPU?: string
|
|
138
|
+
[key: string]: any
|
|
139
|
+
}>
|
|
140
|
+
/* Result of the reranking operation containing scored and ranked documents */
|
|
141
|
+
rerankResult?: () => Data<
|
|
142
|
+
Array<{
|
|
143
|
+
index?: number
|
|
144
|
+
score?: number
|
|
145
|
+
text?: string
|
|
146
|
+
payload?: { [key: string]: any }
|
|
147
|
+
[key: string]: any
|
|
148
|
+
}>
|
|
149
|
+
>
|
|
150
|
+
/* Boolean indicating whether the reranker is currently processing a request */
|
|
151
|
+
isProcessing?: () => Data<boolean>
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/* Local rerank based on GGML and [llama.cpp](https://github.com/ggerganov/llama.cpp)
|
|
156
|
+
|
|
157
|
+
## Notice
|
|
158
|
+
- The device RAM must be larger than 8GB
|
|
159
|
+
- iOS: Recommended use M1+ / A17+ chip device. Supported GPU acceleration by Metal.
|
|
160
|
+
- macOS: Recommended use M1+ chip device. Supported GPU acceleration by Metal.
|
|
161
|
+
- Android: Recommended use Android 13+ system.
|
|
162
|
+
- Supported GPU acceleration by OpenCL, currently only for Qualcomm Adreno 700+ GPUs, other GPUs are not supported.
|
|
163
|
+
- Supported Hexagon NPU for Qualcomm Snapdragon 8 Gen 2+ GPUs.
|
|
164
|
+
- Linux / Windows
|
|
165
|
+
- Supported GPU acceleration, you can choose `vulkan` or `cuda` backend in Accel Variant property
|
|
166
|
+
- Supported Hexagon NPU for Qualcomm Dragonwing IQ9 series+ (Linux) */
|
|
167
|
+
export type GeneratorReranker = Generator &
|
|
168
|
+
GeneratorRerankerDef & {
|
|
169
|
+
templateKey: 'GENERATOR_RERANKER'
|
|
170
|
+
switches?: Array<
|
|
171
|
+
SwitchDef &
|
|
172
|
+
GeneratorRerankerDef & {
|
|
173
|
+
conds?: Array<{
|
|
174
|
+
method: '==' | '!=' | '>' | '<' | '>=' | '<='
|
|
175
|
+
cond:
|
|
176
|
+
| SwitchCondInnerStateCurrentCanvas
|
|
177
|
+
| SwitchCondData
|
|
178
|
+
| {
|
|
179
|
+
__typename: 'SwitchCondInnerStateOutlet'
|
|
180
|
+
outlet:
|
|
181
|
+
| 'contextState'
|
|
182
|
+
| 'contextLoadProgress'
|
|
183
|
+
| 'contextDetails'
|
|
184
|
+
| 'rerankResult'
|
|
185
|
+
| 'isProcessing'
|
|
186
|
+
value: any
|
|
187
|
+
}
|
|
188
|
+
}>
|
|
189
|
+
}
|
|
190
|
+
>
|
|
191
|
+
}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/* Auto generated by build script
|
|
2
|
+
*
|
|
3
|
+
* Serial port communication for USB/UART devices (Android, Desktop only)
|
|
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
|
+
/* Get available serial devices */
|
|
19
|
+
export type GeneratorSerialPortActionGeneratorSerialGetDeviceList = Action & {
|
|
20
|
+
__actionName: 'GENERATOR_SERIAL_GET_DEVICE_LIST'
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/* Attach device */
|
|
24
|
+
export type GeneratorSerialPortActionGeneratorSerialAttach = Action & {
|
|
25
|
+
__actionName: 'GENERATOR_SERIAL_ATTACH'
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/* Dettach device */
|
|
29
|
+
export type GeneratorSerialPortActionGeneratorSerialDetach = Action & {
|
|
30
|
+
__actionName: 'GENERATOR_SERIAL_DETACH'
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/* Send string data (ASCII) */
|
|
34
|
+
export type GeneratorSerialPortActionGeneratorSerialSendString = ActionWithParams & {
|
|
35
|
+
__actionName: 'GENERATOR_SERIAL_SEND_STRING'
|
|
36
|
+
params?: Array<
|
|
37
|
+
| {
|
|
38
|
+
input: 'generatorSerialStringValue'
|
|
39
|
+
value?: string | DataLink | EventProperty
|
|
40
|
+
mapping?: string
|
|
41
|
+
}
|
|
42
|
+
| {
|
|
43
|
+
input: 'generatorSerialStringEncoding'
|
|
44
|
+
value?: string | DataLink | EventProperty
|
|
45
|
+
mapping?: string
|
|
46
|
+
}
|
|
47
|
+
>
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/* Send hex string (e.g. 0123456789ABCDEF) */
|
|
51
|
+
export type GeneratorSerialPortActionGeneratorSerialSendHex = ActionWithParams & {
|
|
52
|
+
__actionName: 'GENERATOR_SERIAL_SEND_HEX'
|
|
53
|
+
params?: Array<{
|
|
54
|
+
input: 'generatorSerialHexValue'
|
|
55
|
+
value?: string | DataLink | EventProperty
|
|
56
|
+
mapping?: string
|
|
57
|
+
}>
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
interface GeneratorSerialPortDef {
|
|
61
|
+
/*
|
|
62
|
+
Default property:
|
|
63
|
+
{
|
|
64
|
+
"attachOnInit": false,
|
|
65
|
+
"driver": "fd",
|
|
66
|
+
"parityBit": "none",
|
|
67
|
+
"dataBits": 8,
|
|
68
|
+
"stopBits": 1,
|
|
69
|
+
"commMode": "raw"
|
|
70
|
+
}
|
|
71
|
+
*/
|
|
72
|
+
property?: {
|
|
73
|
+
/* Try attach on generator initialized On web require user activation to attach device */
|
|
74
|
+
attachOnInit?: boolean | DataLink
|
|
75
|
+
/* The serial device driver */
|
|
76
|
+
driver?: 'fd' | 'usb' | DataLink
|
|
77
|
+
/* The serial device path e.g. /dev/ttyS0 or /dev/bus/usb/001/001 For desktop and web is device index number */
|
|
78
|
+
path?: string | DataLink
|
|
79
|
+
/* The serial USB vendor id (autoconnect first) */
|
|
80
|
+
vendorId?: number | DataLink
|
|
81
|
+
/* The serial USB product id */
|
|
82
|
+
productId?: number | DataLink
|
|
83
|
+
/* The super user binary path (For Android root permission) */
|
|
84
|
+
suPath?: string | DataLink
|
|
85
|
+
/* The serial device baud rate */
|
|
86
|
+
baudRate?: number | DataLink
|
|
87
|
+
/* The serial device parity bit */
|
|
88
|
+
parityBit?: 'none' | 'odd' | 'even' | DataLink
|
|
89
|
+
/* The serial device data bits */
|
|
90
|
+
dataBits?: number | DataLink
|
|
91
|
+
/* The serial device stop bits */
|
|
92
|
+
stopBits?: number | DataLink
|
|
93
|
+
/* The serial device communication mode */
|
|
94
|
+
commMode?: 'raw' | 'EDC' | 'Regex Match' | DataLink
|
|
95
|
+
/* The regex match pattern for packets */
|
|
96
|
+
regexMatch?: string | DataLink
|
|
97
|
+
}
|
|
98
|
+
events?: {
|
|
99
|
+
/* Event for attach the device */
|
|
100
|
+
generatorSerialOnAttach?: Array<EventAction>
|
|
101
|
+
/* Event for detach the device */
|
|
102
|
+
generatorSerialOnDetach?: Array<EventAction>
|
|
103
|
+
/* Event on error */
|
|
104
|
+
generatorSerialOnError?: Array<
|
|
105
|
+
EventAction<string & keyof TemplateEventPropsMap['SerialPort']['generatorSerialOnError']>
|
|
106
|
+
>
|
|
107
|
+
/* Event for receive data */
|
|
108
|
+
generatorSerialOnData?: Array<
|
|
109
|
+
EventAction<string & keyof TemplateEventPropsMap['SerialPort']['generatorSerialOnData']>
|
|
110
|
+
>
|
|
111
|
+
}
|
|
112
|
+
outlets?: {
|
|
113
|
+
/* Available serial devices */
|
|
114
|
+
generatorSerialDeviceList?: () => Data<Array<{ [key: string]: any }>>
|
|
115
|
+
/* Is serial open */
|
|
116
|
+
generatorSerialIsOpen?: () => Data<boolean>
|
|
117
|
+
/* Last rerceive data (Base64) */
|
|
118
|
+
generatorSerialLastDataBase64?: () => Data<string>
|
|
119
|
+
/* Last rerceive plain text */
|
|
120
|
+
generatorSerialLastDataString?: () => Data<string>
|
|
121
|
+
/* Error message */
|
|
122
|
+
generatorSerialErrorMessage?: () => Data<string>
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/* Serial port communication for USB/UART devices (Android, Desktop only) */
|
|
127
|
+
export type GeneratorSerialPort = Generator &
|
|
128
|
+
GeneratorSerialPortDef & {
|
|
129
|
+
templateKey: 'GENERATOR_SERIAL_PORT'
|
|
130
|
+
switches?: Array<
|
|
131
|
+
SwitchDef &
|
|
132
|
+
GeneratorSerialPortDef & {
|
|
133
|
+
conds?: Array<{
|
|
134
|
+
method: '==' | '!=' | '>' | '<' | '>=' | '<='
|
|
135
|
+
cond:
|
|
136
|
+
| SwitchCondInnerStateCurrentCanvas
|
|
137
|
+
| SwitchCondData
|
|
138
|
+
| {
|
|
139
|
+
__typename: 'SwitchCondInnerStateOutlet'
|
|
140
|
+
outlet:
|
|
141
|
+
| 'generatorSerialDeviceList'
|
|
142
|
+
| 'generatorSerialIsOpen'
|
|
143
|
+
| 'generatorSerialLastDataBase64'
|
|
144
|
+
| 'generatorSerialLastDataString'
|
|
145
|
+
| 'generatorSerialErrorMessage'
|
|
146
|
+
value: any
|
|
147
|
+
}
|
|
148
|
+
}>
|
|
149
|
+
}
|
|
150
|
+
>
|
|
151
|
+
}
|