@intlayer/backend 5.4.2 → 5.5.0-canary.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/dist/cjs/controllers/ai.controller.cjs +60 -52
- package/dist/cjs/controllers/ai.controller.cjs.map +1 -1
- package/dist/cjs/controllers/dictionary.controller.cjs +5 -0
- package/dist/cjs/controllers/dictionary.controller.cjs.map +1 -1
- package/dist/cjs/export.cjs +4 -2
- package/dist/cjs/export.cjs.map +1 -1
- package/dist/cjs/routes/ai.routes.cjs +6 -0
- package/dist/cjs/routes/ai.routes.cjs.map +1 -1
- package/dist/cjs/services/dictionary.service.cjs +6 -1
- package/dist/cjs/services/dictionary.service.cjs.map +1 -1
- package/dist/cjs/utils/AI/aiSdk.cjs +140 -0
- package/dist/cjs/utils/AI/aiSdk.cjs.map +1 -0
- package/dist/cjs/utils/AI/askDocQuestion/PROMPT.md +2 -1
- package/dist/cjs/utils/AI/askDocQuestion/askDocQuestion.cjs +32 -27
- package/dist/cjs/utils/AI/askDocQuestion/askDocQuestion.cjs.map +1 -1
- package/dist/cjs/utils/AI/askDocQuestion/embeddings.json +7374 -0
- package/dist/cjs/utils/AI/auditDictionary/PROMPT.md +4 -0
- package/dist/cjs/utils/AI/auditDictionary/index.cjs +36 -43
- package/dist/cjs/utils/AI/auditDictionary/index.cjs.map +1 -1
- package/dist/cjs/utils/AI/auditDictionaryField/PROMPT.md +4 -0
- package/dist/cjs/utils/AI/auditDictionaryField/index.cjs +34 -28
- package/dist/cjs/utils/AI/auditDictionaryField/index.cjs.map +1 -1
- package/dist/cjs/utils/AI/auditDictionaryMetadata/PROMPT.md +4 -0
- package/dist/cjs/utils/AI/auditDictionaryMetadata/index.cjs +23 -23
- package/dist/cjs/utils/AI/auditDictionaryMetadata/index.cjs.map +1 -1
- package/dist/cjs/utils/{auditTag → AI/auditTag}/PROMPT.md +4 -0
- package/dist/cjs/utils/{auditTag → AI/auditTag}/index.cjs +27 -27
- package/dist/cjs/utils/AI/auditTag/index.cjs.map +1 -0
- package/dist/cjs/utils/AI/autocomplete/PROMPT.md +4 -0
- package/dist/cjs/utils/AI/autocomplete/index.cjs +25 -22
- package/dist/cjs/utils/AI/autocomplete/index.cjs.map +1 -1
- package/dist/cjs/utils/AI/translateJSON/PROMPT.md +53 -0
- package/dist/cjs/utils/AI/translateJSON/index.cjs +106 -0
- package/dist/cjs/utils/AI/translateJSON/index.cjs.map +1 -0
- package/dist/cjs/utils/extractJSON.cjs +52 -0
- package/dist/cjs/utils/extractJSON.cjs.map +1 -0
- package/dist/esm/controllers/ai.controller.mjs +58 -51
- package/dist/esm/controllers/ai.controller.mjs.map +1 -1
- package/dist/esm/controllers/dictionary.controller.mjs +5 -0
- package/dist/esm/controllers/dictionary.controller.mjs.map +1 -1
- package/dist/esm/export.mjs +3 -2
- package/dist/esm/export.mjs.map +1 -1
- package/dist/esm/routes/ai.routes.mjs +8 -1
- package/dist/esm/routes/ai.routes.mjs.map +1 -1
- package/dist/esm/services/dictionary.service.mjs +6 -1
- package/dist/esm/services/dictionary.service.mjs.map +1 -1
- package/dist/esm/utils/AI/aiSdk.mjs +115 -0
- package/dist/esm/utils/AI/aiSdk.mjs.map +1 -0
- package/dist/esm/utils/AI/askDocQuestion/PROMPT.md +2 -1
- package/dist/esm/utils/AI/askDocQuestion/askDocQuestion.mjs +32 -27
- package/dist/esm/utils/AI/askDocQuestion/askDocQuestion.mjs.map +1 -1
- package/dist/esm/utils/AI/askDocQuestion/embeddings.json +7374 -0
- package/dist/esm/utils/AI/auditDictionary/PROMPT.md +4 -0
- package/dist/esm/utils/AI/auditDictionary/index.mjs +36 -43
- package/dist/esm/utils/AI/auditDictionary/index.mjs.map +1 -1
- package/dist/esm/utils/AI/auditDictionaryField/PROMPT.md +4 -0
- package/dist/esm/utils/AI/auditDictionaryField/index.mjs +34 -28
- package/dist/esm/utils/AI/auditDictionaryField/index.mjs.map +1 -1
- package/dist/esm/utils/AI/auditDictionaryMetadata/PROMPT.md +4 -0
- package/dist/esm/utils/AI/auditDictionaryMetadata/index.mjs +23 -23
- package/dist/esm/utils/AI/auditDictionaryMetadata/index.mjs.map +1 -1
- package/dist/esm/utils/{auditTag → AI/auditTag}/PROMPT.md +4 -0
- package/dist/esm/utils/AI/auditTag/index.mjs +49 -0
- package/dist/esm/utils/AI/auditTag/index.mjs.map +1 -0
- package/dist/esm/utils/AI/autocomplete/PROMPT.md +4 -0
- package/dist/esm/utils/AI/autocomplete/index.mjs +25 -22
- package/dist/esm/utils/AI/autocomplete/index.mjs.map +1 -1
- package/dist/esm/utils/AI/translateJSON/PROMPT.md +53 -0
- package/dist/esm/utils/AI/translateJSON/index.mjs +81 -0
- package/dist/esm/utils/AI/translateJSON/index.mjs.map +1 -0
- package/dist/esm/utils/extractJSON.mjs +28 -0
- package/dist/esm/utils/extractJSON.mjs.map +1 -0
- package/dist/types/controllers/ai.controller.d.ts +12 -21
- package/dist/types/controllers/ai.controller.d.ts.map +1 -1
- package/dist/types/controllers/dictionary.controller.d.ts.map +1 -1
- package/dist/types/export.d.ts +12 -11
- package/dist/types/export.d.ts.map +1 -1
- package/dist/types/routes/ai.routes.d.ts +5 -0
- package/dist/types/routes/ai.routes.d.ts.map +1 -1
- package/dist/types/services/dictionary.service.d.ts +2 -2
- package/dist/types/services/dictionary.service.d.ts.map +1 -1
- package/dist/types/utils/AI/aiSdk.d.ts +41 -0
- package/dist/types/utils/AI/aiSdk.d.ts.map +1 -0
- package/dist/types/utils/AI/askDocQuestion/askDocQuestion.d.ts +1 -1
- package/dist/types/utils/AI/askDocQuestion/askDocQuestion.d.ts.map +1 -1
- package/dist/types/utils/AI/auditDictionary/index.d.ts +10 -15
- package/dist/types/utils/AI/auditDictionary/index.d.ts.map +1 -1
- package/dist/types/utils/AI/auditDictionaryField/index.d.ts +9 -14
- package/dist/types/utils/AI/auditDictionaryField/index.d.ts.map +1 -1
- package/dist/types/utils/AI/auditDictionaryMetadata/index.d.ts +7 -13
- package/dist/types/utils/AI/auditDictionaryMetadata/index.d.ts.map +1 -1
- package/dist/types/utils/AI/auditTag/index.d.ts +18 -0
- package/dist/types/utils/AI/auditTag/index.d.ts.map +1 -0
- package/dist/types/utils/AI/autocomplete/index.d.ts +6 -12
- package/dist/types/utils/AI/autocomplete/index.d.ts.map +1 -1
- package/dist/types/utils/AI/translateJSON/index.d.ts +24 -0
- package/dist/types/utils/AI/translateJSON/index.d.ts.map +1 -0
- package/dist/types/utils/extractJSON.d.ts +6 -0
- package/dist/types/utils/extractJSON.d.ts.map +1 -0
- package/package.json +13 -7
- package/dist/cjs/utils/auditTag/index.cjs.map +0 -1
- package/dist/esm/utils/auditTag/index.mjs +0 -49
- package/dist/esm/utils/auditTag/index.mjs.map +0 -1
- package/dist/types/utils/auditTag/index.d.ts +0 -30
- package/dist/types/utils/auditTag/index.d.ts.map +0 -1
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
You are an expert in internationalization, copy writing and content management. Your task is to audit the content declaration files in the project and identify any potential issues or inconsistencies. Provide a detailed report of any issues found, including the file path, line number, and a brief explanation of the issue.
|
|
2
|
+
|
|
3
|
+
**Instructions:**
|
|
4
|
+
|
|
5
|
+
2. **Audit Requirements:**
|
|
6
|
+
|
|
7
|
+
- **Consistency:** The dictionary format should be the same as the one provided in entry. You should not rename or translate the entry keys.
|
|
8
|
+
- **Missing Content:** Identify any missing translations and specify the expected content.
|
|
9
|
+
- **Misplaced Content:** Detect if any translations are placed under incorrect keys.
|
|
10
|
+
- **Type Compliance:** Verify that the content types match the declarations (e.g., strings, string arrays).
|
|
11
|
+
|
|
12
|
+
3. **Modification Guidelines:**
|
|
13
|
+
|
|
14
|
+
- **Do Not Alter Structure:** If the file structure is correct, do not modify it. Only add, update, or remove content declarations as necessary.
|
|
15
|
+
- **Return Only Final File Content:** Provide the updated file content without any additional comments or explanations.
|
|
16
|
+
- **Manage Localizations:** If the output languages targeted is a variant contains similar languages, as `en` and `en-GB`, consider `en` as English US, and adapt it into `en-GB` as English UK.
|
|
17
|
+
- **Conflict between language and content:** If you detect a conflict between the language and content, translate it if the Mode Instruction is in 'review' mode
|
|
18
|
+
- **Escape Special Characters:** If the translations contain special characters, escape them using the appropriate escape sequence.
|
|
19
|
+
- **Respect the tags and description instructions:** If the tags and description instructions are provided, ensure that the audited file adheres to them.
|
|
20
|
+
- **Consider the Preset Output Content** If Preset Output Content is provided, and coherent with the entry, you can consider reuse it to fill the output file content.
|
|
21
|
+
- **TypeNode field should not be translated** A value as `{ 'nodeType': 'XXX', ...}` should not be translated.
|
|
22
|
+
|
|
23
|
+
**Application Context**
|
|
24
|
+
|
|
25
|
+
{{applicationContext}}
|
|
26
|
+
|
|
27
|
+
**Mode Instruction:**
|
|
28
|
+
|
|
29
|
+
{{modeInstructions}}
|
|
30
|
+
|
|
31
|
+
**Tags Instructions:**
|
|
32
|
+
|
|
33
|
+
{{tagsInstructions}}
|
|
34
|
+
|
|
35
|
+
**Dictionary Description:**
|
|
36
|
+
|
|
37
|
+
{{dictionaryDescription}}
|
|
38
|
+
|
|
39
|
+
**Entry Content to Translate:**
|
|
40
|
+
|
|
41
|
+
- Given Language: {{entryLocale}}
|
|
42
|
+
|
|
43
|
+
{{entryFileContent}}
|
|
44
|
+
|
|
45
|
+
**Preset Output Content:**
|
|
46
|
+
|
|
47
|
+
- Target Language: {{outputLocale}}
|
|
48
|
+
|
|
49
|
+
{{presetOutputContent}}
|
|
50
|
+
|
|
51
|
+
**Expected Response:**
|
|
52
|
+
|
|
53
|
+
After auditing, provide only the final content of the file as plain text without any Markdown or code block formatting. If no changes are needed, return the file content exactly as it is.
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { retryManager } from "@intlayer/config";
|
|
2
|
+
import { getLocaleName } from "@intlayer/core";
|
|
3
|
+
import { logger } from "./../../../logger/index.mjs";
|
|
4
|
+
import { extractJson } from "./../../../utils/extractJSON.mjs";
|
|
5
|
+
import { generateText } from "ai";
|
|
6
|
+
import { readFileSync } from "fs";
|
|
7
|
+
import { dirname, join } from "path";
|
|
8
|
+
import { fileURLToPath } from "url";
|
|
9
|
+
import { AIProvider, getAIConfig } from "../aiSdk.mjs";
|
|
10
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
11
|
+
const getFileContent = (filePath) => {
|
|
12
|
+
return readFileSync(join(__dirname, filePath), { encoding: "utf-8" });
|
|
13
|
+
};
|
|
14
|
+
const CHAT_GPT_PROMPT = getFileContent("./PROMPT.md");
|
|
15
|
+
const formatLocaleWithName = (locale) => {
|
|
16
|
+
return `${locale}: ${getLocaleName(locale)}`;
|
|
17
|
+
};
|
|
18
|
+
const formatTagInstructions = (tags) => {
|
|
19
|
+
if (!tags || tags.length === 0) {
|
|
20
|
+
return "";
|
|
21
|
+
}
|
|
22
|
+
return `Based on the dictionary content, identify specific tags from the list below that would be relevant:
|
|
23
|
+
|
|
24
|
+
${tags.map(({ key, description }) => `- ${key}: ${description}`).join("\n\n")}`;
|
|
25
|
+
};
|
|
26
|
+
const getModeInstructions = (mode) => {
|
|
27
|
+
if (mode === "complete") {
|
|
28
|
+
return 'Mode: "Complete" - Enrich the preset content with the missing keys and values. Do not update existing keys. Everything should be returned in the output.';
|
|
29
|
+
}
|
|
30
|
+
return 'Mode: "Review" - Fill missing content and review existing keys from the preset content. If you detect misspelled content, or content should be reformulated, correct it.';
|
|
31
|
+
};
|
|
32
|
+
const translateJSON = async ({
|
|
33
|
+
entryFileContent,
|
|
34
|
+
presetOutputContent,
|
|
35
|
+
dictionaryDescription,
|
|
36
|
+
aiOptions,
|
|
37
|
+
entryLocale,
|
|
38
|
+
outputLocale,
|
|
39
|
+
tags,
|
|
40
|
+
mode
|
|
41
|
+
}) => {
|
|
42
|
+
try {
|
|
43
|
+
const aiConfig = await getAIConfig({
|
|
44
|
+
provider: AIProvider.OPENAI,
|
|
45
|
+
model: "gpt-4o-mini-2024-07-18",
|
|
46
|
+
...aiOptions
|
|
47
|
+
});
|
|
48
|
+
const prompt = CHAT_GPT_PROMPT.replace(
|
|
49
|
+
"{{entryLocale}}",
|
|
50
|
+
formatLocaleWithName(entryLocale)
|
|
51
|
+
).replace("{{outputLocale}}", formatLocaleWithName(outputLocale)).replace("{{entryFileContent}}", JSON.stringify(entryFileContent)).replace("{{presetOutputContent}}", JSON.stringify(presetOutputContent)).replace("{{dictionaryDescription}}", dictionaryDescription).replace("{{applicationContext}}", aiOptions?.applicationContext ?? "").replace("{{tagsInstructions}}", formatTagInstructions(tags)).replace("{{modeInstructions}}", getModeInstructions(mode));
|
|
52
|
+
if (!aiConfig) {
|
|
53
|
+
logger.error("Failed to configure AI model");
|
|
54
|
+
return void 0;
|
|
55
|
+
}
|
|
56
|
+
const result = await retryManager(async () => {
|
|
57
|
+
const { text: newContent, usage } = await generateText({
|
|
58
|
+
model: aiConfig.model,
|
|
59
|
+
temperature: aiConfig.temperature,
|
|
60
|
+
messages: [{ role: "system", content: prompt }]
|
|
61
|
+
});
|
|
62
|
+
logger.info(`${usage?.totalTokens ?? 0} tokens used in the request`);
|
|
63
|
+
return {
|
|
64
|
+
fileContent: extractJson(newContent),
|
|
65
|
+
tokenUsed: usage?.totalTokens ?? 0
|
|
66
|
+
};
|
|
67
|
+
})();
|
|
68
|
+
return {
|
|
69
|
+
fileContent: result.fileContent,
|
|
70
|
+
tokenUsed: result.tokenUsed
|
|
71
|
+
};
|
|
72
|
+
} catch (error) {
|
|
73
|
+
logger.error("Error translating JSON:" + error, {
|
|
74
|
+
level: "error"
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
export {
|
|
79
|
+
translateJSON
|
|
80
|
+
};
|
|
81
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/utils/AI/translateJSON/index.ts"],"sourcesContent":["import type { Tag } from '@/types/tag.types';\nimport { retryManager } from '@intlayer/config';\nimport { getLocaleName } from '@intlayer/core';\nimport { logger } from '@logger';\nimport { extractJson } from '@utils/extractJSON';\nimport { generateText } from 'ai';\nimport { readFileSync } from 'fs';\nimport type { Locales } from 'intlayer';\nimport { dirname, join } from 'path';\nimport { fileURLToPath } from 'url';\nimport { AIOptions, AIProvider, getAIConfig } from '../aiSdk';\n\nconst __dirname = dirname(fileURLToPath(import.meta.url));\n\n// Get the content of a file at the specified path\nconst getFileContent = (filePath: string) => {\n return readFileSync(join(__dirname, filePath), { encoding: 'utf-8' });\n};\n\nexport type TranslateJSONOptions = {\n entryFileContent: JSON;\n presetOutputContent: JSON;\n dictionaryDescription: string;\n entryLocale: Locales;\n outputLocale: Locales;\n tags: Tag[];\n aiOptions?: AIOptions;\n mode: 'complete' | 'review';\n};\n\nexport type TranslateJSONResultData = {\n fileContent: string;\n tokenUsed: number;\n};\n\n// The prompt template to send to the AI model\nconst CHAT_GPT_PROMPT = getFileContent('./PROMPT.md');\n\n/**\n * Format a locale with its name.\n *\n * @param locale - The locale to format.\n * @returns A string in the format \"locale: name\", e.g. \"en: English\".\n */\nconst formatLocaleWithName = (locale: Locales): string => {\n return `${locale}: ${getLocaleName(locale)}`;\n};\n\n/**\n * Formats tag instructions for the AI prompt.\n * Creates a string with all available tags and their descriptions.\n *\n * @param tags - The list of tags to format.\n * @returns A formatted string with tag instructions.\n */\nconst formatTagInstructions = (tags: Tag[]): string => {\n if (!tags || tags.length === 0) {\n return '';\n }\n\n // Prepare the tag instructions.\n return `Based on the dictionary content, identify specific tags from the list below that would be relevant:\n \n${tags.map(({ key, description }) => `- ${key}: ${description}`).join('\\n\\n')}`;\n};\n\nconst getModeInstructions = (mode: 'complete' | 'review'): string => {\n if (mode === 'complete') {\n return 'Mode: \"Complete\" - Enrich the preset content with the missing keys and values. Do not update existing keys. Everything should be returned in the output.';\n }\n\n return 'Mode: \"Review\" - Fill missing content and review existing keys from the preset content. If you detect misspelled content, or content should be reformulated, correct it.';\n};\n\n/**\n * TranslateJSONs a content declaration file by constructing a prompt for AI models.\n * The prompt includes details about the project's locales, file paths of content declarations,\n * and requests for identifying issues or inconsistencies.\n */\nexport const translateJSON = async ({\n entryFileContent,\n presetOutputContent,\n dictionaryDescription,\n aiOptions,\n entryLocale,\n outputLocale,\n tags,\n mode,\n}: TranslateJSONOptions): Promise<TranslateJSONResultData | undefined> => {\n try {\n // Get the appropriate AI model configuration\n const aiConfig = await getAIConfig({\n provider: AIProvider.OPENAI,\n model: 'gpt-4o-mini-2024-07-18',\n ...aiOptions,\n });\n\n // Prepare the prompt for AI by replacing placeholders with actual values.\n const prompt = CHAT_GPT_PROMPT.replace(\n '{{entryLocale}}',\n formatLocaleWithName(entryLocale)\n )\n .replace('{{outputLocale}}', formatLocaleWithName(outputLocale))\n .replace('{{entryFileContent}}', JSON.stringify(entryFileContent))\n .replace('{{presetOutputContent}}', JSON.stringify(presetOutputContent))\n .replace('{{dictionaryDescription}}', dictionaryDescription)\n .replace('{{applicationContext}}', aiOptions?.applicationContext ?? '')\n .replace('{{tagsInstructions}}', formatTagInstructions(tags))\n .replace('{{modeInstructions}}', getModeInstructions(mode));\n\n if (!aiConfig) {\n logger.error('Failed to configure AI model');\n return undefined;\n }\n\n const result = await retryManager(async () => {\n // Use the AI SDK to generate the completion\n const { text: newContent, usage } = await generateText({\n model: aiConfig.model,\n temperature: aiConfig.temperature,\n messages: [{ role: 'system', content: prompt }],\n });\n\n logger.info(`${usage?.totalTokens ?? 0} tokens used in the request`);\n\n return {\n fileContent: extractJson(newContent),\n tokenUsed: usage?.totalTokens ?? 0,\n };\n })();\n\n return {\n fileContent: result.fileContent,\n tokenUsed: result.tokenUsed,\n };\n } catch (error) {\n logger.error('Error translating JSON:' + error, {\n level: 'error',\n });\n }\n};\n"],"mappings":"AACA,SAAS,oBAAoB;AAC7B,SAAS,qBAAqB;AAC9B,SAAS,cAAc;AACvB,SAAS,mBAAmB;AAC5B,SAAS,oBAAoB;AAC7B,SAAS,oBAAoB;AAE7B,SAAS,SAAS,YAAY;AAC9B,SAAS,qBAAqB;AAC9B,SAAoB,YAAY,mBAAm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AAC;AAE5D,QAAI,CAAC,UAAU;AACb,aAAO,MAAM,8BAA8B;AAC3C,aAAO;AAAA,IACT;AAEA,UAAM,SAAS,MAAM,aAAa,YAAY;AAE5C,YAAM,EAAE,MAAM,YAAY,MAAM,IAAI,MAAM,aAAa;AAAA,QACrD,OAAO,SAAS;AAAA,QAChB,aAAa,SAAS;AAAA,QACtB,UAAU,CAAC,EAAE,MAAM,UAAU,SAAS,OAAO,CAAC;AAAA,MAChD,CAAC;AAED,aAAO,KAAK,GAAG,OAAO,eAAe,CAAC,6BAA6B;AAEnE,aAAO;AAAA,QACL,aAAa,YAAY,UAAU;AAAA,QACnC,WAAW,OAAO,eAAe;AAAA,MACnC;AAAA,IACF,CAAC,EAAE;AAEH,WAAO;AAAA,MACL,aAAa,OAAO;AAAA,MACpB,WAAW,OAAO;AAAA,IACpB;AAAA,EACF,SAAS,OAAO;AACd,WAAO,MAAM,4BAA4B,OAAO;AAAA,MAC9C,OAAO;AAAA,IACT,CAAC;AAAA,EACH;AACF;","names":[]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const extractJson = (input) => {
|
|
2
|
+
const opening = input.match(/[{[]/);
|
|
3
|
+
if (!opening) throw new Error("No JSON start character ({ or [) found.");
|
|
4
|
+
const startIdx = opening.index;
|
|
5
|
+
const openChar = input[startIdx];
|
|
6
|
+
const closeChar = openChar === "{" ? "}" : "]";
|
|
7
|
+
let depth = 0;
|
|
8
|
+
for (let i = startIdx; i < input.length; i++) {
|
|
9
|
+
const char = input[i];
|
|
10
|
+
if (char === openChar) depth++;
|
|
11
|
+
else if (char === closeChar) {
|
|
12
|
+
depth--;
|
|
13
|
+
if (depth === 0) {
|
|
14
|
+
const jsonSubstring = input.slice(startIdx, i + 1);
|
|
15
|
+
try {
|
|
16
|
+
return JSON.parse(jsonSubstring);
|
|
17
|
+
} catch (err) {
|
|
18
|
+
throw new Error(`Failed to parse JSON: ${err.message}`);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
throw new Error("Reached end of input without closing JSON bracket.");
|
|
24
|
+
};
|
|
25
|
+
export {
|
|
26
|
+
extractJson
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=extractJSON.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/extractJSON.ts"],"sourcesContent":["/**\n * Extracts the first JSON value (object or array) from a string.\n * Returns the parsed value, or throws if no valid JSON is found.\n */\nexport const extractJson = <T = any>(input: string): T => {\n const opening = input.match(/[{[]/);\n if (!opening) throw new Error('No JSON start character ({ or [) found.');\n\n const startIdx = opening.index!;\n const openChar = input[startIdx];\n const closeChar = openChar === '{' ? '}' : ']';\n let depth = 0;\n\n for (let i = startIdx; i < input.length; i++) {\n const char = input[i];\n if (char === openChar) depth++;\n else if (char === closeChar) {\n depth--;\n if (depth === 0) {\n const jsonSubstring = input.slice(startIdx, i + 1);\n try {\n return JSON.parse(jsonSubstring) as T;\n } catch (err) {\n throw new Error(`Failed to parse JSON: ${(err as Error).message}`);\n }\n }\n }\n }\n\n throw new Error('Reached end of input without closing JSON bracket.');\n};\n"],"mappings":"AAIO,MAAM,cAAc,CAAU,UAAqB;AACxD,QAAM,UAAU,MAAM,MAAM,MAAM;AAClC,MAAI,CAAC,QAAS,OAAM,IAAI,MAAM,yCAAyC;AAEvE,QAAM,WAAW,QAAQ;AACzB,QAAM,WAAW,MAAM,QAAQ;AAC/B,QAAM,YAAY,aAAa,MAAM,MAAM;AAC3C,MAAI,QAAQ;AAEZ,WAAS,IAAI,UAAU,IAAI,MAAM,QAAQ,KAAK;AAC5C,UAAM,OAAO,MAAM,CAAC;AACpB,QAAI,SAAS,SAAU;AAAA,aACd,SAAS,WAAW;AAC3B;AACA,UAAI,UAAU,GAAG;AACf,cAAM,gBAAgB,MAAM,MAAM,UAAU,IAAI,CAAC;AACjD,YAAI;AACF,iBAAO,KAAK,MAAM,aAAa;AAAA,QACjC,SAAS,KAAK;AACZ,gBAAM,IAAI,MAAM,yBAA0B,IAAc,OAAO,EAAE;AAAA,QACnE;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,QAAM,IAAI,MAAM,oDAAoD;AACtE;","names":[]}
|
|
@@ -1,20 +1,24 @@
|
|
|
1
1
|
import type { Tag } from '../types/tag.types';
|
|
2
2
|
import { type KeyPath } from '@intlayer/core';
|
|
3
3
|
import type { ResponseWithInformation } from '../middlewares/sessionAuth.middleware';
|
|
4
|
+
import { AIOptions } from '../utils/AI/aiSdk';
|
|
4
5
|
import * as askDocQuestionUtil from '../utils/AI/askDocQuestion/askDocQuestion';
|
|
5
6
|
import * as auditContentDeclarationUtil from '../utils/AI/auditDictionary';
|
|
7
|
+
import * as translateJSONUtil from '../utils/AI/translateJSON';
|
|
6
8
|
import { type ResponseData } from '../utils/responseData';
|
|
7
9
|
import type { NextFunction, Request } from 'express';
|
|
8
10
|
import type { Locales } from 'intlayer';
|
|
11
|
+
export type TranslateJSONBody = Omit<translateJSONUtil.TranslateJSONOptions, 'tags'> & {
|
|
12
|
+
tagsKeys?: string[];
|
|
13
|
+
};
|
|
14
|
+
export type TranslateJSONResult = ResponseData<translateJSONUtil.TranslateJSONResultData>;
|
|
15
|
+
export declare const translateJSON: (req: Request<AuditContentDeclarationBody>, res: ResponseWithInformation<TranslateJSONResult>, _next: NextFunction) => Promise<void>;
|
|
9
16
|
export type AuditContentDeclarationBody = {
|
|
10
|
-
|
|
11
|
-
customPrompt?: string;
|
|
17
|
+
aiOptions?: AIOptions;
|
|
12
18
|
locales: Locales[];
|
|
13
19
|
defaultLocale: Locales;
|
|
14
20
|
fileContent: string;
|
|
15
21
|
filePath?: string;
|
|
16
|
-
model?: string;
|
|
17
|
-
temperature?: number;
|
|
18
22
|
tagsKeys?: string[];
|
|
19
23
|
};
|
|
20
24
|
export type AuditContentDeclarationResult = ResponseData<auditContentDeclarationUtil.AuditFileResultData>;
|
|
@@ -23,13 +27,10 @@ export type AuditContentDeclarationResult = ResponseData<auditContentDeclaration
|
|
|
23
27
|
*/
|
|
24
28
|
export declare const auditContentDeclaration: (req: Request<AuditContentDeclarationBody>, res: ResponseWithInformation<AuditContentDeclarationResult>, _next: NextFunction) => Promise<void>;
|
|
25
29
|
export type AuditContentDeclarationFieldBody = {
|
|
26
|
-
|
|
27
|
-
customPrompt?: string;
|
|
30
|
+
aiOptions?: AIOptions;
|
|
28
31
|
locales: Locales[];
|
|
29
32
|
fileContent: string;
|
|
30
33
|
filePath?: string;
|
|
31
|
-
model?: string;
|
|
32
|
-
temperature?: number;
|
|
33
34
|
tagsKeys?: string[];
|
|
34
35
|
keyPath: KeyPath[];
|
|
35
36
|
};
|
|
@@ -39,11 +40,8 @@ export type AuditContentDeclarationFieldResult = ResponseData<auditContentDeclar
|
|
|
39
40
|
*/
|
|
40
41
|
export declare const auditContentDeclarationField: (req: Request<AuditContentDeclarationFieldBody>, res: ResponseWithInformation<AuditContentDeclarationFieldResult>, _next: NextFunction) => Promise<void>;
|
|
41
42
|
export type AuditContentDeclarationMetadataBody = {
|
|
42
|
-
|
|
43
|
-
customPrompt?: string;
|
|
43
|
+
aiOptions?: AIOptions;
|
|
44
44
|
fileContent: string;
|
|
45
|
-
model?: string;
|
|
46
|
-
temperature?: number;
|
|
47
45
|
};
|
|
48
46
|
export type AuditContentDeclarationMetadataResult = ResponseData<auditContentDeclarationUtil.AuditFileResultData>;
|
|
49
47
|
/**
|
|
@@ -51,11 +49,7 @@ export type AuditContentDeclarationMetadataResult = ResponseData<auditContentDec
|
|
|
51
49
|
*/
|
|
52
50
|
export declare const auditContentDeclarationMetadata: (req: Request<AuditContentDeclarationMetadataBody>, res: ResponseWithInformation<AuditContentDeclarationMetadataResult>, _next: NextFunction) => Promise<void>;
|
|
53
51
|
export type AuditTagBody = {
|
|
54
|
-
|
|
55
|
-
customPrompt?: string;
|
|
56
|
-
filePath?: string;
|
|
57
|
-
model?: string;
|
|
58
|
-
temperature?: number;
|
|
52
|
+
aiOptions?: AIOptions;
|
|
59
53
|
tag: Tag;
|
|
60
54
|
};
|
|
61
55
|
export type AuditTagResult = ResponseData<auditContentDeclarationUtil.AuditFileResultData>;
|
|
@@ -71,10 +65,7 @@ export type AskDocQuestionResult = ResponseData<askDocQuestionUtil.AskDocQuestio
|
|
|
71
65
|
export declare const askDocQuestion: (req: Request<undefined, undefined, AskDocQuestionBody>, res: ResponseWithInformation<AskDocQuestionResult>) => Promise<void>;
|
|
72
66
|
export type AutocompleteBody = {
|
|
73
67
|
text: string;
|
|
74
|
-
|
|
75
|
-
temperature?: number;
|
|
76
|
-
openAiApiKey?: string;
|
|
77
|
-
customPrompt?: string;
|
|
68
|
+
aiOptions?: AIOptions;
|
|
78
69
|
};
|
|
79
70
|
export type AutocompleteResponse = ResponseData<{
|
|
80
71
|
autocompletion: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai.controller.d.ts","sourceRoot":"","sources":["../../../src/controllers/ai.controller.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AAInF,OAAO,KAAK,kBAAkB,MAAM,yCAAyC,CAAC;AAC9E,OAAO,KAAK,2BAA2B,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"ai.controller.d.ts","sourceRoot":"","sources":["../../../src/controllers/ai.controller.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AAInF,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,kBAAk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EF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,EAAE,kBAAkB,CAAC,4BAA4B,EAAE,CAAC;IAC5D,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AACF,MAAM,MAAM,oBAAoB,GAC9B,YAAY,CAAC,kBAAkB,CAAC,oBAAoB,CAAC,CAAC;AAExD,eAAO,MAAM,cAAc,GACzB,KAAK,OAAO,CAAC,SAAS,EAAE,SAAS,EAAE,kBAAkB,CAAC,EACtD,KAAK,uBAAuB,CAAC,oBAAoB,CAAC,kBAuDnD,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,YAAY,CAAC;IAC9C,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC,CAAC;AAEH,eAAO,MAAM,YAAY,GACvB,KAAK,OAAO,CAAC,SAAS,EAAE,SAAS,EAAE,gBAAgB,CAAC,EACpD,KAAK,uBAAuB,CAAC,oBAAoB,CAAC,kBAkCnD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dictionary.controller.d.ts","sourceRoot":"","sources":["../../../src/controllers/dictionary.controller.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,aAAa,EACb,sBAAsB,EAGvB,MAAM,0BAA0B,CAAC;AAElC,OAAO,KAAK,EAEV,UAAU,IAAI,eAAe,EAC9B,MAAM,gBAAgB,CAAC;AAExB,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AAInF,OAAO,EACL,KAAK,uBAAuB,EAE7B,MAAM,+DAA+D,CAAC;AACvE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,6DAA6D,CAAC;AAExG,OAAO,EAGL,KAAK,iBAAiB,EACtB,KAAK,YAAY,EAClB,MAAM,qBAAqB,CAAC;AAC7B,OAA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,MAAM,gBAAgB,GAC3B,KAAK,OAAO,CAAC,qBAAqB,CAAC,EACnC,KAAK,uBAAuB,CAAC,sBAAsB,CAAC,EACpD,OAAO,YAAY,KAClB,OAAO,CAAC,IAAI,
|
|
1
|
+
{"version":3,"file":"dictionary.controller.d.ts","sourceRoot":"","sources":["../../../src/controllers/dictionary.controller.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,aAAa,EACb,sBAAsB,EAGvB,MAAM,0BAA0B,CAAC;AAElC,OAAO,KAAK,EAEV,UAAU,IAAI,eAAe,EAC9B,MAAM,gBAAgB,CAAC;AAExB,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AAInF,OAAO,EACL,KAAK,uBAAuB,EAE7B,MAAM,+DAA+D,CAAC;AACvE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,6DAA6D,CAAC;AAExG,OAAO,EAGL,KAAK,iBAAiB,EACtB,KAAK,YAAY,EAClB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAGrD,MAAM,MAAM,qBAAqB,GAC/B,oBAAoB,CAAC,uBAAuB,CAAC,CAAC;AAChD,MAAM,MAAM,qBAAqB,GAAG,iBAAiB,CAAC,aAAa,CAAC,CAAC;AAErE;;GAEG;AACH,eAAO,MAAM,eAAe,GAC1B,KAAK,OAAO,CAAC,qBAAqB,CAAC,EACnC,KAAK,uBAAuB,CAAC,qBAAqB,CAAC,EACnD,OAAO,YAAY,KAClB,OAAO,CAAC,IAAI,CA+Cd,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG,YAAY,CAAC,MAAM,EAAE,CAAC,CAAC;AAE/D;;GAEG;AACH,eAAO,MAAM,mBAAmB,GAC9B,MAAM,OAAO,EACb,KAAK,uBAAuB,CAAC,yBAAyB,CAAC,EACvD,OAAO,YAAY,kBA4BpB,CAAC;AAEF,MAAM,MAAM,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AAuB,CAAC,sBAAsB,CAAC,EACpD,OAAO,YAAY,KAClB,OAAO,CAAC,IAAI,CAkMd,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAAE,YAAY,EAAE,MAAM,CAAA;CAAE,CAAC;AAC7D,MAAM,MAAM,oBAAoB,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AACvD,MAAM,MAAM,sBAAsB,GAAG,YAAY,CAAC,aAAa,CAAC,CAAC;AAEjE;;GAEG;AACH,eAAO,MAAM,gBAAgB,GAC3B,KAAK,OAAO,CAAC,qBAAqB,EAAE,GAAG,EAAE,oBAAoB,CAAC,EAC9D,KAAK,uBAAuB,CAAC,sBAAsB,CAAC,EACpD,OAAO,YAAY,KAClB,OAAO,CAAC,IAAI,CAiEd,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAAE,YAAY,EAAE,MAAM,CAAA;CAAE,CAAC;AAC7D,MAAM,MAAM,sBAAsB,GAAG,YAAY,CAAC,aAAa,CAAC,CAAC;AAEjE;;GAEG;AACH,eAAO,MAAM,gBAAgB,GAC3B,KAAK,OAAO,CAAC,qBAAqB,CAAC,EACnC,KAAK,uBAAuB,CAAC,sBAAsB,CAAC,EACpD,OAAO,YAAY,KAClB,OAAO,CAAC,IAAI,CAmFd,CAAC"}
|
package/dist/types/export.d.ts
CHANGED
|
@@ -1,26 +1,27 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { getDictionaryRoutes } from './routes/dictionary.routes';
|
|
2
2
|
export { getOrganizationRoutes } from './routes/organization.routes';
|
|
3
3
|
export { getProjectRoutes } from './routes/project.routes';
|
|
4
|
-
export { getDictionaryRoutes } from './routes/dictionary.routes';
|
|
5
4
|
export { getSessionAuthRoutes } from './routes/sessionAuth.routes';
|
|
6
|
-
export
|
|
5
|
+
export { getUserRoutes } from './routes/user.routes';
|
|
6
|
+
export type * from './controllers/ai.controller';
|
|
7
|
+
export type * from './controllers/dictionary.controller';
|
|
8
|
+
export type * from './controllers/eventListener.controller';
|
|
7
9
|
export type * from './controllers/oAuth2.controller';
|
|
8
10
|
export type * from './controllers/organization.controller';
|
|
9
|
-
export type * from './controllers/eventListener.controller';
|
|
10
11
|
export type * from './controllers/project.controller';
|
|
11
12
|
export type * from './controllers/projectAccessKey.controller';
|
|
12
|
-
export type * from './controllers/
|
|
13
|
-
export type * from './controllers/dictionary.controller';
|
|
13
|
+
export type * from './controllers/sessionAuth.controller';
|
|
14
14
|
export type * from './controllers/stripe.controller';
|
|
15
|
-
export type * from './controllers/ai.controller';
|
|
16
15
|
export type * from './controllers/tag.controller';
|
|
17
|
-
export type * from './
|
|
18
|
-
export type * from './types/project.types';
|
|
19
|
-
export type * from './types/user.types';
|
|
16
|
+
export type * from './controllers/user.controller';
|
|
20
17
|
export type * from './types/dictionary.types';
|
|
18
|
+
export type * from './types/oAuth2.types';
|
|
19
|
+
export type * from './types/organization.types';
|
|
21
20
|
export type * from './types/plan.types';
|
|
21
|
+
export type * from './types/project.types';
|
|
22
22
|
export type * from './types/tag.types';
|
|
23
|
-
export type * from './types/
|
|
23
|
+
export type * from './types/user.types';
|
|
24
|
+
export * from './utils/AI/aiSdk';
|
|
24
25
|
export * from './utils/cookies';
|
|
25
26
|
export * from './utils/httpStatusCodes';
|
|
26
27
|
export * from './utils/responseData';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"export.d.ts","sourceRoot":"","sources":["../../src/export.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"export.d.ts","sourceRoot":"","sources":["../../src/export.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGpD,mBAAmB,4BAA4B,CAAC;AAChD,mBAAmB,oCAAoC,CAAC;AACxD,mBAAmB,uCAAuC,CAAC;AAC3D,mBAAmB,gCAAgC,CAAC;AACpD,mBAAmB,sCAAsC,CAAC;AAC1D,mBAAmB,iCAAiC,CAAC;AACrD,mBAAmB,0CAA0C,CAAC;AAC9D,mBAAmB,qCAAqC,CAAC;AACzD,mBAAmB,gCAAgC,CAAC;AACpD,mBAAmB,6BAA6B,CAAC;AACjD,mBAAmB,8BAA8B,CAAC;AAGlD,mBAAmB,0BAA0B,CAAC;AAC9C,mBAAmB,sBAAsB,CAAC;AAC1C,mBAAmB,4BAA4B,CAAC;AAChD,mBAAmB,oBAAoB,CAAC;AACxC,mBAAmB,uBAAuB,CAAC;AAC3C,mBAAmB,mBAAmB,CAAC;AACvC,mBAAmB,oBAAoB,CAAC;AAGxC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC"}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { Router } from 'express';
|
|
2
2
|
export declare const aiRouter: Router;
|
|
3
3
|
export declare const getAiRoutes: () => {
|
|
4
|
+
translateJSON: {
|
|
5
|
+
urlModel: string;
|
|
6
|
+
url: string;
|
|
7
|
+
method: "POST";
|
|
8
|
+
};
|
|
4
9
|
auditContentDeclaration: {
|
|
5
10
|
urlModel: string;
|
|
6
11
|
url: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai.routes.d.ts","sourceRoot":"","sources":["../../../src/routes/ai.routes.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ai.routes.d.ts","sourceRoot":"","sources":["../../../src/routes/ai.routes.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEjC,eAAO,MAAM,QAAQ,EAAE,MAAiB,CAAC;AAIzC,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqCH,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { DictionaryFilters } from '../utils/filtersAndPagination/getDictionaryFiltersAndPagination';
|
|
2
|
-
import type { ObjectId } from 'mongoose';
|
|
3
1
|
import type { Dictionary, DictionaryData, DictionaryDocument } from '../types/dictionary.types';
|
|
4
2
|
import type { Project } from '../types/project.types';
|
|
3
|
+
import type { DictionaryFilters } from '../utils/filtersAndPagination/getDictionaryFiltersAndPagination';
|
|
4
|
+
import { type ObjectId } from 'mongoose';
|
|
5
5
|
/**
|
|
6
6
|
* Finds dictionaries based on filters and pagination options.
|
|
7
7
|
* @param filters - MongoDB filter query.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dictionary.service.d.ts","sourceRoot":"","sources":["../../../src/services/dictionary.service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dictionary.service.d.ts","sourceRoot":"","sources":["../../../src/services/dictionary.service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,cAAc,EACd,kBAAkB,EACnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAIrD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+DAA+D,CAAC;AAMvG,OAAO,EAAS,KAAK,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEhD;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,GAC3B,SAAS,iBAAiB,EAC1B,aAAQ,EACR,cAAW,KACV,OAAO,CAAC,kBAAkB,EAAE,CAsB9B,CAAC;AAEF;;;;GAIG;AACH;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAC5B,cAAc,MAAM,GAAG,QAAQ,KAC9B,OAAO,CAAC,kBAAkB,CA8B5B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,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,kBAAkB,CA2B5B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,GAC/B,cAAc,MAAM,KACnB,OAAO,CAAC,kBAAkB,CAY5B,CAAC;AAWF,eAAO,MAAM,gBAAgB,GAAI,YAAY,UAAU,KAAG,MAiBzD,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Supported AI models
|
|
3
|
+
*/
|
|
4
|
+
export type Model = 'gpt-4o-mini' | 'gpt-4o' | 'gpt-4.1' | 'gpt-4.1-mini' | 'gpt-4.1-nano' | 'gpt-4.5' | 'gpt-3.5-turbo' | 'gpt-4-turbo-preview' | 'gpt-4-vision-preview' | 'gpt-4o-audio-preview' | 'gpt-4o-mini-audio-preview' | 'o1-mini' | 'o1' | 'o1-pro' | 'o3-mini' | 'o3-mini-high' | 'o3' | 'o4-mini' | 'o4-mini-high' | 'claude-3-haiku-20240307' | 'claude-3-sonnet-20240229' | 'claude-3-opus-20240229' | 'mistral-tiny' | 'mistral-small' | 'mistral-small-3.1' | 'mistral-medium' | 'mistral-medium-3' | 'mistral-large' | 'mistral-large-2' | 'mistral-large-latest' | 'codestral' | 'codestral-mamba' | 'mixtral-8x7b' | 'mixtral-8x22b' | 'mathstral-7b' | 'pixtral-large' | 'deepseek-coder' | 'deepseek-chat' | 'deepseek-v3' | 'gemini-1.0-pro' | 'gemini-1.5-pro' | 'gemini-1.5-flash' | (string & {});
|
|
5
|
+
/**
|
|
6
|
+
* Supported AI SDK providers
|
|
7
|
+
*/
|
|
8
|
+
export declare enum AIProvider {
|
|
9
|
+
OPENAI = "openai",
|
|
10
|
+
ANTHROPIC = "anthropic",
|
|
11
|
+
MISTRAL = "mistral",
|
|
12
|
+
DEEPSEEK = "deepseek",
|
|
13
|
+
GEMINI = "gemini"
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Common options for all AI providers
|
|
17
|
+
*/
|
|
18
|
+
export type AIOptions = {
|
|
19
|
+
provider?: AIProvider;
|
|
20
|
+
model?: Model;
|
|
21
|
+
temperature?: number;
|
|
22
|
+
apiKey?: string;
|
|
23
|
+
customPrompt?: string;
|
|
24
|
+
applicationContext?: string;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Configuration for AI model based on provider
|
|
28
|
+
*/
|
|
29
|
+
export type AIModelConfig = {
|
|
30
|
+
model: any;
|
|
31
|
+
temperature?: number;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Get AI model configuration based on the selected provider and options
|
|
35
|
+
* This function handles the configuration for different AI providers
|
|
36
|
+
*
|
|
37
|
+
* @param options Configuration options including provider, API keys, models and temperature
|
|
38
|
+
* @returns Configured AI model ready to use with generateText
|
|
39
|
+
*/
|
|
40
|
+
export declare const getAIConfig: (options?: AIOptions) => Promise<AIModelConfig | undefined>;
|
|
41
|
+
//# sourceMappingURL=aiSdk.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aiSdk.d.ts","sourceRoot":"","sources":["../../../../src/utils/AI/aiSdk.ts"],"names":[],"mappings":"AAOA;;GAEG;AACH,MAAM,MAAM,KAAK,GAEb,aAAa,GACb,QAAQ,GACR,SAAS,GACT,cAAc,GACd,cAAc,GACd,SAAS,GACT,eAAe,GACf,qBAAqB,GACrB,sBAAsB,GACtB,sBAAsB,GACtB,2BAA2B,GAC3B,SAAS,GACT,IAAI,GACJ,QAAQ,GACR,SAAS,GACT,cAAc,GACd,IAAI,GACJ,SAAS,GACT,cAAc,GAEd,yBAAyB,GACzB,0BAA0B,GAC1B,wBAAwB,GAExB,cAAc,GACd,eAAe,GACf,mBAAmB,GACnB,gBAAgB,GAChB,kBAAkB,GAClB,eAAe,GACf,iBAAiB,GACjB,sBAAsB,GACtB,WAAW,GACX,iBAAiB,GACjB,cAAc,GACd,eAAe,GACf,cAAc,GACd,eAAe,GAEf,gBAAgB,GAChB,eAAe,GACf,aAAa,GAEb,gBAAgB,GAChB,gBAAgB,GAChB,kBAAkB,GAClB,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AAElB;;GAEG;AACH,oBAAY,UAAU;IACpB,MAAM,WAAW;IACjB,SAAS,cAAc;IACvB,OAAO,YAAY;IACnB,QAAQ,aAAa;IACrB,MAAM,WAAW;CAClB;AAED;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG;IACtB,QAAQ,CAAC,EAAE,UAAU,CAAC;IACtB,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,KAAK,EAAE,GAAG,CAAC;IACX,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,GACtB,UAAU,SAAS,KAClB,OAAO,CAAC,aAAa,GAAG,SAAS,CA2GnC,CAAC"}
|
|
@@ -31,7 +31,7 @@ export type AskDocQuestionOptions = {
|
|
|
31
31
|
};
|
|
32
32
|
/**
|
|
33
33
|
* Handles the "Ask a question" endpoint in an Express.js route.
|
|
34
|
-
* Processes user messages, retrieves relevant documents, and interacts with
|
|
34
|
+
* Processes user messages, retrieves relevant documents, and interacts with AI models to generate responses.
|
|
35
35
|
*
|
|
36
36
|
* @param messages - An array of chat messages from the user and assistant
|
|
37
37
|
* @returns The assistant's response as a string
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"askDocQuestion.d.ts","sourceRoot":"","sources":["../../../../../src/utils/AI/askDocQuestion/askDocQuestion.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"askDocQuestion.d.ts","sourceRoot":"","sources":["../../../../../src/utils/AI/askDocQuestion/askDocQuestion.ts"],"names":[],"mappings":"AAYA,KAAK,aAAa,GAAG;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB,CAAC;AA6GF;;;GAGG;AACH,eAAO,MAAM,kBAAkB,QAAa,OAAO,CAAC,IAAI,CAuEvD,CAAC;AAKF;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,GAC/B,OAAO,MAAM,KACZ,OAAO,CAAC,aAAa,EAAE,CAgBzB,CAAC;AAGF,MAAM,MAAM,4BAA4B,GAAG;IACzC,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,WAAW,CAAC;IACtC,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAmBF,eAAO,MAAM,UAAU,EAAE,4BAGxB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACrC,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,GACzB,UAAU,4BAA4B,EAAE,EACxC,UAAU,qBAAqB,KAC9B,OAAO,CAAC,oBAAoB,CA8D9B,CAAC"}
|
|
@@ -1,27 +1,22 @@
|
|
|
1
|
-
import type { Locales } from 'intlayer';
|
|
2
1
|
import type { Tag } from '../../../types/tag.types';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
temperature?: number;
|
|
6
|
-
openAiApiKey?: string;
|
|
7
|
-
};
|
|
2
|
+
import type { Locales } from 'intlayer';
|
|
3
|
+
import { AIOptions } from '../aiSdk';
|
|
8
4
|
export type AuditOptions = {
|
|
9
|
-
locales: Locales[];
|
|
10
|
-
defaultLocale: Locales;
|
|
11
5
|
fileContent: string;
|
|
12
6
|
filePath?: string;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
7
|
+
locales: Locales[];
|
|
8
|
+
defaultLocale: Locales;
|
|
9
|
+
tags: Tag[];
|
|
10
|
+
aiOptions?: AIOptions;
|
|
11
|
+
};
|
|
16
12
|
export type AuditFileResultData = {
|
|
17
13
|
fileContent: string;
|
|
18
14
|
tokenUsed: number;
|
|
19
15
|
};
|
|
20
16
|
/**
|
|
21
|
-
* Audits a content declaration file by constructing a prompt for
|
|
17
|
+
* Audits a content declaration file by constructing a prompt for AI models.
|
|
22
18
|
* The prompt includes details about the project's locales, file paths of content declarations,
|
|
23
|
-
* and requests for identifying issues or inconsistencies.
|
|
24
|
-
* and could be adapted to send requests to the ChatGPT model.
|
|
19
|
+
* and requests for identifying issues or inconsistencies.
|
|
25
20
|
*/
|
|
26
|
-
export declare const auditDictionary: ({ fileContent, filePath,
|
|
21
|
+
export declare const auditDictionary: ({ fileContent, filePath, aiOptions, locales, defaultLocale, tags, }: AuditOptions) => Promise<AuditFileResultData | undefined>;
|
|
27
22
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/utils/AI/auditDictionary/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/utils/AI/auditDictionary/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAK7C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAGxC,OAAO,EAAE,SAAS,EAA2B,MAAM,UAAU,CAAC;AAS9D,MAAM,MAAM,YAAY,GAAG;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,aAAa,EAAE,OAAO,CAAC;IACvB,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAiCF;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAAU,qEAOnC,YAAY,KAAG,OAAO,CAAC,mBAAmB,GAAG,SAAS,CA+CxD,CAAC"}
|
|
@@ -1,27 +1,22 @@
|
|
|
1
|
+
import type { Tag } from '../../../types/tag.types';
|
|
1
2
|
import { type KeyPath } from '@intlayer/core';
|
|
2
3
|
import type { Locales } from 'intlayer';
|
|
3
|
-
import
|
|
4
|
-
export type AIOptions = {
|
|
5
|
-
model?: string;
|
|
6
|
-
temperature?: number;
|
|
7
|
-
openAiApiKey?: string;
|
|
8
|
-
};
|
|
4
|
+
import { AIOptions } from '../aiSdk';
|
|
9
5
|
export type AuditDictionaryFieldOptions = {
|
|
10
|
-
locales: Locales[];
|
|
11
6
|
fileContent: string;
|
|
12
|
-
|
|
7
|
+
locales: Locales[];
|
|
13
8
|
keyPath: KeyPath[];
|
|
14
|
-
tags
|
|
15
|
-
|
|
9
|
+
tags: Tag[];
|
|
10
|
+
aiOptions?: AIOptions;
|
|
11
|
+
};
|
|
16
12
|
export type AuditDictionaryFieldResultData = {
|
|
17
13
|
fileContent: string;
|
|
18
14
|
tokenUsed: number;
|
|
19
15
|
};
|
|
20
16
|
/**
|
|
21
|
-
* Audits a content declaration file by constructing a prompt for
|
|
17
|
+
* Audits a content declaration file by constructing a prompt for AI models.
|
|
22
18
|
* The prompt includes details about the project's locales, file paths of content declarations,
|
|
23
|
-
* and requests for identifying issues or inconsistencies.
|
|
24
|
-
* and could be adapted to send requests to the ChatGPT model.
|
|
19
|
+
* and requests for identifying issues or inconsistencies.
|
|
25
20
|
*/
|
|
26
|
-
export declare const auditDictionaryField: ({ fileContent,
|
|
21
|
+
export declare const auditDictionaryField: ({ fileContent, aiOptions, locales, keyPath, tags, }: AuditDictionaryFieldOptions) => Promise<AuditDictionaryFieldResultData | undefined>;
|
|
27
22
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/utils/AI/auditDictionaryField/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/utils/AI/auditDictionaryField/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAiB,KAAK,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAI7D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAGxC,OAAO,EAAE,SAAS,EAA2B,MAAM,UAAU,CAAC;AAS9D,MAAM,MAAM,2BAA2B,GAAG;IACxC,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,8BAA8B,GAAG;IAC3C,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AA+BF;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,GAAU,qDAMxC,2BAA2B,KAAG,OAAO,CACtC,8BAA8B,GAAG,SAAS,CA0C3C,CAAC"}
|
|
@@ -1,24 +1,18 @@
|
|
|
1
1
|
import type { Tag } from '../../../types/tag.types';
|
|
2
|
-
|
|
3
|
-
model?: string;
|
|
4
|
-
temperature?: number;
|
|
5
|
-
openAiApiKey?: string;
|
|
6
|
-
};
|
|
2
|
+
import { AIOptions } from '../aiSdk';
|
|
7
3
|
export type AuditOptions = {
|
|
8
|
-
tags: Tag[];
|
|
9
4
|
fileContent: string;
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
tags: Tag[];
|
|
6
|
+
aiOptions?: AIOptions;
|
|
7
|
+
};
|
|
12
8
|
export type AuditFileResultData = {
|
|
13
9
|
fileContent: string;
|
|
14
10
|
tokenUsed: number;
|
|
15
11
|
};
|
|
16
12
|
/**
|
|
17
|
-
* Audits a content declaration file by constructing a prompt for
|
|
13
|
+
* Audits a content declaration file by constructing a prompt for AI models.
|
|
18
14
|
* The prompt includes details about the project's locales, file paths of content declarations,
|
|
19
|
-
* and requests for identifying issues or inconsistencies.
|
|
20
|
-
* and could be adapted to send requests to the ChatGPT model.
|
|
21
|
-
*
|
|
15
|
+
* and requests for identifying issues or inconsistencies.
|
|
22
16
|
*/
|
|
23
|
-
export declare const auditDictionaryMetadata: ({
|
|
17
|
+
export declare const auditDictionaryMetadata: ({ aiOptions, tags, fileContent, }: AuditOptions) => Promise<AuditFileResultData | undefined>;
|
|
24
18
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/utils/AI/auditDictionaryMetadata/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/utils/AI/auditDictionaryMetadata/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAM7C,OAAO,EAAE,SAAS,EAA2B,MAAM,UAAU,CAAC;AAS9D,MAAM,MAAM,YAAY,GAAG;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAKF;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,GAAU,mCAI3C,YAAY,KAAG,OAAO,CAAC,mBAAmB,GAAG,SAAS,CA6CxD,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Dictionary } from '../../../types/dictionary.types';
|
|
2
|
+
import type { Tag } from '../../../types/tag.types';
|
|
3
|
+
import { AIOptions } from '../aiSdk';
|
|
4
|
+
export type AuditOptions = {
|
|
5
|
+
dictionaries: Dictionary[];
|
|
6
|
+
tag: Tag;
|
|
7
|
+
aiOptions?: AIOptions;
|
|
8
|
+
};
|
|
9
|
+
export type TranslateJSONResultData = {
|
|
10
|
+
fileContent: string;
|
|
11
|
+
tokenUsed: number;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Audits a tag by constructing a prompt for AI models.
|
|
15
|
+
* The prompt includes details about the tag and related dictionaries.
|
|
16
|
+
*/
|
|
17
|
+
export declare const auditTag: ({ aiOptions, dictionaries, tag, }: AuditOptions) => Promise<TranslateJSONResultData | undefined>;
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/utils/AI/auditTag/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAM7C,OAAO,EAAE,SAAS,EAA2B,MAAM,UAAU,CAAC;AAS9D,MAAM,MAAM,YAAY,GAAG;IACzB,YAAY,EAAE,UAAU,EAAE,CAAC;IAC3B,GAAG,EAAE,GAAG,CAAC;IACT,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAKF;;;GAGG;AACH,eAAO,MAAM,QAAQ,GAAU,mCAI5B,YAAY,KAAG,OAAO,CAAC,uBAAuB,GAAG,SAAS,CAwC5D,CAAC"}
|