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