@fugood/bricks-ctor 2.25.0-beta.8 → 2.25.0-beta.81

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 (137) hide show
  1. package/package.json +4 -24
  2. package/tools/__tests__/legacy-forwarder.test.js +91 -0
  3. package/tools/_forward.ts +26 -0
  4. package/tools/deploy.ts +3 -164
  5. package/tools/mcp-server.ts +3 -27
  6. package/tools/postinstall.ts +3 -234
  7. package/tools/pull.ts +3 -121
  8. package/tools/push-config.ts +4 -0
  9. package/tools/simulator.ts +4 -0
  10. package/compile/__tests__/index.test.js +0 -115
  11. package/compile/action-name-map.ts +0 -1015
  12. package/compile/index.ts +0 -1458
  13. package/compile/util.ts +0 -358
  14. package/index.ts +0 -6
  15. package/skills/bricks-ctor/SKILL.md +0 -32
  16. package/skills/bricks-ctor/rules/animation.md +0 -160
  17. package/skills/bricks-ctor/rules/architecture-patterns.md +0 -69
  18. package/skills/bricks-ctor/rules/automations.md +0 -221
  19. package/skills/bricks-ctor/rules/buttress.md +0 -156
  20. package/skills/bricks-ctor/rules/data-calculation.md +0 -209
  21. package/skills/bricks-ctor/rules/local-sync.md +0 -129
  22. package/skills/bricks-ctor/rules/media-flow.md +0 -158
  23. package/skills/bricks-ctor/rules/remote-data-bank.md +0 -196
  24. package/skills/bricks-ctor/rules/standby-transition.md +0 -124
  25. package/skills/bricks-design/LICENSE.txt +0 -180
  26. package/skills/bricks-design/SKILL.md +0 -66
  27. package/skills/rive-marketplace/SKILL.md +0 -99
  28. package/tools/_git-author.ts +0 -29
  29. package/tools/_shell.ts +0 -173
  30. package/tools/icons/.gitattributes +0 -1
  31. package/tools/icons/fa6pro-glyphmap.json +0 -4686
  32. package/tools/icons/fa6pro-meta.json +0 -1
  33. package/tools/mcp-tools/compile.ts +0 -92
  34. package/tools/mcp-tools/huggingface.ts +0 -762
  35. package/tools/mcp-tools/icons.ts +0 -81
  36. package/tools/mcp-tools/lottie.ts +0 -102
  37. package/tools/mcp-tools/media.ts +0 -110
  38. package/tools/preview-main.mjs +0 -306
  39. package/tools/preview.ts +0 -150
  40. package/types/animation.ts +0 -111
  41. package/types/automation.ts +0 -235
  42. package/types/brick-base.ts +0 -80
  43. package/types/bricks/Camera.ts +0 -246
  44. package/types/bricks/Chart.ts +0 -372
  45. package/types/bricks/GenerativeMedia.ts +0 -290
  46. package/types/bricks/Icon.ts +0 -98
  47. package/types/bricks/Image.ts +0 -126
  48. package/types/bricks/Items.ts +0 -476
  49. package/types/bricks/Lottie.ts +0 -168
  50. package/types/bricks/Maps.ts +0 -262
  51. package/types/bricks/QrCode.ts +0 -117
  52. package/types/bricks/Rect.ts +0 -150
  53. package/types/bricks/RichText.ts +0 -128
  54. package/types/bricks/Rive.ts +0 -220
  55. package/types/bricks/Sketch.ts +0 -254
  56. package/types/bricks/Slideshow.ts +0 -201
  57. package/types/bricks/Svg.ts +0 -99
  58. package/types/bricks/Text.ts +0 -148
  59. package/types/bricks/TextInput.ts +0 -242
  60. package/types/bricks/Video.ts +0 -175
  61. package/types/bricks/VideoStreaming.ts +0 -112
  62. package/types/bricks/WebRtcStream.ts +0 -65
  63. package/types/bricks/WebView.ts +0 -168
  64. package/types/bricks/index.ts +0 -22
  65. package/types/canvas.ts +0 -82
  66. package/types/common.ts +0 -144
  67. package/types/data-calc-command.ts +0 -7005
  68. package/types/data-calc-script.ts +0 -21
  69. package/types/data-calc.ts +0 -11
  70. package/types/data.ts +0 -95
  71. package/types/generators/AlarmClock.ts +0 -110
  72. package/types/generators/Assistant.ts +0 -621
  73. package/types/generators/BleCentral.ts +0 -247
  74. package/types/generators/BlePeripheral.ts +0 -208
  75. package/types/generators/CanvasMap.ts +0 -74
  76. package/types/generators/CastlesPay.ts +0 -87
  77. package/types/generators/DataBank.ts +0 -160
  78. package/types/generators/File.ts +0 -432
  79. package/types/generators/GraphQl.ts +0 -132
  80. package/types/generators/Http.ts +0 -222
  81. package/types/generators/HttpServer.ts +0 -176
  82. package/types/generators/Information.ts +0 -103
  83. package/types/generators/Intent.ts +0 -168
  84. package/types/generators/Iterator.ts +0 -108
  85. package/types/generators/Keyboard.ts +0 -105
  86. package/types/generators/LlmAnthropicCompat.ts +0 -212
  87. package/types/generators/LlmAppleBuiltin.ts +0 -159
  88. package/types/generators/LlmGgml.ts +0 -861
  89. package/types/generators/LlmMediaTekNeuroPilot.ts +0 -235
  90. package/types/generators/LlmMlx.ts +0 -227
  91. package/types/generators/LlmOnnx.ts +0 -213
  92. package/types/generators/LlmOpenAiCompat.ts +0 -312
  93. package/types/generators/LlmQualcommAiEngine.ts +0 -247
  94. package/types/generators/Mcp.ts +0 -637
  95. package/types/generators/McpServer.ts +0 -289
  96. package/types/generators/MediaFlow.ts +0 -170
  97. package/types/generators/MqttBroker.ts +0 -141
  98. package/types/generators/MqttClient.ts +0 -141
  99. package/types/generators/Question.ts +0 -408
  100. package/types/generators/RealtimeTranscription.ts +0 -287
  101. package/types/generators/RerankerGgml.ts +0 -191
  102. package/types/generators/SerialPort.ts +0 -151
  103. package/types/generators/SoundPlayer.ts +0 -94
  104. package/types/generators/SoundRecorder.ts +0 -130
  105. package/types/generators/SpeechToTextGgml.ts +0 -419
  106. package/types/generators/SpeechToTextOnnx.ts +0 -236
  107. package/types/generators/SpeechToTextPlatform.ts +0 -85
  108. package/types/generators/SqLite.ts +0 -159
  109. package/types/generators/Step.ts +0 -107
  110. package/types/generators/SttAppleBuiltin.ts +0 -130
  111. package/types/generators/Tcp.ts +0 -126
  112. package/types/generators/TcpServer.ts +0 -147
  113. package/types/generators/TextToSpeechAppleBuiltin.ts +0 -127
  114. package/types/generators/TextToSpeechGgml.ts +0 -221
  115. package/types/generators/TextToSpeechOnnx.ts +0 -178
  116. package/types/generators/TextToSpeechOpenAiLike.ts +0 -121
  117. package/types/generators/ThermalPrinter.ts +0 -191
  118. package/types/generators/Tick.ts +0 -83
  119. package/types/generators/Udp.ts +0 -120
  120. package/types/generators/VadGgml.ts +0 -250
  121. package/types/generators/VadOnnx.ts +0 -231
  122. package/types/generators/VadTraditional.ts +0 -138
  123. package/types/generators/VectorStore.ts +0 -257
  124. package/types/generators/Watchdog.ts +0 -107
  125. package/types/generators/WebCrawler.ts +0 -103
  126. package/types/generators/WebRtc.ts +0 -181
  127. package/types/generators/WebSocket.ts +0 -148
  128. package/types/generators/index.ts +0 -57
  129. package/types/index.ts +0 -13
  130. package/types/subspace.ts +0 -60
  131. package/types/switch.ts +0 -51
  132. package/types/system.ts +0 -707
  133. package/utils/__tests__/id.test.js +0 -58
  134. package/utils/calc.ts +0 -126
  135. package/utils/data.ts +0 -497
  136. package/utils/event-props.ts +0 -886
  137. package/utils/id.ts +0 -80
