@fugood/bricks-project 2.22.0-beta.9 → 2.22.1
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 +108 -17
- package/compile/index.ts +10 -1
- package/package.json +3 -4
- package/tools/postinstall.ts +16 -9
- package/types/animation.ts +2 -1
- package/types/brick-base.ts +79 -0
- package/types/bricks/3DViewer.ts +200 -0
- package/types/bricks/Camera.ts +195 -0
- package/types/bricks/Chart.ts +362 -0
- package/types/bricks/GenerativeMedia.ts +240 -0
- package/types/bricks/Icon.ts +93 -0
- package/types/bricks/Image.ts +104 -0
- package/types/bricks/Items.ts +461 -0
- package/types/bricks/Lottie.ts +159 -0
- package/types/bricks/QrCode.ts +112 -0
- package/types/bricks/Rect.ts +110 -0
- package/types/bricks/RichText.ts +123 -0
- package/types/bricks/Rive.ts +209 -0
- package/types/bricks/Slideshow.ts +155 -0
- package/types/bricks/Svg.ts +94 -0
- package/types/bricks/Text.ts +143 -0
- package/types/bricks/TextInput.ts +231 -0
- package/types/bricks/Video.ts +170 -0
- package/types/bricks/VideoStreaming.ts +107 -0
- package/types/bricks/WebRtcStream.ts +60 -0
- package/types/bricks/WebView.ts +157 -0
- package/types/bricks/index.ts +19 -0
- package/types/common.ts +8 -3
- package/types/data.ts +6 -0
- package/types/generators/AlarmClock.ts +102 -0
- package/types/generators/Assistant.ts +546 -0
- package/types/generators/BleCentral.ts +225 -0
- package/types/generators/BlePeripheral.ts +202 -0
- package/types/generators/CanvasMap.ts +57 -0
- package/types/generators/CastlesPay.ts +77 -0
- package/types/generators/DataBank.ts +123 -0
- package/types/generators/File.ts +351 -0
- package/types/generators/GraphQl.ts +124 -0
- package/types/generators/Http.ts +117 -0
- package/types/generators/HttpServer.ts +164 -0
- package/types/generators/Information.ts +97 -0
- package/types/generators/Intent.ts +107 -0
- package/types/generators/Iterator.ts +95 -0
- package/types/generators/Keyboard.ts +85 -0
- package/types/generators/LlmAnthropicCompat.ts +188 -0
- package/types/generators/LlmGgml.ts +719 -0
- package/types/generators/LlmOnnx.ts +184 -0
- package/types/generators/LlmOpenAiCompat.ts +206 -0
- package/types/generators/LlmQualcommAiEngine.ts +213 -0
- package/types/generators/Mcp.ts +294 -0
- package/types/generators/McpServer.ts +248 -0
- package/types/generators/MediaFlow.ts +142 -0
- package/types/generators/MqttBroker.ts +121 -0
- package/types/generators/MqttClient.ts +129 -0
- package/types/generators/Question.ts +395 -0
- package/types/generators/RealtimeTranscription.ts +180 -0
- package/types/generators/RerankerGgml.ts +153 -0
- package/types/generators/SerialPort.ts +141 -0
- package/types/generators/SoundPlayer.ts +86 -0
- package/types/generators/SoundRecorder.ts +113 -0
- package/types/generators/SpeechToTextGgml.ts +462 -0
- package/types/generators/SpeechToTextOnnx.ts +227 -0
- package/types/generators/SpeechToTextPlatform.ts +75 -0
- package/types/generators/SqLite.ts +118 -0
- package/types/generators/Step.ts +101 -0
- package/types/generators/Tcp.ts +120 -0
- package/types/generators/TcpServer.ts +137 -0
- package/types/generators/TextToSpeechGgml.ts +182 -0
- package/types/generators/TextToSpeechOnnx.ts +169 -0
- package/types/generators/TextToSpeechOpenAiLike.ts +113 -0
- package/types/generators/ThermalPrinter.ts +185 -0
- package/types/generators/Tick.ts +75 -0
- package/types/generators/Udp.ts +109 -0
- package/types/generators/VadGgml.ts +211 -0
- package/types/generators/VectorStore.ts +223 -0
- package/types/generators/Watchdog.ts +96 -0
- package/types/generators/WebCrawler.ts +97 -0
- package/types/generators/WebRtc.ts +165 -0
- package/types/generators/WebSocket.ts +142 -0
- package/types/generators/index.ts +50 -0
- package/types/system.ts +64 -0
- package/utils/data.ts +45 -0
- package/utils/event-props.ts +89 -13
- package/types/bricks.ts +0 -3168
- package/types/generators.ts +0 -7633
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type { SwitchCondInnerStateCurrentCanvas, SwitchCondData, SwitchDef } from '../switch'
|
|
2
|
+
import type { Data, DataLink } from '../data'
|
|
3
|
+
import type {
|
|
4
|
+
Generator,
|
|
5
|
+
EventAction,
|
|
6
|
+
ActionWithDataParams,
|
|
7
|
+
ActionWithParams,
|
|
8
|
+
Action,
|
|
9
|
+
EventProperty,
|
|
10
|
+
} from '../common'
|
|
11
|
+
|
|
12
|
+
/* Start the tick */
|
|
13
|
+
export type GeneratorTickAction_ = Action & {
|
|
14
|
+
__actionName: 'GENERATOR_TICK'
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/* Cancel the tick */
|
|
18
|
+
export type GeneratorTickActionCancel = Action & {
|
|
19
|
+
__actionName: 'GENERATOR_TICK_CANCEL'
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
interface GeneratorTickDef {
|
|
23
|
+
/*
|
|
24
|
+
Default property:
|
|
25
|
+
{}
|
|
26
|
+
*/
|
|
27
|
+
property?: {
|
|
28
|
+
/* Start tick on generator initialized */
|
|
29
|
+
init?: boolean | DataLink
|
|
30
|
+
/* Interval of second for countdown */
|
|
31
|
+
interval?: number | DataLink
|
|
32
|
+
/* Initial value of countdown */
|
|
33
|
+
countdownStartValue?: number | DataLink
|
|
34
|
+
/* Interval of value for countdown */
|
|
35
|
+
countdownInterval?: number | DataLink
|
|
36
|
+
/* Make countdown repeatable */
|
|
37
|
+
repeat?: boolean | DataLink
|
|
38
|
+
/* Map for PROPERTY_BANK_RESULT */
|
|
39
|
+
map?: {} | DataLink
|
|
40
|
+
/* Fallback of MAP_OBJECT */
|
|
41
|
+
mapFallback?: any
|
|
42
|
+
}
|
|
43
|
+
events?: {
|
|
44
|
+
/* Event for each tick start */
|
|
45
|
+
ticking?: Array<EventAction>
|
|
46
|
+
/* Event for tick completed */
|
|
47
|
+
completed?: Array<EventAction>
|
|
48
|
+
}
|
|
49
|
+
outlets?: {
|
|
50
|
+
/* Countdown step value */
|
|
51
|
+
countdown?: () => Data
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/* Execute event in countdown manner */
|
|
56
|
+
export type GeneratorTick = Generator &
|
|
57
|
+
GeneratorTickDef & {
|
|
58
|
+
templateKey: 'GENERATOR_TICK'
|
|
59
|
+
switches: Array<
|
|
60
|
+
SwitchDef &
|
|
61
|
+
GeneratorTickDef & {
|
|
62
|
+
conds?: Array<{
|
|
63
|
+
method: '==' | '!=' | '>' | '<' | '>=' | '<='
|
|
64
|
+
cond:
|
|
65
|
+
| SwitchCondInnerStateCurrentCanvas
|
|
66
|
+
| SwitchCondData
|
|
67
|
+
| {
|
|
68
|
+
__typename: 'SwitchCondInnerStateOutlet'
|
|
69
|
+
outlet: 'countdown'
|
|
70
|
+
value: any
|
|
71
|
+
}
|
|
72
|
+
}>
|
|
73
|
+
}
|
|
74
|
+
>
|
|
75
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import type { SwitchCondInnerStateCurrentCanvas, SwitchCondData, SwitchDef } from '../switch'
|
|
2
|
+
import type { Data, DataLink } from '../data'
|
|
3
|
+
import type {
|
|
4
|
+
Generator,
|
|
5
|
+
EventAction,
|
|
6
|
+
ActionWithDataParams,
|
|
7
|
+
ActionWithParams,
|
|
8
|
+
Action,
|
|
9
|
+
EventProperty,
|
|
10
|
+
} from '../common'
|
|
11
|
+
|
|
12
|
+
/* Bind UDP port */
|
|
13
|
+
export type GeneratorUDPActionBind = Action & {
|
|
14
|
+
__actionName: 'GENERATOR_UDP_BIND'
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/* Send data to target */
|
|
18
|
+
export type GeneratorUDPActionSend = ActionWithParams & {
|
|
19
|
+
__actionName: 'GENERATOR_UDP_SEND'
|
|
20
|
+
params?: Array<
|
|
21
|
+
| {
|
|
22
|
+
input: 'targetHost'
|
|
23
|
+
value?: string | DataLink | EventProperty
|
|
24
|
+
mapping?: string
|
|
25
|
+
}
|
|
26
|
+
| {
|
|
27
|
+
input: 'targetPort'
|
|
28
|
+
value?: number | DataLink | EventProperty
|
|
29
|
+
mapping?: string
|
|
30
|
+
}
|
|
31
|
+
| {
|
|
32
|
+
input: 'sendData'
|
|
33
|
+
value?: string | DataLink | EventProperty
|
|
34
|
+
mapping?: string
|
|
35
|
+
}
|
|
36
|
+
>
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/* Close UDP */
|
|
40
|
+
export type GeneratorUDPActionClose = Action & {
|
|
41
|
+
__actionName: 'GENERATOR_UDP_CLOSE'
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
interface GeneratorUDPDef {
|
|
45
|
+
/*
|
|
46
|
+
Default property:
|
|
47
|
+
{
|
|
48
|
+
"init": false,
|
|
49
|
+
"type": "udp4",
|
|
50
|
+
"encoding": "base64",
|
|
51
|
+
"broadcast": false,
|
|
52
|
+
"multicast": ""
|
|
53
|
+
}
|
|
54
|
+
*/
|
|
55
|
+
property?: {
|
|
56
|
+
/* Bind port on generator initialized */
|
|
57
|
+
init?: boolean | DataLink
|
|
58
|
+
/* The family of socket */
|
|
59
|
+
type?: 'udp4' | 'udp6' | DataLink
|
|
60
|
+
/* Encoding of data */
|
|
61
|
+
encoding?: 'base64' | 'utf8' | 'ascii' | DataLink
|
|
62
|
+
/* Local bind port of UDP (0 or empty is random) */
|
|
63
|
+
localPort?: number | DataLink
|
|
64
|
+
/* Enable receive broadcast packets */
|
|
65
|
+
broadcast?: boolean | DataLink
|
|
66
|
+
/* Join multicast group (Multicast address) */
|
|
67
|
+
multicast?: string | DataLink
|
|
68
|
+
}
|
|
69
|
+
events?: {
|
|
70
|
+
/* Event of UDP port is binded */
|
|
71
|
+
onReady?: Array<EventAction>
|
|
72
|
+
/* Event of receive data */
|
|
73
|
+
onData?: Array<EventAction>
|
|
74
|
+
/* Event of socket closeed */
|
|
75
|
+
onClose?: Array<EventAction>
|
|
76
|
+
/* Event of socket error */
|
|
77
|
+
onError?: Array<EventAction>
|
|
78
|
+
}
|
|
79
|
+
outlets?: {
|
|
80
|
+
/* Local UDP binded port */
|
|
81
|
+
port?: () => Data
|
|
82
|
+
/* Last received packet */
|
|
83
|
+
lastReceive?: () => Data
|
|
84
|
+
/* Error message */
|
|
85
|
+
errorMessage?: () => Data
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/* TCP Server */
|
|
90
|
+
export type GeneratorUDP = Generator &
|
|
91
|
+
GeneratorUDPDef & {
|
|
92
|
+
templateKey: 'GENERATOR_UDP'
|
|
93
|
+
switches: Array<
|
|
94
|
+
SwitchDef &
|
|
95
|
+
GeneratorUDPDef & {
|
|
96
|
+
conds?: Array<{
|
|
97
|
+
method: '==' | '!=' | '>' | '<' | '>=' | '<='
|
|
98
|
+
cond:
|
|
99
|
+
| SwitchCondInnerStateCurrentCanvas
|
|
100
|
+
| SwitchCondData
|
|
101
|
+
| {
|
|
102
|
+
__typename: 'SwitchCondInnerStateOutlet'
|
|
103
|
+
outlet: 'port' | 'lastReceive' | 'errorMessage'
|
|
104
|
+
value: any
|
|
105
|
+
}
|
|
106
|
+
}>
|
|
107
|
+
}
|
|
108
|
+
>
|
|
109
|
+
}
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import type { SwitchCondInnerStateCurrentCanvas, SwitchCondData, SwitchDef } from '../switch'
|
|
2
|
+
import type { Data, DataLink } from '../data'
|
|
3
|
+
import type {
|
|
4
|
+
Generator,
|
|
5
|
+
EventAction,
|
|
6
|
+
ActionWithDataParams,
|
|
7
|
+
ActionWithParams,
|
|
8
|
+
Action,
|
|
9
|
+
EventProperty,
|
|
10
|
+
} from '../common'
|
|
11
|
+
|
|
12
|
+
/* Load the model */
|
|
13
|
+
export type GeneratorVadInferenceActionLoadModel = Action & {
|
|
14
|
+
__actionName: 'GENERATOR_VAD_INFERENCE_LOAD_MODEL'
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/* Detect speech in audio file. You can provide `File URL` property, if not provided, it will use the default `File URL` */
|
|
18
|
+
export type GeneratorVadInferenceActionDetectFile = ActionWithParams & {
|
|
19
|
+
__actionName: 'GENERATOR_VAD_INFERENCE_DETECT_FILE'
|
|
20
|
+
params?: Array<
|
|
21
|
+
| {
|
|
22
|
+
input: 'fileUrl'
|
|
23
|
+
value?: string | DataLink | EventProperty
|
|
24
|
+
mapping?: string
|
|
25
|
+
}
|
|
26
|
+
| {
|
|
27
|
+
input: 'threshold'
|
|
28
|
+
value?: number | DataLink | EventProperty
|
|
29
|
+
mapping?: string
|
|
30
|
+
}
|
|
31
|
+
| {
|
|
32
|
+
input: 'minSpeechDurationMs'
|
|
33
|
+
value?: number | DataLink | EventProperty
|
|
34
|
+
mapping?: string
|
|
35
|
+
}
|
|
36
|
+
| {
|
|
37
|
+
input: 'minSilenceDurationMs'
|
|
38
|
+
value?: number | DataLink | EventProperty
|
|
39
|
+
mapping?: string
|
|
40
|
+
}
|
|
41
|
+
| {
|
|
42
|
+
input: 'maxSpeechDurationS'
|
|
43
|
+
value?: number | DataLink | EventProperty
|
|
44
|
+
mapping?: string
|
|
45
|
+
}
|
|
46
|
+
| {
|
|
47
|
+
input: 'speechPadMs'
|
|
48
|
+
value?: number | DataLink | EventProperty
|
|
49
|
+
mapping?: string
|
|
50
|
+
}
|
|
51
|
+
| {
|
|
52
|
+
input: 'samplesOverlap'
|
|
53
|
+
value?: number | DataLink | EventProperty
|
|
54
|
+
mapping?: string
|
|
55
|
+
}
|
|
56
|
+
>
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/* Detect speech in audio data. Currently only support base64 encoded audio data (16-bit PCM, mono, 16kHz) */
|
|
60
|
+
export type GeneratorVadInferenceActionDetectData = ActionWithParams & {
|
|
61
|
+
__actionName: 'GENERATOR_VAD_INFERENCE_DETECT_DATA'
|
|
62
|
+
params?: Array<
|
|
63
|
+
| {
|
|
64
|
+
input: 'data'
|
|
65
|
+
value?: any | EventProperty
|
|
66
|
+
mapping?: string
|
|
67
|
+
}
|
|
68
|
+
| {
|
|
69
|
+
input: 'threshold'
|
|
70
|
+
value?: number | DataLink | EventProperty
|
|
71
|
+
mapping?: string
|
|
72
|
+
}
|
|
73
|
+
| {
|
|
74
|
+
input: 'minSpeechDurationMs'
|
|
75
|
+
value?: number | DataLink | EventProperty
|
|
76
|
+
mapping?: string
|
|
77
|
+
}
|
|
78
|
+
| {
|
|
79
|
+
input: 'minSilenceDurationMs'
|
|
80
|
+
value?: number | DataLink | EventProperty
|
|
81
|
+
mapping?: string
|
|
82
|
+
}
|
|
83
|
+
| {
|
|
84
|
+
input: 'maxSpeechDurationS'
|
|
85
|
+
value?: number | DataLink | EventProperty
|
|
86
|
+
mapping?: string
|
|
87
|
+
}
|
|
88
|
+
| {
|
|
89
|
+
input: 'speechPadMs'
|
|
90
|
+
value?: number | DataLink | EventProperty
|
|
91
|
+
mapping?: string
|
|
92
|
+
}
|
|
93
|
+
| {
|
|
94
|
+
input: 'samplesOverlap'
|
|
95
|
+
value?: number | DataLink | EventProperty
|
|
96
|
+
mapping?: string
|
|
97
|
+
}
|
|
98
|
+
>
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/* Clear downloaded files (model, audio) & current jobs */
|
|
102
|
+
export type GeneratorVadInferenceActionClearDownload = Action & {
|
|
103
|
+
__actionName: 'GENERATOR_VAD_INFERENCE_CLEAR_DOWNLOAD'
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/* Release context */
|
|
107
|
+
export type GeneratorVadInferenceActionReleaseContext = Action & {
|
|
108
|
+
__actionName: 'GENERATOR_VAD_INFERENCE_RELEASE_CONTEXT'
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
interface GeneratorVadInferenceDef {
|
|
112
|
+
/*
|
|
113
|
+
Default property:
|
|
114
|
+
{
|
|
115
|
+
"init": false,
|
|
116
|
+
"modelName": "silero-v5.1.2",
|
|
117
|
+
"modelUseGPU": true,
|
|
118
|
+
"modelThreads": 4,
|
|
119
|
+
"detectThreshold": 0.5,
|
|
120
|
+
"detectMinSpeechDurationMs": 250,
|
|
121
|
+
"detectMinSilenceDurationMs": 100,
|
|
122
|
+
"detectMaxSpeechDurationS": 30,
|
|
123
|
+
"detectSpeechPadMs": 30,
|
|
124
|
+
"detectSamplesOverlap": 0.1
|
|
125
|
+
}
|
|
126
|
+
*/
|
|
127
|
+
property?: {
|
|
128
|
+
/* Initialize the VAD context on generator initialization
|
|
129
|
+
Please note that it will take some RAM depending on the model size */
|
|
130
|
+
init?: boolean | DataLink
|
|
131
|
+
/* Use model name, currently only supports the Silero VAD model.
|
|
132
|
+
The model download progress will be done in preload stage or the generator initialization stage.
|
|
133
|
+
You can also choose `custom` option and set `Model URL` and `Model SHA1` to use your own model */
|
|
134
|
+
modelName?: 'custom' | 'silero-v5.1.2' | DataLink
|
|
135
|
+
/* The URL or path of model
|
|
136
|
+
We used `ggml` format model, please refer to https://huggingface.co/ggml-org/whisper-vad */
|
|
137
|
+
modelUrl?: string | DataLink
|
|
138
|
+
/* Hash type of model */
|
|
139
|
+
modelHashType?: 'md5' | 'sha256' | 'sha1' | DataLink
|
|
140
|
+
/* Hash of model */
|
|
141
|
+
modelHash?: string | DataLink
|
|
142
|
+
/* Use GPU Acceleration for inference. Currently iOS only. */
|
|
143
|
+
modelUseGPU?: boolean | DataLink
|
|
144
|
+
/* Number of threads to use for processing */
|
|
145
|
+
modelThreads?: number | DataLink
|
|
146
|
+
/* Speech probability threshold (0.0-1.0) */
|
|
147
|
+
detectThreshold?: number | DataLink
|
|
148
|
+
/* Minimum speech duration in milliseconds */
|
|
149
|
+
detectMinSpeechDurationMs?: number | DataLink
|
|
150
|
+
/* Minimum silence duration in milliseconds */
|
|
151
|
+
detectMinSilenceDurationMs?: number | DataLink
|
|
152
|
+
/* Maximum speech duration in seconds */
|
|
153
|
+
detectMaxSpeechDurationS?: number | DataLink
|
|
154
|
+
/* Padding around speech segments in milliseconds */
|
|
155
|
+
detectSpeechPadMs?: number | DataLink
|
|
156
|
+
/* Overlap between analysis windows (0.0-1.0) */
|
|
157
|
+
detectSamplesOverlap?: number | DataLink
|
|
158
|
+
/* The file URL or path to be analyzed.
|
|
159
|
+
It only supported `wav` format with 16kHz sample rate & single (mono) channel */
|
|
160
|
+
detectFileUrl?: string | DataLink
|
|
161
|
+
/* MD5 of file to be analyzed */
|
|
162
|
+
detectFileMd5?: string | DataLink
|
|
163
|
+
}
|
|
164
|
+
events?: {
|
|
165
|
+
/* Event triggered when context state changes */
|
|
166
|
+
onContextStateChange?: Array<EventAction>
|
|
167
|
+
/* Event triggered when error occurs */
|
|
168
|
+
onError?: Array<EventAction>
|
|
169
|
+
/* Event triggered when got detection result */
|
|
170
|
+
onDetected?: Array<EventAction>
|
|
171
|
+
}
|
|
172
|
+
outlets?: {
|
|
173
|
+
/* Context state */
|
|
174
|
+
contextState?: () => Data
|
|
175
|
+
/* Context details */
|
|
176
|
+
contextDetails?: () => Data
|
|
177
|
+
/* Is detecting */
|
|
178
|
+
isDetecting?: () => Data
|
|
179
|
+
/* Detection segments result */
|
|
180
|
+
detectionSegments?: () => Data
|
|
181
|
+
/* Detection details */
|
|
182
|
+
detectionDetails?: () => Data
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/* Local Voice Activity Detection (VAD) inference based on GGML and [whisper.rn](https://github.com/mybigday/whisper.rn) */
|
|
187
|
+
export type GeneratorVadInference = Generator &
|
|
188
|
+
GeneratorVadInferenceDef & {
|
|
189
|
+
templateKey: 'GENERATOR_VAD_INFERENCE'
|
|
190
|
+
switches: Array<
|
|
191
|
+
SwitchDef &
|
|
192
|
+
GeneratorVadInferenceDef & {
|
|
193
|
+
conds?: Array<{
|
|
194
|
+
method: '==' | '!=' | '>' | '<' | '>=' | '<='
|
|
195
|
+
cond:
|
|
196
|
+
| SwitchCondInnerStateCurrentCanvas
|
|
197
|
+
| SwitchCondData
|
|
198
|
+
| {
|
|
199
|
+
__typename: 'SwitchCondInnerStateOutlet'
|
|
200
|
+
outlet:
|
|
201
|
+
| 'contextState'
|
|
202
|
+
| 'contextDetails'
|
|
203
|
+
| 'isDetecting'
|
|
204
|
+
| 'detectionSegments'
|
|
205
|
+
| 'detectionDetails'
|
|
206
|
+
value: any
|
|
207
|
+
}
|
|
208
|
+
}>
|
|
209
|
+
}
|
|
210
|
+
>
|
|
211
|
+
}
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import type { SwitchCondInnerStateCurrentCanvas, SwitchCondData, SwitchDef } from '../switch'
|
|
2
|
+
import type { Data, DataLink } from '../data'
|
|
3
|
+
import type {
|
|
4
|
+
Generator,
|
|
5
|
+
EventAction,
|
|
6
|
+
ActionWithDataParams,
|
|
7
|
+
ActionWithParams,
|
|
8
|
+
Action,
|
|
9
|
+
EventProperty,
|
|
10
|
+
} from '../common'
|
|
11
|
+
|
|
12
|
+
/* Load the model (Only if source is ggml) */
|
|
13
|
+
export type GeneratorVectorStoreActionModelLoad = Action & {
|
|
14
|
+
__actionName: 'GENERATOR_VECTOR_STORE_MODEL_LOAD'
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/* Release the model (Only if source is ggml) */
|
|
18
|
+
export type GeneratorVectorStoreActionModelRelease = Action & {
|
|
19
|
+
__actionName: 'GENERATOR_VECTOR_STORE_MODEL_RELEASE'
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/* Reset the embedding session */
|
|
23
|
+
export type GeneratorVectorStoreActionReset = ActionWithParams & {
|
|
24
|
+
__actionName: 'GENERATOR_VECTOR_STORE_RESET'
|
|
25
|
+
params?: Array<{
|
|
26
|
+
input: 'resetType'
|
|
27
|
+
value?: 'session' | 'all' | DataLink | EventProperty
|
|
28
|
+
mapping?: string
|
|
29
|
+
}>
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/* Insert file content with path or url, support Office / OpenOffice / PDF
|
|
33
|
+
|
|
34
|
+
PDF is not currently supprted in iOS / Android */
|
|
35
|
+
export type GeneratorVectorStoreActionInsertFile = ActionWithParams & {
|
|
36
|
+
__actionName: 'GENERATOR_VECTOR_STORE_INSERT_FILE'
|
|
37
|
+
params?: Array<
|
|
38
|
+
| {
|
|
39
|
+
input: 'filePath'
|
|
40
|
+
value?: string | DataLink | EventProperty
|
|
41
|
+
mapping?: string
|
|
42
|
+
}
|
|
43
|
+
| {
|
|
44
|
+
input: 'fileName'
|
|
45
|
+
value?: string | DataLink | EventProperty
|
|
46
|
+
mapping?: string
|
|
47
|
+
}
|
|
48
|
+
| {
|
|
49
|
+
input: 'fileExtension'
|
|
50
|
+
value?: string | DataLink | EventProperty
|
|
51
|
+
mapping?: string
|
|
52
|
+
}
|
|
53
|
+
| {
|
|
54
|
+
input: 'chunkSize'
|
|
55
|
+
value?: number | DataLink | EventProperty
|
|
56
|
+
mapping?: string
|
|
57
|
+
}
|
|
58
|
+
>
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/* Cancel the file download */
|
|
62
|
+
export type GeneratorVectorStoreActionCancelFileDownload = Action & {
|
|
63
|
+
__actionName: 'GENERATOR_VECTOR_STORE_CANCEL_FILE_DOWNLOAD'
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/* Insert pure text content to vector store */
|
|
67
|
+
export type GeneratorVectorStoreActionInsertContent = ActionWithParams & {
|
|
68
|
+
__actionName: 'GENERATOR_VECTOR_STORE_INSERT_CONTENT'
|
|
69
|
+
params?: Array<
|
|
70
|
+
| {
|
|
71
|
+
input: 'textContent'
|
|
72
|
+
value?: string | DataLink | EventProperty
|
|
73
|
+
mapping?: string
|
|
74
|
+
}
|
|
75
|
+
| {
|
|
76
|
+
input: 'fileName'
|
|
77
|
+
value?: string | DataLink | EventProperty
|
|
78
|
+
mapping?: string
|
|
79
|
+
}
|
|
80
|
+
| {
|
|
81
|
+
input: 'payload'
|
|
82
|
+
value?: {} | DataLink | EventProperty
|
|
83
|
+
mapping?: string
|
|
84
|
+
}
|
|
85
|
+
| {
|
|
86
|
+
input: 'chunkSize'
|
|
87
|
+
value?: number | DataLink | EventProperty
|
|
88
|
+
mapping?: string
|
|
89
|
+
}
|
|
90
|
+
>
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/* Remove file from vector store */
|
|
94
|
+
export type GeneratorVectorStoreActionRemoveFile = ActionWithParams & {
|
|
95
|
+
__actionName: 'GENERATOR_VECTOR_STORE_REMOVE_FILE'
|
|
96
|
+
params?: Array<{
|
|
97
|
+
input: 'fileName'
|
|
98
|
+
value?: string | DataLink | EventProperty
|
|
99
|
+
mapping?: string
|
|
100
|
+
}>
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/* Search similar text chunks in vector store */
|
|
104
|
+
export type GeneratorVectorStoreActionSearch = ActionWithParams & {
|
|
105
|
+
__actionName: 'GENERATOR_VECTOR_STORE_SEARCH'
|
|
106
|
+
params?: Array<
|
|
107
|
+
| {
|
|
108
|
+
input: 'text'
|
|
109
|
+
value?: string | DataLink | EventProperty
|
|
110
|
+
mapping?: string
|
|
111
|
+
}
|
|
112
|
+
| {
|
|
113
|
+
input: 'filename'
|
|
114
|
+
value?: string | DataLink | EventProperty
|
|
115
|
+
mapping?: string
|
|
116
|
+
}
|
|
117
|
+
| {
|
|
118
|
+
input: 'limit'
|
|
119
|
+
value?: number | DataLink | EventProperty
|
|
120
|
+
mapping?: string
|
|
121
|
+
}
|
|
122
|
+
| {
|
|
123
|
+
input: 'threshold'
|
|
124
|
+
value?: number | DataLink | EventProperty
|
|
125
|
+
mapping?: string
|
|
126
|
+
}
|
|
127
|
+
| {
|
|
128
|
+
input: 'ignoreThreshold'
|
|
129
|
+
value?: boolean | DataLink | EventProperty
|
|
130
|
+
mapping?: string
|
|
131
|
+
}
|
|
132
|
+
>
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
interface GeneratorVectorStoreDef {
|
|
136
|
+
/*
|
|
137
|
+
Default property:
|
|
138
|
+
{
|
|
139
|
+
"source": "ggml",
|
|
140
|
+
"ggmlContextSize": 512,
|
|
141
|
+
"openaiBaseUrl": "https://api.openai.com/v1",
|
|
142
|
+
"openaiModel": "text-embedding-3-small",
|
|
143
|
+
"embedSessionId": "default-embeddings",
|
|
144
|
+
"fileChunkSize": 256
|
|
145
|
+
}
|
|
146
|
+
*/
|
|
147
|
+
property?: {
|
|
148
|
+
/* Initialize embedding model context & tokenizer context on subspace mounted */
|
|
149
|
+
init?: boolean | DataLink
|
|
150
|
+
/* Source of embedding model. Note that you can't use the saved embedddings data in different sources. */
|
|
151
|
+
source?: 'ggml' | 'openai' | DataLink
|
|
152
|
+
/* Path of ggml model */
|
|
153
|
+
ggmlModelUrl?: string | DataLink
|
|
154
|
+
/* Hash type of ggml model */
|
|
155
|
+
ggmlModelHashType?: 'sha256' | 'sha1' | 'md5' | DataLink
|
|
156
|
+
/* Hash of ggml model */
|
|
157
|
+
ggmlModelHash?: string | DataLink
|
|
158
|
+
/* Size of ggml context */
|
|
159
|
+
ggmlContextSize?: number | DataLink
|
|
160
|
+
/* Pooling type of ggml model */
|
|
161
|
+
ggmlPoolingType?: 'none' | 'mean' | 'cls' | 'last' | 'rank' | DataLink
|
|
162
|
+
/* Accelerator variant of ggml model */
|
|
163
|
+
ggmlAccelVariant?: 'default' | 'vulkan' | 'cuda' | DataLink
|
|
164
|
+
/* Normalize */
|
|
165
|
+
ggmlEmbdNormalize?: number | DataLink
|
|
166
|
+
/* API key of OpenAI Compatible API */
|
|
167
|
+
openaiApiKey?: string | DataLink
|
|
168
|
+
/* Base URL of OpenAI Compatible API. For example, we can use ollama / llama.cpp server instead of openai */
|
|
169
|
+
openaiBaseUrl?: string | DataLink
|
|
170
|
+
/* Model of OpenAI Compatible API */
|
|
171
|
+
openaiModel?: 'text-embedding-3-small' | 'text-embedding-3-large' | DataLink
|
|
172
|
+
/* Session ID of embedding */
|
|
173
|
+
embedSessionId?: string | DataLink
|
|
174
|
+
/* Storage type of embedding */
|
|
175
|
+
embedStorageType?: 'file' | 'memory' | DataLink
|
|
176
|
+
/* Tokenizer model URL (Recommended to use same with your LLM model, the model will just load with vocab_only mode) */
|
|
177
|
+
tokenizerModelUrl?: string | DataLink
|
|
178
|
+
/* Tokenizer model hash */
|
|
179
|
+
tokenizerModelHash?: string | DataLink
|
|
180
|
+
/* Tokenizer model hash type */
|
|
181
|
+
tokenizerModelHashType?: 'sha256' | 'sha1' | 'md5' | DataLink
|
|
182
|
+
/* Chunk size to handle file content (token), must be less then embedding model context size */
|
|
183
|
+
fileChunkSize?: number | DataLink
|
|
184
|
+
}
|
|
185
|
+
events?: {
|
|
186
|
+
/* Event triggered when error occurs */
|
|
187
|
+
onError?: Array<EventAction>
|
|
188
|
+
}
|
|
189
|
+
outlets?: {
|
|
190
|
+
/* undefined */
|
|
191
|
+
isReady?: () => Data
|
|
192
|
+
/* Whether the embedding is processing */
|
|
193
|
+
processing?: () => Data
|
|
194
|
+
/* Progress of embedding processing */
|
|
195
|
+
processProgress?: () => Data
|
|
196
|
+
/* Files inserted to embedding */
|
|
197
|
+
files?: () => Data
|
|
198
|
+
/* Search result */
|
|
199
|
+
searchResult?: () => Data
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/* Vector Store - File embeddings & search */
|
|
204
|
+
export type GeneratorVectorStore = Generator &
|
|
205
|
+
GeneratorVectorStoreDef & {
|
|
206
|
+
templateKey: 'GENERATOR_VECTOR_STORE'
|
|
207
|
+
switches: Array<
|
|
208
|
+
SwitchDef &
|
|
209
|
+
GeneratorVectorStoreDef & {
|
|
210
|
+
conds?: Array<{
|
|
211
|
+
method: '==' | '!=' | '>' | '<' | '>=' | '<='
|
|
212
|
+
cond:
|
|
213
|
+
| SwitchCondInnerStateCurrentCanvas
|
|
214
|
+
| SwitchCondData
|
|
215
|
+
| {
|
|
216
|
+
__typename: 'SwitchCondInnerStateOutlet'
|
|
217
|
+
outlet: 'isReady' | 'processing' | 'processProgress' | 'files' | 'searchResult'
|
|
218
|
+
value: any
|
|
219
|
+
}
|
|
220
|
+
}>
|
|
221
|
+
}
|
|
222
|
+
>
|
|
223
|
+
}
|