@aigne/core 0.0.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/lib/cjs/assistant/generate-output.js +101 -0
- package/lib/cjs/assistant/select-agent.js +76 -0
- package/lib/cjs/assistant/type.js +11 -0
- package/lib/cjs/common/aid.js +42 -0
- package/lib/cjs/common/index.js +238 -0
- package/lib/cjs/common/resource-manager.js +199 -0
- package/lib/cjs/constants.js +9 -0
- package/lib/cjs/executor/agent.js +10 -0
- package/lib/cjs/executor/aigc.js +28 -0
- package/lib/cjs/executor/api.js +64 -0
- package/lib/cjs/executor/base.js +676 -0
- package/lib/cjs/executor/blocklet.js +25 -0
- package/lib/cjs/executor/call-agent.js +105 -0
- package/lib/cjs/executor/decision.js +478 -0
- package/lib/cjs/executor/image-blender.js +32 -0
- package/lib/cjs/executor/index.js +81 -0
- package/lib/cjs/executor/llm.js +379 -0
- package/lib/cjs/executor/logic.js +167 -0
- package/lib/cjs/index.js +17 -0
- package/lib/cjs/libs/blocklet/vc.js +92 -0
- package/lib/cjs/libs/openapi/request/index.js +24 -0
- package/lib/cjs/libs/openapi/request/util.js +146 -0
- package/lib/cjs/libs/openapi/types/index.js +17 -0
- package/lib/cjs/libs/openapi/util/call.js +15 -0
- package/lib/cjs/libs/openapi/util/check-schema.js +67 -0
- package/lib/cjs/libs/openapi/util/convert-schema.js +44 -0
- package/lib/cjs/libs/openapi/util/flatten-open-api.js +21 -0
- package/lib/cjs/libs/openapi/util/get-open-api-i18n-text.js +7 -0
- package/lib/cjs/logger.js +4 -0
- package/lib/cjs/runtime/resource-blocklet.js +5 -0
- package/lib/cjs/runtime/runtime.js +143 -0
- package/lib/cjs/types/assistant/index.js +31 -0
- package/lib/cjs/types/assistant/mustache/ReadableMustache.js +69 -0
- package/lib/cjs/types/assistant/mustache/directive.js +35 -0
- package/lib/cjs/types/assistant/mustache/mustache.js +688 -0
- package/lib/cjs/types/common/index.js +2 -0
- package/lib/cjs/types/index.js +20 -0
- package/lib/cjs/types/resource/index.js +47 -0
- package/lib/cjs/types/resource/project.js +35 -0
- package/lib/cjs/types/runtime/agent.js +2 -0
- package/lib/cjs/types/runtime/error.js +18 -0
- package/lib/cjs/types/runtime/index.js +37 -0
- package/lib/cjs/types/runtime/runtime-resource-blocklet-state.js +4 -0
- package/lib/cjs/types/runtime/schema.js +259 -0
- package/lib/cjs/utils/cron-job.js +48 -0
- package/lib/cjs/utils/extract-metadata-transform.js +58 -0
- package/lib/cjs/utils/extract-metadata-transform.test.js +61 -0
- package/lib/cjs/utils/fs.js +49 -0
- package/lib/cjs/utils/get-blocklet-agent.js +351 -0
- package/lib/cjs/utils/geti.js +37 -0
- package/lib/cjs/utils/is-non-nullable.js +20 -0
- package/lib/cjs/utils/render-message.js +23 -0
- package/lib/cjs/utils/resolve-secret-inputs.js +49 -0
- package/lib/cjs/utils/retry.js +19 -0
- package/lib/cjs/utils/task-id.js +7 -0
- package/lib/cjs/utils/tool-calls-transform.js +18 -0
- package/lib/esm/assistant/generate-output.js +91 -0
- package/lib/esm/assistant/select-agent.js +71 -0
- package/lib/esm/assistant/type.js +7 -0
- package/lib/esm/common/aid.js +38 -0
- package/lib/esm/common/index.js +232 -0
- package/lib/esm/common/resource-manager.js +192 -0
- package/lib/esm/constants.js +6 -0
- package/lib/esm/executor/agent.js +6 -0
- package/lib/esm/executor/aigc.js +24 -0
- package/lib/esm/executor/api.js +34 -0
- package/lib/esm/executor/base.js +668 -0
- package/lib/esm/executor/blocklet.js +21 -0
- package/lib/esm/executor/call-agent.js +98 -0
- package/lib/esm/executor/decision.js +471 -0
- package/lib/esm/executor/image-blender.js +25 -0
- package/lib/esm/executor/index.js +74 -0
- package/lib/esm/executor/llm.js +372 -0
- package/lib/esm/executor/logic.js +160 -0
- package/lib/esm/index.js +1 -0
- package/lib/esm/libs/blocklet/vc.js +85 -0
- package/lib/esm/libs/openapi/request/index.js +20 -0
- package/lib/esm/libs/openapi/request/util.js +136 -0
- package/lib/esm/libs/openapi/types/index.js +1 -0
- package/lib/esm/libs/openapi/util/call.js +8 -0
- package/lib/esm/libs/openapi/util/check-schema.js +62 -0
- package/lib/esm/libs/openapi/util/convert-schema.js +42 -0
- package/lib/esm/libs/openapi/util/flatten-open-api.js +19 -0
- package/lib/esm/libs/openapi/util/get-open-api-i18n-text.js +5 -0
- package/lib/esm/logger.js +2 -0
- package/lib/esm/runtime/resource-blocklet.js +2 -0
- package/lib/esm/runtime/runtime.js +136 -0
- package/lib/esm/types/assistant/index.js +9 -0
- package/lib/esm/types/assistant/mustache/ReadableMustache.js +63 -0
- package/lib/esm/types/assistant/mustache/directive.js +29 -0
- package/lib/esm/types/assistant/mustache/mustache.js +686 -0
- package/lib/esm/types/common/index.js +1 -0
- package/lib/esm/types/index.js +4 -0
- package/lib/esm/types/resource/index.js +26 -0
- package/lib/esm/types/resource/project.js +29 -0
- package/lib/esm/types/runtime/agent.js +1 -0
- package/lib/esm/types/runtime/error.js +14 -0
- package/lib/esm/types/runtime/index.js +20 -0
- package/lib/esm/types/runtime/runtime-resource-blocklet-state.js +1 -0
- package/lib/esm/types/runtime/schema.js +249 -0
- package/lib/esm/utils/cron-job.js +44 -0
- package/lib/esm/utils/extract-metadata-transform.js +54 -0
- package/lib/esm/utils/extract-metadata-transform.test.js +59 -0
- package/lib/esm/utils/fs.js +41 -0
- package/lib/esm/utils/get-blocklet-agent.js +344 -0
- package/lib/esm/utils/geti.js +30 -0
- package/lib/esm/utils/is-non-nullable.js +13 -0
- package/lib/esm/utils/render-message.js +20 -0
- package/lib/esm/utils/resolve-secret-inputs.js +46 -0
- package/lib/esm/utils/retry.js +16 -0
- package/lib/esm/utils/task-id.js +3 -0
- package/lib/esm/utils/tool-calls-transform.js +15 -0
- package/lib/types/assistant/generate-output.d.ts +29 -0
- package/lib/types/assistant/select-agent.d.ts +14 -0
- package/lib/types/assistant/type.d.ts +61 -0
- package/lib/types/common/aid.d.ts +18 -0
- package/lib/types/common/index.d.ts +7 -0
- package/lib/types/common/resource-manager.d.ts +88 -0
- package/lib/types/constants.d.ts +6 -0
- package/lib/types/executor/agent.d.ts +5 -0
- package/lib/types/executor/aigc.d.ts +9 -0
- package/lib/types/executor/api.d.ts +9 -0
- package/lib/types/executor/base.d.ts +209 -0
- package/lib/types/executor/blocklet.d.ts +9 -0
- package/lib/types/executor/call-agent.d.ts +12 -0
- package/lib/types/executor/decision.d.ts +20 -0
- package/lib/types/executor/image-blender.d.ts +9 -0
- package/lib/types/executor/index.d.ts +8 -0
- package/lib/types/executor/llm.d.ts +38 -0
- package/lib/types/executor/logic.d.ts +9 -0
- package/lib/types/index.d.ts +1 -0
- package/lib/types/libs/blocklet/vc.d.ts +17 -0
- package/lib/types/libs/openapi/request/index.d.ts +17 -0
- package/lib/types/libs/openapi/request/util.d.ts +40 -0
- package/lib/types/libs/openapi/types/index.d.ts +20 -0
- package/lib/types/libs/openapi/util/call.d.ts +2 -0
- package/lib/types/libs/openapi/util/check-schema.d.ts +3 -0
- package/lib/types/libs/openapi/util/convert-schema.d.ts +8 -0
- package/lib/types/libs/openapi/util/flatten-open-api.d.ts +3 -0
- package/lib/types/libs/openapi/util/get-open-api-i18n-text.d.ts +2 -0
- package/lib/types/logger.d.ts +2 -0
- package/lib/types/runtime/resource-blocklet.d.ts +2 -0
- package/lib/types/runtime/runtime.d.ts +20 -0
- package/lib/types/types/assistant/index.d.ts +405 -0
- package/lib/types/types/assistant/mustache/ReadableMustache.d.ts +2 -0
- package/lib/types/types/assistant/mustache/directive.d.ts +6 -0
- package/lib/types/types/assistant/mustache/mustache.d.ts +2 -0
- package/lib/types/types/common/index.d.ts +45 -0
- package/lib/types/types/index.d.ts +4 -0
- package/lib/types/types/resource/index.d.ts +17 -0
- package/lib/types/types/resource/project.d.ts +41 -0
- package/lib/types/types/runtime/agent.d.ts +33 -0
- package/lib/types/types/runtime/error.d.ts +10 -0
- package/lib/types/types/runtime/index.d.ts +116 -0
- package/lib/types/types/runtime/runtime-resource-blocklet-state.d.ts +5 -0
- package/lib/types/types/runtime/schema.d.ts +110 -0
- package/lib/types/utils/cron-job.d.ts +22 -0
- package/lib/types/utils/extract-metadata-transform.d.ts +16 -0
- package/lib/types/utils/extract-metadata-transform.test.d.ts +1 -0
- package/lib/types/utils/fs.d.ts +9 -0
- package/lib/types/utils/get-blocklet-agent.d.ts +219 -0
- package/lib/types/utils/geti.d.ts +1 -0
- package/lib/types/utils/is-non-nullable.d.ts +2 -0
- package/lib/types/utils/render-message.d.ts +6 -0
- package/lib/types/utils/resolve-secret-inputs.d.ts +11 -0
- package/lib/types/utils/retry.d.ts +1 -0
- package/lib/types/utils/task-id.d.ts +1 -0
- package/lib/types/utils/tool-calls-transform.d.ts +2 -0
- package/package.json +67 -0
- package/tsconfig.json +12 -0
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.metadataStreamOutputFormatPrompt = exports.metadataOutputFormatPrompt = exports.metadataSuffix = exports.metadataPrefix = void 0;
|
|
7
|
+
exports.generateOutput = generateOutput;
|
|
8
|
+
exports.extractMetadataFromStream = extractMetadataFromStream;
|
|
9
|
+
const web_1 = require("stream/web");
|
|
10
|
+
const chat_1 = require("@blocklet/ai-kit/api/types/chat");
|
|
11
|
+
const schema_1 = require("../types/runtime/schema");
|
|
12
|
+
const extract_metadata_transform_1 = require("../utils/extract-metadata-transform");
|
|
13
|
+
const retry_1 = __importDefault(require("../utils/retry"));
|
|
14
|
+
exports.metadataPrefix = '```metadata';
|
|
15
|
+
exports.metadataSuffix = '```';
|
|
16
|
+
const metadataOutputFormatPrompt = (schema) => `\
|
|
17
|
+
## Metadata Schema
|
|
18
|
+
Here is the metadata json schema, inside the <metadata-schema></metadata-schema> XML tags:
|
|
19
|
+
<metadata-schema>
|
|
20
|
+
${schema}
|
|
21
|
+
</metadata-schema>
|
|
22
|
+
|
|
23
|
+
## Output Rules
|
|
24
|
+
- You have to generate a json metadata base on the metadata schema above, inside the <metadata-schema></metadata-schema> XML tags
|
|
25
|
+
- Don't make any explanation
|
|
26
|
+
|
|
27
|
+
## Output Format
|
|
28
|
+
[Generate a json data based on the above metadata schema, put the json string into the following code block]
|
|
29
|
+
${exports.metadataPrefix}
|
|
30
|
+
${exports.metadataSuffix}
|
|
31
|
+
|
|
32
|
+
## Output Example
|
|
33
|
+
${exports.metadataPrefix}
|
|
34
|
+
{"key": "value"}
|
|
35
|
+
${exports.metadataSuffix}
|
|
36
|
+
`;
|
|
37
|
+
exports.metadataOutputFormatPrompt = metadataOutputFormatPrompt;
|
|
38
|
+
const metadataStreamOutputFormatPrompt = (schema) => `\
|
|
39
|
+
## Metadata Schema
|
|
40
|
+
Here is the metadata json schema, inside the <metadata-schema></metadata-schema> XML tags:
|
|
41
|
+
<metadata-schema>
|
|
42
|
+
${schema}
|
|
43
|
+
</metadata-schema>
|
|
44
|
+
|
|
45
|
+
## Output Rules
|
|
46
|
+
- You have to generate a text content and a json metadata base on the metadata schema above, inside the <metadata-schema></metadata-schema> XML tags
|
|
47
|
+
- Don't make any explanation
|
|
48
|
+
|
|
49
|
+
## Output Format
|
|
50
|
+
[Your text content here]
|
|
51
|
+
[Generate a json data based on the above metadata schema, put the json string into the following code block]
|
|
52
|
+
${exports.metadataPrefix}
|
|
53
|
+
${exports.metadataSuffix}
|
|
54
|
+
|
|
55
|
+
## Output Example
|
|
56
|
+
[Here is your answer to the the user's question]
|
|
57
|
+
${exports.metadataPrefix}
|
|
58
|
+
{"key": "value"}
|
|
59
|
+
${exports.metadataSuffix}
|
|
60
|
+
`;
|
|
61
|
+
exports.metadataStreamOutputFormatPrompt = metadataStreamOutputFormatPrompt;
|
|
62
|
+
async function generateOutput({ assistant, messages, callAI, maxRetries = 0, datastoreVariables, }) {
|
|
63
|
+
const jsonSchema = (0, schema_1.outputVariablesToJsonSchema)(assistant, { variables: datastoreVariables });
|
|
64
|
+
const joiSchema = (0, schema_1.outputVariablesToJoiSchema)(assistant, { variables: datastoreVariables });
|
|
65
|
+
const outputSchema = JSON.stringify(jsonSchema, null, 2);
|
|
66
|
+
messages.push({
|
|
67
|
+
role: 'system',
|
|
68
|
+
content: (0, exports.metadataOutputFormatPrompt)(outputSchema),
|
|
69
|
+
});
|
|
70
|
+
return (0, retry_1.default)(async () => {
|
|
71
|
+
const result = await callAI({
|
|
72
|
+
assistant,
|
|
73
|
+
input: {
|
|
74
|
+
stream: true,
|
|
75
|
+
messages,
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
let text = '';
|
|
79
|
+
for await (const chunk of extractMetadataFromStream(result, true)) {
|
|
80
|
+
if (chunk.type === 'match')
|
|
81
|
+
text += chunk.text;
|
|
82
|
+
}
|
|
83
|
+
const json = JSON.parse(text);
|
|
84
|
+
return await joiSchema.validateAsync(json);
|
|
85
|
+
}, maxRetries);
|
|
86
|
+
}
|
|
87
|
+
function extractMetadataFromStream(input, extract = true) {
|
|
88
|
+
return input
|
|
89
|
+
.pipeThrough(new web_1.TransformStream({
|
|
90
|
+
transform: (chunk, controller) => {
|
|
91
|
+
if ((0, chat_1.isChatCompletionChunk)(chunk))
|
|
92
|
+
if (chunk.delta.content)
|
|
93
|
+
controller.enqueue(chunk.delta.content);
|
|
94
|
+
},
|
|
95
|
+
}))
|
|
96
|
+
.pipeThrough(new extract_metadata_transform_1.ExtractMetadataTransform({
|
|
97
|
+
// Pass empty string to disable extractor
|
|
98
|
+
start: extract ? exports.metadataPrefix : '',
|
|
99
|
+
end: extract ? exports.metadataSuffix : '',
|
|
100
|
+
}));
|
|
101
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const chat_1 = require("@blocklet/ai-kit/api/types/chat");
|
|
7
|
+
const retry_1 = __importDefault(require("../utils/retry"));
|
|
8
|
+
const selectAgentSystemPrompt = () => `\
|
|
9
|
+
### Job Description
|
|
10
|
+
You are a text classification engine that analyzes text data and assigns categories based on user input or automatically determined categories.
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Task
|
|
14
|
+
Your task is to assign one categories ONLY to the input text and only one category may be assigned returned in the output.
|
|
15
|
+
Additionally, you need to extract the key words from the text that are related to the classification.
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Format
|
|
19
|
+
- "input_text" is in the variable text_field.
|
|
20
|
+
- "categories" are specified as a category list in the variable categories or left empty for automatic determination.
|
|
21
|
+
- "classification_instructions" may be included to improve the classification accuracy.
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
### Constraint
|
|
25
|
+
- DO NOT include anything other than the JSON array in your response.
|
|
26
|
+
- The output results must be within the scope of categories, not content outside the scope
|
|
27
|
+
`;
|
|
28
|
+
async function generateSelectAgentName({ assistant, message, callAI, maxRetries = 0, categories, }) {
|
|
29
|
+
return (0, retry_1.default)(async () => {
|
|
30
|
+
const selectAgentIdResponseByPrompt = await callAI({
|
|
31
|
+
assistant,
|
|
32
|
+
input: {
|
|
33
|
+
messages: [
|
|
34
|
+
{
|
|
35
|
+
role: 'system',
|
|
36
|
+
content: `${selectAgentSystemPrompt()}`,
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
role: 'user',
|
|
40
|
+
content: '\n { "input_text": ["I recently had a great experience with your company. The service was prompt and the staff was very friendly."],\n "categories": [{,"category_name": "Customer Service"}, {"category_name": "Satisfaction"}, {"category_name": "Sales"}, {"category_name": "Product"}],\n "classification_instructions": []}\n',
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
role: 'assistant',
|
|
44
|
+
content: '{"category_name": "Customer Service"}',
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
role: 'user',
|
|
48
|
+
content: '\n {"input_text": ["bad service, slow to bring the food"],\n "categories": [{"category_name": "Food Quality"}, {"category_name": "Experience"}, {"category_name": "Price"}],\n "classification_instructions": []}\n',
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
role: 'assistant',
|
|
52
|
+
content: '{"category_name": "Experience"}',
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
role: 'user',
|
|
56
|
+
content: `\n {"input_text": [${message}],\n "categories": [${categories}],\n "classification_instructions": []}\n`,
|
|
57
|
+
},
|
|
58
|
+
],
|
|
59
|
+
model: assistant?.model,
|
|
60
|
+
temperature: assistant?.temperature,
|
|
61
|
+
topP: assistant?.topP,
|
|
62
|
+
presencePenalty: assistant?.presencePenalty,
|
|
63
|
+
frequencyPenalty: assistant?.frequencyPenalty,
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
let text = '';
|
|
67
|
+
for await (const chunk of selectAgentIdResponseByPrompt) {
|
|
68
|
+
if ((0, chat_1.isChatCompletionChunk)(chunk) && chunk.delta.content) {
|
|
69
|
+
text += chunk.delta.content;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
const json = JSON.parse(text);
|
|
73
|
+
return json;
|
|
74
|
+
}, maxRetries);
|
|
75
|
+
}
|
|
76
|
+
exports.default = generateSelectAgentName;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ToolCompletionDirective = void 0;
|
|
4
|
+
class ToolCompletionDirective extends Error {
|
|
5
|
+
type;
|
|
6
|
+
constructor(message, type) {
|
|
7
|
+
super(message);
|
|
8
|
+
this.type = type;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.ToolCompletionDirective = ToolCompletionDirective;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseIdentity = parseIdentity;
|
|
4
|
+
exports.stringifyIdentity = stringifyIdentity;
|
|
5
|
+
const js_base64_1 = require("js-base64");
|
|
6
|
+
function parseIdentity(aid, options) {
|
|
7
|
+
let blockletDid;
|
|
8
|
+
let projectId;
|
|
9
|
+
let projectRef;
|
|
10
|
+
let agentId;
|
|
11
|
+
try {
|
|
12
|
+
const s = js_base64_1.Base64.decode(aid).split('/');
|
|
13
|
+
if (s.length === 4) {
|
|
14
|
+
[blockletDid, projectId, projectRef, agentId] = s;
|
|
15
|
+
}
|
|
16
|
+
else if (s.length === 3) {
|
|
17
|
+
[projectId, projectRef, agentId] = s;
|
|
18
|
+
}
|
|
19
|
+
else if (s.length === 2) {
|
|
20
|
+
[projectId, agentId] = s;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
console.error('parse assistantId error', { error });
|
|
25
|
+
}
|
|
26
|
+
if (projectId && agentId)
|
|
27
|
+
return {
|
|
28
|
+
blockletDid: blockletDid || undefined,
|
|
29
|
+
projectId,
|
|
30
|
+
projectRef: projectRef || undefined,
|
|
31
|
+
agentId,
|
|
32
|
+
};
|
|
33
|
+
if (options?.rejectWhenError)
|
|
34
|
+
throw new Error(`Invalid assistant identity ${aid}`);
|
|
35
|
+
return undefined;
|
|
36
|
+
}
|
|
37
|
+
function stringifyIdentity({ blockletDid, projectId, projectRef, agentId, }) {
|
|
38
|
+
if (typeof projectId !== 'string' || typeof agentId !== 'string') {
|
|
39
|
+
throw new Error('Invalid aid fragments');
|
|
40
|
+
}
|
|
41
|
+
return js_base64_1.Base64.encodeURI([blockletDid || '', projectId, projectRef || '', agentId].join('/'));
|
|
42
|
+
}
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.defaultImageModel = exports.supportJsonSchemaModels = exports.defaultTextModel = void 0;
|
|
4
|
+
exports.getSupportedModels = getSupportedModels;
|
|
5
|
+
exports.getSupportedImagesModels = getSupportedImagesModels;
|
|
6
|
+
exports.getServiceModePermissionMap = getServiceModePermissionMap;
|
|
7
|
+
exports.defaultTextModel = 'gpt-4o-mini';
|
|
8
|
+
exports.supportJsonSchemaModels = ['gpt-4o', 'gpt-4o-mini'];
|
|
9
|
+
async function getSupportedModels() {
|
|
10
|
+
return [
|
|
11
|
+
{
|
|
12
|
+
brand: 'OpenAI',
|
|
13
|
+
model: 'gpt-4o',
|
|
14
|
+
name: 'GPT4o',
|
|
15
|
+
temperatureMin: 0,
|
|
16
|
+
temperatureMax: 2,
|
|
17
|
+
temperatureDefault: 1,
|
|
18
|
+
topPMin: 0,
|
|
19
|
+
topPMax: 1,
|
|
20
|
+
topPDefault: 1,
|
|
21
|
+
presencePenaltyMin: -2,
|
|
22
|
+
presencePenaltyMax: 2,
|
|
23
|
+
presencePenaltyDefault: 0,
|
|
24
|
+
frequencyPenaltyMin: -2,
|
|
25
|
+
frequencyPenaltyMax: 2,
|
|
26
|
+
frequencyPenaltyDefault: 0,
|
|
27
|
+
maxTokensMin: 1,
|
|
28
|
+
maxTokensMax: 128000,
|
|
29
|
+
maxTokensDefault: 128000,
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
brand: 'OpenAI',
|
|
33
|
+
model: 'gpt-4o-mini',
|
|
34
|
+
name: 'GPT4o mini',
|
|
35
|
+
temperatureMin: 0,
|
|
36
|
+
temperatureMax: 2,
|
|
37
|
+
temperatureDefault: 1,
|
|
38
|
+
topPMin: 0,
|
|
39
|
+
topPMax: 1,
|
|
40
|
+
topPDefault: 1,
|
|
41
|
+
presencePenaltyMin: -2,
|
|
42
|
+
presencePenaltyMax: 2,
|
|
43
|
+
presencePenaltyDefault: 0,
|
|
44
|
+
frequencyPenaltyMin: -2,
|
|
45
|
+
frequencyPenaltyMax: 2,
|
|
46
|
+
frequencyPenaltyDefault: 0,
|
|
47
|
+
maxTokensMin: 1,
|
|
48
|
+
maxTokensMax: 128000,
|
|
49
|
+
maxTokensDefault: 128000,
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
brand: 'OpenAI',
|
|
53
|
+
model: 'gpt-3.5-turbo',
|
|
54
|
+
name: 'GPT3.5 turbo',
|
|
55
|
+
temperatureMin: 0,
|
|
56
|
+
temperatureMax: 2,
|
|
57
|
+
temperatureDefault: 1,
|
|
58
|
+
topPMin: 0,
|
|
59
|
+
topPMax: 1,
|
|
60
|
+
topPDefault: 1,
|
|
61
|
+
presencePenaltyMin: -2,
|
|
62
|
+
presencePenaltyMax: 2,
|
|
63
|
+
presencePenaltyDefault: 0,
|
|
64
|
+
frequencyPenaltyMin: -2,
|
|
65
|
+
frequencyPenaltyMax: 2,
|
|
66
|
+
frequencyPenaltyDefault: 0,
|
|
67
|
+
maxTokensMin: 1,
|
|
68
|
+
maxTokensMax: 4096,
|
|
69
|
+
maxTokensDefault: 4096,
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
brand: 'OpenAI',
|
|
73
|
+
model: 'gpt-3.5-turbo-16k',
|
|
74
|
+
name: 'GPT3.5 turbo 16k',
|
|
75
|
+
temperatureMin: 0,
|
|
76
|
+
temperatureMax: 2,
|
|
77
|
+
temperatureDefault: 1,
|
|
78
|
+
topPMin: 0,
|
|
79
|
+
topPMax: 1,
|
|
80
|
+
topPDefault: 1,
|
|
81
|
+
presencePenaltyMin: -2,
|
|
82
|
+
presencePenaltyMax: 2,
|
|
83
|
+
presencePenaltyDefault: 0,
|
|
84
|
+
frequencyPenaltyMin: -2,
|
|
85
|
+
frequencyPenaltyMax: 2,
|
|
86
|
+
frequencyPenaltyDefault: 0,
|
|
87
|
+
maxTokensMin: 1,
|
|
88
|
+
maxTokensMax: 16385,
|
|
89
|
+
maxTokensDefault: 16385,
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
brand: 'OpenAI',
|
|
93
|
+
model: 'gpt-4',
|
|
94
|
+
name: 'GPT4',
|
|
95
|
+
temperatureMin: 0,
|
|
96
|
+
temperatureMax: 2,
|
|
97
|
+
temperatureDefault: 1,
|
|
98
|
+
topPMin: 0,
|
|
99
|
+
topPMax: 1,
|
|
100
|
+
topPDefault: 1,
|
|
101
|
+
presencePenaltyMin: -2,
|
|
102
|
+
presencePenaltyMax: 2,
|
|
103
|
+
presencePenaltyDefault: 0,
|
|
104
|
+
frequencyPenaltyMin: -2,
|
|
105
|
+
frequencyPenaltyMax: 2,
|
|
106
|
+
frequencyPenaltyDefault: 0,
|
|
107
|
+
maxTokensMin: 1,
|
|
108
|
+
maxTokensMax: 8192,
|
|
109
|
+
maxTokensDefault: 8192,
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
brand: 'OpenAI',
|
|
113
|
+
model: 'gpt-4-32k',
|
|
114
|
+
name: 'GPT4 32k',
|
|
115
|
+
temperatureMin: 0,
|
|
116
|
+
temperatureMax: 2,
|
|
117
|
+
temperatureDefault: 1,
|
|
118
|
+
topPMin: 0,
|
|
119
|
+
topPMax: 1,
|
|
120
|
+
topPDefault: 1,
|
|
121
|
+
presencePenaltyMin: -2,
|
|
122
|
+
presencePenaltyMax: 2,
|
|
123
|
+
presencePenaltyDefault: 0,
|
|
124
|
+
frequencyPenaltyMin: -2,
|
|
125
|
+
frequencyPenaltyMax: 2,
|
|
126
|
+
frequencyPenaltyDefault: 0,
|
|
127
|
+
maxTokensMin: 1,
|
|
128
|
+
maxTokensMax: 32768,
|
|
129
|
+
maxTokensDefault: 32768,
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
brand: 'Google',
|
|
133
|
+
model: 'gemini-pro',
|
|
134
|
+
name: 'Gemini Pro',
|
|
135
|
+
temperatureMin: 0,
|
|
136
|
+
temperatureMax: 2,
|
|
137
|
+
temperatureDefault: 1,
|
|
138
|
+
topPMin: 0.1,
|
|
139
|
+
topPMax: 1,
|
|
140
|
+
topPDefault: 1,
|
|
141
|
+
maxTokensMin: 1,
|
|
142
|
+
maxTokensMax: 2048,
|
|
143
|
+
maxTokensDefault: 2048,
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
brand: 'Mistral AI',
|
|
147
|
+
model: 'openRouter/mistralai/mistral-7b-instruct',
|
|
148
|
+
name: 'Mistral 7B Instruct',
|
|
149
|
+
temperatureMin: 0,
|
|
150
|
+
temperatureMax: 2,
|
|
151
|
+
temperatureDefault: 1,
|
|
152
|
+
topPMin: 0,
|
|
153
|
+
topPMax: 1,
|
|
154
|
+
topPDefault: 1,
|
|
155
|
+
maxTokensMin: 1,
|
|
156
|
+
maxTokensMax: 8192,
|
|
157
|
+
maxTokensDefault: 8192,
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
brand: 'Mistral AI',
|
|
161
|
+
model: 'openRouter/mistralai/mixtral-8x7b-instruct',
|
|
162
|
+
name: 'Mixtral 8x7B Instruct (beta)',
|
|
163
|
+
temperatureMin: 0,
|
|
164
|
+
temperatureMax: 2,
|
|
165
|
+
temperatureDefault: 1,
|
|
166
|
+
topPMin: 0,
|
|
167
|
+
topPMax: 1,
|
|
168
|
+
topPDefault: 1,
|
|
169
|
+
maxTokensMin: 1,
|
|
170
|
+
maxTokensMax: 32768,
|
|
171
|
+
maxTokensDefault: 32768,
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
brand: 'Hugging Face',
|
|
175
|
+
model: 'Hugging Face',
|
|
176
|
+
disabled: true,
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
brand: 'Azure OpenAI',
|
|
180
|
+
model: 'Azure OpenAI',
|
|
181
|
+
disabled: true,
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
brand: 'Replicate',
|
|
185
|
+
model: 'Replicate',
|
|
186
|
+
disabled: true,
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
brand: 'Vertex AI',
|
|
190
|
+
model: 'Vertex AI',
|
|
191
|
+
disabled: true,
|
|
192
|
+
},
|
|
193
|
+
];
|
|
194
|
+
}
|
|
195
|
+
exports.defaultImageModel = 'dall-e-2';
|
|
196
|
+
async function getSupportedImagesModels() {
|
|
197
|
+
return [
|
|
198
|
+
{
|
|
199
|
+
brand: 'OpenAI',
|
|
200
|
+
model: 'dall-e-2',
|
|
201
|
+
nMin: 1,
|
|
202
|
+
nMax: 10,
|
|
203
|
+
nDefault: 1,
|
|
204
|
+
size: ['256x256', '512x512', '1024x1024'],
|
|
205
|
+
sizeDefault: '256x256',
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
brand: 'OpenAI',
|
|
209
|
+
model: 'dall-e-3',
|
|
210
|
+
nMin: 1,
|
|
211
|
+
nMax: 1,
|
|
212
|
+
nDefault: 1,
|
|
213
|
+
quality: ['standard', 'hd'],
|
|
214
|
+
qualityDefault: 'standard',
|
|
215
|
+
size: ['1024x1024', '1792x1024', '1024x1792'],
|
|
216
|
+
sizeDefault: '1024x1024',
|
|
217
|
+
style: ['vivid', 'natural'],
|
|
218
|
+
styleDefault: 'vivid',
|
|
219
|
+
},
|
|
220
|
+
];
|
|
221
|
+
}
|
|
222
|
+
function getServiceModePermissionMap(serviceMode) {
|
|
223
|
+
const permissionMap = {
|
|
224
|
+
single: {
|
|
225
|
+
ensureViewAllProjectsRoles: ['owner', 'admin', 'promptsEditor'],
|
|
226
|
+
ensurePromptsEditorRoles: ['owner', 'admin', 'promptsEditor'],
|
|
227
|
+
ensurePromptsAdminRoles: ['owner', 'admin', 'promptsEditor'],
|
|
228
|
+
},
|
|
229
|
+
multiple: {
|
|
230
|
+
ensureViewAllProjectsRoles: [],
|
|
231
|
+
// no need to check, everyone can do it, will check author permission in the backend
|
|
232
|
+
ensurePromptsEditorRoles: undefined,
|
|
233
|
+
ensurePromptsAdminRoles: ['owner', 'admin', 'promptsEditor'],
|
|
234
|
+
},
|
|
235
|
+
};
|
|
236
|
+
// try to fallback to 'single-tenant'
|
|
237
|
+
return permissionMap[serviceMode] || permissionMap.single;
|
|
238
|
+
}
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ResourceManager = void 0;
|
|
7
|
+
const promises_1 = require("fs/promises");
|
|
8
|
+
const path_1 = require("path");
|
|
9
|
+
const component_1 = require("@blocklet/sdk/lib/component");
|
|
10
|
+
const config_1 = __importDefault(require("@blocklet/sdk/lib/config"));
|
|
11
|
+
const fs_extra_1 = require("fs-extra");
|
|
12
|
+
const lodash_1 = require("lodash");
|
|
13
|
+
const yaml_1 = require("yaml");
|
|
14
|
+
const constants_1 = require("../constants");
|
|
15
|
+
const logger_1 = __importDefault(require("../logger"));
|
|
16
|
+
const types_1 = require("../types");
|
|
17
|
+
const is_non_nullable_1 = require("../utils/is-non-nullable");
|
|
18
|
+
const getResourceList = () => {
|
|
19
|
+
return types_1.ResourceTypes.flatMap((type) => (0, component_1.getResources)({ types: [{ did: constants_1.AIGNE_STUDIO_COMPONENT_DID, type }], skipRunningCheck: true }).map((i) => ({
|
|
20
|
+
...i,
|
|
21
|
+
type,
|
|
22
|
+
}))).filter((0, is_non_nullable_1.isPropsNonNullable)('path'));
|
|
23
|
+
};
|
|
24
|
+
async function loadProjectsFromResourceBlockletDir({ did, path, }) {
|
|
25
|
+
if (!(await (0, fs_extra_1.exists)(path)))
|
|
26
|
+
return [];
|
|
27
|
+
const projectYamlPaths = (await (0, promises_1.readdir)(path)).map((filename) => (0, path_1.join)(path, filename, `${filename}.yaml`));
|
|
28
|
+
return (await Promise.all(projectYamlPaths.map(async (filepath) => {
|
|
29
|
+
try {
|
|
30
|
+
const project = await (0, types_1.validateResourceProject)((0, yaml_1.parse)((await (0, promises_1.readFile)(filepath)).toString()));
|
|
31
|
+
return {
|
|
32
|
+
...project,
|
|
33
|
+
blocklet: { did },
|
|
34
|
+
dir: (0, path_1.dirname)(filepath),
|
|
35
|
+
agentMap: Object.fromEntries(project.agents.map((i) => [i.id, i])),
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
logger_1.default.error('parse aigne project resource file error', { error });
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
}))).filter(is_non_nullable_1.isNonNullable);
|
|
43
|
+
}
|
|
44
|
+
const loadResourceKnowledge = async () => {
|
|
45
|
+
const dirs = getResourceList().filter((i) => i.type === 'knowledge');
|
|
46
|
+
if (dirs.length === 0)
|
|
47
|
+
return [];
|
|
48
|
+
return (await Promise.all(dirs.map(async (item) => {
|
|
49
|
+
try {
|
|
50
|
+
if (!(await (0, fs_extra_1.exists)(item.path)))
|
|
51
|
+
return undefined;
|
|
52
|
+
const knowledgeIds = await (0, promises_1.readdir)(item.path);
|
|
53
|
+
if (!knowledgeIds.length)
|
|
54
|
+
return undefined;
|
|
55
|
+
return await Promise.all(knowledgeIds.map(async (knowledgeId) => {
|
|
56
|
+
try {
|
|
57
|
+
const knowledgePath = (0, path_1.join)(item.path, knowledgeId);
|
|
58
|
+
const vectorsPath = (0, path_1.join)(knowledgePath, 'vectors');
|
|
59
|
+
const uploadPath = (0, path_1.join)(knowledgePath, 'uploads');
|
|
60
|
+
const sourcesPath = (0, path_1.join)(knowledgePath, 'sources');
|
|
61
|
+
const processedPath = (0, path_1.join)(knowledgePath, 'processed');
|
|
62
|
+
const logoPath = (0, path_1.join)(knowledgePath, 'logo.png');
|
|
63
|
+
const knowledgeJsonPath = (0, path_1.join)(knowledgePath, 'knowledge.yaml');
|
|
64
|
+
const knowledge = (0, yaml_1.parse)((await (0, promises_1.readFile)(knowledgeJsonPath)).toString());
|
|
65
|
+
const documentsPath = (0, path_1.join)(knowledgePath, 'documents.yaml');
|
|
66
|
+
const documents = (0, yaml_1.parse)((await (0, promises_1.readFile)(documentsPath)).toString());
|
|
67
|
+
const contentsPath = (0, path_1.join)(knowledgePath, 'contents.yaml');
|
|
68
|
+
const contents = (await (0, fs_extra_1.exists)(contentsPath)) ? (0, yaml_1.parse)((await (0, promises_1.readFile)(contentsPath)).toString()) : [];
|
|
69
|
+
const segmentsPath = (0, path_1.join)(knowledgePath, 'segments.yaml');
|
|
70
|
+
const segments = (await (0, fs_extra_1.exists)(segmentsPath)) ? (0, yaml_1.parse)((await (0, promises_1.readFile)(segmentsPath)).toString()) : [];
|
|
71
|
+
return {
|
|
72
|
+
title: item.title,
|
|
73
|
+
did: item.did,
|
|
74
|
+
knowledge: { projectId: knowledge.appId, ...knowledge },
|
|
75
|
+
documents,
|
|
76
|
+
segments,
|
|
77
|
+
contents,
|
|
78
|
+
blockletDid: item.did,
|
|
79
|
+
vectorsPath,
|
|
80
|
+
uploadPath, // old source
|
|
81
|
+
sourcesPath, // new source
|
|
82
|
+
processedPath,
|
|
83
|
+
logoPath,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
logger_1.default.error('read knowledge resource error', { error });
|
|
88
|
+
}
|
|
89
|
+
return undefined;
|
|
90
|
+
}));
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
logger_1.default.error('read knowledge resource error', { error });
|
|
94
|
+
}
|
|
95
|
+
return undefined;
|
|
96
|
+
})))
|
|
97
|
+
.flat()
|
|
98
|
+
.filter(is_non_nullable_1.isNonNullable);
|
|
99
|
+
};
|
|
100
|
+
async function loadResources() {
|
|
101
|
+
const list = getResourceList().filter((i) => i.type !== 'knowledge');
|
|
102
|
+
const resources = (0, lodash_1.groupBy)(await Promise.all(list.map(async (item) => ({ ...item, projects: await loadProjectsFromResourceBlockletDir(item) }))), (i) => i.type);
|
|
103
|
+
const knowledgeList = await loadResourceKnowledge();
|
|
104
|
+
return {
|
|
105
|
+
knowledge: {
|
|
106
|
+
knowledgeList,
|
|
107
|
+
blockletMap: Object.fromEntries(Object.entries((0, lodash_1.groupBy)(knowledgeList, (i) => i.blockletDid)).map(([blockletDid, kbs]) => [
|
|
108
|
+
blockletDid,
|
|
109
|
+
{ knowledgeMap: Object.fromEntries(kbs.map((i) => [i.knowledge.id, i])) },
|
|
110
|
+
])),
|
|
111
|
+
},
|
|
112
|
+
agents: Object.fromEntries(Object.entries(resources).map(([type, group]) => {
|
|
113
|
+
const blocklets = Object.entries((0, lodash_1.groupBy)(group.flatMap((i) => i.projects), (i) => i.blocklet.did)).map(([blockletDid, projects]) => ({
|
|
114
|
+
did: blockletDid,
|
|
115
|
+
status: group[0].status,
|
|
116
|
+
projectMap: Object.fromEntries(projects.map((i) => [i.project.id, i])),
|
|
117
|
+
}));
|
|
118
|
+
return [
|
|
119
|
+
type,
|
|
120
|
+
{
|
|
121
|
+
projects: group.flatMap((i) => i.projects),
|
|
122
|
+
blockletMap: Object.fromEntries(blocklets.map((i) => [i.did, i])),
|
|
123
|
+
},
|
|
124
|
+
];
|
|
125
|
+
})),
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
class ResourceManager {
|
|
129
|
+
constructor({ wait = 5000, watch = true } = {}) {
|
|
130
|
+
if (watch) {
|
|
131
|
+
const reload = (0, lodash_1.throttle)(async () => {
|
|
132
|
+
logger_1.default.info('reload resource states');
|
|
133
|
+
await this.reload()
|
|
134
|
+
.then((resource) => {
|
|
135
|
+
logger_1.default.info('reload resource states success', {
|
|
136
|
+
projects: Object.values(resource.agents).reduce((res, i) => i.projects.length + res, 0),
|
|
137
|
+
knowledge: resource.knowledge.knowledgeList.length,
|
|
138
|
+
});
|
|
139
|
+
})
|
|
140
|
+
.catch((error) => {
|
|
141
|
+
logger_1.default.error('reload resource states error', { error });
|
|
142
|
+
});
|
|
143
|
+
}, wait, { leading: false, trailing: true });
|
|
144
|
+
config_1.default.events.on(config_1.default.Events.componentAdded, reload);
|
|
145
|
+
config_1.default.events.on(config_1.default.Events.componentRemoved, reload);
|
|
146
|
+
config_1.default.events.on(config_1.default.Events.componentStarted, reload);
|
|
147
|
+
config_1.default.events.on(config_1.default.Events.componentStopped, reload);
|
|
148
|
+
config_1.default.events.on(config_1.default.Events.componentUpdated, reload);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
promise;
|
|
152
|
+
get resources() {
|
|
153
|
+
if (!this.promise) {
|
|
154
|
+
this.promise = loadResources();
|
|
155
|
+
}
|
|
156
|
+
return this.promise;
|
|
157
|
+
}
|
|
158
|
+
async reload() {
|
|
159
|
+
this.promise = loadResources();
|
|
160
|
+
return this.resources;
|
|
161
|
+
}
|
|
162
|
+
async getProjects({ blockletDid, type }) {
|
|
163
|
+
const resources = await this.resources;
|
|
164
|
+
const list = resources.agents[type]?.projects ?? [];
|
|
165
|
+
if (blockletDid) {
|
|
166
|
+
return list.filter((i) => i.blocklet.did === blockletDid);
|
|
167
|
+
}
|
|
168
|
+
return list;
|
|
169
|
+
}
|
|
170
|
+
async getProject({ blockletDid, projectId, type, }) {
|
|
171
|
+
const resources = await this.resources;
|
|
172
|
+
for (const t of type ? [type].flat() : types_1.ResourceTypes) {
|
|
173
|
+
const p = resources.agents[t]?.blockletMap[blockletDid]?.projectMap[projectId];
|
|
174
|
+
if (p)
|
|
175
|
+
return p;
|
|
176
|
+
}
|
|
177
|
+
return undefined;
|
|
178
|
+
}
|
|
179
|
+
async getAgent({ blockletDid, projectId, agentId, type = types_1.ResourceTypes, }) {
|
|
180
|
+
const resources = await this.resources;
|
|
181
|
+
for (const t of [type].flat()) {
|
|
182
|
+
const blocklet = resources.agents[t]?.blockletMap[blockletDid];
|
|
183
|
+
const project = blocklet?.projectMap[projectId];
|
|
184
|
+
const agent = project?.agentMap[agentId];
|
|
185
|
+
if (agent)
|
|
186
|
+
return { agent, project: project.project, blocklet: { did: blockletDid } };
|
|
187
|
+
}
|
|
188
|
+
return undefined;
|
|
189
|
+
}
|
|
190
|
+
async getKnowledgeList() {
|
|
191
|
+
const resources = await this.resources;
|
|
192
|
+
return resources.knowledge.knowledgeList;
|
|
193
|
+
}
|
|
194
|
+
async getKnowledge({ blockletDid, knowledgeId }) {
|
|
195
|
+
const resources = await this.resources;
|
|
196
|
+
return resources.knowledge.blockletMap[blockletDid]?.knowledgeMap[knowledgeId];
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
exports.ResourceManager = ResourceManager;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AIGNE_ISSUE_VC_PREFIX = exports.NFT_BLENDER_COMPONENT_DID = exports.AIGNE_STUDIO_COMPONENT_DID = exports.AIGNE_RUNTIME_CUSTOM_COMPONENT_ID = exports.AIGNE_COMPONENTS_COMPONENT_DID = exports.AIGNE_RUNTIME_COMPONENT_DID = void 0;
|
|
4
|
+
exports.AIGNE_RUNTIME_COMPONENT_DID = 'z2qaBP9SahqU2L2YA3ip7NecwKACMByTFuiJ2';
|
|
5
|
+
exports.AIGNE_COMPONENTS_COMPONENT_DID = 'z2qa6fvjmjew4pWJyTsKaWFuNoMUMyXDh5A1D';
|
|
6
|
+
exports.AIGNE_RUNTIME_CUSTOM_COMPONENT_ID = 'grc9q1cveub6pnl8';
|
|
7
|
+
exports.AIGNE_STUDIO_COMPONENT_DID = 'z8iZpog7mcgcgBZzTiXJCWESvmnRrQmnd3XBB';
|
|
8
|
+
exports.NFT_BLENDER_COMPONENT_DID = 'z8ia1ieY5KhEC4LMRETzS5nUwD7PvAND8qkfX';
|
|
9
|
+
exports.AIGNE_ISSUE_VC_PREFIX = 'AIGNE';
|