@cognigy/rest-api-client 2025.15.1 → 2025.16.0
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/CHANGELOG.md +10 -0
- package/build/apigroups/MetricsAPIGroup_2_0.js +10 -0
- package/build/apigroups/ResourcesAPIGroup_2_0.js +6 -0
- package/build/apigroups/SimulationAPIGroup_2_0.js +4 -0
- package/build/shared/charts/descriptors/logic/if/if.js +2 -2
- package/build/shared/charts/descriptors/logic/switch/switch.js +30 -21
- package/build/shared/charts/descriptors/message/question/question.js +3 -3
- package/build/shared/charts/descriptors/message/question/utils/validateQuestionAnswer.js +2 -2
- package/build/shared/charts/descriptors/service/aiAgent/aiAgentJob.js +29 -22
- package/build/shared/charts/descriptors/service/aiAgent/helpers/createToolDefinitions.js +4 -4
- package/build/shared/charts/descriptors/service/llmPrompt/LLMPromptV2.js +24 -18
- package/build/shared/charts/descriptors/transcripts/addTranscriptStep.js +3 -3
- package/build/shared/interfaces/generativeAI/IGenerativeAIModels.js +1 -0
- package/build/shared/interfaces/resources/IGetAiAgentJobsTools.js +3 -0
- package/build/shared/interfaces/resources/IKnowledgeDescriptor.js +38 -5
- package/build/shared/interfaces/resources/ILargeLanguageModel.js +15 -1
- package/build/shared/interfaces/restAPI/metrics/callCounter/v3.0/ICallCounterPreAggregatedValue_3_0.js +3 -0
- package/build/shared/interfaces/restAPI/metrics/callCounter/v3.0/IGetCallCounterOrganisationRest_3_0.js +3 -0
- package/build/shared/interfaces/restAPI/metrics/callCounter/v3.0/IGetCallCounterRest_3_0.js +3 -0
- package/build/shared/interfaces/restAPI/metrics/callCounter/v3.0/index.js +3 -0
- package/build/shared/interfaces/restAPI/resources/aiAgent/v2.0/IAiAgentJobNodeWithTools_2_0.js +65 -0
- package/build/shared/interfaces/restAPI/resources/aiAgent/v2.0/IGetAiAgentJobAndToolsRest_2_0 .js +4 -0
- package/build/shared/interfaces/restAPI/resources/knowledgeStore/v2.0/IIndexKnowledgeDescriptorsRest_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/resources/knowledgeStore/v2.0/extension/IRunKnowledgeExtensionRest_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/resources/knowledgeStore/v2.0/index.js +16 -0
- package/build/shared/interfaces/restAPI/simulation/simulationRunBatch/IStopSimulationRunBatchRest_2_0.js +3 -0
- package/build/shared/interfaces/security/ICallCounterPreAggregatedValue.js +3 -0
- package/dist/esm/apigroups/MetricsAPIGroup_2_0.js +10 -0
- package/dist/esm/apigroups/ResourcesAPIGroup_2_0.js +6 -0
- package/dist/esm/apigroups/SimulationAPIGroup_2_0.js +4 -0
- package/dist/esm/shared/charts/descriptors/logic/if/if.js +2 -2
- package/dist/esm/shared/charts/descriptors/logic/switch/switch.js +30 -21
- package/dist/esm/shared/charts/descriptors/message/question/question.js +3 -3
- package/dist/esm/shared/charts/descriptors/message/question/utils/validateQuestionAnswer.js +4 -3
- package/dist/esm/shared/charts/descriptors/service/aiAgent/aiAgentJob.js +28 -21
- package/dist/esm/shared/charts/descriptors/service/aiAgent/helpers/createToolDefinitions.js +4 -4
- package/dist/esm/shared/charts/descriptors/service/llmPrompt/LLMPromptV2.js +31 -25
- package/dist/esm/shared/charts/descriptors/transcripts/addTranscriptStep.js +3 -3
- package/dist/esm/shared/interfaces/generativeAI/IGenerativeAIModels.js +1 -0
- package/dist/esm/shared/interfaces/resources/IGetAiAgentJobsTools.js +2 -0
- package/dist/esm/shared/interfaces/resources/IKnowledgeDescriptor.js +37 -5
- package/dist/esm/shared/interfaces/resources/ILargeLanguageModel.js +13 -0
- package/dist/esm/shared/interfaces/restAPI/metrics/callCounter/v3.0/ICallCounterPreAggregatedValue_3_0.js +2 -0
- package/dist/esm/shared/interfaces/restAPI/metrics/callCounter/v3.0/IGetCallCounterOrganisationRest_3_0.js +2 -0
- package/dist/esm/shared/interfaces/restAPI/metrics/callCounter/v3.0/IGetCallCounterRest_3_0.js +2 -0
- package/dist/esm/shared/interfaces/restAPI/metrics/callCounter/v3.0/index.js +2 -0
- package/dist/esm/shared/interfaces/restAPI/resources/aiAgent/v2.0/IAiAgentJobNodeWithTools_2_0.js +65 -0
- package/dist/esm/shared/interfaces/restAPI/resources/aiAgent/v2.0/IGetAiAgentJobAndToolsRest_2_0 .js +3 -0
- package/dist/esm/shared/interfaces/restAPI/resources/knowledgeStore/v2.0/IIndexKnowledgeDescriptorsRest_2_0.js +2 -0
- package/dist/esm/shared/interfaces/restAPI/resources/knowledgeStore/v2.0/extension/IRunKnowledgeExtensionRest_2_0.js +2 -0
- package/dist/esm/shared/interfaces/restAPI/resources/knowledgeStore/v2.0/index.js +2 -1
- package/dist/esm/shared/interfaces/restAPI/simulation/simulationRunBatch/IStopSimulationRunBatchRest_2_0.js +2 -0
- package/dist/esm/shared/interfaces/security/ICallCounterPreAggregatedValue.js +2 -0
- package/package.json +1 -1
- package/types/index.d.ts +257 -23
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.knowledgeDescriptorSchema = exports.knowledgeFieldSchema = exports.knowledgeFieldTypes = void 0;
|
|
3
|
+
exports.buildConfigValidationSchema = exports.knowledgeDescriptorSchema = exports.knowledgeFieldSchema = exports.knowledgeFieldTypes = void 0;
|
|
4
4
|
const INodeDescriptorSet_1 = require("./INodeDescriptorSet");
|
|
5
5
|
exports.knowledgeFieldTypes = [
|
|
6
6
|
"text",
|
|
@@ -20,13 +20,13 @@ exports.knowledgeFieldTypes = [
|
|
|
20
20
|
"daterange",
|
|
21
21
|
"connection",
|
|
22
22
|
"condition",
|
|
23
|
-
"description"
|
|
23
|
+
"description"
|
|
24
24
|
];
|
|
25
25
|
exports.knowledgeFieldSchema = {
|
|
26
26
|
title: "knowledgeFieldSchema",
|
|
27
27
|
type: "object",
|
|
28
28
|
additionalProperties: false,
|
|
29
|
-
properties: Object.assign(Object.assign({}, INodeDescriptorSet_1.nodeFieldSchema.properties), { type: { type: "string", enum: [...exports.knowledgeFieldTypes] }, key: { type: "string", minLength: 1, maxLength: 200 } })
|
|
29
|
+
properties: Object.assign(Object.assign({}, INodeDescriptorSet_1.nodeFieldSchema.properties), { type: { type: "string", enum: [...exports.knowledgeFieldTypes] }, key: { type: "string", minLength: 1, maxLength: 200 } })
|
|
30
30
|
};
|
|
31
31
|
const { type, summary, defaultLabel, sections, form } = INodeDescriptorSet_1.nodeDescriptorSchema.properties;
|
|
32
32
|
exports.knowledgeDescriptorSchema = {
|
|
@@ -39,7 +39,40 @@ exports.knowledgeDescriptorSchema = {
|
|
|
39
39
|
summary,
|
|
40
40
|
sections,
|
|
41
41
|
form,
|
|
42
|
-
fields: { type: "array", items: exports.knowledgeFieldSchema }
|
|
43
|
-
}
|
|
42
|
+
fields: { type: "array", items: exports.knowledgeFieldSchema }
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
const filterNonConfigFields = ({ type }) => !["description"].includes(type);
|
|
46
|
+
const buildConfigValidationSchema = (fields) => ({
|
|
47
|
+
type: "object",
|
|
48
|
+
additionalProperties: false,
|
|
49
|
+
required: (fields || []).filter(filterNonConfigFields).map(({ key }) => key),
|
|
50
|
+
properties: Object.assign({}, (fields || []).filter(filterNonConfigFields).reduce((result, field) => (Object.assign(Object.assign({}, result), { [field.key]: mapFieldToSchema(field) })), {}))
|
|
51
|
+
});
|
|
52
|
+
exports.buildConfigValidationSchema = buildConfigValidationSchema;
|
|
53
|
+
const mapFieldToSchema = ({ type, params }) => {
|
|
54
|
+
switch (type) {
|
|
55
|
+
case "checkbox":
|
|
56
|
+
case "toggle":
|
|
57
|
+
return { type: "boolean" };
|
|
58
|
+
case "number":
|
|
59
|
+
case "slider":
|
|
60
|
+
return { type: "number" };
|
|
61
|
+
case "textArray":
|
|
62
|
+
return {
|
|
63
|
+
type: "array",
|
|
64
|
+
minLength: (params === null || params === void 0 ? void 0 : params.required) ? 1 : 0
|
|
65
|
+
};
|
|
66
|
+
case "json":
|
|
67
|
+
return {
|
|
68
|
+
type: ["object", "array"],
|
|
69
|
+
additionalProperties: true
|
|
70
|
+
};
|
|
71
|
+
default:
|
|
72
|
+
return {
|
|
73
|
+
type: "string",
|
|
74
|
+
minLength: (params === null || params === void 0 ? void 0 : params.required) ? 1 : 0
|
|
75
|
+
};
|
|
76
|
+
}
|
|
44
77
|
};
|
|
45
78
|
//# sourceMappingURL=IKnowledgeDescriptor.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.largeLanguageModelQuerySchema = exports.largeLanguageModelSchema = exports.largeLanguageModelDataSchema = exports.llmFallbackSchema = exports.googleGeminiMetaSchema = exports.googleVertexAIMetaSchema = exports.azureOpenAIMetaSchema = exports.openAICompatibleMetaSchema = exports.openAIMetaSchema = exports.alephAlphaMetaSchema = exports.awsBedrockMetaSchema = exports.mistralMetaSchema = exports.anthropicMetaSchema = void 0;
|
|
3
|
+
exports.isIGraphLargeLanguageModel = exports.largeLanguageModelQuerySchema = exports.largeLanguageModelSchema = exports.largeLanguageModelDataSchema = exports.llmFallbackSchema = exports.googleGeminiMetaSchema = exports.googleVertexAIMetaSchema = exports.azureOpenAIMetaSchema = exports.openAICompatibleMetaSchema = exports.openAIMetaSchema = exports.alephAlphaMetaSchema = exports.awsBedrockMetaSchema = exports.mistralMetaSchema = exports.anthropicMetaSchema = void 0;
|
|
4
4
|
/* Custom Modules */
|
|
5
5
|
const createQuerySchema_1 = require("../../helper/createQuerySchema");
|
|
6
6
|
const IEntityMeta_1 = require("./IEntityMeta");
|
|
@@ -162,4 +162,18 @@ exports.largeLanguageModelSchema = {
|
|
|
162
162
|
properties: Object.assign(Object.assign(Object.assign({}, exports.largeLanguageModelDataSchema.properties), IEntityMeta_1.entityMetaSchema.properties), { projectReference: { type: "string", format: "mongo-id" }, organisationReference: { type: "string", format: "mongo-id" }, referenceId: { type: "string", format: "uuid" } })
|
|
163
163
|
};
|
|
164
164
|
exports.largeLanguageModelQuerySchema = (0, createQuerySchema_1.createQuerySchema)("largeLanguageModelQuerySchema", exports.largeLanguageModelSchema);
|
|
165
|
+
const isIGraphLargeLanguageModel = (resource) => {
|
|
166
|
+
return (resource &&
|
|
167
|
+
resource.type === "largeLanguageModel" &&
|
|
168
|
+
resource._id &&
|
|
169
|
+
resource.name &&
|
|
170
|
+
resource.referenceId &&
|
|
171
|
+
resource.properties &&
|
|
172
|
+
resource.properties.modelType &&
|
|
173
|
+
resource.properties.createdAt &&
|
|
174
|
+
resource.properties.createdBy &&
|
|
175
|
+
resource.properties.lastChanged &&
|
|
176
|
+
resource.properties.lastChangedBy);
|
|
177
|
+
};
|
|
178
|
+
exports.isIGraphLargeLanguageModel = isIGraphLargeLanguageModel;
|
|
165
179
|
//# sourceMappingURL=ILargeLanguageModel.js.map
|
package/build/shared/interfaces/restAPI/resources/aiAgent/v2.0/IAiAgentJobNodeWithTools_2_0.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @openapi
|
|
3
|
+
* components:
|
|
4
|
+
* schemas:
|
|
5
|
+
* IAiAgentJobNodeWithTools_2_0:
|
|
6
|
+
* type: object
|
|
7
|
+
* properties:
|
|
8
|
+
* _id:
|
|
9
|
+
* type: string
|
|
10
|
+
* referenceId:
|
|
11
|
+
* type: string
|
|
12
|
+
* type:
|
|
13
|
+
* type: string
|
|
14
|
+
* example: "aiAgentJob"
|
|
15
|
+
* label:
|
|
16
|
+
* type: string
|
|
17
|
+
* comment:
|
|
18
|
+
* type: string
|
|
19
|
+
* commentColor:
|
|
20
|
+
* type: string
|
|
21
|
+
* analyticsLabel:
|
|
22
|
+
* type: string
|
|
23
|
+
* nullable: true
|
|
24
|
+
* isDisabled:
|
|
25
|
+
* type: boolean
|
|
26
|
+
* isEntryPoint:
|
|
27
|
+
* type: boolean
|
|
28
|
+
* extension:
|
|
29
|
+
* type: string
|
|
30
|
+
* config:
|
|
31
|
+
* type: object
|
|
32
|
+
* description: Job node configuration (content varies by implementation)
|
|
33
|
+
* tools:
|
|
34
|
+
* type: array
|
|
35
|
+
* items:
|
|
36
|
+
* $ref: '#/components/schemas/IAiAgentJobToolNode_2_0'
|
|
37
|
+
* IAiAgentJobToolNode_2_0:
|
|
38
|
+
* type: object
|
|
39
|
+
* properties:
|
|
40
|
+
* _id:
|
|
41
|
+
* type: string
|
|
42
|
+
* referenceId:
|
|
43
|
+
* type: string
|
|
44
|
+
* type:
|
|
45
|
+
* type: string
|
|
46
|
+
* label:
|
|
47
|
+
* type: string
|
|
48
|
+
* comment:
|
|
49
|
+
* type: string
|
|
50
|
+
* commentColor:
|
|
51
|
+
* type: string
|
|
52
|
+
* analyticsLabel:
|
|
53
|
+
* type: string
|
|
54
|
+
* nullable: true
|
|
55
|
+
* isDisabled:
|
|
56
|
+
* type: boolean
|
|
57
|
+
* isEntryPoint:
|
|
58
|
+
* type: boolean
|
|
59
|
+
* extension:
|
|
60
|
+
* type: string
|
|
61
|
+
* config:
|
|
62
|
+
* type: object
|
|
63
|
+
* description: Tool node configuration (content varies by tool type)
|
|
64
|
+
*/
|
|
65
|
+
//# sourceMappingURL=IAiAgentJobNodeWithTools_2_0.js.map
|
|
@@ -1,3 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
2
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./IIndexKnowledgeDescriptorsRest_2_0"), exports);
|
|
18
|
+
__exportStar(require("./extension/IRunKnowledgeExtensionRest_2_0"), exports);
|
|
3
19
|
//# sourceMappingURL=index.js.map
|
|
@@ -51,6 +51,16 @@ export function MetricsAPIGroup_2_0(instance) {
|
|
|
51
51
|
return GenericAPIFn(`/new/v2.0/projects/${projectId}/conversationcounter?${stringifyQuery(args)}`, "GET", self)(undefined, options);
|
|
52
52
|
},
|
|
53
53
|
getConversationCounterOrganisation: (args, options) => GenericAPIFn(`/new/v2.0/conversationcounter?${stringifyQuery(args)}`, "GET", self)(undefined, options),
|
|
54
|
+
getPreAggregatedConversationCounter: (_a, options) => {
|
|
55
|
+
var { projectId } = _a, args = __rest(_a, ["projectId"]);
|
|
56
|
+
return GenericAPIFn(`/new/v3.0/projects/${projectId}/conversationcounter?${stringifyQuery(args)}`, "GET", self)(undefined, options);
|
|
57
|
+
},
|
|
58
|
+
getPreAggregatedConversationCounterOrganisation: (args, options) => GenericAPIFn(`/new/v3.0/conversationcounter?${stringifyQuery(args)}`, "GET", self)(undefined, options),
|
|
59
|
+
getPreAggregatedCallCounter: (_a, options) => {
|
|
60
|
+
var { projectId } = _a, args = __rest(_a, ["projectId"]);
|
|
61
|
+
return GenericAPIFn(`/new/v3.0/projects/${projectId}/callcounter?${stringifyQuery(args)}`, "GET", self)(undefined, options);
|
|
62
|
+
},
|
|
63
|
+
getPreAggregatedCallCounterOrganisation: (args, options) => GenericAPIFn(`/new/v3.0/callcounter?${stringifyQuery(args)}`, "GET", self)(undefined, options),
|
|
54
64
|
getKnowledgeQueryCounter: (_a, options) => {
|
|
55
65
|
var { projectId } = _a, args = __rest(_a, ["projectId"]);
|
|
56
66
|
return GenericAPIFn(`/new/v2.0/projects/${projectId}/knowledgequerycounter?${stringifyQuery(args)}`, "GET", self)(undefined, options);
|
|
@@ -546,6 +546,7 @@ export const ResourcesAPIGroup_2_0 = (instance) => {
|
|
|
546
546
|
validateAiAgentName: (args, options) => GenericAPIFn("/new/v2.0/aiagents/validatename", "POST", self)(args, options),
|
|
547
547
|
getAiAgentHiringTemplates: (args, options) => GenericAPIFn("/new/v2.0/aiagents/hire/templates", "GET", self)(args, options),
|
|
548
548
|
hireAiAgent: (args, options) => GenericAPIFn("/new/v2.0/aiagents/hire", "POST", self)(args, options),
|
|
549
|
+
getAiAgentJobsAndTools: ({ aiAgentId }, options) => GenericAPIFn(`/new/v2.0/aiagents/${aiAgentId}/jobs`, "GET", self)(undefined, options),
|
|
549
550
|
generateNodeOutput(_a, options) {
|
|
550
551
|
var { flowId } = _a, args = __rest(_a, ["flowId"]);
|
|
551
552
|
return GenericAPIFn(`/new/v2.0/flows/${flowId}/chart/nodes/output/generate`, "POST", self)(args, options);
|
|
@@ -578,6 +579,11 @@ export const ResourcesAPIGroup_2_0 = (instance) => {
|
|
|
578
579
|
var { knowledgeStoreId } = _a, args = __rest(_a, ["knowledgeStoreId"]);
|
|
579
580
|
return GenericAPIFn(`/new/v2.0/knowledgestores/${knowledgeStoreId}`, "PATCH", self)(args, options);
|
|
580
581
|
},
|
|
582
|
+
runKnowledgeExtension: (_a, options) => {
|
|
583
|
+
var { knowledgeStoreId } = _a, args = __rest(_a, ["knowledgeStoreId"]);
|
|
584
|
+
return GenericAPIFn(`/new/v2.0/knowledgestores/${knowledgeStoreId}/extensions/run`, "POST", self)(args, options);
|
|
585
|
+
},
|
|
586
|
+
indexKnowledgeDescriptors: ({ knowledgeStoreId }, options) => GenericAPIFn(`/new/v2.0/knowledgestores/${knowledgeStoreId}/descriptors`, "GET", self)(undefined, options),
|
|
581
587
|
indexKnowledgeSources: (_a, options) => {
|
|
582
588
|
var { knowledgeStoreId } = _a, args = __rest(_a, ["knowledgeStoreId"]);
|
|
583
589
|
return GenericAPIFn(`/new/v2.0/knowledgestores/${knowledgeStoreId}/sources?${stringifyQuery(args)}`, "GET", self)(undefined, options);
|
|
@@ -31,6 +31,10 @@ export function SimulationAPIGroup_2_0(instance) {
|
|
|
31
31
|
var { simulationReference, simulationRunBatchReference } = _a, args = __rest(_a, ["simulationReference", "simulationRunBatchReference"]);
|
|
32
32
|
return GenericAPIFn(`/testing/beta/simulations/${simulationReference}/batches/${simulationRunBatchReference}?${stringifyQuery(args)}`, "GET", self)(undefined, options);
|
|
33
33
|
},
|
|
34
|
+
stopSimulationRunBatch: (_a, options) => {
|
|
35
|
+
var { simulationReference, simulationRunBatchReference } = _a, args = __rest(_a, ["simulationReference", "simulationRunBatchReference"]);
|
|
36
|
+
return GenericAPIFn(`/testing/beta/simulations/${simulationReference}/batches/${simulationRunBatchReference}/stop?${stringifyQuery(args)}`, "POST", self)(undefined, options);
|
|
37
|
+
},
|
|
34
38
|
indexSimulationRuns: (_a, options) => {
|
|
35
39
|
var { simulationReference, simulationRunBatchReference } = _a, args = __rest(_a, ["simulationReference", "simulationRunBatchReference"]);
|
|
36
40
|
return GenericAPIFn(`/testing/beta/simulations/${simulationReference}/batches/${simulationRunBatchReference}/runs?${stringifyQuery(args)}`, "GET", self)(undefined, options);
|
|
@@ -53,13 +53,13 @@ export const IF = createNodeDescriptor({
|
|
|
53
53
|
switch (type) {
|
|
54
54
|
case "rule":
|
|
55
55
|
{
|
|
56
|
-
isConditionTrue = api.evaluateRule(rule);
|
|
56
|
+
isConditionTrue = yield api.evaluateRule(rule);
|
|
57
57
|
}
|
|
58
58
|
break;
|
|
59
59
|
case "condition":
|
|
60
60
|
default:
|
|
61
61
|
{
|
|
62
|
-
isConditionTrue = api.parseCognigyScriptCondition(condition);
|
|
62
|
+
isConditionTrue = yield api.parseCognigyScriptCondition(condition);
|
|
63
63
|
}
|
|
64
64
|
break;
|
|
65
65
|
}
|
|
@@ -188,32 +188,41 @@ export const SWITCH = createNodeDescriptor({
|
|
|
188
188
|
* by mistake, then CS has already been parsed,
|
|
189
189
|
* causing the parser return empty string.
|
|
190
190
|
*/
|
|
191
|
-
parsedOperator = (_a = api.parseCognigyScriptText(`{{${operator}}}`)) !== null && _a !== void 0 ? _a : operator;
|
|
191
|
+
parsedOperator = (_a = (yield api.parseCognigyScriptText(`{{${operator}}}`))) !== null && _a !== void 0 ? _a : operator;
|
|
192
192
|
if (parsedOperator === "") {
|
|
193
193
|
parsedOperator = operator;
|
|
194
194
|
}
|
|
195
195
|
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
196
|
+
let matchedCase = undefined;
|
|
197
|
+
if (children) {
|
|
198
|
+
for (const child of children) {
|
|
199
|
+
if (child.type !== "case") {
|
|
200
|
+
continue;
|
|
201
|
+
}
|
|
202
|
+
const check = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
203
|
+
var _b, _c;
|
|
204
|
+
if (useStrict) {
|
|
205
|
+
return (yield api.parseCognigyScriptText(`${(_b = child.config.case.value) === null || _b === void 0 ? void 0 : _b.trim()}`)) === parsedOperator;
|
|
206
|
+
}
|
|
207
|
+
else {
|
|
208
|
+
/**
|
|
209
|
+
* We cast the case
|
|
210
|
+
* and the operator to strings to avoid issues
|
|
211
|
+
* where e.g. the case contains a string but the
|
|
212
|
+
* operator is a number. We do not support switching on
|
|
213
|
+
* objects
|
|
214
|
+
*/
|
|
215
|
+
const parsedCognigyScriptText = `${yield api.parseCognigyScriptText(`${(_c = child.config.case.value) === null || _c === void 0 ? void 0 : _c.trim()}`)}`;
|
|
216
|
+
const parsedOperatorString = `${parsedOperator}`;
|
|
217
|
+
return parsedCognigyScriptText === parsedOperatorString;
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
if (yield check()) {
|
|
221
|
+
matchedCase = child;
|
|
222
|
+
break;
|
|
223
|
+
}
|
|
200
224
|
}
|
|
201
|
-
|
|
202
|
-
return api.parseCognigyScriptText(`${(_a = child.config.case.value) === null || _a === void 0 ? void 0 : _a.trim()}`) === parsedOperator;
|
|
203
|
-
}
|
|
204
|
-
else {
|
|
205
|
-
/**
|
|
206
|
-
* We cast the case
|
|
207
|
-
* and the operator to strings to avoid issues
|
|
208
|
-
* where e.g. the case contains a string but the
|
|
209
|
-
* operator is a number. We do not support switching on
|
|
210
|
-
* objects
|
|
211
|
-
*/
|
|
212
|
-
const parsedCognigyScriptText = `${api.parseCognigyScriptText(`${(_b = child.config.case.value) === null || _b === void 0 ? void 0 : _b.trim()}`)}`;
|
|
213
|
-
const parsedOperatorString = `${parsedOperator}`;
|
|
214
|
-
return parsedCognigyScriptText === parsedOperatorString;
|
|
215
|
-
}
|
|
216
|
-
});
|
|
225
|
+
}
|
|
217
226
|
if (matchedCase) {
|
|
218
227
|
api.setNextNode(matchedCase.id);
|
|
219
228
|
return;
|
|
@@ -1897,7 +1897,7 @@ DO NOT talk about other topics. Do not offer general assistance.`,
|
|
|
1897
1897
|
// set input.result, so we can use it for validation
|
|
1898
1898
|
input.result = result;
|
|
1899
1899
|
// Verify that answer is valid based on some other conditions defined in the function
|
|
1900
|
-
const isValid = validateQuestionAnswer(cognigy, config);
|
|
1900
|
+
const isValid = yield validateQuestionAnswer(cognigy, config);
|
|
1901
1901
|
if (!isValid) {
|
|
1902
1902
|
input.result = null;
|
|
1903
1903
|
}
|
|
@@ -2055,7 +2055,7 @@ DO NOT talk about other topics. Do not offer general assistance.`,
|
|
|
2055
2055
|
// if a result location was specified, try to get the result from that location
|
|
2056
2056
|
// if the location returns a falsey value, the answer is invalid
|
|
2057
2057
|
if (resultLocation && result) {
|
|
2058
|
-
result = api.parseCognigyScriptResultLocation(resultLocation);
|
|
2058
|
+
result = yield api.parseCognigyScriptResultLocation(resultLocation);
|
|
2059
2059
|
// If we want detailed results, augment the result object accordingly
|
|
2060
2060
|
if (storeDetailedResults && result !== null && result !== undefined) {
|
|
2061
2061
|
result = {
|
|
@@ -2408,7 +2408,7 @@ DO NOT talk about other topics. Do not offer general assistance.`,
|
|
|
2408
2408
|
// #region 5.2.3 Reprompt
|
|
2409
2409
|
// check if there is an extra condition defined for reprompts and check whether it was truthy
|
|
2410
2410
|
if (sayReprompt && repromptCondition) {
|
|
2411
|
-
const repromptConditionResult = !!api.parseCognigyScriptCondition(repromptCondition);
|
|
2411
|
+
const repromptConditionResult = !!(yield api.parseCognigyScriptCondition(repromptCondition));
|
|
2412
2412
|
!repromptConditionResult && api.logDebugMessage(`UI__DEBUG_MODE__QUESTION__MESSAGE_6`, "Skipping Reprompt Message");
|
|
2413
2413
|
sayReprompt = repromptConditionResult;
|
|
2414
2414
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
export const validateQuestionAnswer = (cognigy, config) => __awaiter(void 0, void 0, void 0, function* () {
|
|
2
3
|
const { additionalValidation, escalateIntentsAction, escalateIntentsThreshold, escalateIntentsValidIntents } = config;
|
|
3
4
|
const { input, api } = cognigy;
|
|
4
5
|
let isValid = true;
|
|
5
6
|
// check if there is an extra condition defined and check whether it was truthy
|
|
6
7
|
if (additionalValidation) {
|
|
7
|
-
const additionalValidationResult = !!api.parseCognigyScriptCondition(additionalValidation);
|
|
8
|
+
const additionalValidationResult = !!(yield api.parseCognigyScriptCondition(additionalValidation));
|
|
8
9
|
!additionalValidationResult && api.logDebugMessage(`UI__DEBUG_MODE__QUESTION__MESSAGE_7`, "Invalid Answer");
|
|
9
10
|
isValid = additionalValidationResult;
|
|
10
11
|
}
|
|
@@ -16,5 +17,5 @@ export const validateQuestionAnswer = (cognigy, config) => {
|
|
|
16
17
|
}
|
|
17
18
|
}
|
|
18
19
|
return isValid;
|
|
19
|
-
};
|
|
20
|
+
});
|
|
20
21
|
//# sourceMappingURL=validateQuestionAnswer.js.map
|
|
@@ -10,6 +10,7 @@ import { generateSearchPrompt } from "./helpers/generateSearchPrompt";
|
|
|
10
10
|
import { getUserMemory } from "./helpers/getUserMemory";
|
|
11
11
|
import { createToolDefinitions } from "./helpers/createToolDefinitions";
|
|
12
12
|
import { TranscriptEntryType, TranscriptRole } from "../../../../interfaces/transcripts/transcripts";
|
|
13
|
+
export const AI_AGENT_TOOLS_WHITELIST = ["aiAgentJobDefault", "aiAgentJobTool", "aiAgentJobMCPTool"];
|
|
13
14
|
export const AI_AGENT_JOB = createNodeDescriptor({
|
|
14
15
|
type: "aiAgentJob",
|
|
15
16
|
defaultLabel: "AI Agent",
|
|
@@ -18,7 +19,7 @@ export const AI_AGENT_JOB = createNodeDescriptor({
|
|
|
18
19
|
collapsable: true,
|
|
19
20
|
placement: {
|
|
20
21
|
children: {
|
|
21
|
-
whitelist:
|
|
22
|
+
whitelist: AI_AGENT_TOOLS_WHITELIST,
|
|
22
23
|
},
|
|
23
24
|
},
|
|
24
25
|
},
|
|
@@ -847,7 +848,7 @@ export const AI_AGENT_JOB = createNodeDescriptor({
|
|
|
847
848
|
],
|
|
848
849
|
tags: ["ai", "aiAgent"],
|
|
849
850
|
function: ({ cognigy, config, childConfigs, nodeId }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
850
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21;
|
|
851
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23;
|
|
851
852
|
const { api, context, input, profile, flowReferenceId } = cognigy;
|
|
852
853
|
const { aiAgent, llmProviderReferenceId, name: jobName, description: jobDescription, instructions: jobInstructions, outputImmediately, toolChoice, useStrict, memoryType, selectedProfileFields, memoryContextInjection, knowledgeSearchBehavior, knowledgeSearchTags, knowledgeSearchTagsFilterOp, knowledgeSearchAiAgentKnowledge, knowledgeSearchJobKnowledge, knowledgeSearchJobStore, knowledgeSearchGenerateSearchPrompt, knowledgeSearchTopK, timeoutInMs, maxTokens, temperature, logErrorToSystem, storeErrorInInput, errorHandling, errorHandlingGotoTarget, errorMessage, debugConfig, debugLogTokenCount, debugLogSystemPrompt, debugLogToolDefinitions, debugResult, debugLogLLMLatency, storeLocation, contextKey, inputKey, streamStoreCopyInInput, streamStopTokens, processImages, transcriptImageHandling, sessionParams } = config;
|
|
853
854
|
try {
|
|
@@ -897,7 +898,7 @@ export const AI_AGENT_JOB = createNodeDescriptor({
|
|
|
897
898
|
throw new Error(`[VG2] Error on AI Agent Job node. Error message: ${error.message}`);
|
|
898
899
|
}
|
|
899
900
|
}
|
|
900
|
-
const
|
|
901
|
+
const _24 = profile, { profileId, accepted_gdpr, prevent_data_collection, privacy_policy } = _24, cleanedProfile = __rest(_24, ["profileId", "accepted_gdpr", "prevent_data_collection", "privacy_policy"]);
|
|
901
902
|
const userMemory = getUserMemory(memoryType, selectedProfileFields, aiAgent, cleanedProfile);
|
|
902
903
|
/**
|
|
903
904
|
* ----- Knowledge Search Section -----
|
|
@@ -1212,14 +1213,20 @@ export const AI_AGENT_JOB = createNodeDescriptor({
|
|
|
1212
1213
|
const mainToolCall = llmResult.toolCalls[0];
|
|
1213
1214
|
let isMcpToolCall = false;
|
|
1214
1215
|
// Find the child node with the toolId of the tool call
|
|
1215
|
-
let toolChild =
|
|
1216
|
+
let toolChild = undefined;
|
|
1217
|
+
for (const child of childConfigs) {
|
|
1218
|
+
if (child.type === "aiAgentJobTool" && ((_5 = child.config) === null || _5 === void 0 ? void 0 : _5.toolId) && (yield api.parseCognigyScriptText((_6 = child.config) === null || _6 === void 0 ? void 0 : _6.toolId)) === mainToolCall.function.name) {
|
|
1219
|
+
toolChild = child;
|
|
1220
|
+
break;
|
|
1221
|
+
}
|
|
1222
|
+
}
|
|
1216
1223
|
if (!toolChild && toolMap.has(mainToolCall.function.name)) {
|
|
1217
1224
|
// If the tool call is from an MCP tool, set the next node to the corresponding child node
|
|
1218
1225
|
toolChild = childConfigs.find(child => child.id === toolMap.get(mainToolCall.function.name));
|
|
1219
1226
|
isMcpToolCall = true;
|
|
1220
1227
|
}
|
|
1221
1228
|
if (mainToolCall.function.name !== "retrieve_knowledge" && toolChild === undefined) {
|
|
1222
|
-
(
|
|
1229
|
+
(_7 = api.logDebugError) === null || _7 === void 0 ? void 0 : _7.call(api, `UI__DEBUG_MODE__AI_AGENT_JOB__TOOL_CALL__ERROR__BODY <b>${mainToolCall.function.name}</b>`, "UI__DEBUG_MODE__AI_AGENT_JOB__TOOL_CALL__ERROR__HEADER");
|
|
1223
1230
|
}
|
|
1224
1231
|
// Add last tool call to session state for loading it from Tool Answer Node
|
|
1225
1232
|
api.updateSessionStateValues({
|
|
@@ -1227,21 +1234,21 @@ export const AI_AGENT_JOB = createNodeDescriptor({
|
|
|
1227
1234
|
flow: flowReferenceId,
|
|
1228
1235
|
node: nodeId,
|
|
1229
1236
|
} }, (isMcpToolCall && {
|
|
1230
|
-
mcpServerUrl: (
|
|
1231
|
-
timeout: (
|
|
1237
|
+
mcpServerUrl: (_8 = toolChild === null || toolChild === void 0 ? void 0 : toolChild.config) === null || _8 === void 0 ? void 0 : _8.mcpServerUrl,
|
|
1238
|
+
timeout: (_9 = toolChild === null || toolChild === void 0 ? void 0 : toolChild.config) === null || _9 === void 0 ? void 0 : _9.timeout,
|
|
1232
1239
|
mcpToolNode: toolChild === null || toolChild === void 0 ? void 0 : toolChild.id,
|
|
1233
1240
|
})), { toolCall: mainToolCall }),
|
|
1234
1241
|
});
|
|
1235
1242
|
// if there are any parameters/arguments, add them to the input slots
|
|
1236
1243
|
if (mainToolCall.function.arguments) {
|
|
1237
|
-
input.aiAgent = Object.assign(Object.assign({}, input.aiAgent), { toolArgs: Object.assign(Object.assign({}, (
|
|
1244
|
+
input.aiAgent = Object.assign(Object.assign({}, input.aiAgent), { toolArgs: Object.assign(Object.assign({}, (_11 = (_10 = input.aiAgent) === null || _10 === void 0 ? void 0 : _10.toolArgs) !== null && _11 !== void 0 ? _11 : {}), mainToolCall.function.arguments) });
|
|
1238
1245
|
}
|
|
1239
1246
|
// Debug Message for Tool Calls, configured in the Tool Node
|
|
1240
|
-
if ((
|
|
1241
|
-
const toolId = isMcpToolCall ? mainToolCall.function.name : api.parseCognigyScriptText(toolChild.config.toolId);
|
|
1247
|
+
if ((_12 = toolChild === null || toolChild === void 0 ? void 0 : toolChild.config) === null || _12 === void 0 ? void 0 : _12.debugMessage) {
|
|
1248
|
+
const toolId = isMcpToolCall ? mainToolCall.function.name : yield api.parseCognigyScriptText(toolChild.config.toolId);
|
|
1242
1249
|
const messageLines = [`<b>UI__DEBUG_MODE__AI_AGENT_JOB__TOOL_CALL__DEBUG_MESSAGE__HEADER:</b> ${toolId}`];
|
|
1243
1250
|
// Arguments / Parameters Slots
|
|
1244
|
-
const slots = ((
|
|
1251
|
+
const slots = ((_13 = mainToolCall === null || mainToolCall === void 0 ? void 0 : mainToolCall.function) === null || _13 === void 0 ? void 0 : _13.arguments) && Object.keys(mainToolCall.function.arguments);
|
|
1245
1252
|
const hasSlots = slots && slots.length > 0;
|
|
1246
1253
|
messageLines.push(`<b>UI__DEBUG_MODE__AI_AGENT_JOB__TOOL_CALL__DEBUG_MESSAGE__SLOTS</b>${hasSlots ? "" : " -"}`);
|
|
1247
1254
|
if (hasSlots) {
|
|
@@ -1256,7 +1263,7 @@ export const AI_AGENT_JOB = createNodeDescriptor({
|
|
|
1256
1263
|
messageLines.push(`- ${slot}: ${slotValueAsString}`);
|
|
1257
1264
|
});
|
|
1258
1265
|
}
|
|
1259
|
-
(
|
|
1266
|
+
(_14 = api.logDebugMessage) === null || _14 === void 0 ? void 0 : _14.call(api, messageLines.join("\n"), "UI__DEBUG_MODE__AI_AGENT_JOB__TOOL_CALL__DEBUG_MESSAGE__HEADER");
|
|
1260
1267
|
}
|
|
1261
1268
|
if (toolChild) {
|
|
1262
1269
|
api.setNextNode(toolChild.id);
|
|
@@ -1281,11 +1288,11 @@ export const AI_AGENT_JOB = createNodeDescriptor({
|
|
|
1281
1288
|
}
|
|
1282
1289
|
// Optionally output the result immediately
|
|
1283
1290
|
if (llmResult.result && outputImmediately && !llmPromptOptions.stream) {
|
|
1284
|
-
yield ((
|
|
1291
|
+
yield ((_15 = api.output) === null || _15 === void 0 ? void 0 : _15.call(api, llmResult.result, {}));
|
|
1285
1292
|
}
|
|
1286
1293
|
else if (llmResult.finishReason && llmPromptOptions.stream) {
|
|
1287
1294
|
// send the finishReason as last output for a stream
|
|
1288
|
-
(
|
|
1295
|
+
(_16 = api.output) === null || _16 === void 0 ? void 0 : _16.call(api, "", {
|
|
1289
1296
|
_cognigy: {
|
|
1290
1297
|
_preventTranscript: true,
|
|
1291
1298
|
_messageId,
|
|
@@ -1308,7 +1315,7 @@ export const AI_AGENT_JOB = createNodeDescriptor({
|
|
|
1308
1315
|
}
|
|
1309
1316
|
// Add response to Cognigy Input/Context for further usage
|
|
1310
1317
|
if (storeLocation === "context") {
|
|
1311
|
-
(
|
|
1318
|
+
(_17 = api.addToContext) === null || _17 === void 0 ? void 0 : _17.call(api, contextKey, llmResult, "simple");
|
|
1312
1319
|
}
|
|
1313
1320
|
else if (storeLocation === "input") {
|
|
1314
1321
|
api.addToInput(inputKey, llmResult);
|
|
@@ -1321,14 +1328,14 @@ export const AI_AGENT_JOB = createNodeDescriptor({
|
|
|
1321
1328
|
const errorDetails = {
|
|
1322
1329
|
name: (error === null || error === void 0 ? void 0 : error.name) || "Error",
|
|
1323
1330
|
code: (error === null || error === void 0 ? void 0 : error.code) || (error === null || error === void 0 ? void 0 : error.httpStatusCode),
|
|
1324
|
-
message: (error === null || error === void 0 ? void 0 : error.message) || ((
|
|
1331
|
+
message: (error === null || error === void 0 ? void 0 : error.message) || ((_18 = error.originalErrorDetails) === null || _18 === void 0 ? void 0 : _18.message),
|
|
1325
1332
|
};
|
|
1326
|
-
(
|
|
1333
|
+
(_19 = api.emitEvent) === null || _19 === void 0 ? void 0 : _19.call(api, "nodeError", { nodeId, flowId: flowReferenceId, errorMessage: error });
|
|
1327
1334
|
if (logErrorToSystem) {
|
|
1328
|
-
(
|
|
1335
|
+
(_20 = api.log) === null || _20 === void 0 ? void 0 : _20.call(api, "error", JSON.stringify(errorDetails));
|
|
1329
1336
|
}
|
|
1330
1337
|
if (errorHandling !== "stop") {
|
|
1331
|
-
(
|
|
1338
|
+
(_21 = api.logDebugError) === null || _21 === void 0 ? void 0 : _21.call(api, errorDetails.message + (errorDetails.code ? ` (error code: ${errorDetails.code})` : ""), errorDetails.name);
|
|
1332
1339
|
}
|
|
1333
1340
|
if (storeErrorInInput) {
|
|
1334
1341
|
input.aiAgent = input.aiAgent || {};
|
|
@@ -1337,7 +1344,7 @@ export const AI_AGENT_JOB = createNodeDescriptor({
|
|
|
1337
1344
|
if (errorHandling === "continue") {
|
|
1338
1345
|
// output the timeout message
|
|
1339
1346
|
if (errorMessage) {
|
|
1340
|
-
yield ((
|
|
1347
|
+
yield ((_22 = api.output) === null || _22 === void 0 ? void 0 : _22.call(api, errorMessage, null));
|
|
1341
1348
|
}
|
|
1342
1349
|
// Set default node as next node
|
|
1343
1350
|
const defaultChild = childConfigs.find(child => child.type === "aiAgentJobDefault");
|
|
@@ -1349,7 +1356,7 @@ export const AI_AGENT_JOB = createNodeDescriptor({
|
|
|
1349
1356
|
if (!errorHandlingGotoTarget) {
|
|
1350
1357
|
throw new Error("GoTo Target is required");
|
|
1351
1358
|
}
|
|
1352
|
-
if (!((
|
|
1359
|
+
if (!((_23 = api.checkThink) === null || _23 === void 0 ? void 0 : _23.call(api, nodeId))) {
|
|
1353
1360
|
api.resetNextNodes();
|
|
1354
1361
|
yield api.executeFlow({
|
|
1355
1362
|
flowNode: {
|
|
@@ -34,11 +34,11 @@ export const createToolDefinitions = (childConfigs, api, useStrict) => __awaiter
|
|
|
34
34
|
}
|
|
35
35
|
const toolId = child.config.toolId;
|
|
36
36
|
if ((child.type === "aiAgentJobTool" || child.type === "llmPromptTool") &&
|
|
37
|
-
(!child.config.condition || !!api.parseCognigyScriptCondition(child.config.condition))) {
|
|
37
|
+
(!child.config.condition || !!(yield api.parseCognigyScriptCondition(child.config.condition)))) {
|
|
38
38
|
if (!toolId) {
|
|
39
39
|
throw new Error(`Tool ID is missing in Tool Node configuration.`);
|
|
40
40
|
}
|
|
41
|
-
const parsedToolId = api.parseCognigyScriptText(toolId);
|
|
41
|
+
const parsedToolId = yield api.parseCognigyScriptText(toolId);
|
|
42
42
|
if (!validateToolId(parsedToolId)) {
|
|
43
43
|
throw new Error(`Tool ID ${parsedToolId} is not valid. Please use only alphanumeric characters, dashes and underscores.`);
|
|
44
44
|
}
|
|
@@ -51,7 +51,7 @@ export const createToolDefinitions = (childConfigs, api, useStrict) => __awaiter
|
|
|
51
51
|
type: "function",
|
|
52
52
|
function: {
|
|
53
53
|
name: parsedToolId,
|
|
54
|
-
description: api.parseCognigyScriptText(child.config.description),
|
|
54
|
+
description: yield api.parseCognigyScriptText(child.config.description),
|
|
55
55
|
},
|
|
56
56
|
};
|
|
57
57
|
if (useStrict) {
|
|
@@ -63,7 +63,7 @@ export const createToolDefinitions = (childConfigs, api, useStrict) => __awaiter
|
|
|
63
63
|
tools.push(tool);
|
|
64
64
|
}
|
|
65
65
|
if ((child.type === "aiAgentJobMCPTool" || child.type === "llmPromptMCPTool") &&
|
|
66
|
-
(!child.config.condition || !!api.parseCognigyScriptCondition(child.config.condition))) {
|
|
66
|
+
(!child.config.condition || !!(yield api.parseCognigyScriptCondition(child.config.condition)))) {
|
|
67
67
|
if (!child.config.mcpServerUrl) {
|
|
68
68
|
throw new Error(`MCP Server URL is missing in Tool Node configuration.`);
|
|
69
69
|
}
|