@coasys/ad4m 0.10.0-prerelease → 0.10.0-rc10
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/lib/index.cjs +8167 -683
- package/lib/index.js +8167 -684
- package/lib/src/Ad4mClient.d.ts +2 -0
- package/lib/src/Ad4mClient.js +8 -2
- package/lib/src/PubSub.d.ts +1 -0
- package/lib/src/PubSub.js +1 -0
- package/lib/src/ai/AIClient.d.ts +19 -0
- package/lib/src/ai/AIClient.js +236 -0
- package/lib/src/ai/AIResolver.d.ts +14 -0
- package/lib/src/ai/AIResolver.js +145 -0
- package/lib/src/ai/Tasks.d.ts +37 -0
- package/lib/src/ai/Tasks.js +165 -0
- package/lib/src/buildSchema.js +3 -1
- package/lib/src/expression/ExpressionClient.d.ts +1 -1
- package/lib/src/expression/ExpressionClient.js +13 -1
- package/lib/src/index.d.ts +2 -0
- package/lib/src/index.js +2 -0
- package/lib/src/language/LanguageContext.d.ts +1 -0
- package/lib/src/perspectives/PerspectiveProxy.js +84 -60
- package/lib/src/runtime/RuntimeClient.d.ts +0 -2
- package/lib/src/runtime/RuntimeClient.js +0 -20
- package/lib/src/runtime/RuntimeResolver.d.ts +0 -1
- package/lib/src/runtime/RuntimeResolver.js +1 -21
- package/lib/src/schema.gql +48 -1
- package/lib/src/subject/SubjectEntity.js +0 -2
- package/lib/src/typeDefs.js +48 -1
- package/package.json +7 -3
- package/src/Ad4mClient.test.ts +77 -1
- package/src/Ad4mClient.ts +7 -0
- package/src/PubSub.ts +2 -1
- package/src/ai/AIClient.ts +252 -0
- package/src/ai/AIResolver.ts +147 -0
- package/src/ai/Tasks.ts +121 -0
- package/src/buildSchema.ts +3 -1
- package/src/expression/ExpressionClient.ts +14 -1
- package/src/index.ts +2 -0
- package/src/perspectives/PerspectiveProxy.ts +90 -67
- package/src/runtime/RuntimeClient.ts +0 -21
- package/src/runtime/RuntimeResolver.ts +0 -17
- package/src/subject/SubjectEntity.ts +0 -2
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { Field, InputType, ObjectType } from "type-graphql";
|
|
11
|
+
let AIPromptExamplesInput = class AIPromptExamplesInput {
|
|
12
|
+
constructor(input, output) {
|
|
13
|
+
this.input = input;
|
|
14
|
+
this.output = output;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
__decorate([
|
|
18
|
+
Field(),
|
|
19
|
+
__metadata("design:type", String)
|
|
20
|
+
], AIPromptExamplesInput.prototype, "input", void 0);
|
|
21
|
+
__decorate([
|
|
22
|
+
Field(),
|
|
23
|
+
__metadata("design:type", String)
|
|
24
|
+
], AIPromptExamplesInput.prototype, "output", void 0);
|
|
25
|
+
AIPromptExamplesInput = __decorate([
|
|
26
|
+
InputType(),
|
|
27
|
+
__metadata("design:paramtypes", [String, String])
|
|
28
|
+
], AIPromptExamplesInput);
|
|
29
|
+
export { AIPromptExamplesInput };
|
|
30
|
+
let AIPromptExamples = class AIPromptExamples {
|
|
31
|
+
constructor(input, output) {
|
|
32
|
+
this.input = input;
|
|
33
|
+
this.output = output;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
__decorate([
|
|
37
|
+
Field(),
|
|
38
|
+
__metadata("design:type", String)
|
|
39
|
+
], AIPromptExamples.prototype, "input", void 0);
|
|
40
|
+
__decorate([
|
|
41
|
+
Field(),
|
|
42
|
+
__metadata("design:type", String)
|
|
43
|
+
], AIPromptExamples.prototype, "output", void 0);
|
|
44
|
+
AIPromptExamples = __decorate([
|
|
45
|
+
ObjectType(),
|
|
46
|
+
__metadata("design:paramtypes", [String, String])
|
|
47
|
+
], AIPromptExamples);
|
|
48
|
+
export { AIPromptExamples };
|
|
49
|
+
let AITaskInput = class AITaskInput {
|
|
50
|
+
constructor(name, model_id, system_prompt, prompt_examples, metaData) {
|
|
51
|
+
this.name = name;
|
|
52
|
+
this.modelId = model_id;
|
|
53
|
+
this.systemPrompt = system_prompt;
|
|
54
|
+
this.promptExamples = prompt_examples;
|
|
55
|
+
this.metaData = metaData;
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
__decorate([
|
|
59
|
+
Field(),
|
|
60
|
+
__metadata("design:type", String)
|
|
61
|
+
], AITaskInput.prototype, "name", void 0);
|
|
62
|
+
__decorate([
|
|
63
|
+
Field(),
|
|
64
|
+
__metadata("design:type", String)
|
|
65
|
+
], AITaskInput.prototype, "modelId", void 0);
|
|
66
|
+
__decorate([
|
|
67
|
+
Field(),
|
|
68
|
+
__metadata("design:type", String)
|
|
69
|
+
], AITaskInput.prototype, "systemPrompt", void 0);
|
|
70
|
+
__decorate([
|
|
71
|
+
Field(type => [AIPromptExamplesInput]),
|
|
72
|
+
__metadata("design:type", Array)
|
|
73
|
+
], AITaskInput.prototype, "promptExamples", void 0);
|
|
74
|
+
__decorate([
|
|
75
|
+
Field(type => String, { nullable: true }),
|
|
76
|
+
__metadata("design:type", String)
|
|
77
|
+
], AITaskInput.prototype, "metaData", void 0);
|
|
78
|
+
AITaskInput = __decorate([
|
|
79
|
+
InputType(),
|
|
80
|
+
__metadata("design:paramtypes", [String, String, String, Array, String])
|
|
81
|
+
], AITaskInput);
|
|
82
|
+
export { AITaskInput };
|
|
83
|
+
let AITask = class AITask {
|
|
84
|
+
constructor(name, model_id, task_id, system_prompt, prompt_examples, metaData, created_at, updated_at) {
|
|
85
|
+
this.name = name;
|
|
86
|
+
this.modelId = model_id;
|
|
87
|
+
this.taskId = task_id;
|
|
88
|
+
this.systemPrompt = system_prompt;
|
|
89
|
+
this.promptExamples = prompt_examples;
|
|
90
|
+
this.metaData = metaData;
|
|
91
|
+
this.createdAt = created_at;
|
|
92
|
+
this.updatedAt = updated_at;
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
__decorate([
|
|
96
|
+
Field(),
|
|
97
|
+
__metadata("design:type", String)
|
|
98
|
+
], AITask.prototype, "name", void 0);
|
|
99
|
+
__decorate([
|
|
100
|
+
Field(),
|
|
101
|
+
__metadata("design:type", String)
|
|
102
|
+
], AITask.prototype, "modelId", void 0);
|
|
103
|
+
__decorate([
|
|
104
|
+
Field(),
|
|
105
|
+
__metadata("design:type", String)
|
|
106
|
+
], AITask.prototype, "taskId", void 0);
|
|
107
|
+
__decorate([
|
|
108
|
+
Field(),
|
|
109
|
+
__metadata("design:type", String)
|
|
110
|
+
], AITask.prototype, "systemPrompt", void 0);
|
|
111
|
+
__decorate([
|
|
112
|
+
Field(type => [AIPromptExamples]),
|
|
113
|
+
__metadata("design:type", Array)
|
|
114
|
+
], AITask.prototype, "promptExamples", void 0);
|
|
115
|
+
__decorate([
|
|
116
|
+
Field(type => String, { nullable: true }),
|
|
117
|
+
__metadata("design:type", String)
|
|
118
|
+
], AITask.prototype, "metaData", void 0);
|
|
119
|
+
__decorate([
|
|
120
|
+
Field(),
|
|
121
|
+
__metadata("design:type", String)
|
|
122
|
+
], AITask.prototype, "createdAt", void 0);
|
|
123
|
+
__decorate([
|
|
124
|
+
Field(),
|
|
125
|
+
__metadata("design:type", String)
|
|
126
|
+
], AITask.prototype, "updatedAt", void 0);
|
|
127
|
+
AITask = __decorate([
|
|
128
|
+
ObjectType(),
|
|
129
|
+
__metadata("design:paramtypes", [String, String, String, String, Array, String, String, String])
|
|
130
|
+
], AITask);
|
|
131
|
+
export { AITask };
|
|
132
|
+
let AIModelLoadingStatus = class AIModelLoadingStatus {
|
|
133
|
+
constructor(model, status, progress, downloaded, loaded) {
|
|
134
|
+
this.model = model;
|
|
135
|
+
this.status = status;
|
|
136
|
+
this.progress = progress;
|
|
137
|
+
this.downloaded = downloaded;
|
|
138
|
+
this.loaded = loaded;
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
__decorate([
|
|
142
|
+
Field(),
|
|
143
|
+
__metadata("design:type", String)
|
|
144
|
+
], AIModelLoadingStatus.prototype, "model", void 0);
|
|
145
|
+
__decorate([
|
|
146
|
+
Field(),
|
|
147
|
+
__metadata("design:type", String)
|
|
148
|
+
], AIModelLoadingStatus.prototype, "status", void 0);
|
|
149
|
+
__decorate([
|
|
150
|
+
Field(),
|
|
151
|
+
__metadata("design:type", Number)
|
|
152
|
+
], AIModelLoadingStatus.prototype, "progress", void 0);
|
|
153
|
+
__decorate([
|
|
154
|
+
Field(),
|
|
155
|
+
__metadata("design:type", Boolean)
|
|
156
|
+
], AIModelLoadingStatus.prototype, "downloaded", void 0);
|
|
157
|
+
__decorate([
|
|
158
|
+
Field(),
|
|
159
|
+
__metadata("design:type", Boolean)
|
|
160
|
+
], AIModelLoadingStatus.prototype, "loaded", void 0);
|
|
161
|
+
AIModelLoadingStatus = __decorate([
|
|
162
|
+
ObjectType(),
|
|
163
|
+
__metadata("design:paramtypes", [String, String, Number, Boolean, Boolean])
|
|
164
|
+
], AIModelLoadingStatus);
|
|
165
|
+
export { AIModelLoadingStatus };
|
package/lib/src/buildSchema.js
CHANGED
|
@@ -9,6 +9,7 @@ import LanguageResolver from "./language/LanguageResolver";
|
|
|
9
9
|
import NeighbourhoodResolver from "./neighbourhood/NeighbourhoodResolver";
|
|
10
10
|
import PerspectiveResolver from "./perspectives/PerspectiveResolver";
|
|
11
11
|
import RuntimeResolver from "./runtime/RuntimeResolver";
|
|
12
|
+
import AIResolver from "./ai/AIResolver";
|
|
12
13
|
const __filename = fileURLToPath(import.meta.url);
|
|
13
14
|
const __dirname = path.dirname(__filename);
|
|
14
15
|
buildSchema({
|
|
@@ -18,7 +19,8 @@ buildSchema({
|
|
|
18
19
|
LanguageResolver,
|
|
19
20
|
NeighbourhoodResolver,
|
|
20
21
|
PerspectiveResolver,
|
|
21
|
-
RuntimeResolver
|
|
22
|
+
RuntimeResolver,
|
|
23
|
+
AIResolver
|
|
22
24
|
],
|
|
23
25
|
emitSchemaFile: {
|
|
24
26
|
path: __dirname + '/schema.gql',
|
|
@@ -4,7 +4,7 @@ import { ExpressionRendered } from "./Expression";
|
|
|
4
4
|
export declare class ExpressionClient {
|
|
5
5
|
#private;
|
|
6
6
|
constructor(client: ApolloClient<any>);
|
|
7
|
-
get(url: string): Promise<ExpressionRendered>;
|
|
7
|
+
get(url: string, alwaysGet?: boolean): Promise<ExpressionRendered>;
|
|
8
8
|
getMany(urls: string[]): Promise<ExpressionRendered[]>;
|
|
9
9
|
getRaw(url: string): Promise<string>;
|
|
10
10
|
create(content: any, languageAddress: string): Promise<string>;
|
|
@@ -12,12 +12,24 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
12
12
|
var _ExpressionClient_apolloClient;
|
|
13
13
|
import { gql } from "@apollo/client/core";
|
|
14
14
|
import unwrapApolloResult from "../unwrapApolloResult";
|
|
15
|
+
import { Literal } from "../Literal";
|
|
15
16
|
export class ExpressionClient {
|
|
16
17
|
constructor(client) {
|
|
17
18
|
_ExpressionClient_apolloClient.set(this, void 0);
|
|
18
19
|
__classPrivateFieldSet(this, _ExpressionClient_apolloClient, client, "f");
|
|
19
20
|
}
|
|
20
|
-
async get(url) {
|
|
21
|
+
async get(url, alwaysGet = false) {
|
|
22
|
+
if (!alwaysGet) {
|
|
23
|
+
try {
|
|
24
|
+
let literalValue = Literal.fromUrl(url).get();
|
|
25
|
+
if (typeof literalValue === 'object' && literalValue !== null) {
|
|
26
|
+
if ('author' in literalValue && 'timestamp' in literalValue && 'data' in literalValue && 'proof' in literalValue) {
|
|
27
|
+
return literalValue;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
catch (e) { }
|
|
32
|
+
}
|
|
21
33
|
const { expression } = unwrapApolloResult(await __classPrivateFieldGet(this, _ExpressionClient_apolloClient, "f").query({
|
|
22
34
|
query: gql `query expression($url: String!) {
|
|
23
35
|
expression(url: $url) {
|
package/lib/src/index.d.ts
CHANGED
package/lib/src/index.js
CHANGED
|
@@ -307,7 +307,14 @@ export class PerspectiveProxy {
|
|
|
307
307
|
*/
|
|
308
308
|
async isSubjectInstance(expression, subjectClass) {
|
|
309
309
|
let className = await this.stringOrTemplateObjectToSubjectClass(subjectClass);
|
|
310
|
-
|
|
310
|
+
let isInstance = false;
|
|
311
|
+
const maxAttempts = 5;
|
|
312
|
+
let attempts = 0;
|
|
313
|
+
while (attempts < maxAttempts && !isInstance) {
|
|
314
|
+
isInstance = await this.infer(`subject_class("${className}", C), instance(C, "${expression}")`);
|
|
315
|
+
attempts++;
|
|
316
|
+
}
|
|
317
|
+
return isInstance;
|
|
311
318
|
}
|
|
312
319
|
/** For an existing subject instance (existing in the perspective's links)
|
|
313
320
|
* this function returns a proxy object that can be used to access the subject's
|
|
@@ -368,65 +375,82 @@ export class PerspectiveProxy {
|
|
|
368
375
|
return instances;
|
|
369
376
|
}
|
|
370
377
|
buildQueryFromTemplate(obj) {
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
query
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
378
|
+
let result;
|
|
379
|
+
// We need to avoid strict mode for the following intropsective code
|
|
380
|
+
(function (obj) {
|
|
381
|
+
// Collect all string properties of the object in a list
|
|
382
|
+
let properties = [];
|
|
383
|
+
// Collect all collections of the object in a list
|
|
384
|
+
let collections = [];
|
|
385
|
+
// Collect all string properties of the object in a list
|
|
386
|
+
if (Object.getPrototypeOf(obj).__properties) {
|
|
387
|
+
Object.keys(Object.getPrototypeOf(obj).__properties).forEach(p => properties.push(p));
|
|
388
|
+
}
|
|
389
|
+
else {
|
|
390
|
+
properties.push(...Object.keys(obj).filter(key => !Array.isArray(obj[key])));
|
|
391
|
+
}
|
|
392
|
+
// Collect all collections of the object in a list
|
|
393
|
+
if (Object.getPrototypeOf(obj).__collections) {
|
|
394
|
+
Object.keys(Object.getPrototypeOf(obj).__collections).filter(key => key !== 'isSubjectInstance').forEach(c => !collections.includes(c) ?? collections.push(c));
|
|
395
|
+
}
|
|
396
|
+
else {
|
|
397
|
+
collections.push(...Object.keys(obj).filter(key => Array.isArray(obj[key])).filter(key => key !== 'isSubjectInstance'));
|
|
398
|
+
}
|
|
399
|
+
// Collect all set functions of the object in a list
|
|
400
|
+
let setFunctions = Object.getOwnPropertyNames(obj).filter(key => (typeof obj[key] === "function") && key.startsWith("set") && !key.startsWith("setCollection"));
|
|
401
|
+
// Add all set functions of the object's prototype to that list
|
|
402
|
+
setFunctions = setFunctions.concat(Object.getOwnPropertyNames(Object.getPrototypeOf(obj)).filter(key => {
|
|
403
|
+
const descriptor = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(obj), key);
|
|
404
|
+
return descriptor && typeof descriptor.value === "function" && key.startsWith("set") && !key.startsWith("setCollection");
|
|
405
|
+
}));
|
|
406
|
+
// Collect all add functions of the object in a list
|
|
407
|
+
let addFunctions = Object.getOwnPropertyNames(obj).filter(key => (Object.prototype.hasOwnProperty.call(obj, key) && typeof obj[key] === "function") && key.startsWith("add"));
|
|
408
|
+
// Add all add functions of the object's prototype to that list
|
|
409
|
+
addFunctions = addFunctions.concat(Object.getOwnPropertyNames(Object.getPrototypeOf(obj)).filter(key => {
|
|
410
|
+
const descriptor = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(obj), key);
|
|
411
|
+
return descriptor && typeof descriptor.value === "function" && key.startsWith("add");
|
|
412
|
+
}));
|
|
413
|
+
// Collect all remove functions of the object in a list
|
|
414
|
+
let removeFunctions = Object.getOwnPropertyNames(obj).filter(key => (Object.prototype.hasOwnProperty.call(obj, key) && typeof obj[key] === "function") && key.startsWith("remove"));
|
|
415
|
+
// Add all remove functions of the object's prototype to that list
|
|
416
|
+
removeFunctions = removeFunctions.concat(Object.getOwnPropertyNames(Object.getPrototypeOf(obj)).filter(key => {
|
|
417
|
+
const descriptor = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(obj), key);
|
|
418
|
+
return descriptor && typeof descriptor.value === "function" && key.startsWith("remove");
|
|
419
|
+
}));
|
|
420
|
+
// Collect all add functions of the object in a list
|
|
421
|
+
let setCollectionFunctions = Object.getOwnPropertyNames(obj).filter(key => (Object.prototype.hasOwnProperty.call(obj, key) && typeof obj[key] === "function") && key.startsWith("setCollection"));
|
|
422
|
+
// Add all add functions of the object's prototype to that list
|
|
423
|
+
setCollectionFunctions = setCollectionFunctions.concat(Object.getOwnPropertyNames(Object.getPrototypeOf(obj)).filter(key => {
|
|
424
|
+
const descriptor = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(obj), key);
|
|
425
|
+
return descriptor && typeof descriptor.value === "function" && key.startsWith("setCollection");
|
|
426
|
+
}));
|
|
427
|
+
// Construct query to find all subject classes that have the given properties and collections
|
|
428
|
+
let query = `subject_class(Class, C)`;
|
|
429
|
+
for (let property of properties) {
|
|
430
|
+
query += `, property(C, "${property}")`;
|
|
431
|
+
}
|
|
432
|
+
for (let collection of collections) {
|
|
433
|
+
query += `, collection(C, "${collection}")`;
|
|
434
|
+
}
|
|
435
|
+
for (let setFunction of setFunctions) {
|
|
436
|
+
// e.g. "setState" -> "state"
|
|
437
|
+
let property = setFunction.substring(3);
|
|
438
|
+
property = property.charAt(0).toLowerCase() + property.slice(1);
|
|
439
|
+
query += `, property_setter(C, "${property}", _)`;
|
|
440
|
+
}
|
|
441
|
+
for (let addFunction of addFunctions) {
|
|
442
|
+
query += `, collection_adder(C, "${collectionAdderToName(addFunction)}", _)`;
|
|
443
|
+
}
|
|
444
|
+
for (let removeFunction of removeFunctions) {
|
|
445
|
+
query += `, collection_remover(C, "${collectionRemoverToName(removeFunction)}", _)`;
|
|
446
|
+
}
|
|
447
|
+
for (let setCollectionFunction of setCollectionFunctions) {
|
|
448
|
+
query += `, collection_setter(C, "${collectionSetterToName(setCollectionFunction)}", _)`;
|
|
449
|
+
}
|
|
450
|
+
query += ".";
|
|
451
|
+
result = query;
|
|
452
|
+
}(obj));
|
|
453
|
+
return result;
|
|
430
454
|
}
|
|
431
455
|
/** Returns all subject classes that match the given template object.
|
|
432
456
|
* This function looks at the properties of the template object and
|
|
@@ -34,9 +34,7 @@ export declare class RuntimeClient {
|
|
|
34
34
|
updateNotification(id: string, notification: NotificationInput): Promise<boolean>;
|
|
35
35
|
removeNotification(id: string): Promise<boolean>;
|
|
36
36
|
addNotificationTriggeredCallback(cb: NotificationTriggeredCallback): void;
|
|
37
|
-
addNotificationRequestedCallback(cb: NotificationRequestedCallback): void;
|
|
38
37
|
subscribeNotificationTriggered(): void;
|
|
39
|
-
subscribeNotificationRequested(): void;
|
|
40
38
|
addMessageCallback(cb: MessageCallback): void;
|
|
41
39
|
subscribeMessageReceived(): void;
|
|
42
40
|
addExceptionCallback(cb: ExceptionCallback): void;
|
|
@@ -56,12 +56,10 @@ export class RuntimeClient {
|
|
|
56
56
|
__classPrivateFieldSet(this, _RuntimeClient_messageReceivedCallbacks, [], "f");
|
|
57
57
|
__classPrivateFieldSet(this, _RuntimeClient_exceptionOccurredCallbacks, [], "f");
|
|
58
58
|
__classPrivateFieldSet(this, _RuntimeClient_notificationTriggeredCallbacks, [], "f");
|
|
59
|
-
__classPrivateFieldSet(this, _RuntimeClient_notificationRequestedCallbacks, [], "f");
|
|
60
59
|
if (subscribe) {
|
|
61
60
|
this.subscribeMessageReceived();
|
|
62
61
|
this.subscribeExceptionOccurred();
|
|
63
62
|
this.subscribeNotificationTriggered();
|
|
64
|
-
this.subscribeNotificationRequested();
|
|
65
63
|
}
|
|
66
64
|
}
|
|
67
65
|
async info() {
|
|
@@ -292,9 +290,6 @@ export class RuntimeClient {
|
|
|
292
290
|
addNotificationTriggeredCallback(cb) {
|
|
293
291
|
__classPrivateFieldGet(this, _RuntimeClient_notificationTriggeredCallbacks, "f").push(cb);
|
|
294
292
|
}
|
|
295
|
-
addNotificationRequestedCallback(cb) {
|
|
296
|
-
__classPrivateFieldGet(this, _RuntimeClient_notificationRequestedCallbacks, "f").push(cb);
|
|
297
|
-
}
|
|
298
293
|
subscribeNotificationTriggered() {
|
|
299
294
|
__classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").subscribe({
|
|
300
295
|
query: gql ` subscription {
|
|
@@ -310,21 +305,6 @@ export class RuntimeClient {
|
|
|
310
305
|
error: (e) => console.error(e)
|
|
311
306
|
});
|
|
312
307
|
}
|
|
313
|
-
subscribeNotificationRequested() {
|
|
314
|
-
__classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").subscribe({
|
|
315
|
-
query: gql ` subscription {
|
|
316
|
-
runtimeNotificationRequested { ${NOTIFICATION_FIELDS} }
|
|
317
|
-
}
|
|
318
|
-
`
|
|
319
|
-
}).subscribe({
|
|
320
|
-
next: result => {
|
|
321
|
-
__classPrivateFieldGet(this, _RuntimeClient_notificationRequestedCallbacks, "f").forEach(cb => {
|
|
322
|
-
cb(result.data.runtimeNotificationRequested);
|
|
323
|
-
});
|
|
324
|
-
},
|
|
325
|
-
error: (e) => console.error(e)
|
|
326
|
-
});
|
|
327
|
-
}
|
|
328
308
|
addMessageCallback(cb) {
|
|
329
309
|
__classPrivateFieldGet(this, _RuntimeClient_messageReceivedCallbacks, "f").push(cb);
|
|
330
310
|
}
|
|
@@ -76,6 +76,5 @@ export default class RuntimeResolver {
|
|
|
76
76
|
runtimeUpdateNotification(id: string, notification: NotificationInput): boolean;
|
|
77
77
|
runtimeRemoveNotification(id: string): boolean;
|
|
78
78
|
runtimeGrantNotification(id: string): boolean;
|
|
79
|
-
runtimeNotificationRequested(): Notification;
|
|
80
79
|
runtimeNotificationTriggered(): TriggeredNotification;
|
|
81
80
|
}
|
|
@@ -15,7 +15,7 @@ import { Perspective, PerspectiveExpression, PerspectiveInput } from "../perspec
|
|
|
15
15
|
import { ExpressionProof } from "../expression/Expression";
|
|
16
16
|
import { LinkExpression } from "../links/Links";
|
|
17
17
|
import { ExceptionType } from "../Exception";
|
|
18
|
-
import { RUNTIME_MESSAGED_RECEIVED_TOPIC, EXCEPTION_OCCURRED_TOPIC,
|
|
18
|
+
import { RUNTIME_MESSAGED_RECEIVED_TOPIC, EXCEPTION_OCCURRED_TOPIC, RUNTIME_NOTIFICATION_TRIGGERED_TOPIC } from '../PubSub';
|
|
19
19
|
const testLink = new LinkExpression();
|
|
20
20
|
testLink.author = "did:ad4m:test";
|
|
21
21
|
testLink.timestamp = Date.now();
|
|
@@ -304,20 +304,6 @@ let RuntimeResolver = class RuntimeResolver {
|
|
|
304
304
|
runtimeGrantNotification(id) {
|
|
305
305
|
return true;
|
|
306
306
|
}
|
|
307
|
-
runtimeNotificationRequested() {
|
|
308
|
-
return {
|
|
309
|
-
id: "test-id",
|
|
310
|
-
granted: false,
|
|
311
|
-
description: "Test description",
|
|
312
|
-
appName: "Test app name",
|
|
313
|
-
appUrl: "https://example.com",
|
|
314
|
-
appIconPath: "https://fluxsocial.io/favicon",
|
|
315
|
-
trigger: "triple(X, ad4m://has_type, flux://message)",
|
|
316
|
-
perspectiveIds: ["u983ud-jdhh38d"],
|
|
317
|
-
webhookUrl: "https://example.com/webhook",
|
|
318
|
-
webhookAuth: "test-auth",
|
|
319
|
-
};
|
|
320
|
-
}
|
|
321
307
|
runtimeNotificationTriggered() {
|
|
322
308
|
return {
|
|
323
309
|
perspectiveId: "test-perspective-id",
|
|
@@ -522,12 +508,6 @@ __decorate([
|
|
|
522
508
|
__metadata("design:paramtypes", [String]),
|
|
523
509
|
__metadata("design:returntype", Boolean)
|
|
524
510
|
], RuntimeResolver.prototype, "runtimeGrantNotification", null);
|
|
525
|
-
__decorate([
|
|
526
|
-
Subscription({ topics: RUNTIME_NOTIFICATION_REQUESTED_TOPIC, nullable: true }),
|
|
527
|
-
__metadata("design:type", Function),
|
|
528
|
-
__metadata("design:paramtypes", []),
|
|
529
|
-
__metadata("design:returntype", Notification)
|
|
530
|
-
], RuntimeResolver.prototype, "runtimeNotificationRequested", null);
|
|
531
511
|
__decorate([
|
|
532
512
|
Subscription({ topics: RUNTIME_NOTIFICATION_TRIGGERED_TOPIC, nullable: true }),
|
|
533
513
|
__metadata("design:type", Function),
|
package/lib/src/schema.gql
CHANGED
|
@@ -3,6 +3,43 @@
|
|
|
3
3
|
# !!! DO NOT MODIFY THIS FILE BY YOURSELF !!!
|
|
4
4
|
# -----------------------------------------------
|
|
5
5
|
|
|
6
|
+
type AIModelLoadingStatus {
|
|
7
|
+
downloaded: Boolean!
|
|
8
|
+
loaded: Boolean!
|
|
9
|
+
model: String!
|
|
10
|
+
progress: Float!
|
|
11
|
+
status: String!
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
type AIPromptExamples {
|
|
15
|
+
input: String!
|
|
16
|
+
output: String!
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
input AIPromptExamplesInput {
|
|
20
|
+
input: String!
|
|
21
|
+
output: String!
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
type AITask {
|
|
25
|
+
createdAt: String!
|
|
26
|
+
metaData: String
|
|
27
|
+
modelId: String!
|
|
28
|
+
name: String!
|
|
29
|
+
promptExamples: [AIPromptExamples!]!
|
|
30
|
+
systemPrompt: String!
|
|
31
|
+
taskId: String!
|
|
32
|
+
updatedAt: String!
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
input AITaskInput {
|
|
36
|
+
metaData: String
|
|
37
|
+
modelId: String!
|
|
38
|
+
name: String!
|
|
39
|
+
promptExamples: [AIPromptExamplesInput!]!
|
|
40
|
+
systemPrompt: String!
|
|
41
|
+
}
|
|
42
|
+
|
|
6
43
|
type Agent {
|
|
7
44
|
did: String!
|
|
8
45
|
directMessageLanguage: String
|
|
@@ -229,6 +266,14 @@ type Mutation {
|
|
|
229
266
|
agentUnlock(holochain: Boolean!, passphrase: String!): AgentStatus!
|
|
230
267
|
agentUpdateDirectMessageLanguage(directMessageLanguage: String!): Agent!
|
|
231
268
|
agentUpdatePublicPerspective(perspective: PerspectiveInput!): Agent!
|
|
269
|
+
aiAddTask(task: AITaskInput!): AITask!
|
|
270
|
+
aiCloseTranscriptionStream(streamId: String!): String!
|
|
271
|
+
aiEmbed(modelId: String!, text: String!): String!
|
|
272
|
+
aiFeedTranscriptionStream(audio: [Float!]!, streamId: String!): String!
|
|
273
|
+
aiOpenTranscriptionStream(modelId: String!): String!
|
|
274
|
+
aiPrompt(prompt: String!, taskId: String!): String!
|
|
275
|
+
aiRemoveTask(taskId: String!): AITask!
|
|
276
|
+
aiUpdateTask(task: AITaskInput!, taskId: String!): AITask!
|
|
232
277
|
deleteTrustedAgents(agents: [String!]!): [String!]!
|
|
233
278
|
expressionCreate(content: String!, languageAddress: String!): String!
|
|
234
279
|
expressionInteract(interactionCall: InteractionCall!, url: String!): String
|
|
@@ -349,6 +394,8 @@ type Query {
|
|
|
349
394
|
agentGetEntanglementProofs: [EntanglementProof!]!
|
|
350
395
|
agentIsLocked: Boolean!
|
|
351
396
|
agentStatus: AgentStatus!
|
|
397
|
+
aiModelLoadingStatus(model: String!): AIModelLoadingStatus!
|
|
398
|
+
aiTasks: [AITask!]!
|
|
352
399
|
expression(url: String!): ExpressionRendered
|
|
353
400
|
expressionInteractions(url: String!): [InteractionMeta!]!
|
|
354
401
|
expressionMany(urls: [String!]!): [ExpressionRendered]!
|
|
@@ -402,6 +449,7 @@ type Subscription {
|
|
|
402
449
|
agentAppsChanged: [Apps!]
|
|
403
450
|
agentStatusChanged: AgentStatus
|
|
404
451
|
agentUpdated: Agent
|
|
452
|
+
aiTranscriptionText(streamId: String!): String!
|
|
405
453
|
exceptionOccurred: ExceptionInfo
|
|
406
454
|
neighbourhoodSignal(perspectiveUUID: String!): PerspectiveExpression
|
|
407
455
|
perspectiveAdded: PerspectiveHandle
|
|
@@ -412,7 +460,6 @@ type Subscription {
|
|
|
412
460
|
perspectiveSyncStateChange(uuid: String!): String!
|
|
413
461
|
perspectiveUpdated: PerspectiveHandle
|
|
414
462
|
runtimeMessageReceived: PerspectiveExpression
|
|
415
|
-
runtimeNotificationRequested: Notification
|
|
416
463
|
runtimeNotificationTriggered: TriggeredNotification
|
|
417
464
|
}
|
|
418
465
|
|
|
@@ -42,9 +42,7 @@ export class SubjectEntity {
|
|
|
42
42
|
}
|
|
43
43
|
async getData(id) {
|
|
44
44
|
const tempId = id ?? __classPrivateFieldGet(this, _SubjectEntity_baseExpression, "f");
|
|
45
|
-
console.log("SubjectEntity: getData");
|
|
46
45
|
let data = await __classPrivateFieldGet(this, _SubjectEntity_perspective, "f").getSubjectData(__classPrivateFieldGet(this, _SubjectEntity_subjectClass, "f"), tempId);
|
|
47
|
-
console.log("SubjectEntity got data:", data);
|
|
48
46
|
Object.assign(this, data);
|
|
49
47
|
__classPrivateFieldSet(this, _SubjectEntity_baseExpression, tempId, "f");
|
|
50
48
|
return this;
|