@@ -1,231 +0,0 @@
1
- /* Auto generated by build script
2
- *
3
- * Local Voice Activity Detection (VAD) inference based on [transformers.js](https://huggingface.co/docs/transformers.js)
4
- * You can use any compatible VAD model from HuggingFace (Silero VAD, smart-turn, etc.)
5
- */
6
- import type { SwitchCondInnerStateCurrentCanvas, SwitchCondData, SwitchDef } from '../switch'
7
- import type { Data, DataLink } from '../data'
8
- import type {
9
- Brick,
10
- Generator,
11
- EventAction,
12
- ActionWithDataParams,
13
- ActionWithParams,
14
- Action,
15
- EventProperty,
16
- } from '../common'
17
- import type { TemplateEventPropsMap } from '../../utils/event-props'
18
-
19
- /* Load the model */
20
- export type GeneratorVadInferenceOnnxActionLoadModel = Action & {
21
- __actionName: 'GENERATOR_ONNX_VAD_LOAD_MODEL'
22
- }
23
-
24
- /* Detect speech in audio file */
25
- export type GeneratorVadInferenceOnnxActionDetectFile = ActionWithParams & {
26
- __actionName: 'GENERATOR_ONNX_VAD_DETECT_FILE'
27
- params?: Array<
28
- | {
29
- input: 'fileUrl'
30
- value?: string | DataLink | EventProperty
31
- mapping?: string
32
- }
33
- | {
34
- input: 'threshold'
35
- value?: number | DataLink | EventProperty
36
- mapping?: string
37
- }
38
- | {
39
- input: 'minSpeechDurationMs'
40
- value?: number | DataLink | EventProperty
41
- mapping?: string
42
- }
43
- | {
44
- input: 'minSilenceDurationMs'
45
- value?: number | DataLink | EventProperty
46
- mapping?: string
47
- }
48
- | {
49
- input: 'maxSpeechDurationS'
50
- value?: number | DataLink | EventProperty
51
- mapping?: string
52
- }
53
- | {
54
- input: 'speechPadMs'
55
- value?: number | DataLink | EventProperty
56
- mapping?: string
57
- }
58
- >
59
- }
60
-
61
- /* Detect speech in audio data */
62
- export type GeneratorVadInferenceOnnxActionDetectData = ActionWithParams & {
63
- __actionName: 'GENERATOR_ONNX_VAD_DETECT_DATA'
64
- params?: Array<
65
- | {
66
- input: 'data'
67
- value?: any | EventProperty
68
- mapping?: string
69
- }
70
- | {
71
- input: 'threshold'
72
- value?: number | DataLink | EventProperty
73
- mapping?: string
74
- }
75
- | {
76
- input: 'minSpeechDurationMs'
77
- value?: number | DataLink | EventProperty
78
- mapping?: string
79
- }
80
- | {
81
- input: 'minSilenceDurationMs'
82
- value?: number | DataLink | EventProperty
83
- mapping?: string
84
- }
85
- | {
86
- input: 'maxSpeechDurationS'
87
- value?: number | DataLink | EventProperty
88
- mapping?: string
89
- }
90
- | {
91
- input: 'speechPadMs'
92
- value?: number | DataLink | EventProperty
93
- mapping?: string
94
- }
95
- >
96
- }
97
-
98
- /* Clean cache */
99
- export type GeneratorVadInferenceOnnxActionCleanCache = Action & {
100
- __actionName: 'GENERATOR_ONNX_VAD_CLEAN_CACHE'
101
- }
102
-
103
- /* Release context */
104
- export type GeneratorVadInferenceOnnxActionReleaseContext = Action & {
105
- __actionName: 'GENERATOR_ONNX_VAD_RELEASE_CONTEXT'
106
- }
107
-
108
- interface GeneratorVadInferenceOnnxDef {
109
- /*
110
- Default property:
111
- {
112
- "modelType": "auto",
113
- "detectThreshold": 0.5,
114
- "detectMinSpeechDurationMs": 250,
115
- "detectMinSilenceDurationMs": 100,
116
- "detectMaxSpeechDurationS": 30,
117
- "detectSpeechPadMs": 30,
118
- "executionMode": "sequential"
119
- }
120
- */
121
- property?: {
122
- /* Initialize the VAD context on generator initialization */
123
- init?: boolean | DataLink
124
- /* VAD model */
125
- model?: string | DataLink
126
- /* Model type (auto-detected from config.json) */
127
- modelType?: string | DataLink
128
- /* Quantize type */
129
- quantizeType?:
130
- | 'auto'
131
- | 'none'
132
- | 'fp16'
133
- | 'q8'
134
- | 'int8'
135
- | 'uint8'
136
- | 'q4'
137
- | 'bnb4'
138
- | 'q4f16'
139
- | DataLink
140
- /* Speech probability threshold (0.0-1.0) */
141
- detectThreshold?: number | DataLink
142
- /* Minimum speech duration in milliseconds */
143
- detectMinSpeechDurationMs?: number | DataLink
144
- /* Minimum silence duration in milliseconds */
145
- detectMinSilenceDurationMs?: number | DataLink
146
- /* Maximum speech duration in seconds */
147
- detectMaxSpeechDurationS?: number | DataLink
148
- /* Padding around speech segments in milliseconds */
149
- detectSpeechPadMs?: number | DataLink
150
- /* Executor candidates, descending order of priority
151
- Default will be xnnpack, wasm, cpu */
152
- executors?:
153
- | Array<'qnn' | 'dml' | 'nnapi' | 'xnnpack' | 'coreml' | 'cpu' | 'wasm' | 'webgpu' | DataLink>
154
- | DataLink
155
- /* Execution mode
156
- Usually when the model has many branches, setting this option to `parallel` will give you better performance. */
157
- executionMode?: 'sequential' | 'parallel' | DataLink
158
- /* QNN backend */
159
- qnnBackend?: 'HTP' | 'HTA' | 'DSP' | 'GPU' | 'CPU' | DataLink
160
- /* Enable FP16 for QNN HTP */
161
- qnnHtpEnableFp16?: boolean | DataLink
162
- /* Enable QNN debug */
163
- qnnEnableDebug?: boolean | DataLink
164
- }
165
- events?: {
166
- /* Event triggered when context state changes */
167
- onContextStateChange?: Array<
168
- EventAction<string & keyof TemplateEventPropsMap['OnnxVad']['onContextStateChange']>
169
- >
170
- /* Event triggered when error occurs */
171
- onError?: Array<EventAction<string & keyof TemplateEventPropsMap['OnnxVad']['onError']>>
172
- /* Event triggered when got detection result */
173
- onDetected?: Array<EventAction<string & keyof TemplateEventPropsMap['OnnxVad']['onDetected']>>
174
- }
175
- outlets?: {
176
- /* Context state */
177
- contextState?: () => Data<string>
178
- /* Is detecting */
179
- isDetecting?: () => Data<boolean>
180
- /* Detection segments result */
181
- detectionSegments?: () => Data<
182
- Array<{
183
- start?: number
184
- end?: number
185
- confidence?: number
186
- t0?: number
187
- t1?: number
188
- [key: string]: any
189
- }>
190
- >
191
- /* Detection details */
192
- detectionDetails?: () => Data<{
193
- result?: string
194
- segments?: Array<{
195
- start?: number
196
- end?: number
197
- confidence?: number
198
- t0?: number
199
- t1?: number
200
- [key: string]: any
201
- }>
202
- time?: number
203
- startTime?: number
204
- endTime?: number
205
- [key: string]: any
206
- }>
207
- }
208
- }
209
-
210
- /* Local Voice Activity Detection (VAD) inference based on [transformers.js](https://huggingface.co/docs/transformers.js)
211
- You can use any compatible VAD model from HuggingFace (Silero VAD, smart-turn, etc.) */
212
- export type GeneratorVadInferenceOnnx = Generator &
213
- GeneratorVadInferenceOnnxDef & {
214
- templateKey: 'GENERATOR_ONNX_VAD'
215
- switches?: Array<
216
- SwitchDef &
217
- GeneratorVadInferenceOnnxDef & {
218
- conds?: Array<{
219
- method: '==' | '!=' | '>' | '<' | '>=' | '<='
220
- cond:
221
- | SwitchCondInnerStateCurrentCanvas
222
- | SwitchCondData
223
- | {
224
- __typename: 'SwitchCondInnerStateOutlet'
225
- outlet: 'contextState' | 'isDetecting' | 'detectionSegments' | 'detectionDetails'
226
- value: any
227
- }
228
- }>
229
- }
230
- >
231
- }
@@ -1,138 +0,0 @@
1
- /* Auto generated by build script
2
- *
3
- * Traditional Voice Activity Detection (VAD) using pitch detection and RMS volume analysis
4
- * No model download required - pure algorithmic approach
5
- */
6
- import type { SwitchCondInnerStateCurrentCanvas, SwitchCondData, SwitchDef } from '../switch'
7
- import type { Data, DataLink } from '../data'
8
- import type {
9
- Brick,
10
- Generator,
11
- EventAction,
12
- ActionWithDataParams,
13
- ActionWithParams,
14
- Action,
15
- EventProperty,
16
- } from '../common'
17
- import type { TemplateEventPropsMap } from '../../utils/event-props'
18
-
19
- /* Detect speech in audio file */
20
- export type GeneratorVadInferenceTraditionalActionDetectFile = ActionWithParams & {
21
- __actionName: 'GENERATOR_TRADITIONAL_VAD_DETECT_FILE'
22
- params?: Array<{
23
- input: 'fileUrl'
24
- value?: string | DataLink | EventProperty
25
- mapping?: string
26
- }>
27
- }
28
-
29
- /* Detect speech in audio data stream */
30
- export type GeneratorVadInferenceTraditionalActionDetectData = ActionWithParams & {
31
- __actionName: 'GENERATOR_TRADITIONAL_VAD_DETECT_DATA'
32
- params?: Array<{
33
- input: 'data'
34
- value?: any | EventProperty
35
- mapping?: string
36
- }>
37
- }
38
-
39
- interface GeneratorVadInferenceTraditionalDef {
40
- /*
41
- Default property:
42
- {
43
- "detectVocalFreqMin": 75,
44
- "detectVocalFreqMax": 900,
45
- "detectThreshold": 0.5,
46
- "detectMinSpeechDurationMs": 250,
47
- "detectMinSilenceDurationMs": 100,
48
- "detectMaxSpeechDurationS": 30,
49
- "detectSpeechPadMs": 30
50
- }
51
- */
52
- property?: {
53
- /* Minimum vocal frequency in Hz */
54
- detectVocalFreqMin?: number | DataLink
55
- /* Maximum vocal frequency in Hz */
56
- detectVocalFreqMax?: number | DataLink
57
- /* Volume threshold in dB */
58
- detectVolumeThreshold?: number | DataLink
59
- /* Speech probability threshold (0.0-1.0) - maps to frequency clarity */
60
- detectThreshold?: number | DataLink
61
- /* Minimum speech duration in milliseconds */
62
- detectMinSpeechDurationMs?: number | DataLink
63
- /* Minimum silence duration in milliseconds */
64
- detectMinSilenceDurationMs?: number | DataLink
65
- /* Maximum speech duration in seconds */
66
- detectMaxSpeechDurationS?: number | DataLink
67
- /* Padding around speech segments in milliseconds */
68
- detectSpeechPadMs?: number | DataLink
69
- /* The file URL or path to be analyzed */
70
- detectFileUrl?: string | DataLink
71
- /* MD5 of file to be analyzed */
72
- detectFileMd5?: string | DataLink
73
- }
74
- events?: {
75
- /* Event triggered when context state changes */
76
- onContextStateChange?: Array<
77
- EventAction<string & keyof TemplateEventPropsMap['TraditionalVad']['onContextStateChange']>
78
- >
79
- /* Event triggered when detection result is available */
80
- onDetected?: Array<
81
- EventAction<string & keyof TemplateEventPropsMap['TraditionalVad']['onDetected']>
82
- >
83
- /* Event triggered when error occurs */
84
- onError?: Array<EventAction<string & keyof TemplateEventPropsMap['TraditionalVad']['onError']>>
85
- }
86
- outlets?: {
87
- /* Context state */
88
- contextState?: () => Data<string>
89
- /* Is detecting */
90
- isDetecting?: () => Data<boolean>
91
- /* Is speaking (real-time) */
92
- isSpeaking?: () => Data<boolean>
93
- /* Detection segments result */
94
- detectionSegments?: () => Data<
95
- Array<{
96
- t0?: number
97
- t1?: number
98
- [key: string]: any
99
- }>
100
- >
101
- /* Current volume in dB */
102
- currentVolume?: () => Data<number>
103
- /* Current frequency clarity (0-1) */
104
- currentClarity?: () => Data<number>
105
- /* Current detected frequency in Hz */
106
- currentFrequency?: () => Data<number>
107
- }
108
- }
109
-
110
- /* Traditional Voice Activity Detection (VAD) using pitch detection and RMS volume analysis
111
- No model download required - pure algorithmic approach */
112
- export type GeneratorVadInferenceTraditional = Generator &
113
- GeneratorVadInferenceTraditionalDef & {
114
- templateKey: 'GENERATOR_TRADITIONAL_VAD'
115
- switches?: Array<
116
- SwitchDef &
117
- GeneratorVadInferenceTraditionalDef & {
118
- conds?: Array<{
119
- method: '==' | '!=' | '>' | '<' | '>=' | '<='
120
- cond:
121
- | SwitchCondInnerStateCurrentCanvas
122
- | SwitchCondData
123
- | {
124
- __typename: 'SwitchCondInnerStateOutlet'
125
- outlet:
126
- | 'contextState'
127
- | 'isDetecting'
128
- | 'isSpeaking'
129
- | 'detectionSegments'
130
- | 'currentVolume'
131
- | 'currentClarity'
132
- | 'currentFrequency'
133
- value: any
134
- }
135
- }>
136
- }
137
- >
138
- }
@@ -1,257 +0,0 @@
1
- /* Auto generated by build script
2
- *
3
- * Vector database for semantic search. Supports GGML (on-device GGUF models) and OpenAI Compatible API (OpenAI/ollama/llama.cpp) as embedding sources
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 the model (Only if source is ggml) */
19
- export type GeneratorVectorStoreActionModelLoad = Action & {
20
- __actionName: 'GENERATOR_VECTOR_STORE_MODEL_LOAD'
21
- }
22
-
23
- /* Release the model (Only if source is ggml) */
24
- export type GeneratorVectorStoreActionModelRelease = Action & {
25
- __actionName: 'GENERATOR_VECTOR_STORE_MODEL_RELEASE'
26
- }
27
-
28
- /* Reset the embedding session */
29
- export type GeneratorVectorStoreActionReset = ActionWithParams & {
30
- __actionName: 'GENERATOR_VECTOR_STORE_RESET'
31
- params?: Array<{
32
- input: 'resetType'
33
- value?: 'session' | 'all' | DataLink | EventProperty
34
- mapping?: string
35
- }>
36
- }
37
-
38
- /* Insert file content with path or url, support Office / OpenOffice / PDF
39
-
40
- PDF is not currently supprted in iOS / Android */
41
- export type GeneratorVectorStoreActionInsertFile = ActionWithParams & {
42
- __actionName: 'GENERATOR_VECTOR_STORE_INSERT_FILE'
43
- params?: Array<
44
- | {
45
- input: 'filePath'
46
- value?: string | DataLink | EventProperty
47
- mapping?: string
48
- }
49
- | {
50
- input: 'fileName'
51
- value?: string | DataLink | EventProperty
52
- mapping?: string
53
- }
54
- | {
55
- input: 'fileExtension'
56
- value?: string | DataLink | EventProperty
57
- mapping?: string
58
- }
59
- | {
60
- input: 'chunkSize'
61
- value?: number | DataLink | EventProperty
62
- mapping?: string
63
- }
64
- >
65
- }
66
-
67
- /* Cancel the file download */
68
- export type GeneratorVectorStoreActionCancelFileDownload = Action & {
69
- __actionName: 'GENERATOR_VECTOR_STORE_CANCEL_FILE_DOWNLOAD'
70
- }
71
-
72
- /* Insert pure text content to vector store */
73
- export type GeneratorVectorStoreActionInsertContent = ActionWithParams & {
74
- __actionName: 'GENERATOR_VECTOR_STORE_INSERT_CONTENT'
75
- params?: Array<
76
- | {
77
- input: 'textContent'
78
- value?: string | DataLink | EventProperty
79
- mapping?: string
80
- }
81
- | {
82
- input: 'fileName'
83
- value?: string | DataLink | EventProperty
84
- mapping?: string
85
- }
86
- | {
87
- input: 'payload'
88
- value?: {} | DataLink | EventProperty
89
- mapping?: string
90
- }
91
- | {
92
- input: 'chunkSize'
93
- value?: number | DataLink | EventProperty
94
- mapping?: string
95
- }
96
- >
97
- }
98
-
99
- /* Remove file from vector store */
100
- export type GeneratorVectorStoreActionRemoveFile = ActionWithParams & {
101
- __actionName: 'GENERATOR_VECTOR_STORE_REMOVE_FILE'
102
- params?: Array<{
103
- input: 'fileName'
104
- value?: string | DataLink | EventProperty
105
- mapping?: string
106
- }>
107
- }
108
-
109
- /* Search similar text chunks in vector store */
110
- export type GeneratorVectorStoreActionSearch = ActionWithParams & {
111
- __actionName: 'GENERATOR_VECTOR_STORE_SEARCH'
112
- params?: Array<
113
- | {
114
- input: 'text'
115
- value?: string | DataLink | EventProperty
116
- mapping?: string
117
- }
118
- | {
119
- input: 'filename'
120
- value?: string | DataLink | EventProperty
121
- mapping?: string
122
- }
123
- | {
124
- input: 'limit'
125
- value?: number | DataLink | EventProperty
126
- mapping?: string
127
- }
128
- | {
129
- input: 'threshold'
130
- value?: number | DataLink | EventProperty
131
- mapping?: string
132
- }
133
- | {
134
- input: 'ignoreThreshold'
135
- value?: boolean | DataLink | EventProperty
136
- mapping?: string
137
- }
138
- >
139
- }
140
-
141
- interface GeneratorVectorStoreDef {
142
- /*
143
- Default property:
144
- {
145
- "source": "ggml",
146
- "ggmlContextSize": 512,
147
- "openaiBaseUrl": "https://api.openai.com/v1",
148
- "openaiModel": "text-embedding-3-small",
149
- "embedSessionId": "default-embeddings",
150
- "fileChunkSize": 256
151
- }
152
- */
153
- property?: {
154
- /* Initialize embedding model context & tokenizer context on subspace mounted */
155
- init?: boolean | DataLink
156
- /* Source of embedding model. Note that you can't use the saved embedddings data in different sources. */
157
- source?: 'ggml' | 'openai' | DataLink
158
- /* Path of ggml model */
159
- ggmlModelUrl?: string | DataLink
160
- /* Hash type of ggml model */
161
- ggmlModelHashType?: 'sha256' | 'sha1' | 'md5' | DataLink
162
- /* Hash of ggml model */
163
- ggmlModelHash?: string | DataLink
164
- /* Size of ggml context */
165
- ggmlContextSize?: number | DataLink
166
- /* Pooling type of ggml model */
167
- ggmlPoolingType?: 'none' | 'mean' | 'cls' | 'last' | 'rank' | DataLink
168
- /* GGML accelerator variant (Only for desktop)
169
- `default` - CPU / Metal (macOS)
170
- `vulkan` - Use Vulkan
171
- `cuda` - Use CUDA
172
- `snapdragon` - Use OpenCL/Hexagon of Qualcomm Snapdragon */
173
- ggmlAccelVariant?: 'default' | 'vulkan' | 'cuda' | 'snapdragon' | DataLink
174
- /* Devices. For example:
175
-
176
- Metal or CPU for iOS/tvOS/MacOS
177
- OpenCL or CPU for Android
178
- - Add `HTP0`, `HTP1`, `...` for OpenCL/Hexagon devices (Use HTP* for all HTP devices)
179
- For Desktop, you may want to include/exclude GPUs */
180
- ggmlDevices?: Array<string | DataLink> | DataLink
181
- /* Normalize */
182
- ggmlEmbdNormalize?: number | DataLink
183
- /* API key of OpenAI Compatible API */
184
- openaiApiKey?: string | DataLink
185
- /* Base URL of OpenAI Compatible API. For example, we can use ollama / llama.cpp server instead of openai */
186
- openaiBaseUrl?: string | DataLink
187
- /* Model of OpenAI Compatible API */
188
- openaiModel?: 'text-embedding-3-small' | 'text-embedding-3-large' | DataLink
189
- /* Session ID of embedding */
190
- embedSessionId?: string | DataLink
191
- /* Storage type of embedding */
192
- embedStorageType?: 'file' | 'memory' | DataLink
193
- /* Tokenizer model URL (Recommended to use same with your LLM model, the model will just load with vocab_only mode) */
194
- tokenizerModelUrl?: string | DataLink
195
- /* Tokenizer model hash */
196
- tokenizerModelHash?: string | DataLink
197
- /* Tokenizer model hash type */
198
- tokenizerModelHashType?: 'sha256' | 'sha1' | 'md5' | DataLink
199
- /* Chunk size to handle file content (token), must be less then embedding model context size */
200
- fileChunkSize?: number | DataLink
201
- }
202
- events?: {
203
- /* Event triggered when error occurs */
204
- onError?: Array<EventAction<string & keyof TemplateEventPropsMap['VectorStore']['onError']>>
205
- }
206
- outlets?: {
207
- /* undefined */
208
- isReady?: () => Data<boolean>
209
- /* Whether the embedding is processing */
210
- processing?: () => Data<boolean>
211
- /* Progress of embedding processing */
212
- processProgress?: () => Data<{
213
- chunking?: number
214
- embedding?: number
215
- writing?: number
216
- [key: string]: any
217
- }>
218
- /* Files inserted to embedding */
219
- files?: () => Data<Array<string>>
220
- /* Search result */
221
- searchResult?: () => Data<
222
- Array<{
223
- sessionId?: string
224
- payload?: { [key: string]: any }
225
- filename?: string
226
- text?: string
227
- textTokenSize?: number
228
- fileTokenPos?: number
229
- fileTokenLength?: number
230
- distance?: number
231
- [key: string]: any
232
- }>
233
- >
234
- }
235
- }
236
-
237
- /* Vector database for semantic search. Supports GGML (on-device GGUF models) and OpenAI Compatible API (OpenAI/ollama/llama.cpp) as embedding sources */
238
- export type GeneratorVectorStore = Generator &
239
- GeneratorVectorStoreDef & {
240
- templateKey: 'GENERATOR_VECTOR_STORE'
241
- switches?: Array<
242
- SwitchDef &
243
- GeneratorVectorStoreDef & {
244
- conds?: Array<{
245
- method: '==' | '!=' | '>' | '<' | '>=' | '<='
246
- cond:
247
- | SwitchCondInnerStateCurrentCanvas
248
- | SwitchCondData
249
- | {
250
- __typename: 'SwitchCondInnerStateOutlet'
251
- outlet: 'isReady' | 'processing' | 'processProgress' | 'files' | 'searchResult'
252
- value: any
253
- }
254
- }>
255
- }
256
- >
257
- }