@coasys/ad4m 0.12.0-rc1-dev.1 → 0.12.0-rc1-dev.2
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/jest.config.js +4 -4
- package/lib/index.cjs +5999 -6046
- package/lib/index.js +5977 -6040
- package/lib/src/Ad4mClient.d.ts +16 -9
- package/lib/src/Ad4mClient.js +25 -46
- package/lib/src/Ad4mClient.test.d.ts +1 -0
- package/lib/src/Ad4mClient.test.js +1204 -0
- package/lib/src/Literal.d.ts +2 -1
- package/lib/src/Literal.js +35 -38
- package/lib/src/Literal.test.d.ts +1 -0
- package/lib/src/Literal.test.js +41 -0
- package/lib/src/SmartLiteral.d.ts +2 -1
- package/lib/src/SmartLiteral.js +15 -30
- package/lib/src/agent/AgentClient.d.ts +4 -1
- package/lib/src/agent/AgentClient.js +99 -79
- package/lib/src/ai/AIClient.d.ts +2 -1
- package/lib/src/ai/AIClient.js +220 -224
- package/lib/src/expression/ExpressionClient.d.ts +1 -1
- package/lib/src/expression/ExpressionClient.js +86 -73
- package/lib/src/index.d.ts +1 -1
- package/lib/src/index.js +1 -1
- package/lib/src/language/LanguageClient.d.ts +1 -1
- package/lib/src/language/LanguageClient.js +52 -52
- package/lib/src/model/Ad4mModel.d.ts +157 -937
- package/lib/src/model/Ad4mModel.js +212 -2799
- package/lib/src/model/Ad4mModel.test.js +1002 -561
- package/lib/src/model/decorators.d.ts +94 -426
- package/lib/src/model/decorators.js +333 -741
- package/lib/src/model/mutation.d.ts +81 -0
- package/lib/src/model/mutation.js +317 -0
- package/lib/src/model/parentUtils.d.ts +32 -0
- package/lib/src/model/parentUtils.js +64 -0
- package/lib/src/model/prolog/generatePrologFacts.d.ts +36 -0
- package/lib/src/model/prolog/generatePrologFacts.js +139 -0
- package/lib/src/model/prolog/index.d.ts +1 -0
- package/lib/src/model/prolog/index.js +1 -0
- package/lib/src/model/query/ModelQueryBuilder.d.ts +82 -0
- package/lib/src/model/query/ModelQueryBuilder.js +115 -0
- package/lib/src/model/query/QueryBuilder.d.ts +101 -0
- package/lib/src/model/query/QueryBuilder.js +193 -0
- package/lib/src/model/query/SurrealQueryBuilder.d.ts +48 -0
- package/lib/src/model/query/SurrealQueryBuilder.js +371 -0
- package/lib/src/model/query/fetchInstance.d.ts +24 -0
- package/lib/src/model/query/fetchInstance.js +144 -0
- package/lib/src/model/query/hydration.d.ts +54 -0
- package/lib/src/model/query/hydration.js +214 -0
- package/lib/src/model/query/operations.d.ts +59 -0
- package/lib/src/model/query/operations.js +384 -0
- package/lib/src/model/query/snapshot.d.ts +59 -0
- package/lib/src/model/query/snapshot.js +106 -0
- package/lib/src/model/query/surrealCompiler.d.ts +42 -0
- package/lib/src/model/query/surrealCompiler.js +304 -0
- package/lib/src/model/schema/fromJSONSchema.d.ts +67 -0
- package/lib/src/model/schema/fromJSONSchema.js +264 -0
- package/lib/src/model/schema/metadata.d.ts +15 -0
- package/lib/src/model/schema/metadata.js +112 -0
- package/lib/src/model/subscription.d.ts +47 -0
- package/lib/src/model/subscription.js +231 -0
- package/lib/src/model/transaction.d.ts +27 -0
- package/lib/src/model/transaction.js +32 -0
- package/lib/src/model/types.d.ts +195 -0
- package/lib/src/model/types.js +8 -0
- package/lib/src/model/util.js +7 -7
- package/lib/src/neighbourhood/NeighbourhoodClient.d.ts +5 -1
- package/lib/src/neighbourhood/NeighbourhoodClient.js +263 -181
- package/lib/src/neighbourhood/NeighbourhoodProxy.d.ts +2 -1
- package/lib/src/neighbourhood/NeighbourhoodProxy.js +13 -28
- package/lib/src/neighbourhood/NeighbourhoodProxy.test.js +1 -5
- package/lib/src/perspectives/PerspectiveClient.d.ts +9 -9
- package/lib/src/perspectives/PerspectiveClient.js +316 -240
- package/lib/src/perspectives/PerspectiveProxy.d.ts +54 -92
- package/lib/src/perspectives/PerspectiveProxy.js +803 -444
- package/lib/src/runtime/RuntimeClient.d.ts +5 -1
- package/lib/src/runtime/RuntimeClient.js +412 -238
- package/lib/src/shacl/SHACLFlow.test.js +164 -105
- package/lib/src/shacl/SHACLShape.d.ts +17 -3
- package/lib/src/shacl/SHACLShape.js +127 -90
- package/lib/src/shacl/SHACLShape.test.js +244 -176
- package/lib/src/utils.d.ts +8 -0
- package/lib/src/utils.js +21 -7
- package/package.json +8 -13
- package/src/Ad4mClient.test.ts +1564 -1315
- package/src/Ad4mClient.ts +55 -54
- package/src/Literal.test.ts +45 -26
- package/src/Literal.ts +82 -66
- package/src/SmartLiteral.ts +74 -58
- package/src/agent/AgentClient.ts +144 -99
- package/src/ai/AIClient.ts +409 -359
- package/src/expression/ExpressionClient.ts +142 -96
- package/src/index.ts +1 -1
- package/src/language/LanguageClient.ts +137 -113
- package/src/model/Ad4mModel.test.ts +1128 -647
- package/src/model/Ad4mModel.ts +485 -3249
- package/src/model/IMPROVEMENTS.md +482 -0
- package/src/model/PREDICATE_COLLISION_FIX.md +651 -0
- package/src/model/README.md +317 -0
- package/src/model/SHACL_MUTATION_DECOUPLING.md +356 -0
- package/src/model/SUBSCRIPTION_STRATEGY.md +317 -0
- package/src/model/TC39_STAGE_3_DECORATORS.md +609 -0
- package/src/model/decorators.ts +689 -1046
- package/src/model/mutation.ts +461 -0
- package/src/model/parentUtils.ts +91 -0
- package/src/model/prolog/generatePrologFacts.ts +176 -0
- package/src/model/prolog/index.ts +1 -0
- package/src/model/query/ModelQueryBuilder.ts +173 -0
- package/src/model/query/fetchInstance.ts +181 -0
- package/src/model/query/hydration.ts +273 -0
- package/src/model/query/operations.ts +510 -0
- package/src/model/query/snapshot.ts +126 -0
- package/src/model/query/surrealCompiler.ts +376 -0
- package/src/model/schema/fromJSONSchema.ts +411 -0
- package/src/model/schema/metadata.ts +148 -0
- package/src/model/subscription.ts +307 -0
- package/src/model/transaction.ts +60 -0
- package/src/model/types.ts +207 -0
- package/src/model/util.ts +47 -48
- package/src/neighbourhood/NeighbourhoodClient.ts +393 -251
- package/src/neighbourhood/NeighbourhoodProxy.test.ts +3 -7
- package/src/neighbourhood/NeighbourhoodProxy.ts +58 -40
- package/src/perspectives/PerspectiveClient.ts +779 -540
- package/src/perspectives/PerspectiveProxy.ts +2860 -2053
- package/src/runtime/RuntimeClient.ts +775 -476
- package/src/shacl/SHACLFlow.test.ts +196 -129
- package/src/shacl/SHACLShape.test.ts +284 -190
- package/src/shacl/SHACLShape.ts +225 -172
- package/src/utils.ts +31 -17
- package/tsconfig.json +9 -10
- package/src/model/Subject.ts +0 -159
package/lib/src/ai/AIClient.js
CHANGED
|
@@ -1,342 +1,338 @@
|
|
|
1
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
2
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
5
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
6
|
-
};
|
|
7
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
-
};
|
|
12
|
-
var _AIClient_apolloClient, _AIClient_transcriptionSubscriptions;
|
|
13
1
|
import { gql } from "@apollo/client";
|
|
14
2
|
import unwrapApolloResult from "../unwrapApolloResult";
|
|
15
|
-
import
|
|
16
|
-
import
|
|
3
|
+
import { isSocketCloseError } from "../utils";
|
|
4
|
+
import base64js from "base64-js";
|
|
5
|
+
import pako from "pako";
|
|
17
6
|
import { AITaskInput } from "./Tasks";
|
|
18
7
|
export class AIClient {
|
|
19
8
|
constructor(apolloClient, subscribe = true) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
__classPrivateFieldSet(this, _AIClient_apolloClient, apolloClient, "f");
|
|
9
|
+
this._transcriptionSubscriptions = new Map();
|
|
10
|
+
this._apolloClient = apolloClient;
|
|
23
11
|
}
|
|
24
12
|
async getModels() {
|
|
25
|
-
const result = await
|
|
13
|
+
const result = await this._apolloClient.query({
|
|
26
14
|
query: gql `
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
15
|
+
query {
|
|
16
|
+
aiGetModels {
|
|
17
|
+
id
|
|
18
|
+
name
|
|
19
|
+
api {
|
|
20
|
+
baseUrl
|
|
21
|
+
apiKey
|
|
22
|
+
model
|
|
23
|
+
apiType
|
|
24
|
+
}
|
|
25
|
+
local {
|
|
26
|
+
fileName
|
|
27
|
+
tokenizerSource {
|
|
28
|
+
repo
|
|
29
|
+
revision
|
|
30
|
+
fileName
|
|
31
|
+
}
|
|
32
|
+
huggingfaceRepo
|
|
33
|
+
revision
|
|
34
|
+
}
|
|
35
|
+
modelType
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
`,
|
|
51
39
|
});
|
|
52
40
|
return unwrapApolloResult(result).aiGetModels;
|
|
53
41
|
}
|
|
54
42
|
async addModel(model) {
|
|
55
|
-
const result = await
|
|
43
|
+
const result = await this._apolloClient.mutate({
|
|
56
44
|
mutation: gql `
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
variables: { model }
|
|
45
|
+
mutation ($model: ModelInput!) {
|
|
46
|
+
aiAddModel(model: $model)
|
|
47
|
+
}
|
|
48
|
+
`,
|
|
49
|
+
variables: { model },
|
|
62
50
|
});
|
|
63
51
|
return unwrapApolloResult(result).aiAddModel;
|
|
64
52
|
}
|
|
65
53
|
async updateModel(modelId, model) {
|
|
66
|
-
const result = await
|
|
54
|
+
const result = await this._apolloClient.mutate({
|
|
67
55
|
mutation: gql `
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
variables: { modelId, model }
|
|
56
|
+
mutation ($modelId: String!, $model: ModelInput!) {
|
|
57
|
+
aiUpdateModel(modelId: $modelId, model: $model)
|
|
58
|
+
}
|
|
59
|
+
`,
|
|
60
|
+
variables: { modelId, model },
|
|
73
61
|
});
|
|
74
62
|
return unwrapApolloResult(result).aiUpdateModel;
|
|
75
63
|
}
|
|
76
64
|
async removeModel(modelId) {
|
|
77
|
-
const result = await
|
|
65
|
+
const result = await this._apolloClient.mutate({
|
|
78
66
|
mutation: gql `
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
variables: { modelId }
|
|
67
|
+
mutation ($modelId: String!) {
|
|
68
|
+
aiRemoveModel(modelId: $modelId)
|
|
69
|
+
}
|
|
70
|
+
`,
|
|
71
|
+
variables: { modelId },
|
|
84
72
|
});
|
|
85
73
|
return unwrapApolloResult(result).aiRemoveModel;
|
|
86
74
|
}
|
|
87
75
|
async setDefaultModel(modelType, modelId) {
|
|
88
|
-
const result = await
|
|
76
|
+
const result = await this._apolloClient.mutate({
|
|
89
77
|
mutation: gql `
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
variables: { modelId, modelType }
|
|
78
|
+
mutation ($modelType: ModelType!, $modelId: String!) {
|
|
79
|
+
aiSetDefaultModel(modelType: $modelType, modelId: $modelId)
|
|
80
|
+
}
|
|
81
|
+
`,
|
|
82
|
+
variables: { modelId, modelType },
|
|
95
83
|
});
|
|
96
84
|
return unwrapApolloResult(result).aiSetDefaultModel;
|
|
97
85
|
}
|
|
98
86
|
async getDefaultModel(modelType) {
|
|
99
|
-
const result = await
|
|
87
|
+
const result = await this._apolloClient.query({
|
|
100
88
|
query: gql `
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
variables: { modelType }
|
|
89
|
+
query ($modelType: ModelType!) {
|
|
90
|
+
aiGetDefaultModel(modelType: $modelType) {
|
|
91
|
+
id
|
|
92
|
+
name
|
|
93
|
+
api {
|
|
94
|
+
baseUrl
|
|
95
|
+
apiKey
|
|
96
|
+
model
|
|
97
|
+
apiType
|
|
98
|
+
}
|
|
99
|
+
local {
|
|
100
|
+
fileName
|
|
101
|
+
tokenizerSource {
|
|
102
|
+
repo
|
|
103
|
+
revision
|
|
104
|
+
fileName
|
|
105
|
+
}
|
|
106
|
+
huggingfaceRepo
|
|
107
|
+
revision
|
|
108
|
+
}
|
|
109
|
+
modelType
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
`,
|
|
113
|
+
variables: { modelType },
|
|
126
114
|
});
|
|
127
115
|
return unwrapApolloResult(result).aiGetDefaultModel;
|
|
128
116
|
}
|
|
129
117
|
async tasks() {
|
|
130
|
-
const { aiTasks } = unwrapApolloResult(await
|
|
118
|
+
const { aiTasks } = unwrapApolloResult(await this._apolloClient.query({
|
|
131
119
|
query: gql `
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
120
|
+
query {
|
|
121
|
+
aiTasks {
|
|
122
|
+
name
|
|
123
|
+
modelId
|
|
124
|
+
taskId
|
|
125
|
+
systemPrompt
|
|
126
|
+
promptExamples {
|
|
127
|
+
input
|
|
128
|
+
output
|
|
129
|
+
}
|
|
130
|
+
metaData
|
|
131
|
+
createdAt
|
|
132
|
+
updatedAt
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
`,
|
|
148
136
|
}));
|
|
149
137
|
return aiTasks;
|
|
150
138
|
}
|
|
151
139
|
async addTask(name, modelId, systemPrompt, promptExamples, metaData) {
|
|
152
140
|
const task = new AITaskInput(name, modelId, systemPrompt, promptExamples, metaData);
|
|
153
|
-
const { aiAddTask } = unwrapApolloResult(await
|
|
141
|
+
const { aiAddTask } = unwrapApolloResult(await this._apolloClient.mutate({
|
|
154
142
|
mutation: gql `
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
`,
|
|
171
|
-
variables: {
|
|
172
|
-
task
|
|
143
|
+
mutation AiAddTask($task: AITaskInput!) {
|
|
144
|
+
aiAddTask(task: $task) {
|
|
145
|
+
name
|
|
146
|
+
modelId
|
|
147
|
+
taskId
|
|
148
|
+
systemPrompt
|
|
149
|
+
promptExamples {
|
|
150
|
+
input
|
|
151
|
+
output
|
|
152
|
+
}
|
|
153
|
+
metaData
|
|
154
|
+
createdAt
|
|
155
|
+
updatedAt
|
|
173
156
|
}
|
|
157
|
+
}
|
|
158
|
+
`,
|
|
159
|
+
variables: {
|
|
160
|
+
task,
|
|
161
|
+
},
|
|
174
162
|
}));
|
|
175
163
|
return aiAddTask;
|
|
176
164
|
}
|
|
177
165
|
async removeTask(taskId) {
|
|
178
|
-
const { aiRemoveTask } = unwrapApolloResult(await
|
|
166
|
+
const { aiRemoveTask } = unwrapApolloResult(await this._apolloClient.mutate({
|
|
179
167
|
mutation: gql `
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
`,
|
|
196
|
-
variables: {
|
|
197
|
-
taskId
|
|
168
|
+
mutation AiRemoveTask($taskId: String!) {
|
|
169
|
+
aiRemoveTask(taskId: $taskId) {
|
|
170
|
+
name
|
|
171
|
+
modelId
|
|
172
|
+
taskId
|
|
173
|
+
systemPrompt
|
|
174
|
+
promptExamples {
|
|
175
|
+
input
|
|
176
|
+
output
|
|
177
|
+
}
|
|
178
|
+
metaData
|
|
179
|
+
createdAt
|
|
180
|
+
updatedAt
|
|
198
181
|
}
|
|
182
|
+
}
|
|
183
|
+
`,
|
|
184
|
+
variables: {
|
|
185
|
+
taskId,
|
|
186
|
+
},
|
|
199
187
|
}));
|
|
200
188
|
return aiRemoveTask;
|
|
201
189
|
}
|
|
202
190
|
async updateTask(taskId, task) {
|
|
203
|
-
const { aiUpdateTask } = unwrapApolloResult(await
|
|
191
|
+
const { aiUpdateTask } = unwrapApolloResult(await this._apolloClient.mutate({
|
|
204
192
|
mutation: gql `
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
193
|
+
mutation AiUpdateTask($taskId: String!, $task: AITaskInput!) {
|
|
194
|
+
aiUpdateTask(taskId: $taskId, task: $task) {
|
|
195
|
+
name
|
|
196
|
+
modelId
|
|
197
|
+
taskId
|
|
198
|
+
systemPrompt
|
|
199
|
+
promptExamples {
|
|
200
|
+
input
|
|
201
|
+
output
|
|
202
|
+
}
|
|
203
|
+
metaData
|
|
204
|
+
createdAt
|
|
205
|
+
updatedAt
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
`,
|
|
221
209
|
variables: {
|
|
222
210
|
taskId,
|
|
223
211
|
task: {
|
|
224
212
|
name: task.name,
|
|
225
213
|
modelId: task.modelId,
|
|
226
214
|
systemPrompt: task.systemPrompt,
|
|
227
|
-
promptExamples: task.promptExamples
|
|
228
|
-
}
|
|
229
|
-
}
|
|
215
|
+
promptExamples: task.promptExamples,
|
|
216
|
+
},
|
|
217
|
+
},
|
|
230
218
|
}));
|
|
231
219
|
return aiUpdateTask;
|
|
232
220
|
}
|
|
233
221
|
async modelLoadingStatus(model) {
|
|
234
|
-
const { aiModelLoadingStatus } = unwrapApolloResult(await
|
|
222
|
+
const { aiModelLoadingStatus } = unwrapApolloResult(await this._apolloClient.query({
|
|
235
223
|
query: gql `
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
`,
|
|
246
|
-
variables: {
|
|
247
|
-
model
|
|
224
|
+
query AiModelLoadingStatus($model: String!) {
|
|
225
|
+
aiModelLoadingStatus(model: $model) {
|
|
226
|
+
model
|
|
227
|
+
status
|
|
228
|
+
progress
|
|
229
|
+
loaded
|
|
230
|
+
downloaded
|
|
248
231
|
}
|
|
232
|
+
}
|
|
233
|
+
`,
|
|
234
|
+
variables: {
|
|
235
|
+
model,
|
|
236
|
+
},
|
|
249
237
|
}));
|
|
250
238
|
return aiModelLoadingStatus;
|
|
251
239
|
}
|
|
252
240
|
async prompt(taskId, prompt) {
|
|
253
|
-
const { aiPrompt } = unwrapApolloResult(await
|
|
241
|
+
const { aiPrompt } = unwrapApolloResult(await this._apolloClient.mutate({
|
|
254
242
|
mutation: gql `
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
243
|
+
mutation AiPrompt($taskId: String!, $prompt: String!) {
|
|
244
|
+
aiPrompt(taskId: $taskId, prompt: $prompt)
|
|
245
|
+
}
|
|
246
|
+
`,
|
|
259
247
|
variables: {
|
|
260
248
|
taskId,
|
|
261
|
-
prompt
|
|
262
|
-
}
|
|
249
|
+
prompt,
|
|
250
|
+
},
|
|
263
251
|
}));
|
|
264
252
|
return aiPrompt;
|
|
265
253
|
}
|
|
266
254
|
async embed(modelId, text) {
|
|
267
|
-
const { aiEmbed } = unwrapApolloResult(await
|
|
255
|
+
const { aiEmbed } = unwrapApolloResult(await this._apolloClient.mutate({
|
|
268
256
|
mutation: gql `
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
257
|
+
mutation aiEmbed($modelId: String!, $text: String!) {
|
|
258
|
+
aiEmbed(modelId: $modelId, text: $text)
|
|
259
|
+
}
|
|
260
|
+
`,
|
|
273
261
|
variables: {
|
|
274
262
|
modelId,
|
|
275
|
-
text
|
|
276
|
-
}
|
|
263
|
+
text,
|
|
264
|
+
},
|
|
277
265
|
}));
|
|
278
266
|
const compressed = base64js.toByteArray(aiEmbed);
|
|
279
|
-
const decompressed = JSON.parse(pako.inflate(compressed, { to:
|
|
267
|
+
const decompressed = JSON.parse(pako.inflate(compressed, { to: "string" }));
|
|
280
268
|
return decompressed;
|
|
281
269
|
}
|
|
282
270
|
async openTranscriptionStream(modelId, streamCallback, params) {
|
|
283
|
-
const { aiOpenTranscriptionStream } = unwrapApolloResult(await
|
|
271
|
+
const { aiOpenTranscriptionStream } = unwrapApolloResult(await this._apolloClient.mutate({
|
|
284
272
|
mutation: gql `
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
273
|
+
mutation AiOpenTranscriptionStream(
|
|
274
|
+
$modelId: String!
|
|
275
|
+
$params: VoiceActivityParamsInput
|
|
276
|
+
) {
|
|
277
|
+
aiOpenTranscriptionStream(modelId: $modelId, params: $params)
|
|
278
|
+
}
|
|
279
|
+
`,
|
|
289
280
|
variables: {
|
|
290
281
|
modelId,
|
|
291
|
-
params
|
|
292
|
-
}
|
|
282
|
+
params,
|
|
283
|
+
},
|
|
293
284
|
}));
|
|
294
|
-
const subscription =
|
|
285
|
+
const subscription = this._apolloClient
|
|
286
|
+
.subscribe({
|
|
295
287
|
query: gql ` subscription {
|
|
296
288
|
aiTranscriptionText(streamId: "${aiOpenTranscriptionStream}")
|
|
297
|
-
}
|
|
298
|
-
})
|
|
289
|
+
}`,
|
|
290
|
+
})
|
|
291
|
+
.subscribe({
|
|
299
292
|
next(data) {
|
|
300
293
|
streamCallback(data.data.aiTranscriptionText);
|
|
301
294
|
return data.data.aiTranscriptionText;
|
|
302
295
|
},
|
|
303
296
|
error(err) {
|
|
304
|
-
|
|
305
|
-
|
|
297
|
+
if (!isSocketCloseError(err))
|
|
298
|
+
console.error(err);
|
|
299
|
+
},
|
|
306
300
|
});
|
|
307
|
-
|
|
301
|
+
this._transcriptionSubscriptions.set(aiOpenTranscriptionStream, subscription);
|
|
308
302
|
return aiOpenTranscriptionStream;
|
|
309
303
|
}
|
|
310
304
|
async closeTranscriptionStream(streamId) {
|
|
311
|
-
const { aiCloseTranscriptionStream } = unwrapApolloResult(await
|
|
305
|
+
const { aiCloseTranscriptionStream } = unwrapApolloResult(await this._apolloClient.mutate({
|
|
312
306
|
mutation: gql `
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
307
|
+
mutation aiCloseTranscriptionStream($streamId: String!) {
|
|
308
|
+
aiCloseTranscriptionStream(streamId: $streamId)
|
|
309
|
+
}
|
|
310
|
+
`,
|
|
317
311
|
variables: {
|
|
318
|
-
streamId
|
|
319
|
-
}
|
|
312
|
+
streamId,
|
|
313
|
+
},
|
|
320
314
|
}));
|
|
321
|
-
const subscription =
|
|
315
|
+
const subscription = this._transcriptionSubscriptions.get(streamId);
|
|
322
316
|
if (!subscription.closed) {
|
|
323
317
|
subscription.unsubscribe();
|
|
324
318
|
}
|
|
325
319
|
return aiCloseTranscriptionStream;
|
|
326
320
|
}
|
|
327
321
|
async feedTranscriptionStream(streamIds, audio) {
|
|
328
|
-
const { aiFeedTranscriptionStream } = unwrapApolloResult(await
|
|
322
|
+
const { aiFeedTranscriptionStream } = unwrapApolloResult(await this._apolloClient.mutate({
|
|
329
323
|
mutation: gql `
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
324
|
+
mutation AiFeedTranscriptionStream(
|
|
325
|
+
$streamIds: [String!]!
|
|
326
|
+
$audio: [Float!]!
|
|
327
|
+
) {
|
|
328
|
+
aiFeedTranscriptionStream(streamIds: $streamIds, audio: $audio)
|
|
329
|
+
}
|
|
330
|
+
`,
|
|
334
331
|
variables: {
|
|
335
332
|
streamIds: Array.isArray(streamIds) ? streamIds : [streamIds],
|
|
336
|
-
audio: audio
|
|
337
|
-
}
|
|
333
|
+
audio: audio,
|
|
334
|
+
},
|
|
338
335
|
}));
|
|
339
336
|
return aiFeedTranscriptionStream;
|
|
340
337
|
}
|
|
341
338
|
}
|
|
342
|
-
_AIClient_apolloClient = new WeakMap(), _AIClient_transcriptionSubscriptions = new WeakMap();
|
|
@@ -2,7 +2,7 @@ import { ApolloClient } from "@apollo/client/core";
|
|
|
2
2
|
import { InteractionCall, InteractionMeta } from "../language/Language";
|
|
3
3
|
import { ExpressionRendered } from "./Expression";
|
|
4
4
|
export declare class ExpressionClient {
|
|
5
|
-
|
|
5
|
+
private _apolloClient;
|
|
6
6
|
constructor(client: ApolloClient<any>);
|
|
7
7
|
get(url: string, alwaysGet?: boolean): Promise<ExpressionRendered>;
|
|
8
8
|
getMany(urls: string[]): Promise<ExpressionRendered[]>;
|