@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.
Files changed (129) hide show
  1. package/compile/action-name-map.ts +988 -0
  2. package/compile/index.ts +1245 -0
  3. package/compile/util.ts +358 -0
  4. package/index.ts +6 -0
  5. package/package.json +28 -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 +32 -0
  9. package/skills/bricks-project/rules/animation.md +159 -0
  10. package/skills/bricks-project/rules/architecture-patterns.md +69 -0
  11. package/skills/bricks-project/rules/automations.md +221 -0
  12. package/skills/bricks-project/rules/buttress.md +156 -0
  13. package/skills/bricks-project/rules/data-calculation.md +208 -0
  14. package/skills/bricks-project/rules/local-sync.md +129 -0
  15. package/skills/bricks-project/rules/media-flow.md +158 -0
  16. package/skills/bricks-project/rules/remote-data-bank.md +196 -0
  17. package/skills/bricks-project/rules/standby-transition.md +124 -0
  18. package/skills/rive-marketplace/SKILL.md +99 -0
  19. package/tools/deploy.ts +151 -0
  20. package/tools/icons/.gitattributes +1 -0
  21. package/tools/icons/fa6pro-glyphmap.json +4686 -0
  22. package/tools/icons/fa6pro-meta.json +3671 -0
  23. package/tools/mcp-server.ts +28 -0
  24. package/tools/mcp-tools/compile.ts +91 -0
  25. package/tools/mcp-tools/huggingface.ts +762 -0
  26. package/tools/mcp-tools/icons.ts +70 -0
  27. package/tools/mcp-tools/lottie.ts +102 -0
  28. package/tools/mcp-tools/media.ts +110 -0
  29. package/tools/postinstall.ts +229 -0
  30. package/tools/preview-main.mjs +293 -0
  31. package/tools/preview.ts +143 -0
  32. package/tools/pull.ts +116 -0
  33. package/tsconfig.json +16 -0
  34. package/types/animation.ts +100 -0
  35. package/types/automation.ts +235 -0
  36. package/types/brick-base.ts +80 -0
  37. package/types/bricks/Camera.ts +246 -0
  38. package/types/bricks/Chart.ts +372 -0
  39. package/types/bricks/GenerativeMedia.ts +276 -0
  40. package/types/bricks/Icon.ts +98 -0
  41. package/types/bricks/Image.ts +114 -0
  42. package/types/bricks/Items.ts +476 -0
  43. package/types/bricks/Lottie.ts +168 -0
  44. package/types/bricks/Maps.ts +262 -0
  45. package/types/bricks/QrCode.ts +117 -0
  46. package/types/bricks/Rect.ts +150 -0
  47. package/types/bricks/RichText.ts +128 -0
  48. package/types/bricks/Rive.ts +220 -0
  49. package/types/bricks/Slideshow.ts +201 -0
  50. package/types/bricks/Svg.ts +99 -0
  51. package/types/bricks/Text.ts +148 -0
  52. package/types/bricks/TextInput.ts +242 -0
  53. package/types/bricks/Video.ts +175 -0
  54. package/types/bricks/VideoStreaming.ts +112 -0
  55. package/types/bricks/WebRtcStream.ts +65 -0
  56. package/types/bricks/WebView.ts +168 -0
  57. package/types/bricks/index.ts +21 -0
  58. package/types/canvas.ts +82 -0
  59. package/types/common.ts +144 -0
  60. package/types/data-calc-command.ts +7005 -0
  61. package/types/data-calc-script.ts +21 -0
  62. package/types/data-calc.ts +11 -0
  63. package/types/data.ts +95 -0
  64. package/types/generators/AlarmClock.ts +110 -0
  65. package/types/generators/Assistant.ts +621 -0
  66. package/types/generators/BleCentral.ts +247 -0
  67. package/types/generators/BlePeripheral.ts +208 -0
  68. package/types/generators/CanvasMap.ts +74 -0
  69. package/types/generators/CastlesPay.ts +87 -0
  70. package/types/generators/DataBank.ts +160 -0
  71. package/types/generators/File.ts +432 -0
  72. package/types/generators/GraphQl.ts +132 -0
  73. package/types/generators/Http.ts +222 -0
  74. package/types/generators/HttpServer.ts +176 -0
  75. package/types/generators/Information.ts +103 -0
  76. package/types/generators/Intent.ts +168 -0
  77. package/types/generators/Iterator.ts +108 -0
  78. package/types/generators/Keyboard.ts +105 -0
  79. package/types/generators/LlmAnthropicCompat.ts +212 -0
  80. package/types/generators/LlmAppleBuiltin.ts +159 -0
  81. package/types/generators/LlmGgml.ts +861 -0
  82. package/types/generators/LlmMediaTekNeuroPilot.ts +235 -0
  83. package/types/generators/LlmMlx.ts +227 -0
  84. package/types/generators/LlmOnnx.ts +213 -0
  85. package/types/generators/LlmOpenAiCompat.ts +244 -0
  86. package/types/generators/LlmQualcommAiEngine.ts +247 -0
  87. package/types/generators/Mcp.ts +637 -0
  88. package/types/generators/McpServer.ts +289 -0
  89. package/types/generators/MediaFlow.ts +170 -0
  90. package/types/generators/MqttBroker.ts +141 -0
  91. package/types/generators/MqttClient.ts +141 -0
  92. package/types/generators/Question.ts +408 -0
  93. package/types/generators/RealtimeTranscription.ts +279 -0
  94. package/types/generators/RerankerGgml.ts +191 -0
  95. package/types/generators/SerialPort.ts +151 -0
  96. package/types/generators/SoundPlayer.ts +94 -0
  97. package/types/generators/SoundRecorder.ts +130 -0
  98. package/types/generators/SpeechToTextGgml.ts +415 -0
  99. package/types/generators/SpeechToTextOnnx.ts +236 -0
  100. package/types/generators/SpeechToTextPlatform.ts +85 -0
  101. package/types/generators/SqLite.ts +159 -0
  102. package/types/generators/Step.ts +107 -0
  103. package/types/generators/SttAppleBuiltin.ts +130 -0
  104. package/types/generators/Tcp.ts +126 -0
  105. package/types/generators/TcpServer.ts +147 -0
  106. package/types/generators/TextToSpeechAppleBuiltin.ts +127 -0
  107. package/types/generators/TextToSpeechGgml.ts +221 -0
  108. package/types/generators/TextToSpeechOnnx.ts +178 -0
  109. package/types/generators/TextToSpeechOpenAiLike.ts +121 -0
  110. package/types/generators/ThermalPrinter.ts +191 -0
  111. package/types/generators/Tick.ts +83 -0
  112. package/types/generators/Udp.ts +120 -0
  113. package/types/generators/VadGgml.ts +250 -0
  114. package/types/generators/VadOnnx.ts +231 -0
  115. package/types/generators/VadTraditional.ts +138 -0
  116. package/types/generators/VectorStore.ts +257 -0
  117. package/types/generators/Watchdog.ts +107 -0
  118. package/types/generators/WebCrawler.ts +103 -0
  119. package/types/generators/WebRtc.ts +181 -0
  120. package/types/generators/WebSocket.ts +148 -0
  121. package/types/generators/index.ts +57 -0
  122. package/types/index.ts +13 -0
  123. package/types/subspace.ts +59 -0
  124. package/types/switch.ts +51 -0
  125. package/types/system.ts +707 -0
  126. package/utils/calc.ts +126 -0
  127. package/utils/data.ts +497 -0
  128. package/utils/event-props.ts +836 -0
  129. package/utils/id.ts +80 -0
@@ -0,0 +1,231 @@
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
+ }
@@ -0,0 +1,138 @@
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
+ }
@@ -0,0 +1,257 @@
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
+ }