@tiangong-lca/tidas-sdk 0.1.20 → 0.1.21
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/README.md +174 -451
- package/dist/core/base/TidasEntity.d.ts +190 -0
- package/dist/core/base/TidasEntity.d.ts.map +1 -0
- package/dist/core/base/TidasEntity.js +433 -0
- package/dist/core/base/TidasEntity.js.map +1 -0
- package/dist/core/config/GlobalConfig.d.ts +60 -0
- package/dist/core/config/GlobalConfig.d.ts.map +1 -0
- package/dist/core/config/GlobalConfig.js +110 -0
- package/dist/core/config/GlobalConfig.js.map +1 -0
- package/dist/core/config/ValidationConfig.d.ts +70 -0
- package/dist/core/config/ValidationConfig.d.ts.map +1 -0
- package/dist/core/config/ValidationConfig.js +157 -0
- package/dist/core/config/ValidationConfig.js.map +1 -0
- package/dist/core/copilot/ai.d.ts +150 -0
- package/dist/core/copilot/ai.d.ts.map +1 -0
- package/dist/core/copilot/ai.js +581 -0
- package/dist/core/copilot/ai.js.map +1 -0
- package/dist/core/copilot/base.d.ts +83 -0
- package/dist/core/copilot/base.d.ts.map +1 -0
- package/dist/core/copilot/base.js +193 -0
- package/dist/core/copilot/base.js.map +1 -0
- package/dist/core/copilot/index.d.ts +1 -0
- package/dist/core/copilot/index.d.ts.map +1 -0
- package/dist/core/copilot/index.js +2 -0
- package/dist/core/copilot/index.js.map +1 -0
- package/dist/core/entities/TidasContact.d.ts +14 -0
- package/dist/core/entities/TidasContact.d.ts.map +1 -0
- package/dist/core/entities/TidasContact.js +124 -0
- package/dist/core/entities/TidasContact.js.map +1 -0
- package/dist/core/entities/TidasFlow.d.ts +14 -0
- package/dist/core/entities/TidasFlow.d.ts.map +1 -0
- package/dist/core/entities/TidasFlow.js +143 -0
- package/dist/core/entities/TidasFlow.js.map +1 -0
- package/dist/core/entities/TidasFlowProperty.d.ts +14 -0
- package/dist/core/entities/TidasFlowProperty.d.ts.map +1 -0
- package/dist/core/entities/TidasFlowProperty.js +156 -0
- package/dist/core/entities/TidasFlowProperty.js.map +1 -0
- package/dist/core/entities/TidasLCIAMethod.d.ts +14 -0
- package/dist/core/entities/TidasLCIAMethod.d.ts.map +1 -0
- package/dist/core/entities/TidasLCIAMethod.js +177 -0
- package/dist/core/entities/TidasLCIAMethod.js.map +1 -0
- package/dist/core/entities/TidasLifeCycleModel.d.ts +14 -0
- package/dist/core/entities/TidasLifeCycleModel.d.ts.map +1 -0
- package/dist/core/entities/TidasLifeCycleModel.js +169 -0
- package/dist/core/entities/TidasLifeCycleModel.js.map +1 -0
- package/dist/core/entities/TidasProcess.d.ts +14 -0
- package/dist/core/entities/TidasProcess.d.ts.map +1 -0
- package/dist/core/entities/TidasProcess.js +191 -0
- package/dist/core/entities/TidasProcess.js.map +1 -0
- package/dist/core/entities/TidasSource.d.ts +14 -0
- package/dist/core/entities/TidasSource.d.ts.map +1 -0
- package/dist/core/entities/TidasSource.js +146 -0
- package/dist/core/entities/TidasSource.js.map +1 -0
- package/dist/core/entities/TidasUnitGroup.d.ts +14 -0
- package/dist/core/entities/TidasUnitGroup.d.ts.map +1 -0
- package/dist/core/entities/TidasUnitGroup.js +177 -0
- package/dist/core/entities/TidasUnitGroup.js.map +1 -0
- package/dist/core/factories/index.d.ts +46 -0
- package/dist/core/factories/index.d.ts.map +1 -0
- package/dist/core/factories/index.js +223 -0
- package/dist/core/factories/index.js.map +1 -0
- package/dist/core/index.d.ts +9 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +56 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/zod-factories.d.ts +71 -0
- package/dist/core/zod-factories.d.ts.map +1 -0
- package/dist/core/zod-factories.js +169 -0
- package/dist/core/zod-factories.js.map +1 -0
- package/dist/core/zod-proxy.d.ts +108 -0
- package/dist/core/zod-proxy.d.ts.map +1 -0
- package/dist/core/zod-proxy.js +382 -0
- package/dist/core/zod-proxy.js.map +1 -0
- package/dist/data/bundled-methodologies.json +1259 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +73 -0
- package/dist/index.js.map +1 -0
- package/dist/schemas/index.d.ts +48 -0
- package/dist/schemas/index.d.ts.map +1 -0
- package/dist/schemas/index.js +112 -0
- package/dist/schemas/index.js.map +1 -0
- package/dist/schemas/tidas_contacts.schema.d.ts +124 -0
- package/dist/schemas/tidas_contacts.schema.d.ts.map +1 -0
- package/dist/schemas/tidas_contacts.schema.js +75 -0
- package/dist/schemas/tidas_contacts.schema.js.map +1 -0
- package/dist/schemas/tidas_contacts_category.schema.d.ts +3 -0
- package/dist/schemas/tidas_contacts_category.schema.d.ts.map +1 -0
- package/dist/schemas/tidas_contacts_category.schema.js +53 -0
- package/dist/schemas/tidas_contacts_category.schema.js.map +1 -0
- package/dist/schemas/tidas_data_types.schema.d.ts +34 -0
- package/dist/schemas/tidas_data_types.schema.d.ts.map +1 -0
- package/dist/schemas/tidas_data_types.schema.js +60 -0
- package/dist/schemas/tidas_data_types.schema.js.map +1 -0
- package/dist/schemas/tidas_flowproperties.schema.d.ts +152 -0
- package/dist/schemas/tidas_flowproperties.schema.d.ts.map +1 -0
- package/dist/schemas/tidas_flowproperties.schema.js +88 -0
- package/dist/schemas/tidas_flowproperties.schema.js.map +1 -0
- package/dist/schemas/tidas_flowproperties_category.schema.d.ts +3 -0
- package/dist/schemas/tidas_flowproperties_category.schema.d.ts.map +1 -0
- package/dist/schemas/tidas_flowproperties_category.schema.js +28 -0
- package/dist/schemas/tidas_flowproperties_category.schema.js.map +1 -0
- package/dist/schemas/tidas_flows.schema.d.ts +215 -0
- package/dist/schemas/tidas_flows.schema.d.ts.map +1 -0
- package/dist/schemas/tidas_flows.schema.js +165 -0
- package/dist/schemas/tidas_flows.schema.js.map +1 -0
- package/dist/schemas/tidas_flows_elementary_category.schema.d.ts +3 -0
- package/dist/schemas/tidas_flows_elementary_category.schema.d.ts.map +1 -0
- package/dist/schemas/tidas_flows_elementary_category.schema.js +309 -0
- package/dist/schemas/tidas_flows_elementary_category.schema.js.map +1 -0
- package/dist/schemas/tidas_flows_product_category.schema.d.ts +3 -0
- package/dist/schemas/tidas_flows_product_category.schema.d.ts.map +1 -0
- package/dist/schemas/tidas_flows_product_category.schema.js +28508 -0
- package/dist/schemas/tidas_flows_product_category.schema.js.map +1 -0
- package/dist/schemas/tidas_lciamethods.schema.d.ts +546 -0
- package/dist/schemas/tidas_lciamethods.schema.d.ts.map +1 -0
- package/dist/schemas/tidas_lciamethods.schema.js +513 -0
- package/dist/schemas/tidas_lciamethods.schema.js.map +1 -0
- package/dist/schemas/tidas_lciamethods_category.schema.d.ts +3 -0
- package/dist/schemas/tidas_lciamethods_category.schema.d.ts.map +1 -0
- package/dist/schemas/tidas_lciamethods_category.schema.js +278 -0
- package/dist/schemas/tidas_lciamethods_category.schema.js.map +1 -0
- package/dist/schemas/tidas_lifecyclemodels.schema.d.ts +465 -0
- package/dist/schemas/tidas_lifecyclemodels.schema.d.ts.map +1 -0
- package/dist/schemas/tidas_lifecyclemodels.schema.js +420 -0
- package/dist/schemas/tidas_lifecyclemodels.schema.js.map +1 -0
- package/dist/schemas/tidas_locations_category.schema.d.ts +3 -0
- package/dist/schemas/tidas_locations_category.schema.d.ts.map +1 -0
- package/dist/schemas/tidas_locations_category.schema.js +655 -0
- package/dist/schemas/tidas_locations_category.schema.js.map +1 -0
- package/dist/schemas/tidas_processes.schema.d.ts +626 -0
- package/dist/schemas/tidas_processes.schema.d.ts.map +1 -0
- package/dist/schemas/tidas_processes.schema.js +659 -0
- package/dist/schemas/tidas_processes.schema.js.map +1 -0
- package/dist/schemas/tidas_processes_category.schema.d.ts +3 -0
- package/dist/schemas/tidas_processes_category.schema.d.ts.map +1 -0
- package/dist/schemas/tidas_processes_category.schema.js +4904 -0
- package/dist/schemas/tidas_processes_category.schema.js.map +1 -0
- package/dist/schemas/tidas_sources.schema.d.ts +113 -0
- package/dist/schemas/tidas_sources.schema.d.ts.map +1 -0
- package/dist/schemas/tidas_sources.schema.js +73 -0
- package/dist/schemas/tidas_sources.schema.js.map +1 -0
- package/dist/schemas/tidas_sources_category.schema.d.ts +3 -0
- package/dist/schemas/tidas_sources_category.schema.d.ts.map +1 -0
- package/dist/schemas/tidas_sources_category.schema.js +43 -0
- package/dist/schemas/tidas_sources_category.schema.js.map +1 -0
- package/dist/schemas/tidas_unitgroups.schema.d.ts +140 -0
- package/dist/schemas/tidas_unitgroups.schema.d.ts.map +1 -0
- package/dist/schemas/tidas_unitgroups.schema.js +103 -0
- package/dist/schemas/tidas_unitgroups.schema.js.map +1 -0
- package/dist/schemas/tidas_unitgroups_category.schema.d.ts +3 -0
- package/dist/schemas/tidas_unitgroups_category.schema.d.ts.map +1 -0
- package/dist/schemas/tidas_unitgroups_category.schema.js +28 -0
- package/dist/schemas/tidas_unitgroups_category.schema.js.map +1 -0
- package/dist/services/copilot-service.d.ts +147 -0
- package/dist/services/copilot-service.d.ts.map +1 -0
- package/dist/services/copilot-service.js +259 -0
- package/dist/services/copilot-service.js.map +1 -0
- package/dist/services/index.d.ts +9 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/index.js +24 -0
- package/dist/services/index.js.map +1 -0
- package/dist/types/index.d.ts +22 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +21 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/multi-lang-types.d.ts +23 -0
- package/dist/types/multi-lang-types.d.ts.map +1 -0
- package/dist/types/multi-lang-types.js +40 -0
- package/dist/types/multi-lang-types.js.map +1 -0
- package/dist/types/tidas_contacts.d.ts +72 -0
- package/dist/types/tidas_contacts.d.ts.map +1 -0
- package/dist/types/tidas_contacts.js +8 -0
- package/dist/types/tidas_contacts.js.map +1 -0
- package/dist/types/tidas_contacts_category.d.ts +43 -0
- package/dist/types/tidas_contacts_category.d.ts.map +1 -0
- package/dist/types/tidas_contacts_category.js +8 -0
- package/dist/types/tidas_contacts_category.js.map +1 -0
- package/dist/types/tidas_data_types.d.ts +116 -0
- package/dist/types/tidas_data_types.d.ts.map +1 -0
- package/dist/types/tidas_data_types.js +8 -0
- package/dist/types/tidas_data_types.js.map +1 -0
- package/dist/types/tidas_flowproperties.d.ts +73 -0
- package/dist/types/tidas_flowproperties.d.ts.map +1 -0
- package/dist/types/tidas_flowproperties.js +8 -0
- package/dist/types/tidas_flowproperties.js.map +1 -0
- package/dist/types/tidas_flowproperties_category.d.ts +23 -0
- package/dist/types/tidas_flowproperties_category.d.ts.map +1 -0
- package/dist/types/tidas_flowproperties_category.js +8 -0
- package/dist/types/tidas_flowproperties_category.js.map +1 -0
- package/dist/types/tidas_flows.d.ts +113 -0
- package/dist/types/tidas_flows.d.ts.map +1 -0
- package/dist/types/tidas_flows.js +8 -0
- package/dist/types/tidas_flows.js.map +1 -0
- package/dist/types/tidas_flows_elementary_category.d.ts +227 -0
- package/dist/types/tidas_flows_elementary_category.d.ts.map +1 -0
- package/dist/types/tidas_flows_elementary_category.js +8 -0
- package/dist/types/tidas_flows_elementary_category.js.map +1 -0
- package/dist/types/tidas_flows_product_category.d.ts +18391 -0
- package/dist/types/tidas_flows_product_category.d.ts.map +1 -0
- package/dist/types/tidas_flows_product_category.js +8 -0
- package/dist/types/tidas_flows_product_category.js.map +1 -0
- package/dist/types/tidas_lciamethods.d.ts +231 -0
- package/dist/types/tidas_lciamethods.d.ts.map +1 -0
- package/dist/types/tidas_lciamethods.js +8 -0
- package/dist/types/tidas_lciamethods.js.map +1 -0
- package/dist/types/tidas_lciamethods_category.d.ts +215 -0
- package/dist/types/tidas_lciamethods_category.d.ts.map +1 -0
- package/dist/types/tidas_lciamethods_category.js +8 -0
- package/dist/types/tidas_lciamethods_category.js.map +1 -0
- package/dist/types/tidas_lifecyclemodels.d.ts +259 -0
- package/dist/types/tidas_lifecyclemodels.d.ts.map +1 -0
- package/dist/types/tidas_lifecyclemodels.js +8 -0
- package/dist/types/tidas_lifecyclemodels.js.map +1 -0
- package/dist/types/tidas_locations_category.d.ts +7 -0
- package/dist/types/tidas_locations_category.d.ts.map +1 -0
- package/dist/types/tidas_locations_category.js +8 -0
- package/dist/types/tidas_locations_category.js.map +1 -0
- package/dist/types/tidas_processes.d.ts +301 -0
- package/dist/types/tidas_processes.d.ts.map +1 -0
- package/dist/types/tidas_processes.js +8 -0
- package/dist/types/tidas_processes.js.map +1 -0
- package/dist/types/tidas_processes_category.d.ts +3327 -0
- package/dist/types/tidas_processes_category.d.ts.map +1 -0
- package/dist/types/tidas_processes_category.js +8 -0
- package/dist/types/tidas_processes_category.js.map +1 -0
- package/dist/types/tidas_sources.d.ts +58 -0
- package/dist/types/tidas_sources.d.ts.map +1 -0
- package/dist/types/tidas_sources.js +8 -0
- package/dist/types/tidas_sources.js.map +1 -0
- package/dist/types/tidas_sources_category.d.ts +35 -0
- package/dist/types/tidas_sources_category.d.ts.map +1 -0
- package/dist/types/tidas_sources_category.js +8 -0
- package/dist/types/tidas_sources_category.js.map +1 -0
- package/dist/types/tidas_unitgroups.d.ts +85 -0
- package/dist/types/tidas_unitgroups.d.ts.map +1 -0
- package/dist/types/tidas_unitgroups.js +8 -0
- package/dist/types/tidas_unitgroups.js.map +1 -0
- package/dist/types/tidas_unitgroups_category.d.ts +23 -0
- package/dist/types/tidas_unitgroups_category.d.ts.map +1 -0
- package/dist/types/tidas_unitgroups_category.js +8 -0
- package/dist/types/tidas_unitgroups_category.js.map +1 -0
- package/dist/utils/diff.d.ts +47 -0
- package/dist/utils/diff.d.ts.map +1 -0
- package/dist/utils/diff.js +263 -0
- package/dist/utils/diff.js.map +1 -0
- package/dist/utils/index.d.ts +7 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +31 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/object-utils.d.ts +47 -0
- package/dist/utils/object-utils.d.ts.map +1 -0
- package/dist/utils/object-utils.js +332 -0
- package/dist/utils/object-utils.js.map +1 -0
- package/package.json +4 -4
|
@@ -0,0 +1,581 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.extractJson = void 0;
|
|
37
|
+
exports.extractValidJsonWithRetry = extractValidJsonWithRetry;
|
|
38
|
+
exports.suggestEntireObject = suggestEntireObject;
|
|
39
|
+
exports.fixJsonDataWithAI = fixJsonDataWithAI;
|
|
40
|
+
exports.suggest = suggest;
|
|
41
|
+
exports.reviewData = reviewData;
|
|
42
|
+
exports.getModel = getModel;
|
|
43
|
+
const openai_1 = require("@langchain/openai");
|
|
44
|
+
const prompts_1 = require("@langchain/core/prompts");
|
|
45
|
+
const output_parsers_1 = require("@langchain/core/output_parsers");
|
|
46
|
+
const object_utils_1 = require("../../utils/object-utils");
|
|
47
|
+
const base_1 = require("./base");
|
|
48
|
+
async function getModel(modelConfig) {
|
|
49
|
+
const chat_model = new openai_1.ChatOpenAI({
|
|
50
|
+
model: modelConfig.model || process.env.OPENAI_CHAT_MODEL,
|
|
51
|
+
configuration: {
|
|
52
|
+
apiKey: modelConfig.apiKey || process.env.OPENAI_API_KEY,
|
|
53
|
+
baseURL: modelConfig.baseURL || process.env.OPENAI_BASE_URL,
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
return chat_model;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Custom extractor
|
|
60
|
+
*
|
|
61
|
+
* Extracts JSON content from a string where
|
|
62
|
+
* JSON is embedded between ```json and ``` tags.
|
|
63
|
+
*/
|
|
64
|
+
const extractJson = (output, schema, returnSingle = true) => {
|
|
65
|
+
const text = typeof output === 'string'
|
|
66
|
+
? output
|
|
67
|
+
: (output.content || output.toString());
|
|
68
|
+
// Define the regular expression pattern to match JSON blocks
|
|
69
|
+
const pattern = /```json(.*?)```/gs;
|
|
70
|
+
// Find all non-overlapping matches of the pattern in the string
|
|
71
|
+
const matches = text.match(pattern);
|
|
72
|
+
if (!matches || matches.length === 0) {
|
|
73
|
+
throw new Error('No JSON blocks found in AI response');
|
|
74
|
+
}
|
|
75
|
+
// Process each match, attempting to parse it as JSON
|
|
76
|
+
try {
|
|
77
|
+
const results = matches.map((match) => {
|
|
78
|
+
// Remove the markdown code block syntax to isolate the JSON string
|
|
79
|
+
const jsonStr = match.replace(/```json|```/g, '').trim();
|
|
80
|
+
let jsonData;
|
|
81
|
+
try {
|
|
82
|
+
jsonData = JSON.parse(jsonStr);
|
|
83
|
+
}
|
|
84
|
+
catch (parseError) {
|
|
85
|
+
console.error('Invalid JSON format Error:', JSON.stringify(parseError));
|
|
86
|
+
throw new Error(`Invalid JSON format: ${jsonStr.substring(0, 100)}...`);
|
|
87
|
+
}
|
|
88
|
+
const isValid = (0, object_utils_1.validateSchema)(jsonData, schema);
|
|
89
|
+
if (!isValid) {
|
|
90
|
+
throw new Error(`JSON does not match expected schema`);
|
|
91
|
+
}
|
|
92
|
+
return jsonData;
|
|
93
|
+
});
|
|
94
|
+
return returnSingle && results.length === 1 ? results[0] : results;
|
|
95
|
+
}
|
|
96
|
+
catch (error) {
|
|
97
|
+
console.error('JSON extraction failed:', error);
|
|
98
|
+
throw new Error(`Failed to extract valid JSON: ${error.message}`);
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
exports.extractJson = extractJson;
|
|
102
|
+
async function fixJsonDataWithAI(data, originalData, modelConfig) {
|
|
103
|
+
const fixPrompt = `
|
|
104
|
+
There are two JSON objects, first one is the original data, second one is the data after some modifications.
|
|
105
|
+
|
|
106
|
+
Due to some content processing, the structure of the second JSON data has changed compared to the first one. Please modify the second JSON data according to the first JSON data, so that its structure matches the first JSON data.
|
|
107
|
+
|
|
108
|
+
The first JSON data is:
|
|
109
|
+
{originalData}
|
|
110
|
+
|
|
111
|
+
The second JSON data is:
|
|
112
|
+
{data}
|
|
113
|
+
|
|
114
|
+
Output your answer as JSON that
|
|
115
|
+
matches the given schema: \`\`\`json\n{schema}\n\`\`\`.
|
|
116
|
+
Make sure to wrap the answer in \`\`\`json and \`\`\` tags
|
|
117
|
+
`;
|
|
118
|
+
const schema = (0, object_utils_1.generateSchema)(originalData);
|
|
119
|
+
const model = await getModel(modelConfig || {});
|
|
120
|
+
const parser = new output_parsers_1.JsonOutputParser();
|
|
121
|
+
const prompt = new prompts_1.PromptTemplate({
|
|
122
|
+
template: fixPrompt,
|
|
123
|
+
inputVariables: ['originalData', 'data', 'schema'],
|
|
124
|
+
});
|
|
125
|
+
const chain = prompt.pipe(model).pipe(parser);
|
|
126
|
+
const result = await chain.invoke({
|
|
127
|
+
originalData: JSON.stringify(originalData),
|
|
128
|
+
data: JSON.stringify(data),
|
|
129
|
+
schema: JSON.stringify(schema),
|
|
130
|
+
});
|
|
131
|
+
return extractJson(result, schema);
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Extracts valid JSON data from AI response with retry mechanism
|
|
135
|
+
* Combines extractJson and fixJsonDataWithAI functions to ensure the extracted data
|
|
136
|
+
* matches the original data structure
|
|
137
|
+
*
|
|
138
|
+
* @param data - The AI response or data containing JSON
|
|
139
|
+
* @param originalData - The original data structure to match
|
|
140
|
+
* @param schema - The schema to validate against
|
|
141
|
+
* @param maxRetries - Maximum number of retry attempts (default: 3)
|
|
142
|
+
* @returns The extracted and validated JSON data
|
|
143
|
+
*/
|
|
144
|
+
async function extractValidJsonWithRetry(data, originalData, schema, maxRetries = 3) {
|
|
145
|
+
// Use provided schema or generate from original data
|
|
146
|
+
const validationSchema = schema || (0, object_utils_1.generateSchema)(originalData);
|
|
147
|
+
let lastError = null;
|
|
148
|
+
for (let attempt = 1; attempt <= maxRetries; attempt++) {
|
|
149
|
+
try {
|
|
150
|
+
console.log(`Attempt ${attempt} of ${maxRetries}: Extracting JSON...`);
|
|
151
|
+
// First try to extract JSON directly
|
|
152
|
+
try {
|
|
153
|
+
const extractedData = extractJson(data, validationSchema, true);
|
|
154
|
+
// Validate the extracted data matches the original structure
|
|
155
|
+
if ((0, object_utils_1.validateSchema)(extractedData, validationSchema)) {
|
|
156
|
+
console.log(`Success on attempt ${attempt}: JSON extracted and validated`);
|
|
157
|
+
return extractedData;
|
|
158
|
+
}
|
|
159
|
+
// If validation fails, try to fix the structure
|
|
160
|
+
console.log(`Attempt ${attempt}: Structure mismatch, attempting to fix...`);
|
|
161
|
+
const fixedData = await fixJsonDataWithAI(extractedData, originalData);
|
|
162
|
+
if ((0, object_utils_1.validateSchema)(fixedData, validationSchema)) {
|
|
163
|
+
console.log(`Success on attempt ${attempt}: JSON structure fixed`);
|
|
164
|
+
return fixedData;
|
|
165
|
+
}
|
|
166
|
+
throw new Error('Fixed data still does not match original structure');
|
|
167
|
+
}
|
|
168
|
+
catch (extractError) {
|
|
169
|
+
// If extraction fails completely, try to fix the raw data
|
|
170
|
+
console.log('ExtractError:', JSON.stringify(extractError), `\nAttempt ${attempt}: Direct extraction failed, using AI to fix...`);
|
|
171
|
+
// Convert data to string if needed
|
|
172
|
+
const dataStr = typeof data === 'string' ? data : JSON.stringify(data);
|
|
173
|
+
// Use AI to fix and extract
|
|
174
|
+
const fixedData = await fixJsonDataWithAI(dataStr, originalData);
|
|
175
|
+
if ((0, object_utils_1.validateSchema)(fixedData, validationSchema)) {
|
|
176
|
+
console.log(`Success on attempt ${attempt}: AI fixed and extracted JSON`);
|
|
177
|
+
return fixedData;
|
|
178
|
+
}
|
|
179
|
+
throw new Error('AI-fixed data does not match original structure');
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
catch (error) {
|
|
183
|
+
lastError = error;
|
|
184
|
+
console.error(`Attempt ${attempt} failed:`, lastError.message);
|
|
185
|
+
if (attempt < maxRetries) {
|
|
186
|
+
console.log(`Retrying in 1 second...`);
|
|
187
|
+
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
// All attempts failed
|
|
192
|
+
throw new Error(`Failed to extract valid JSON after ${maxRetries} attempts. Last error: ${lastError?.message}`);
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Suggests improvements to data based on TIDAS methodology rules.
|
|
196
|
+
*
|
|
197
|
+
* This function uses AI to analyze the provided data against TIDAS methodology rules
|
|
198
|
+
* and suggests optimized content that better complies with the methodology requirements.
|
|
199
|
+
* The function ensures that the data structure remains unchanged while improving the content.
|
|
200
|
+
*
|
|
201
|
+
* @param data - The original data object to be improved. Can be any JSON-serializable object
|
|
202
|
+
* such as process names, descriptions, or other TIDAS/ILCD data elements.
|
|
203
|
+
* @param methodology - The methodology rules to apply. Can be:
|
|
204
|
+
* - A complete methodology object loaded from YAML
|
|
205
|
+
* - A specific rule object extracted using getRuleFromMethodologyByPath
|
|
206
|
+
* - A custom rule object with description and rules properties
|
|
207
|
+
* @param modelConfig - The configuration for the AI model. Can be:
|
|
208
|
+
* - A complete model configuration object
|
|
209
|
+
* - A custom model configuration object with model, apiKey, and baseURL properties
|
|
210
|
+
* @returns Promise<any> - The improved data with the same structure as the input but with
|
|
211
|
+
* optimized content that better complies with the methodology.
|
|
212
|
+
* The returned data is guaranteed to match the original schema.
|
|
213
|
+
*
|
|
214
|
+
* @example
|
|
215
|
+
* ```typescript
|
|
216
|
+
* // Example 1: Improve a process name using specific rules
|
|
217
|
+
* const nameData = [{ '@xml:lang': 'en', '#text': 'Process 1' }];
|
|
218
|
+
* const rule = getRuleFromMethodologyByPath(methodology, 'processDataSet.processInformation.dataSetInformation.name.baseName');
|
|
219
|
+
* const improvedName = await suggest(nameData, rule);
|
|
220
|
+
* // Returns: [{ '@xml:lang': 'en', '#text': 'Production of Product A using Technology X' }]
|
|
221
|
+
*
|
|
222
|
+
* // Example 2: Improve data using full methodology
|
|
223
|
+
* const processData = { name: 'test', description: 'simple desc' };
|
|
224
|
+
* const improvedData = await suggest(processData, fullMethodology);
|
|
225
|
+
* // Returns data with improved names and descriptions
|
|
226
|
+
* ```
|
|
227
|
+
*
|
|
228
|
+
* @throws {Error} If the AI model fails to generate valid JSON
|
|
229
|
+
* @throws {Error} If the OpenAI API is not configured properly
|
|
230
|
+
*/
|
|
231
|
+
async function suggest(data, methodology, modelConfig) {
|
|
232
|
+
const startTime = Date.now();
|
|
233
|
+
// Prompt template for the AI model
|
|
234
|
+
const suggestPrompt = `
|
|
235
|
+
You are an Expert in the field of Life Cycle Assessment (LCA) and the TIDAS methodology.
|
|
236
|
+
|
|
237
|
+
You are given a JSON Object Data and the corresponding TIDAS methodology which offers the rules for the data.
|
|
238
|
+
|
|
239
|
+
Your task is to modify the data content according to the methodology rules, optimizing it to better comply with the methodology requirements.
|
|
240
|
+
Provide the optimized JSON result, and ensure that the data structure remains unchanged.
|
|
241
|
+
|
|
242
|
+
The data is:
|
|
243
|
+
{data}
|
|
244
|
+
|
|
245
|
+
The methodology is:
|
|
246
|
+
{methodology}
|
|
247
|
+
|
|
248
|
+
Output your answer as JSON that
|
|
249
|
+
matches the given schema: \`\`\`json\n{schema}\n\`\`\`.
|
|
250
|
+
Make sure to wrap the answer in \`\`\`json and \`\`\` tags
|
|
251
|
+
|
|
252
|
+
`;
|
|
253
|
+
// Initialize the AI model
|
|
254
|
+
const model = await getModel(modelConfig || {});
|
|
255
|
+
// Create the prompt template with input variables
|
|
256
|
+
const prompt = new prompts_1.PromptTemplate({
|
|
257
|
+
template: suggestPrompt,
|
|
258
|
+
inputVariables: ['data', 'methodology', 'schema'],
|
|
259
|
+
});
|
|
260
|
+
// Generate schema from the input data to ensure structure preservation
|
|
261
|
+
const schema = (0, object_utils_1.generateSchema)(data);
|
|
262
|
+
// Create parser for JSON output
|
|
263
|
+
const parser = new output_parsers_1.JsonOutputParser();
|
|
264
|
+
// Build the processing chain
|
|
265
|
+
const chain = prompt.pipe(model).pipe(parser);
|
|
266
|
+
// Invoke the AI model with the formatted inputs
|
|
267
|
+
const result = await chain.invoke({
|
|
268
|
+
data: JSON.stringify(data),
|
|
269
|
+
methodology: JSON.stringify(methodology),
|
|
270
|
+
schema: JSON.stringify(schema),
|
|
271
|
+
});
|
|
272
|
+
// Log performance metrics
|
|
273
|
+
const endTime = Date.now();
|
|
274
|
+
console.log(`Suggestion took ${endTime - startTime}ms`);
|
|
275
|
+
return result;
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Reviews data against TIDAS methodology rules and provides structured feedback.
|
|
279
|
+
*
|
|
280
|
+
* This function uses AI to analyze the provided data against TIDAS methodology rules
|
|
281
|
+
* and provides a review with comments and a compliance score. Unlike the suggest function
|
|
282
|
+
* which modifies data, this function only provides assessment and feedback.
|
|
283
|
+
*
|
|
284
|
+
* @param data - The data object to be reviewed. Can be any JSON-serializable object
|
|
285
|
+
* such as process names, descriptions, or other TIDAS/ILCD data elements.
|
|
286
|
+
* @param methodology - The methodology rules to evaluate against. Can be:
|
|
287
|
+
* - A complete methodology object loaded from YAML
|
|
288
|
+
* - A specific rule object extracted using getRuleFromMethodologyByPath
|
|
289
|
+
* - A custom rule object with description and rules properties
|
|
290
|
+
* @param modelConfig - The configuration for the AI model. Can be:
|
|
291
|
+
* - A complete model configuration object
|
|
292
|
+
* - A custom model configuration object with model, apiKey, and baseURL properties
|
|
293
|
+
* @returns Promise<{review_comment: string, review_score: number}> - A structured review containing:
|
|
294
|
+
* - review_comment: Detailed feedback on compliance and suggestions for improvement
|
|
295
|
+
* - review_score: A numerical score from 0-100 indicating compliance level
|
|
296
|
+
*
|
|
297
|
+
* @example
|
|
298
|
+
* ```typescript
|
|
299
|
+
* // Example 1: Review a process name against specific rules
|
|
300
|
+
* const nameData = [{ '@xml:lang': 'en', '#text': 'Process 1' }];
|
|
301
|
+
* const rule = getRuleFromMethodologyByPath(methodology, 'processDataSet.processInformation.dataSetInformation.name.baseName');
|
|
302
|
+
* const review = await reviewData(nameData, rule);
|
|
303
|
+
* // Returns: {
|
|
304
|
+
* // review_comment: "The process name 'Process 1' is too generic. It should include specific information about...",
|
|
305
|
+
* // review_score: 45
|
|
306
|
+
* // }
|
|
307
|
+
*
|
|
308
|
+
* // Example 2: Review complete process data
|
|
309
|
+
* const processData = { name: 'test', description: 'simple desc' };
|
|
310
|
+
* const review = await reviewData(processData, fullMethodology);
|
|
311
|
+
* // Returns comprehensive review with score
|
|
312
|
+
* ```
|
|
313
|
+
*
|
|
314
|
+
* @throws {Error} If the AI model fails to generate valid structured output
|
|
315
|
+
* @throws {Error} If the OpenAI API is not configured properly
|
|
316
|
+
*/
|
|
317
|
+
async function reviewData(data, methodology, modelConfig) {
|
|
318
|
+
const startTime = Date.now();
|
|
319
|
+
// Review prompt template for the AI model
|
|
320
|
+
const reviewPrompt = `
|
|
321
|
+
You are an Expert in the field of Life Cycle Assessment (LCA) and the TIDAS methodology.
|
|
322
|
+
|
|
323
|
+
You are given a JSON Object Data and the corresponding TIDAS methodology rules to review against.
|
|
324
|
+
|
|
325
|
+
Your task is to:
|
|
326
|
+
1. Analyze the data against the methodology rules
|
|
327
|
+
2. Identify areas of compliance and non-compliance
|
|
328
|
+
3. Provide specific, actionable feedback
|
|
329
|
+
4. Assign a compliance score from 0-100
|
|
330
|
+
|
|
331
|
+
The data to review is:
|
|
332
|
+
{data}
|
|
333
|
+
|
|
334
|
+
The methodology rules are:
|
|
335
|
+
{methodology}
|
|
336
|
+
|
|
337
|
+
Provide a detailed review with the following structure:
|
|
338
|
+
- review_comment: A comprehensive review comment that includes:
|
|
339
|
+
* What aspects comply well with the methodology
|
|
340
|
+
* What aspects need improvement
|
|
341
|
+
* Specific suggestions for improvement
|
|
342
|
+
* Overall assessment of data quality
|
|
343
|
+
- review_score: A numerical score from 0-100 where:
|
|
344
|
+
* 0-30: Poor compliance, major issues
|
|
345
|
+
* 31-50: Below average, significant improvements needed
|
|
346
|
+
* 51-70: Average compliance, some improvements recommended
|
|
347
|
+
* 71-85: Good compliance, minor improvements possible
|
|
348
|
+
* 86-100: Excellent compliance with methodology
|
|
349
|
+
|
|
350
|
+
Output your answer as JSON in this exact format:
|
|
351
|
+
\`\`\`json
|
|
352
|
+
{{
|
|
353
|
+
"review_comment": "Your detailed review here",
|
|
354
|
+
"review_score": 75
|
|
355
|
+
}}
|
|
356
|
+
\`\`\`
|
|
357
|
+
`;
|
|
358
|
+
// Initialize the AI model with structured output
|
|
359
|
+
const model = await getModel(modelConfig || {});
|
|
360
|
+
// Define the output schema using Zod
|
|
361
|
+
const { z } = await Promise.resolve().then(() => __importStar(require('zod')));
|
|
362
|
+
const reviewSchema = z.object({
|
|
363
|
+
review_comment: z
|
|
364
|
+
.string()
|
|
365
|
+
.describe('Detailed review comment with compliance assessment and suggestions'),
|
|
366
|
+
review_score: z
|
|
367
|
+
.number()
|
|
368
|
+
.min(0)
|
|
369
|
+
.max(100)
|
|
370
|
+
.describe('Compliance score from 0-100'),
|
|
371
|
+
});
|
|
372
|
+
// Configure model with structured output
|
|
373
|
+
const modelWithStructure = model.withStructuredOutput(reviewSchema, {
|
|
374
|
+
name: 'review_output',
|
|
375
|
+
});
|
|
376
|
+
// Create the prompt template with input variables
|
|
377
|
+
const prompt = new prompts_1.PromptTemplate({
|
|
378
|
+
template: reviewPrompt,
|
|
379
|
+
inputVariables: ['data', 'methodology'],
|
|
380
|
+
});
|
|
381
|
+
// Build the processing chain
|
|
382
|
+
const chain = prompt.pipe(modelWithStructure);
|
|
383
|
+
try {
|
|
384
|
+
// Invoke the AI model with the formatted inputs
|
|
385
|
+
const result = await chain.invoke({
|
|
386
|
+
data: JSON.stringify(data, null, 2),
|
|
387
|
+
methodology: JSON.stringify(methodology, null, 2),
|
|
388
|
+
});
|
|
389
|
+
// Log performance metrics
|
|
390
|
+
const endTime = Date.now();
|
|
391
|
+
console.log(`Review completed in ${endTime - startTime}ms`);
|
|
392
|
+
console.log(`Review score: ${result.review_score}/100`);
|
|
393
|
+
return result;
|
|
394
|
+
}
|
|
395
|
+
catch (error) {
|
|
396
|
+
console.error('Review failed:', error);
|
|
397
|
+
// Fallback to parsing from regular output if structured output fails
|
|
398
|
+
try {
|
|
399
|
+
const prompt = new prompts_1.PromptTemplate({
|
|
400
|
+
template: reviewPrompt,
|
|
401
|
+
inputVariables: ['data', 'methodology'],
|
|
402
|
+
});
|
|
403
|
+
const chain = prompt.pipe(model);
|
|
404
|
+
const result = await chain.invoke({
|
|
405
|
+
data: JSON.stringify(data, null, 2),
|
|
406
|
+
methodology: JSON.stringify(methodology, null, 2),
|
|
407
|
+
});
|
|
408
|
+
// Extract JSON from the response
|
|
409
|
+
const text = result.content;
|
|
410
|
+
const jsonMatch = text.match(/```json\s*([\s\S]*?)\s*```/);
|
|
411
|
+
if (jsonMatch && jsonMatch[1]) {
|
|
412
|
+
const parsed = JSON.parse(jsonMatch[1]);
|
|
413
|
+
// Validate the structure
|
|
414
|
+
if (typeof parsed.review_comment === 'string' &&
|
|
415
|
+
typeof parsed.review_score === 'number' &&
|
|
416
|
+
parsed.review_score >= 0 &&
|
|
417
|
+
parsed.review_score <= 100) {
|
|
418
|
+
const endTime = Date.now();
|
|
419
|
+
console.log(`Review completed in ${endTime - startTime}ms (fallback mode)`);
|
|
420
|
+
console.log(`Review score: ${parsed.review_score}/100`);
|
|
421
|
+
return parsed;
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
throw new Error('Failed to extract valid review structure from AI response');
|
|
425
|
+
}
|
|
426
|
+
catch (fallbackError) {
|
|
427
|
+
throw new Error(`Review failed: ${fallbackError.message}`);
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
/**
|
|
432
|
+
* Suggests improvements for an entire object based on all applicable methodology rules.
|
|
433
|
+
*
|
|
434
|
+
* This function analyzes a complete data object against all relevant methodology rules,
|
|
435
|
+
* applies AI suggestions to each applicable field, and returns a new object with improvements.
|
|
436
|
+
*
|
|
437
|
+
* @param data - The complete data object to improve (TidasEntity or plain object)
|
|
438
|
+
* @param methodologyType - The type of methodology to use:
|
|
439
|
+
* - A string key for available methodologies (e.g., 'processes', 'flows')
|
|
440
|
+
* - A methodology object already loaded
|
|
441
|
+
* @param options - Optional configuration:
|
|
442
|
+
* - parallelRequests: Number of parallel AI requests (default: 1)
|
|
443
|
+
* - skipPaths: Array of paths to skip
|
|
444
|
+
* - maxRetries: Maximum retries per rule (default: 1)
|
|
445
|
+
* @returns Promise<any> - Improved data object with the same structure as input
|
|
446
|
+
*
|
|
447
|
+
* @example
|
|
448
|
+
* ```typescript
|
|
449
|
+
* // Example: Improve an entire Process object
|
|
450
|
+
* const process = createProcess();
|
|
451
|
+
* process.processDataSet.processInformation.dataSetInformation['common:UUID'] = 'test-123';
|
|
452
|
+
* const improvedData = await suggestEntireObject(process, 'processes');
|
|
453
|
+
*
|
|
454
|
+
* // Create a new Process with improved data
|
|
455
|
+
* const improvedProcess = createProcess();
|
|
456
|
+
* Object.assign(improvedProcess, improvedData);
|
|
457
|
+
* ```
|
|
458
|
+
*/
|
|
459
|
+
async function suggestEntireObject(data, methodologyType, options) {
|
|
460
|
+
const startTime = Date.now();
|
|
461
|
+
// Default options
|
|
462
|
+
const opts = {
|
|
463
|
+
skipPaths: [],
|
|
464
|
+
maxRetries: 1,
|
|
465
|
+
...options,
|
|
466
|
+
};
|
|
467
|
+
console.log('Starting comprehensive object improvement...');
|
|
468
|
+
// Load methodology if string is provided
|
|
469
|
+
let methodology;
|
|
470
|
+
if (typeof methodologyType === 'string') {
|
|
471
|
+
const methodologyData = (0, base_1.getMethodologyData)(methodologyType);
|
|
472
|
+
if (!methodologyData) {
|
|
473
|
+
throw new Error(`Unknown methodology type: ${methodologyType}. Available types: ${base_1.availableMethodologies.join(', ')}`);
|
|
474
|
+
}
|
|
475
|
+
methodology = methodologyData;
|
|
476
|
+
console.log(`Loaded methodology: ${methodologyType}`);
|
|
477
|
+
}
|
|
478
|
+
else {
|
|
479
|
+
methodology = methodologyType;
|
|
480
|
+
}
|
|
481
|
+
// Get all rule paths from the methodology
|
|
482
|
+
const allRulePaths = (0, base_1.listRulePathsFromMethodology)(methodology);
|
|
483
|
+
console.log(`Found ${allRulePaths.length} rule paths`);
|
|
484
|
+
// Convert TidasEntity to plain object if needed
|
|
485
|
+
let plainData = data;
|
|
486
|
+
if (data && typeof data.getValue === 'function') {
|
|
487
|
+
// It's a TidasEntity, extract the raw data
|
|
488
|
+
plainData = JSON.parse(JSON.stringify(data));
|
|
489
|
+
}
|
|
490
|
+
// Create a deep copy for modifications
|
|
491
|
+
const improvedData = JSON.parse(JSON.stringify(plainData));
|
|
492
|
+
// Helper function to get value from path
|
|
493
|
+
const getValueByPath = (obj, path) => {
|
|
494
|
+
const pathParts = path.split('.');
|
|
495
|
+
let current = obj;
|
|
496
|
+
for (const part of pathParts) {
|
|
497
|
+
if (current && typeof current === 'object' && part in current) {
|
|
498
|
+
current = current[part];
|
|
499
|
+
}
|
|
500
|
+
else {
|
|
501
|
+
return undefined;
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
return current;
|
|
505
|
+
};
|
|
506
|
+
// Helper function to set value at path
|
|
507
|
+
const setValueByPath = (obj, path, value) => {
|
|
508
|
+
const pathParts = path.split('.');
|
|
509
|
+
let target = obj;
|
|
510
|
+
for (let i = 0; i < pathParts.length - 1; i++) {
|
|
511
|
+
if (!target[pathParts[i]]) {
|
|
512
|
+
target[pathParts[i]] = {};
|
|
513
|
+
}
|
|
514
|
+
target = target[pathParts[i]];
|
|
515
|
+
}
|
|
516
|
+
target[pathParts[pathParts.length - 1]] = value;
|
|
517
|
+
};
|
|
518
|
+
// Process rule for a single path
|
|
519
|
+
const processPath = async (path) => {
|
|
520
|
+
// Skip if in skip list
|
|
521
|
+
if (opts.skipPaths && opts.skipPaths.includes(path)) {
|
|
522
|
+
console.log(`Skipping path (user request): ${path}`);
|
|
523
|
+
return null;
|
|
524
|
+
}
|
|
525
|
+
try {
|
|
526
|
+
// Get rule for this path
|
|
527
|
+
const rule = (0, base_1.getRuleFromMethodologyByPath)(methodology, path);
|
|
528
|
+
if (!rule) {
|
|
529
|
+
return null;
|
|
530
|
+
}
|
|
531
|
+
// Extract value at this path from the data
|
|
532
|
+
const currentValue = getValueByPath(plainData, path);
|
|
533
|
+
// Skip if no value at this path
|
|
534
|
+
if (currentValue === undefined || currentValue === null) {
|
|
535
|
+
console.log(`Skipping path (no data): ${path}`);
|
|
536
|
+
return null;
|
|
537
|
+
}
|
|
538
|
+
console.log(`Processing: ${path}`);
|
|
539
|
+
// Apply suggestion with retry
|
|
540
|
+
for (let retry = 1; retry <= opts.maxRetries; retry++) {
|
|
541
|
+
try {
|
|
542
|
+
const suggestedValue = await suggest(currentValue, rule);
|
|
543
|
+
// Validate structure is preserved
|
|
544
|
+
const originalSchema = (0, object_utils_1.generateSchema)(currentValue);
|
|
545
|
+
if ((0, object_utils_1.validateSchema)(suggestedValue, originalSchema)) {
|
|
546
|
+
console.log(` ✓ Improved: ${path}`);
|
|
547
|
+
return {
|
|
548
|
+
path,
|
|
549
|
+
original: currentValue,
|
|
550
|
+
suggested: suggestedValue,
|
|
551
|
+
};
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
catch (error) {
|
|
555
|
+
console.log(` Retry ${retry}/${opts.maxRetries} failed: ${error.message}`);
|
|
556
|
+
if (retry < opts.maxRetries) {
|
|
557
|
+
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
catch (error) {
|
|
563
|
+
console.error(`Error processing ${path}:`, error.message);
|
|
564
|
+
}
|
|
565
|
+
return null;
|
|
566
|
+
};
|
|
567
|
+
// Process all paths in parallel
|
|
568
|
+
console.log('Processing all paths in parallel...');
|
|
569
|
+
const results = await Promise.all(allRulePaths.map((path) => processPath(path)));
|
|
570
|
+
// Filter out null results and apply improvements
|
|
571
|
+
const improvements = results.filter((r) => r !== null);
|
|
572
|
+
// Apply all improvements to the improvedData object
|
|
573
|
+
for (const improvement of improvements) {
|
|
574
|
+
setValueByPath(improvedData, improvement.path, improvement.suggested);
|
|
575
|
+
}
|
|
576
|
+
const endTime = Date.now();
|
|
577
|
+
console.log(`\nCompleted ${methodologyType} Suggestion in ${endTime - startTime}ms`);
|
|
578
|
+
console.log(`Applied ${improvements.length} improvements out of ${allRulePaths.length} possible paths`);
|
|
579
|
+
return improvedData;
|
|
580
|
+
}
|
|
581
|
+
//# sourceMappingURL=ai.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai.js","sourceRoot":"","sources":["../../../src/core/copilot/ai.ts"],"names":[],"mappings":";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