@breadstone-tools/localizator-ai 0.0.12-beta.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/Generator/Interfaces/IResourceGeneratorOptions.d.ts +21 -0
- package/Generator/Interfaces/IResourceGeneratorOptions.d.ts.map +1 -0
- package/Generator/Interfaces/IResourceGeneratorOptions.js +4 -0
- package/Generator/Interfaces/IResourceGeneratorOptions.js.map +1 -0
- package/Generator/Interfaces/IResourceGeneratorResult.d.ts +11 -0
- package/Generator/Interfaces/IResourceGeneratorResult.d.ts.map +1 -0
- package/Generator/Interfaces/IResourceGeneratorResult.js +4 -0
- package/Generator/Interfaces/IResourceGeneratorResult.js.map +1 -0
- package/Generator/ResourceGenerator.d.ts +66 -0
- package/Generator/ResourceGenerator.d.ts.map +1 -0
- package/Generator/ResourceGenerator.js +174 -0
- package/Generator/ResourceGenerator.js.map +1 -0
- package/Generator/Strategies/Abstracts/BaseResourceGeneratorStrategy.d.ts +49 -0
- package/Generator/Strategies/Abstracts/BaseResourceGeneratorStrategy.d.ts.map +1 -0
- package/Generator/Strategies/Abstracts/BaseResourceGeneratorStrategy.js +80 -0
- package/Generator/Strategies/Abstracts/BaseResourceGeneratorStrategy.js.map +1 -0
- package/Generator/Strategies/ChatGptResourceGeneratorStrategy.d.ts +31 -0
- package/Generator/Strategies/ChatGptResourceGeneratorStrategy.d.ts.map +1 -0
- package/Generator/Strategies/ChatGptResourceGeneratorStrategy.js +54 -0
- package/Generator/Strategies/ChatGptResourceGeneratorStrategy.js.map +1 -0
- package/Generator/Strategies/GeminiResourceGeneratorStrategy.d.ts +31 -0
- package/Generator/Strategies/GeminiResourceGeneratorStrategy.d.ts.map +1 -0
- package/Generator/Strategies/GeminiResourceGeneratorStrategy.js +90 -0
- package/Generator/Strategies/GeminiResourceGeneratorStrategy.js.map +1 -0
- package/Generator/Strategies/Interfaces/IResourceGeneratorStrategy.d.ts +31 -0
- package/Generator/Strategies/Interfaces/IResourceGeneratorStrategy.d.ts.map +1 -0
- package/Generator/Strategies/Interfaces/IResourceGeneratorStrategy.js +4 -0
- package/Generator/Strategies/Interfaces/IResourceGeneratorStrategy.js.map +1 -0
- package/Generator/Strategies/Interfaces/IResourceGeneratorStrategyConfig.d.ts +24 -0
- package/Generator/Strategies/Interfaces/IResourceGeneratorStrategyConfig.d.ts.map +1 -0
- package/Generator/Strategies/Interfaces/IResourceGeneratorStrategyConfig.js +3 -0
- package/Generator/Strategies/Interfaces/IResourceGeneratorStrategyConfig.js.map +1 -0
- package/Index.d.ts +8 -0
- package/Index.d.ts.map +1 -0
- package/Index.js +10 -0
- package/Index.js.map +1 -0
- package/LICENSE +21 -0
- package/package.json +22 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { IResourceGeneratorStrategyConfig } from '../Strategies/Interfaces/IResourceGeneratorStrategyConfig.js';
|
|
2
|
+
/**
|
|
3
|
+
* Represents the `IResourceGeneratorOptions` interface.
|
|
4
|
+
*
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export interface IResourceGeneratorOptions {
|
|
8
|
+
/**
|
|
9
|
+
* The dry run parameter ensures that no changes are made.
|
|
10
|
+
*/
|
|
11
|
+
dryRun: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* The configuration for the resource generator strategy.
|
|
14
|
+
*/
|
|
15
|
+
config: IResourceGeneratorStrategyConfig;
|
|
16
|
+
/**
|
|
17
|
+
* The chunk size for the generator. It will be used to split the resources into smaller chunks.
|
|
18
|
+
*/
|
|
19
|
+
chunkSize: number;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=IResourceGeneratorOptions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IResourceGeneratorOptions.d.ts","sourceRoot":"","sources":["../../../src/Generator/Interfaces/IResourceGeneratorOptions.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,8DAA8D,CAAC;AAIrH;;;;GAIG;AACH,MAAM,WAAW,yBAAyB;IAItC;;OAEG;IACH,MAAM,EAAE,OAAO,CAAC;IAEhB;;OAEG;IACH,MAAM,EAAE,gCAAgC,CAAC;IAEzC;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;CAIrB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IResourceGeneratorOptions.js","sourceRoot":"","sources":["../../../src/Generator/Interfaces/IResourceGeneratorOptions.ts"],"names":[],"mappings":";AAAA,kBAAkB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { IResourceInfo } from '@breadstone-tools/localizator-core';
|
|
2
|
+
/**
|
|
3
|
+
* Represents the `IResourceGeneratorResult` interface.
|
|
4
|
+
*
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export interface IResourceGeneratorResult {
|
|
8
|
+
resource: IResourceInfo;
|
|
9
|
+
locale: string;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=IResourceGeneratorResult.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IResourceGeneratorResult.d.ts","sourceRoot":"","sources":["../../../src/Generator/Interfaces/IResourceGeneratorResult.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AAIxE;;;;GAIG;AACH,MAAM,WAAW,wBAAwB;IAIrC,QAAQ,EAAE,aAAa,CAAC;IAExB,MAAM,EAAE,MAAM,CAAC;CAIlB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IResourceGeneratorResult.js","sourceRoot":"","sources":["../../../src/Generator/Interfaces/IResourceGeneratorResult.ts"],"names":[],"mappings":";AAAA,kBAAkB"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { type IFileSystem, type ILogger } from '@breadstone-infrastructure/utilities';
|
|
2
|
+
import type { IResourceGeneratorOptions } from './Interfaces/IResourceGeneratorOptions.js';
|
|
3
|
+
import type { IResourceGeneratorResult } from './Interfaces/IResourceGeneratorResult.js';
|
|
4
|
+
import type { ResourceTransformer, ResourceScanner, IResourceInfo } from '@breadstone-tools/localizator-core';
|
|
5
|
+
/**
|
|
6
|
+
* Class responsible for generating translated resources using AI.
|
|
7
|
+
*
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
export declare class ResourceGenerator {
|
|
11
|
+
private readonly _logger;
|
|
12
|
+
private readonly _fileSystem;
|
|
13
|
+
private readonly _resourceTransformer;
|
|
14
|
+
private readonly _resourceScanner;
|
|
15
|
+
private readonly _options;
|
|
16
|
+
private readonly _strategies;
|
|
17
|
+
/**
|
|
18
|
+
* Constructs a new instance of the `ResourceGenerator` class.
|
|
19
|
+
*
|
|
20
|
+
* @param logger - The logger service.
|
|
21
|
+
* @param fileSystem - The service to handle file operations.
|
|
22
|
+
* @param resourceTransformer - The service to handle resource transformations.
|
|
23
|
+
* @param options - The configuration options for the generator.
|
|
24
|
+
*/
|
|
25
|
+
constructor(logger: ILogger, fileSystem: IFileSystem, resourceTransformer: ResourceTransformer, resourceScanner: ResourceScanner, options: IResourceGeneratorOptions);
|
|
26
|
+
/**
|
|
27
|
+
* Generates resources using the specified strategy.
|
|
28
|
+
*
|
|
29
|
+
* @public
|
|
30
|
+
* @param resource - The resource to generate.
|
|
31
|
+
* @param locales - The locales to generate the resource for.
|
|
32
|
+
* @param strategy - The strategy to use for generation.
|
|
33
|
+
* @param onlyNew - The optionla flag to indicate if only new resources should be generated.
|
|
34
|
+
* @returns The generated resources.
|
|
35
|
+
*/
|
|
36
|
+
run(resource: IResourceInfo, locales: Array<string>, strategy: string, onlyNew?: boolean): Promise<Array<IResourceGeneratorResult>>;
|
|
37
|
+
/**
|
|
38
|
+
* Processes a resource using the specified strategy.
|
|
39
|
+
*
|
|
40
|
+
* @private
|
|
41
|
+
* @param strategy - The strategy to use for processing.
|
|
42
|
+
* @param resource - The resource to process.
|
|
43
|
+
* @param locale - The locale to process the resource for.
|
|
44
|
+
* @param onlyNew - The optionla flag to indicate if only new resources should be generated.
|
|
45
|
+
* @returns The processed resource.
|
|
46
|
+
*/
|
|
47
|
+
private processResource;
|
|
48
|
+
/**
|
|
49
|
+
* Gets the strategy for the specified strategy name.
|
|
50
|
+
*
|
|
51
|
+
* @private
|
|
52
|
+
* @param strategy - The strategy name.
|
|
53
|
+
* @returns The strategy.
|
|
54
|
+
*/
|
|
55
|
+
private getStrategy;
|
|
56
|
+
/**
|
|
57
|
+
* Gets the target file path for the specified resource and locale.
|
|
58
|
+
*
|
|
59
|
+
* @private
|
|
60
|
+
* @param resource - The resource to generate the target file path for.
|
|
61
|
+
* @param locale - The locale to generate the target file path for.
|
|
62
|
+
* @returns The target file path.
|
|
63
|
+
*/
|
|
64
|
+
private getTargetFilePath;
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=ResourceGenerator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ResourceGenerator.d.ts","sourceRoot":"","sources":["../../src/Generator/ResourceGenerator.ts"],"names":[],"mappings":"AAEA,OAAO,EAAqE,KAAK,WAAW,EAAE,KAAK,OAAO,EAAE,MAAM,sCAAsC,CAAC;AACzJ,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,2CAA2C,CAAC;AAI3F,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,0CAA0C,CAAC;AAEzF,OAAO,KAAK,EAAE,mBAAmB,EAAE,eAAe,EAAE,aAAa,EAAkB,MAAM,oCAAoC,CAAC;AAI9H;;;;GAIG;AACH,qBAAa,iBAAiB;IAI1B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAU;IAClC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAc;IAC1C,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAsB;IAC3D,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAkB;IACnD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA4B;IACrD,OAAO,CAAC,QAAQ,CAAC,WAAW,CAA0C;IAMtE;;;;;;;OAOG;gBACgB,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,eAAe,EAAE,eAAe,EAAE,OAAO,EAAE,yBAAyB;IAe3K;;;;;;;;;OASG;IACU,GAAG,CAAC,QAAQ,EAAE,aAAa,EAAE,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC;IA4BhJ;;;;;;;;;OASG;YACW,eAAe;IAkD7B;;;;;;OAMG;IACH,OAAO,CAAC,WAAW;IA0BnB;;;;;;;OAOG;IACH,OAAO,CAAC,iBAAiB;CAW5B"}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// #region Imports
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.ResourceGenerator = void 0;
|
|
5
|
+
const utilities_1 = require("@breadstone-infrastructure/utilities");
|
|
6
|
+
const ChatGptResourceGeneratorStrategy_js_1 = require("./Strategies/ChatGptResourceGeneratorStrategy.js");
|
|
7
|
+
const GeminiResourceGeneratorStrategy_js_1 = require("./Strategies/GeminiResourceGeneratorStrategy.js");
|
|
8
|
+
const process_1 = require("process");
|
|
9
|
+
// #endregion
|
|
10
|
+
/**
|
|
11
|
+
* Class responsible for generating translated resources using AI.
|
|
12
|
+
*
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
class ResourceGenerator {
|
|
16
|
+
// #region Fields
|
|
17
|
+
_logger;
|
|
18
|
+
_fileSystem;
|
|
19
|
+
_resourceTransformer;
|
|
20
|
+
_resourceScanner;
|
|
21
|
+
_options;
|
|
22
|
+
_strategies;
|
|
23
|
+
// #endregion
|
|
24
|
+
// #region Ctor
|
|
25
|
+
/**
|
|
26
|
+
* Constructs a new instance of the `ResourceGenerator` class.
|
|
27
|
+
*
|
|
28
|
+
* @param logger - The logger service.
|
|
29
|
+
* @param fileSystem - The service to handle file operations.
|
|
30
|
+
* @param resourceTransformer - The service to handle resource transformations.
|
|
31
|
+
* @param options - The configuration options for the generator.
|
|
32
|
+
*/
|
|
33
|
+
constructor(logger, fileSystem, resourceTransformer, resourceScanner, options) {
|
|
34
|
+
this._logger = logger;
|
|
35
|
+
this._options = options;
|
|
36
|
+
this._fileSystem = fileSystem;
|
|
37
|
+
this._resourceTransformer = resourceTransformer;
|
|
38
|
+
this._resourceScanner = resourceScanner;
|
|
39
|
+
this._strategies = new Map()
|
|
40
|
+
.set('chatgpt', new ChatGptResourceGeneratorStrategy_js_1.ChatGptResourceGeneratorStrategy(fileSystem, options.config))
|
|
41
|
+
.set('gemini', new GeminiResourceGeneratorStrategy_js_1.GeminiResourceGeneratorStrategy(fileSystem, options.config));
|
|
42
|
+
}
|
|
43
|
+
// #endregion
|
|
44
|
+
// #region Methods
|
|
45
|
+
/**
|
|
46
|
+
* Generates resources using the specified strategy.
|
|
47
|
+
*
|
|
48
|
+
* @public
|
|
49
|
+
* @param resource - The resource to generate.
|
|
50
|
+
* @param locales - The locales to generate the resource for.
|
|
51
|
+
* @param strategy - The strategy to use for generation.
|
|
52
|
+
* @param onlyNew - The optionla flag to indicate if only new resources should be generated.
|
|
53
|
+
* @returns The generated resources.
|
|
54
|
+
*/
|
|
55
|
+
async run(resource, locales, strategy, onlyNew) {
|
|
56
|
+
const generatorStrategy = this.getStrategy(strategy);
|
|
57
|
+
const results = new Array();
|
|
58
|
+
if (locales.length === 0) {
|
|
59
|
+
this._logger.warn((0, utilities_1.t) ` ${(0, utilities_1.yellow)('No locales specified, skipping...')}`);
|
|
60
|
+
}
|
|
61
|
+
for (const locale of locales) {
|
|
62
|
+
// eslint-disable-next-line no-await-in-loop
|
|
63
|
+
const result = await this.processResource(generatorStrategy, resource, locale, onlyNew);
|
|
64
|
+
if (!this._options.dryRun) {
|
|
65
|
+
this._fileSystem.writeAllText(result.path, result.toString());
|
|
66
|
+
this._logger.log(` ${result.name} generated to ${(0, utilities_1.dim)(utilities_1.Path.relative(process.cwd(), result.path))}`);
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
this._logger.log((0, utilities_1.t) ` ${(0, utilities_1.gray)('Dry run enabled, skipping...')}`);
|
|
70
|
+
}
|
|
71
|
+
results.push({
|
|
72
|
+
resource: result,
|
|
73
|
+
locale
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
return Promise.resolve(results);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Processes a resource using the specified strategy.
|
|
80
|
+
*
|
|
81
|
+
* @private
|
|
82
|
+
* @param strategy - The strategy to use for processing.
|
|
83
|
+
* @param resource - The resource to process.
|
|
84
|
+
* @param locale - The locale to process the resource for.
|
|
85
|
+
* @param onlyNew - The optionla flag to indicate if only new resources should be generated.
|
|
86
|
+
* @returns The processed resource.
|
|
87
|
+
*/
|
|
88
|
+
async processResource(strategy, resource, locale, onlyNew) {
|
|
89
|
+
let models = this._resourceTransformer.transform(resource);
|
|
90
|
+
let targetModels = new Array();
|
|
91
|
+
const chunks = utilities_1.ArrayExtensions.chunk(models, this._options.chunkSize);
|
|
92
|
+
const targetFilePath = this.getTargetFilePath(resource, locale);
|
|
93
|
+
this._logger.log(` Transcribing from ${(0, utilities_1.bold)(resource.locale)} to ${(0, utilities_1.bold)(locale)}`);
|
|
94
|
+
this._logger.log(` Splitting ${(0, utilities_1.bold)(models.length.toString())} models into ${(0, utilities_1.bold)(chunks.length.toString())} chunks`);
|
|
95
|
+
process_1.stdout.write(' Processing ');
|
|
96
|
+
// handle if only new is set
|
|
97
|
+
if (onlyNew) {
|
|
98
|
+
// load target resource
|
|
99
|
+
const targetResource = this._resourceScanner.scan(targetFilePath, resource.type).at(0);
|
|
100
|
+
if (!targetResource) {
|
|
101
|
+
throw new Error((0, utilities_1.t) `The target resource could not be found.`);
|
|
102
|
+
}
|
|
103
|
+
const m = this._resourceTransformer.transform(targetResource);
|
|
104
|
+
// get resources form source that are not in target
|
|
105
|
+
models = models.filter((x) => targetModels.every((y) => y.key !== x.key));
|
|
106
|
+
targetModels = m;
|
|
107
|
+
}
|
|
108
|
+
for (const chunk of utilities_1.ArrayExtensions.chunk(models, this._options.chunkSize)) {
|
|
109
|
+
// eslint-disable-next-line no-await-in-loop
|
|
110
|
+
const x = await strategy.transcribe({
|
|
111
|
+
resource: resource,
|
|
112
|
+
models: chunk
|
|
113
|
+
}, locale);
|
|
114
|
+
// actually, gemini generates more modesl than the input, we have to check this here.
|
|
115
|
+
if (x.length !== chunk.length) {
|
|
116
|
+
this._logger.warn(` ${(0, utilities_1.yellow)('Warning:')} ${(0, utilities_1.bold)(chunk.length.toString())} models were expected, but ${(0, utilities_1.bold)(x.length.toString())} were generated.`);
|
|
117
|
+
}
|
|
118
|
+
targetModels.push(...x);
|
|
119
|
+
}
|
|
120
|
+
process.stdout.write('\n');
|
|
121
|
+
const meta = {
|
|
122
|
+
name: this._fileSystem.getFileName(targetFilePath),
|
|
123
|
+
path: targetFilePath,
|
|
124
|
+
locale: locale,
|
|
125
|
+
target: resource.type
|
|
126
|
+
};
|
|
127
|
+
const transformedResource = this._resourceTransformer.serialize(targetModels, meta);
|
|
128
|
+
return transformedResource;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Gets the strategy for the specified strategy name.
|
|
132
|
+
*
|
|
133
|
+
* @private
|
|
134
|
+
* @param strategy - The strategy name.
|
|
135
|
+
* @returns The strategy.
|
|
136
|
+
*/
|
|
137
|
+
getStrategy(strategy) {
|
|
138
|
+
const generatorStrategy = this._strategies.get(strategy);
|
|
139
|
+
if (generatorStrategy === undefined) {
|
|
140
|
+
throw new Error((0, utilities_1.t) `The specified strategy '${strategy}' is not supported.`);
|
|
141
|
+
}
|
|
142
|
+
let progressTimer = null;
|
|
143
|
+
generatorStrategy.on('start', () => {
|
|
144
|
+
progressTimer = setInterval(() => {
|
|
145
|
+
process.stdout.write((0, utilities_1.gray)('.'));
|
|
146
|
+
}, 1000);
|
|
147
|
+
});
|
|
148
|
+
generatorStrategy.on('end', () => {
|
|
149
|
+
if (progressTimer) {
|
|
150
|
+
clearInterval(progressTimer);
|
|
151
|
+
progressTimer = null;
|
|
152
|
+
}
|
|
153
|
+
// process.stdout.write('\n');
|
|
154
|
+
});
|
|
155
|
+
return generatorStrategy;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Gets the target file path for the specified resource and locale.
|
|
159
|
+
*
|
|
160
|
+
* @private
|
|
161
|
+
* @param resource - The resource to generate the target file path for.
|
|
162
|
+
* @param locale - The locale to generate the target file path for.
|
|
163
|
+
* @returns The target file path.
|
|
164
|
+
*/
|
|
165
|
+
getTargetFilePath(resource, locale) {
|
|
166
|
+
const info = new utilities_1.FileSystemInfo(resource.path);
|
|
167
|
+
// double getFileNameWithoutExtension is not a typo, we need to remove the locale from the name
|
|
168
|
+
const targetName = `${this._fileSystem.getFileNameWithoutExtension(this._fileSystem.getFileNameWithoutExtension(resource.name))}.${locale}.${resource.type}`;
|
|
169
|
+
const targetPath = utilities_1.Path.combine(info.directoryPath, targetName);
|
|
170
|
+
return targetPath;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
exports.ResourceGenerator = ResourceGenerator;
|
|
174
|
+
//# sourceMappingURL=ResourceGenerator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ResourceGenerator.js","sourceRoot":"","sources":["../../src/Generator/ResourceGenerator.ts"],"names":[],"mappings":";AAAA,kBAAkB;;;AAElB,oEAAyJ;AAGzJ,0GAAoG;AACpG,wGAAkG;AAElG,qCAAiC;AAGjC,aAAa;AAEb;;;;GAIG;AACH,MAAa,iBAAiB;IAE1B,iBAAiB;IAEA,OAAO,CAAU;IACjB,WAAW,CAAc;IACzB,oBAAoB,CAAsB;IAC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CAAC;YACpC,CAAC,EAAE,IAAI,CAAC,CAAC;QACb,CAAC,CAAC,CAAC;QAEH,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE;YAC7B,IAAI,aAAa,EAAE,CAAC;gBAChB,aAAa,CAAC,aAA0C,CAAC,CAAC;gBAC1D,aAAa,GAAG,IAAI,CAAC;YACzB,CAAC;YACD,8BAA8B;QAClC,CAAC,CAAC,CAAC;QAEH,OAAO,iBAAiB,CAAC;IAC7B,CAAC;IAED;;;;;;;OAOG;IACK,iBAAiB,CAAC,QAAuB,EAAE,MAAc;QAC7D,MAAM,IAAI,GAAG,IAAI,0BAAc,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAC/C,+FAA+F;QAC/F,MAAM,UAAU,GAAG,GAAG,IAAI,CAAC,WAAW,CAAC,2BAA2B,CAAC,IAAI,CAAC,WAAW,CAAC,2BAA2B,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,MAAM,IAAI,QAAQ,CAAC,IAAI,EAAE,CAAC;QAC7J,MAAM,UAAU,GAAG,gBAAI,CAAC,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE,UAAU,CAAC,CAAC;QAEhE,OAAO,UAAU,CAAC;IACtB,CAAC;CAIJ;AA5LD,8CA4LC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { EventEmitter } from 'events';
|
|
2
|
+
import type { IResourceGeneratorStrategy, IResourceGeneratorStrategyEventMap } from '../Interfaces/IResourceGeneratorStrategy.js';
|
|
3
|
+
import type { IResourceInfo, IResourceModel } from '@breadstone-tools/localizator-core';
|
|
4
|
+
import type { IResourceGeneratorStrategyConfig } from '../Interfaces/IResourceGeneratorStrategyConfig.js';
|
|
5
|
+
import type { IFileSystem } from '@breadstone-infrastructure/utilities';
|
|
6
|
+
/**
|
|
7
|
+
* Abstract base class for AI-based resource generation strategies.
|
|
8
|
+
*
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
export declare abstract class BaseResourceGeneratorStrategy extends EventEmitter<IResourceGeneratorStrategyEventMap> implements IResourceGeneratorStrategy {
|
|
12
|
+
private readonly _fileSystem;
|
|
13
|
+
private readonly _config;
|
|
14
|
+
/**
|
|
15
|
+
* Constructs a new instance of the `BaseResourceGeneratorStrategy` class.
|
|
16
|
+
*
|
|
17
|
+
* @protected
|
|
18
|
+
* @param fileSystem - The service to handle file operations.
|
|
19
|
+
* @param config - The configuration for the strategy.
|
|
20
|
+
*/
|
|
21
|
+
protected constructor(fileSystem: IFileSystem, config: IResourceGeneratorStrategyConfig);
|
|
22
|
+
/**
|
|
23
|
+
* Returns the `config` property.
|
|
24
|
+
*
|
|
25
|
+
* @public
|
|
26
|
+
* @readonly
|
|
27
|
+
*/
|
|
28
|
+
get config(): IResourceGeneratorStrategyConfig;
|
|
29
|
+
abstract processResource(prompt: {
|
|
30
|
+
system: string;
|
|
31
|
+
assistant: string;
|
|
32
|
+
content: string;
|
|
33
|
+
}): Promise<string>;
|
|
34
|
+
/**
|
|
35
|
+
* Transcribes a resource to the specified locale.
|
|
36
|
+
*
|
|
37
|
+
* @public
|
|
38
|
+
* @abstract
|
|
39
|
+
* @param data - The resource and models to transcribe.
|
|
40
|
+
* @param locale - The target locale.
|
|
41
|
+
* @returns The transcribed resource.
|
|
42
|
+
*/
|
|
43
|
+
transcribe(data: {
|
|
44
|
+
resource: IResourceInfo;
|
|
45
|
+
models: Array<IResourceModel>;
|
|
46
|
+
}, locale: string): Promise<Array<IResourceModel>>;
|
|
47
|
+
private mangleJsonString;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=BaseResourceGeneratorStrategy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseResourceGeneratorStrategy.d.ts","sourceRoot":"","sources":["../../../../src/Generator/Strategies/Abstracts/BaseResourceGeneratorStrategy.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,KAAK,EAAE,0BAA0B,EAAE,kCAAkC,EAAE,MAAM,6CAA6C,CAAC;AAClI,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACxF,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,mDAAmD,CAAC;AAC1G,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AAIxE;;;;GAIG;AACH,8BAAsB,6BAA8B,SAAQ,YAAY,CAAC,kCAAkC,CAAE,YAAW,0BAA0B;IAI9I,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAc;IAC1C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAmC;IAM3D;;;;;;OAMG;IACH,SAAS,aAAa,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,gCAAgC;IAWvF;;;;;OAKG;IACH,IAAW,MAAM,IAAI,gCAAgC,CAEpD;aAMe,eAAe,CAAC,MAAM,EAAE;QACpC,MAAM,EAAE,MAAM,CAAC;QACf,SAAS,EAAE,MAAM,CAAC;QAClB,OAAO,EAAE,MAAM,CAAC;KACnB,GAAG,OAAO,CAAC,MAAM,CAAC;IAEnB;;;;;;;;OAQG;IACU,UAAU,CAAC,IAAI,EAAE;QAC1B,QAAQ,EAAE,aAAa,CAAC;QACxB,MAAM,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC;KACjC,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;IAsBlD,OAAO,CAAC,gBAAgB;CAW3B"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-disable @stylistic/indent-binary-ops */
|
|
3
|
+
/* eslint-disable @stylistic/quotes */
|
|
4
|
+
// #region Imports
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.BaseResourceGeneratorStrategy = void 0;
|
|
7
|
+
const events_1 = require("events");
|
|
8
|
+
// #endregion
|
|
9
|
+
/**
|
|
10
|
+
* Abstract base class for AI-based resource generation strategies.
|
|
11
|
+
*
|
|
12
|
+
* @public
|
|
13
|
+
*/
|
|
14
|
+
class BaseResourceGeneratorStrategy extends events_1.EventEmitter {
|
|
15
|
+
// #region Fields
|
|
16
|
+
_fileSystem;
|
|
17
|
+
_config;
|
|
18
|
+
// #endregion
|
|
19
|
+
// #region Constructor
|
|
20
|
+
/**
|
|
21
|
+
* Constructs a new instance of the `BaseResourceGeneratorStrategy` class.
|
|
22
|
+
*
|
|
23
|
+
* @protected
|
|
24
|
+
* @param fileSystem - The service to handle file operations.
|
|
25
|
+
* @param config - The configuration for the strategy.
|
|
26
|
+
*/
|
|
27
|
+
constructor(fileSystem, config) {
|
|
28
|
+
super();
|
|
29
|
+
this._fileSystem = fileSystem;
|
|
30
|
+
this._config = config;
|
|
31
|
+
}
|
|
32
|
+
// #endregion
|
|
33
|
+
// #region Properties
|
|
34
|
+
/**
|
|
35
|
+
* Returns the `config` property.
|
|
36
|
+
*
|
|
37
|
+
* @public
|
|
38
|
+
* @readonly
|
|
39
|
+
*/
|
|
40
|
+
get config() {
|
|
41
|
+
return this._config;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Transcribes a resource to the specified locale.
|
|
45
|
+
*
|
|
46
|
+
* @public
|
|
47
|
+
* @abstract
|
|
48
|
+
* @param data - The resource and models to transcribe.
|
|
49
|
+
* @param locale - The target locale.
|
|
50
|
+
* @returns The transcribed resource.
|
|
51
|
+
*/
|
|
52
|
+
async transcribe(data, locale) {
|
|
53
|
+
const systemPrompt = '' +
|
|
54
|
+
`Translate a locale ${data.resource.type} content from ${data.resource.locale} to ${locale}. ` +
|
|
55
|
+
`It's a key-value structure. Do not translate the keys. Consider the context of the value to make better translation. ` +
|
|
56
|
+
`Do not extends the key-value structure with additional keys. `;
|
|
57
|
+
const assistantPrompt = '' +
|
|
58
|
+
`Translate from ${data.resource.locale} to ${locale}. ` +
|
|
59
|
+
`Return the translation in the same format.`;
|
|
60
|
+
this.emit('start');
|
|
61
|
+
const content = await this.processResource({
|
|
62
|
+
system: systemPrompt,
|
|
63
|
+
assistant: assistantPrompt,
|
|
64
|
+
content: this.mangleJsonString(JSON.stringify(data.models))
|
|
65
|
+
});
|
|
66
|
+
this.emit('end');
|
|
67
|
+
return JSON.parse(content);
|
|
68
|
+
}
|
|
69
|
+
mangleJsonString(jsonString) {
|
|
70
|
+
try {
|
|
71
|
+
// Parse and re-stringify the JSON to remove all formatting
|
|
72
|
+
return JSON.stringify(JSON.parse(jsonString));
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
throw new Error(`Invalid JSON string: ${error.message}`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
exports.BaseResourceGeneratorStrategy = BaseResourceGeneratorStrategy;
|
|
80
|
+
//# sourceMappingURL=BaseResourceGeneratorStrategy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseResourceGeneratorStrategy.js","sourceRoot":"","sources":["../../../../src/Generator/Strategies/Abstracts/BaseResourceGeneratorStrategy.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,sCAAsC;AACtC,kBAAkB;;;AAElB,mCAAsC;AAMtC,aAAa;AAEb;;;;GAIG;AACH,MAAsB,6BAA8B,SAAQ,qBAAgD;IAExG,iBAAiB;IAEA,WAAW,CAAc;IACzB,OAAO,CAAmC;IAE3D,aAAa;IAEb,sBAAsB;IAEtB;;;;;;OAMG;IACH,YAAsB,UAAuB,EAAE,MAAwC;QACnF,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;QAC9B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IAC1B,CAAC;IAED,aAAa;IAEb,qBAAqB;IAErB;;;;;OAKG;IACH,IAAW,MAAM;QACb,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAYD;;;;;;;;OAQG;IACI,KAAK,CAAC,UAAU,CAAC,IAGvB,EAAE,MAAc;QACb,MAAM,YAAY,GAAG,EAAE;YACnB,sBAAsB,IAAI,CAAC,QAAQ,CAAC,IAAI,iBAAiB,IAAI,CAAC,QAAQ,CAAC,MAAM,OAAO,MAAM,IAAI;YAC9F,uHAAuH;YACvH,+DAA+D,CAAC;QACpE,MAAM,eAAe,GAAG,EAAE;YACtB,kBAAkB,IAAI,CAAC,QAAQ,CAAC,MAAM,OAAO,MAAM,IAAI;YACvD,4CAA4C,CAAC;QAEjD,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAEnB,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC;YACvC,MAAM,EAAE,YAAY;YACpB,SAAS,EAAE,eAAe;YAC1B,OAAO,EAAE,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;SAC9D,CAAC,CAAC;QAEH,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAEjB,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC/B,CAAC;IAEO,gBAAgB,CAAC,UAAkB;QACvC,IAAI,CAAC;YACD,2DAA2D;YAC3D,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC;QAClD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,wBAAwB,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QAC7D,CAAC;IACL,CAAC;CAIJ;AA9FD,sEA8FC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { IFileSystem } from '@breadstone-infrastructure/utilities';
|
|
2
|
+
import type { IResourceGeneratorStrategyConfig } from './Interfaces/IResourceGeneratorStrategyConfig.js';
|
|
3
|
+
import { BaseResourceGeneratorStrategy } from './Abstracts/BaseResourceGeneratorStrategy.js';
|
|
4
|
+
/**
|
|
5
|
+
* Service to handle AI-based translations using OpenAI.
|
|
6
|
+
*
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
export declare class ChatGptResourceGeneratorStrategy extends BaseResourceGeneratorStrategy {
|
|
10
|
+
/**
|
|
11
|
+
* Constructs a new instance of the `ChatGptResourceGeneratorStrategy` class.
|
|
12
|
+
*
|
|
13
|
+
* @param fileSystem - The service to handle file operations.
|
|
14
|
+
* @param options - The configuration options for the strategy.
|
|
15
|
+
*/
|
|
16
|
+
constructor(fileSystem: IFileSystem, options: IResourceGeneratorStrategyConfig);
|
|
17
|
+
/**
|
|
18
|
+
* Translates a resource to the specified locale.
|
|
19
|
+
*
|
|
20
|
+
* @public
|
|
21
|
+
* @override
|
|
22
|
+
* @param prompt - The prompt to translate.
|
|
23
|
+
* @returns The translated resource
|
|
24
|
+
*/
|
|
25
|
+
processResource(prompt: {
|
|
26
|
+
system: string;
|
|
27
|
+
assistant: string;
|
|
28
|
+
content: string;
|
|
29
|
+
}): Promise<string>;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=ChatGptResourceGeneratorStrategy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChatGptResourceGeneratorStrategy.d.ts","sourceRoot":"","sources":["../../../src/Generator/Strategies/ChatGptResourceGeneratorStrategy.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,kDAAkD,CAAC;AACzG,OAAO,EAAE,6BAA6B,EAAE,MAAM,8CAA8C,CAAC;AAI7F;;;;GAIG;AACH,qBAAa,gCAAiC,SAAQ,6BAA6B;IAI/E;;;;;OAKG;gBACgB,UAAU,EAAE,WAAW,EAAE,OAAO,EAAE,gCAAgC;IAQrF;;;;;;;OAOG;IACmB,eAAe,CAAC,MAAM,EAAE;QAC1C,MAAM,EAAE,MAAM,CAAC;QACf,SAAS,EAAE,MAAM,CAAC;QAClB,OAAO,EAAE,MAAM,CAAC;KACnB,GAAG,OAAO,CAAC,MAAM,CAAC;CAiBtB"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// #region Imports
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.ChatGptResourceGeneratorStrategy = void 0;
|
|
8
|
+
const openai_1 = __importDefault(require("openai"));
|
|
9
|
+
const BaseResourceGeneratorStrategy_js_1 = require("./Abstracts/BaseResourceGeneratorStrategy.js");
|
|
10
|
+
// #endregion
|
|
11
|
+
/**
|
|
12
|
+
* Service to handle AI-based translations using OpenAI.
|
|
13
|
+
*
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
class ChatGptResourceGeneratorStrategy extends BaseResourceGeneratorStrategy_js_1.BaseResourceGeneratorStrategy {
|
|
17
|
+
// #region Ctor
|
|
18
|
+
/**
|
|
19
|
+
* Constructs a new instance of the `ChatGptResourceGeneratorStrategy` class.
|
|
20
|
+
*
|
|
21
|
+
* @param fileSystem - The service to handle file operations.
|
|
22
|
+
* @param options - The configuration options for the strategy.
|
|
23
|
+
*/
|
|
24
|
+
constructor(fileSystem, options) {
|
|
25
|
+
super(fileSystem, options);
|
|
26
|
+
}
|
|
27
|
+
// #endregion
|
|
28
|
+
// #region Methods
|
|
29
|
+
/**
|
|
30
|
+
* Translates a resource to the specified locale.
|
|
31
|
+
*
|
|
32
|
+
* @public
|
|
33
|
+
* @override
|
|
34
|
+
* @param prompt - The prompt to translate.
|
|
35
|
+
* @returns The translated resource
|
|
36
|
+
*/
|
|
37
|
+
async processResource(prompt) {
|
|
38
|
+
const openai = new openai_1.default({ apiKey: this.config.apiKey });
|
|
39
|
+
try {
|
|
40
|
+
const response = await openai.completions.create({
|
|
41
|
+
model: this.config.model,
|
|
42
|
+
prompt: `${prompt.system} ${prompt.assistant} ${prompt.content}`,
|
|
43
|
+
temperature: this.config.temperature,
|
|
44
|
+
stream: false
|
|
45
|
+
});
|
|
46
|
+
return response.choices[0].text;
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
throw new Error(`Translation error: ${error.message}`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.ChatGptResourceGeneratorStrategy = ChatGptResourceGeneratorStrategy;
|
|
54
|
+
//# sourceMappingURL=ChatGptResourceGeneratorStrategy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChatGptResourceGeneratorStrategy.js","sourceRoot":"","sources":["../../../src/Generator/Strategies/ChatGptResourceGeneratorStrategy.ts"],"names":[],"mappings":";AAAA,kBAAkB;;;;;;AAElB,oDAA4B;AAG5B,mGAA6F;AAE7F,aAAa;AAEb;;;;GAIG;AACH,MAAa,gCAAiC,SAAQ,gEAA6B;IAE/E,eAAe;IAEf;;;;;OAKG;IACH,YAAmB,UAAuB,EAAE,OAAyC;QACjF,KAAK,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IAC/B,CAAC;IAED,aAAa;IAEb,kBAAkB;IAElB;;;;;;;OAOG;IACa,KAAK,CAAC,eAAe,CAAC,MAIrC;QACG,MAAM,MAAM,GAAG,IAAI,gBAAM,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;QAE1D,IAAI,CAAC;YACD,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC;gBAC7C,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK;gBACxB,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,SAAS,IAAI,MAAM,CAAC,OAAO,EAAE;gBAChE,WAAW,EAAE,IAAI,CAAC,MAAM,CAAC,WAAW;gBACpC,MAAM,EAAE,KAAK;aAChB,CAAC,CAAC;YACH,OAAO,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QACpC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,sBAAsB,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QAC3D,CAAC;IACL,CAAC;CAGJ;AA/CD,4EA+CC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { IResourceGeneratorStrategyConfig } from './Interfaces/IResourceGeneratorStrategyConfig.js';
|
|
2
|
+
import { BaseResourceGeneratorStrategy } from './Abstracts/BaseResourceGeneratorStrategy.js';
|
|
3
|
+
import type { IFileSystem } from '@breadstone-infrastructure/utilities';
|
|
4
|
+
/**
|
|
5
|
+
* Service to handle AI-based translations using Gemini.
|
|
6
|
+
*
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
export declare class GeminiResourceGeneratorStrategy extends BaseResourceGeneratorStrategy {
|
|
10
|
+
/**
|
|
11
|
+
* Constructs a new instance of the `GeminiResourceGeneratorStrategy` class.
|
|
12
|
+
*
|
|
13
|
+
* @param fileSystem - The service to handle file operations.
|
|
14
|
+
* @param options - The configuration options for the strategy.
|
|
15
|
+
*/
|
|
16
|
+
constructor(fileSystem: IFileSystem, options: IResourceGeneratorStrategyConfig);
|
|
17
|
+
/**
|
|
18
|
+
* Translates a resource to the specified locale.
|
|
19
|
+
*
|
|
20
|
+
* @public
|
|
21
|
+
* @override
|
|
22
|
+
* @param prompt - The prompt to translate.
|
|
23
|
+
* @returns The translated resource
|
|
24
|
+
*/
|
|
25
|
+
processResource(prompt: {
|
|
26
|
+
system: string;
|
|
27
|
+
assistant: string;
|
|
28
|
+
content: string;
|
|
29
|
+
}): Promise<string>;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=GeminiResourceGeneratorStrategy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GeminiResourceGeneratorStrategy.d.ts","sourceRoot":"","sources":["../../../src/Generator/Strategies/GeminiResourceGeneratorStrategy.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,kDAAkD,CAAC;AAEzG,OAAO,EAAE,6BAA6B,EAAE,MAAM,8CAA8C,CAAC;AAC7F,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AAIxE;;;;GAIG;AACH,qBAAa,+BAAgC,SAAQ,6BAA6B;IAI9E;;;;;OAKG;gBACgB,UAAU,EAAE,WAAW,EAAE,OAAO,EAAE,gCAAgC;IAQrF;;;;;;;OAOG;IACmB,eAAe,CAAC,MAAM,EAAE;QAC1C,MAAM,EAAE,MAAM,CAAC;QACf,SAAS,EAAE,MAAM,CAAC;QAClB,OAAO,EAAE,MAAM,CAAC;KACnB,GAAG,OAAO,CAAC,MAAM,CAAC;CAyDtB"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// #region Imports
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.GeminiResourceGeneratorStrategy = void 0;
|
|
5
|
+
const generative_ai_1 = require("@google/generative-ai");
|
|
6
|
+
const BaseResourceGeneratorStrategy_js_1 = require("./Abstracts/BaseResourceGeneratorStrategy.js");
|
|
7
|
+
// #endregion
|
|
8
|
+
/**
|
|
9
|
+
* Service to handle AI-based translations using Gemini.
|
|
10
|
+
*
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
class GeminiResourceGeneratorStrategy extends BaseResourceGeneratorStrategy_js_1.BaseResourceGeneratorStrategy {
|
|
14
|
+
// #region Constructor
|
|
15
|
+
/**
|
|
16
|
+
* Constructs a new instance of the `GeminiResourceGeneratorStrategy` class.
|
|
17
|
+
*
|
|
18
|
+
* @param fileSystem - The service to handle file operations.
|
|
19
|
+
* @param options - The configuration options for the strategy.
|
|
20
|
+
*/
|
|
21
|
+
constructor(fileSystem, options) {
|
|
22
|
+
super(fileSystem, options);
|
|
23
|
+
}
|
|
24
|
+
// #endregion
|
|
25
|
+
// #region Methods
|
|
26
|
+
/**
|
|
27
|
+
* Translates a resource to the specified locale.
|
|
28
|
+
*
|
|
29
|
+
* @public
|
|
30
|
+
* @override
|
|
31
|
+
* @param prompt - The prompt to translate.
|
|
32
|
+
* @returns The translated resource
|
|
33
|
+
*/
|
|
34
|
+
async processResource(prompt) {
|
|
35
|
+
const generativeAI = new generative_ai_1.GoogleGenerativeAI(this.config.apiKey);
|
|
36
|
+
const model = generativeAI.getGenerativeModel({
|
|
37
|
+
model: this.config.model,
|
|
38
|
+
generationConfig: {
|
|
39
|
+
temperature: this.config.temperature,
|
|
40
|
+
responseMimeType: 'application/json',
|
|
41
|
+
responseSchema: {
|
|
42
|
+
type: generative_ai_1.SchemaType.ARRAY,
|
|
43
|
+
items: {
|
|
44
|
+
type: generative_ai_1.SchemaType.OBJECT,
|
|
45
|
+
properties: {
|
|
46
|
+
key: {
|
|
47
|
+
type: generative_ai_1.SchemaType.STRING,
|
|
48
|
+
description: 'The key of the transform model'
|
|
49
|
+
},
|
|
50
|
+
value: {
|
|
51
|
+
type: generative_ai_1.SchemaType.STRING,
|
|
52
|
+
description: 'The value of the transform model'
|
|
53
|
+
},
|
|
54
|
+
comment: {
|
|
55
|
+
type: generative_ai_1.SchemaType.STRING,
|
|
56
|
+
description: 'The comment of the transform model'
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
required: ['key', 'value', 'comment']
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
try {
|
|
65
|
+
const response = await model.generateContent({
|
|
66
|
+
systemInstruction: prompt.system,
|
|
67
|
+
contents: [
|
|
68
|
+
{
|
|
69
|
+
role: 'assistant',
|
|
70
|
+
parts: [{ text: prompt.assistant }]
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
role: 'assistant',
|
|
74
|
+
parts: [{ text: this.config.extendedInstruction }]
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
role: 'assistant',
|
|
78
|
+
parts: [{ text: prompt.content }]
|
|
79
|
+
}
|
|
80
|
+
]
|
|
81
|
+
});
|
|
82
|
+
return response.response.text();
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
throw new Error(`Translation error: ${error.message}`);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
exports.GeminiResourceGeneratorStrategy = GeminiResourceGeneratorStrategy;
|
|
90
|
+
//# sourceMappingURL=GeminiResourceGeneratorStrategy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GeminiResourceGeneratorStrategy.js","sourceRoot":"","sources":["../../../src/Generator/Strategies/GeminiResourceGeneratorStrategy.ts"],"names":[],"mappings":";AAAA,kBAAkB;;;AAGlB,yDAAuE;AACvE,mGAA6F;AAG7F,aAAa;AAEb;;;;GAIG;AACH,MAAa,+BAAgC,SAAQ,gEAA6B;IAE9E,sBAAsB;IAEtB;;;;;OAKG;IACH,YAAmB,UAAuB,EAAE,OAAyC;QACjF,KAAK,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IAC/B,CAAC;IAED,aAAa;IAEb,kBAAkB;IAElB;;;;;;;OAOG;IACa,KAAK,CAAC,eAAe,CAAC,MAIrC;QACG,MAAM,YAAY,GAAG,IAAI,kCAAkB,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAChE,MAAM,KAAK,GAAG,YAAY,CAAC,kBAAkB,CAAC;YAC1C,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK;YACxB,gBAAgB,EAAE;gBACd,WAAW,EAAE,IAAI,CAAC,MAAM,CAAC,WAAW;gBACpC,gBAAgB,EAAE,kBAAkB;gBACpC,cAAc,EAAE;oBACZ,IAAI,EA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1
|
+
import type { IResourceInfo, IResourceModel } from '@breadstone-tools/localizator-core';
|
|
2
|
+
import type EventEmitter from 'events';
|
|
3
|
+
/**
|
|
4
|
+
* Event map for the `BaseParser`.
|
|
5
|
+
*
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export interface IResourceGeneratorStrategyEventMap {
|
|
9
|
+
start: [];
|
|
10
|
+
end: [];
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Represents the `IResourceGeneratorStrategy` interface.
|
|
14
|
+
*
|
|
15
|
+
* @public
|
|
16
|
+
*/
|
|
17
|
+
export interface IResourceGeneratorStrategy extends Pick<EventEmitter<IResourceGeneratorStrategyEventMap>, 'on'> {
|
|
18
|
+
/**
|
|
19
|
+
* Transcribes a resource to the specified locale.
|
|
20
|
+
*
|
|
21
|
+
* @public
|
|
22
|
+
* @param data - The resource to translate.
|
|
23
|
+
* @param locale - The target locale.
|
|
24
|
+
* @returns The translated resource
|
|
25
|
+
*/
|
|
26
|
+
transcribe(data: {
|
|
27
|
+
resource: IResourceInfo;
|
|
28
|
+
models: Array<IResourceModel>;
|
|
29
|
+
}, locale: string): Promise<Array<IResourceModel>>;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=IResourceGeneratorStrategy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IResourceGeneratorStrategy.d.ts","sourceRoot":"","sources":["../../../../src/Generator/Strategies/Interfaces/IResourceGeneratorStrategy.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACxF,OAAO,KAAK,YAAY,MAAM,QAAQ,CAAC;AAIvC;;;;GAIG;AACH,MAAM,WAAW,kCAAkC;IAC/C,KAAK,EAAE,EAAE,CAAC;IACV,GAAG,EAAE,EAAE,CAAC;CACX;AAED;;;;GAIG;AACH,MAAM,WAAW,0BAA2B,SAAQ,IAAI,CAAC,YAAY,CAAC,kCAAkC,CAAC,EAAE,IAAI,CAAC;IAI5G;;;;;;;OAOG;IACH,UAAU,CAAC,IAAI,EAAE;QACb,QAAQ,EAAE,aAAa,CAAC;QACxB,MAAM,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC;KACjC,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC;CAItD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IResourceGeneratorStrategy.js","sourceRoot":"","sources":["../../../../src/Generator/Strategies/Interfaces/IResourceGeneratorStrategy.ts"],"names":[],"mappings":";AAAA,kBAAkB"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration interface for resource generator strategy.
|
|
3
|
+
*
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
export interface IResourceGeneratorStrategyConfig {
|
|
7
|
+
/**
|
|
8
|
+
* The API key used for authentication.
|
|
9
|
+
*/
|
|
10
|
+
apiKey: string;
|
|
11
|
+
/**
|
|
12
|
+
* The model to be used for generation.
|
|
13
|
+
*/
|
|
14
|
+
model: string;
|
|
15
|
+
/**
|
|
16
|
+
* The temperature setting for the generation process.
|
|
17
|
+
*/
|
|
18
|
+
temperature: number;
|
|
19
|
+
/**
|
|
20
|
+
* Additional instructions to extend the generation process.
|
|
21
|
+
*/
|
|
22
|
+
extendedInstruction: string;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=IResourceGeneratorStrategyConfig.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IResourceGeneratorStrategyConfig.d.ts","sourceRoot":"","sources":["../../../../src/Generator/Strategies/Interfaces/IResourceGeneratorStrategyConfig.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,WAAW,gCAAgC;IAI7C;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,mBAAmB,EAAE,MAAM,CAAC;CAI/B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IResourceGeneratorStrategyConfig.js","sourceRoot":"","sources":["../../../../src/Generator/Strategies/Interfaces/IResourceGeneratorStrategyConfig.ts"],"names":[],"mappings":""}
|
package/Index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type { IResourceGeneratorOptions } from './Generator/Interfaces/IResourceGeneratorOptions.js';
|
|
2
|
+
export type { IResourceGeneratorResult } from './Generator/Interfaces/IResourceGeneratorResult.js';
|
|
3
|
+
export { ResourceGenerator } from './Generator/ResourceGenerator.js';
|
|
4
|
+
export type { IResourceGeneratorStrategy } from './Generator/Strategies/Interfaces/IResourceGeneratorStrategy.js';
|
|
5
|
+
export type { IResourceGeneratorStrategyConfig } from './Generator/Strategies/Interfaces/IResourceGeneratorStrategyConfig.js';
|
|
6
|
+
export { ChatGptResourceGeneratorStrategy } from './Generator/Strategies/ChatGptResourceGeneratorStrategy.js';
|
|
7
|
+
export { GeminiResourceGeneratorStrategy } from './Generator/Strategies/GeminiResourceGeneratorStrategy.js';
|
|
8
|
+
//# sourceMappingURL=Index.d.ts.map
|
package/Index.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Index.d.ts","sourceRoot":"","sources":["../src/Index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,yBAAyB,EAAE,MAAM,qDAAqD,CAAC;AACrG,YAAY,EAAE,wBAAwB,EAAE,MAAM,oDAAoD,CAAC;AACnG,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,YAAY,EAAE,0BAA0B,EAAE,MAAM,iEAAiE,CAAC;AAClH,YAAY,EAAE,gCAAgC,EAAE,MAAM,uEAAuE,CAAC;AAC9H,OAAO,EAAE,gCAAgC,EAAE,MAAM,4DAA4D,CAAC;AAC9G,OAAO,EAAE,+BAA+B,EAAE,MAAM,2DAA2D,CAAC"}
|
package/Index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GeminiResourceGeneratorStrategy = exports.ChatGptResourceGeneratorStrategy = exports.ResourceGenerator = void 0;
|
|
4
|
+
var ResourceGenerator_js_1 = require("./Generator/ResourceGenerator.js");
|
|
5
|
+
Object.defineProperty(exports, "ResourceGenerator", { enumerable: true, get: function () { return ResourceGenerator_js_1.ResourceGenerator; } });
|
|
6
|
+
var ChatGptResourceGeneratorStrategy_js_1 = require("./Generator/Strategies/ChatGptResourceGeneratorStrategy.js");
|
|
7
|
+
Object.defineProperty(exports, "ChatGptResourceGeneratorStrategy", { enumerable: true, get: function () { return ChatGptResourceGeneratorStrategy_js_1.ChatGptResourceGeneratorStrategy; } });
|
|
8
|
+
var GeminiResourceGeneratorStrategy_js_1 = require("./Generator/Strategies/GeminiResourceGeneratorStrategy.js");
|
|
9
|
+
Object.defineProperty(exports, "GeminiResourceGeneratorStrategy", { enumerable: true, get: function () { return GeminiResourceGeneratorStrategy_js_1.GeminiResourceGeneratorStrategy; } });
|
|
10
|
+
//# sourceMappingURL=Index.js.map
|
package/Index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Index.js","sourceRoot":"","sources":["../src/Index.ts"],"names":[],"mappings":";;;AAEA,yEAAqE;AAA5D,yHAAA,iBAAiB,OAAA;AAG1B,kHAA8G;AAArG,uJAAA,gCAAgC,OAAA;AACzC,gHAA4G;AAAnG,qJAAA,+BAA+B,OAAA"}
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Breadstone
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/package.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@breadstone-tools/localizator-ai",
|
|
3
|
+
"description": "Localizator ai library",
|
|
4
|
+
"version": "0.0.12-beta.0",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "andre.wehlert <awehlert@breadstone.de> (https://www.breadstone.de)",
|
|
7
|
+
"repository": {
|
|
8
|
+
"url": "git+ssh://git@github.com/RueDeRennes/mosaik.git"
|
|
9
|
+
},
|
|
10
|
+
"type": "commonjs",
|
|
11
|
+
"main": "./Index.js",
|
|
12
|
+
"commonjs": "./Index.js",
|
|
13
|
+
"module": "./Index.js",
|
|
14
|
+
"types": "./Index.d.ts",
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@breadstone-infrastructure/utilities": "^0.0.12-beta.0",
|
|
17
|
+
"@breadstone-tools/localizator-core": "^0.0.12-beta.0",
|
|
18
|
+
"@google/generative-ai": "^0.24.1",
|
|
19
|
+
"cheerio": "^1.0.0",
|
|
20
|
+
"openai": "^4.97.0"
|
|
21
|
+
}
|
|
22
|
+
}
|