@mate-academy/llm-gateway 2.0.1 → 2.1.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/README.md +1 -0
- package/dist/LLMService.typedefs.d.ts +3 -1
- package/dist/LLMService.typedefs.js +1 -1
- package/dist/LLMService.typedefs.js.map +1 -1
- package/dist/functional.utils.js +1 -1
- package/dist/promptBuilder.js +1 -1
- package/dist/providers/GoogleGenerativeAI/GoogleGenerativeAI.constants.js +1 -1
- package/dist/providers/GoogleGenerativeAI/GoogleGenerativeAI.constants.js.map +1 -1
- package/dist/providers/GoogleGenerativeAI/GoogleGenerativeAI.entity.js +1 -1
- package/dist/providers/GoogleGenerativeAI/GoogleGenerativeAI.entity.js.map +1 -1
- package/dist/providers/GoogleGenerativeAI/GoogleGenerativeAI.typedefs.d.ts +1 -1
- package/dist/providers/GoogleGenerativeAI/GoogleGenerativeAI.typedefs.js +1 -1
- package/dist/providers/GoogleGenerativeAI/GoogleGenerativeAI.typedefs.js.map +1 -1
- package/dist/providers/GoogleGenerativeAI/services/GoogleGenerativeAIAssistance.service.js +1 -1
- package/dist/providers/GoogleGenerativeAI/services/GoogleGenerativeAISpeechToText.service.js +1 -1
- package/dist/providers/GoogleGenerativeAI/services/GoogleGenerativeAISpeechToText.service.js.map +1 -1
- package/dist/providers/OpenAI/OpenAI.entity.js +1 -1
- package/dist/providers/OpenAI/OpenAI.entity.js.map +1 -1
- package/dist/providers/OpenAI/services/OpenAIAssistance.service.js +1 -1
- package/dist/providers/OpenAI/services/OpenAISpeechToText.service.js +1 -1
- package/dist/providers/OpenAI/services/OpenAISpeechToText.service.js.map +1 -1
- package/package.json +17 -11
package/README.md
CHANGED
|
@@ -237,6 +237,7 @@ const chat = await assistanceService.createChat({
|
|
|
237
237
|
```typescript
|
|
238
238
|
const transcription = await speechToTextService.transcribe({
|
|
239
239
|
pathToAudio: '/path/to/audio.mp3',
|
|
240
|
+
mimeType: LLMUploadFileMimeTypes.AUDIO_MP3, // Optional, but recommended
|
|
240
241
|
model: preferredModel,
|
|
241
242
|
});
|
|
242
243
|
|
|
@@ -203,7 +203,8 @@ export declare enum LLMUploadFileMimeTypes {
|
|
|
203
203
|
PLAIN_TEXT = "text/plain",
|
|
204
204
|
AUDIO_MP3 = "audio/mp3",
|
|
205
205
|
AUDIO_MPEG = "audio/mpeg",
|
|
206
|
-
AUDIO_WAV = "audio/wav"
|
|
206
|
+
AUDIO_WAV = "audio/wav",
|
|
207
|
+
AUDIO_WEBM = "audio/webm"
|
|
207
208
|
}
|
|
208
209
|
export type LLMImageMimeType = LLMUploadFileMimeTypes.IMAGE_PNG | LLMUploadFileMimeTypes.IMAGE_JPEG | LLMUploadFileMimeTypes.IMAGE_JPG | LLMUploadFileMimeTypes.IMAGE_GIF | LLMUploadFileMimeTypes.IMAGE_WEBP | LLMUploadFileMimeTypes.IMAGE_SVG_XML | LLMUploadFileMimeTypes.IMAGE_BMP;
|
|
209
210
|
/**
|
|
@@ -332,6 +333,7 @@ export interface CombineMessagesOptions<Provider extends LLMProviders, TokenCoun
|
|
|
332
333
|
*/
|
|
333
334
|
export interface LLMTranscribeOptions<Provider extends LLMProviders> {
|
|
334
335
|
pathToAudio: string;
|
|
336
|
+
mimeType?: LLMUploadFileMimeTypes;
|
|
335
337
|
model: LLMModel<Provider>;
|
|
336
338
|
}
|
|
337
339
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var LLMProviders,LLMPurposes,LLMRoles,LLMMessageContentType,LLMUploadFileMimeTypes;Object.defineProperty(exports,"__esModule",{value:!0}),exports.LLMUploadFileMimeTypes=exports.LLMMessageContentType=exports.LLMRoles=exports.LLMPurposes=exports.LLMProviders=void 0,function(e){e.OpenAI="OpenAI",e.GoogleGenerativeAI="GoogleGenerativeAI"}(LLMProviders||(exports.LLMProviders=LLMProviders={})),function(e){e.Completion="completion",e.Assistance="assistance",e.SpeechToText="speech_to_text",e.TextToSpeech="text_to_speech"}(LLMPurposes||(exports.LLMPurposes=LLMPurposes={})),function(e){e.User="user",e.Assistant="assistant"}(LLMRoles||(exports.LLMRoles=LLMRoles={})),function(e){e.TEXT="text",e.IMAGE_URL="image_url",e.IMAGE_FILE="image_file"}(LLMMessageContentType||(exports.LLMMessageContentType=LLMMessageContentType={})),function(e){e.IMAGE_PNG="image/png",e.IMAGE_JPEG="image/jpeg",e.IMAGE_JPG="image/jpg",e.IMAGE_GIF="image/gif",e.IMAGE_WEBP="image/webp",e.IMAGE_SVG_XML="image/svg+xml",e.IMAGE_BMP="image/bmp",e.PLAIN_TEXT="text/plain",e.AUDIO_MP3="audio/mp3",e.AUDIO_MPEG="audio/mpeg",e.AUDIO_WAV="audio/wav"}(LLMUploadFileMimeTypes||(exports.LLMUploadFileMimeTypes=LLMUploadFileMimeTypes={}));
|
|
1
|
+
"use strict";var LLMProviders,LLMPurposes,LLMRoles,LLMMessageContentType,LLMUploadFileMimeTypes;Object.defineProperty(exports,"__esModule",{value:!0}),exports.LLMUploadFileMimeTypes=exports.LLMMessageContentType=exports.LLMRoles=exports.LLMPurposes=exports.LLMProviders=void 0,function(e){e.OpenAI="OpenAI",e.GoogleGenerativeAI="GoogleGenerativeAI"}(LLMProviders||(exports.LLMProviders=LLMProviders={})),function(e){e.Completion="completion",e.Assistance="assistance",e.SpeechToText="speech_to_text",e.TextToSpeech="text_to_speech"}(LLMPurposes||(exports.LLMPurposes=LLMPurposes={})),function(e){e.User="user",e.Assistant="assistant"}(LLMRoles||(exports.LLMRoles=LLMRoles={})),function(e){e.TEXT="text",e.IMAGE_URL="image_url",e.IMAGE_FILE="image_file"}(LLMMessageContentType||(exports.LLMMessageContentType=LLMMessageContentType={})),function(e){e.IMAGE_PNG="image/png",e.IMAGE_JPEG="image/jpeg",e.IMAGE_JPG="image/jpg",e.IMAGE_GIF="image/gif",e.IMAGE_WEBP="image/webp",e.IMAGE_SVG_XML="image/svg+xml",e.IMAGE_BMP="image/bmp",e.PLAIN_TEXT="text/plain",e.AUDIO_MP3="audio/mp3",e.AUDIO_MPEG="audio/mpeg",e.AUDIO_WAV="audio/wav",e.AUDIO_WEBM="audio/webm"}(LLMUploadFileMimeTypes||(exports.LLMUploadFileMimeTypes=LLMUploadFileMimeTypes={}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LLMService.typedefs.js","sourceRoot":"","sources":["../src/LLMService.typedefs.ts"],"names":[],"mappings":";;;AAkBA;;GAEG;AACH,IAAY,YAGX;AAHD,WAAY,YAAY;IACtB,iCAAiB,CAAA;IACjB,yDAAyC,CAAA;AAC3C,CAAC,EAHW,YAAY,4BAAZ,YAAY,QAGvB;AAkBD;;GAEG;AACH,IAAY,WAKX;AALD,WAAY,WAAW;IACrB,wCAAyB,CAAA;IACzB,wCAAyB,CAAA;IACzB,8CAA+B,CAAA;IAC/B,8CAA+B,CAAA;AACjC,CAAC,EALW,WAAW,2BAAX,WAAW,QAKtB;AAyFD;;GAEG;AACH,IAAY,QAGX;AAHD,WAAY,QAAQ;IAClB,yBAAa,CAAA;IACb,mCAAuB,CAAA;AACzB,CAAC,EAHW,QAAQ,wBAAR,QAAQ,QAGnB;AAED;;GAEG;AACH,IAAY,qBAIX;AAJD,WAAY,qBAAqB;IAC/B,sCAAa,CAAA;IACb,gDAAuB,CAAA;IACvB,kDAAyB,CAAA;AAC3B,CAAC,EAJW,qBAAqB,qCAArB,qBAAqB,QAIhC;AAqFD;;GAEG;AACH,IAAY,
|
|
1
|
+
{"version":3,"file":"LLMService.typedefs.js","sourceRoot":"","sources":["../src/LLMService.typedefs.ts"],"names":[],"mappings":";;;AAkBA;;GAEG;AACH,IAAY,YAGX;AAHD,WAAY,YAAY;IACtB,iCAAiB,CAAA;IACjB,yDAAyC,CAAA;AAC3C,CAAC,EAHW,YAAY,4BAAZ,YAAY,QAGvB;AAkBD;;GAEG;AACH,IAAY,WAKX;AALD,WAAY,WAAW;IACrB,wCAAyB,CAAA;IACzB,wCAAyB,CAAA;IACzB,8CAA+B,CAAA;IAC/B,8CAA+B,CAAA;AACjC,CAAC,EALW,WAAW,2BAAX,WAAW,QAKtB;AAyFD;;GAEG;AACH,IAAY,QAGX;AAHD,WAAY,QAAQ;IAClB,yBAAa,CAAA;IACb,mCAAuB,CAAA;AACzB,CAAC,EAHW,QAAQ,wBAAR,QAAQ,QAGnB;AAED;;GAEG;AACH,IAAY,qBAIX;AAJD,WAAY,qBAAqB;IAC/B,sCAAa,CAAA;IACb,gDAAuB,CAAA;IACvB,kDAAyB,CAAA;AAC3B,CAAC,EAJW,qBAAqB,qCAArB,qBAAqB,QAIhC;AAqFD;;GAEG;AACH,IAAY,sBAaX;AAbD,WAAY,sBAAsB;IAChC,iDAAuB,CAAA;IACvB,mDAAyB,CAAA;IACzB,iDAAuB,CAAA;IACvB,iDAAuB,CAAA;IACvB,mDAAyB,CAAA;IACzB,yDAA+B,CAAA;IAC/B,iDAAuB,CAAA;IACvB,mDAAyB,CAAA;IACzB,iDAAuB,CAAA;IACvB,mDAAyB,CAAA;IACzB,iDAAuB,CAAA;IACvB,mDAAyB,CAAA;AAC3B,CAAC,EAbW,sBAAsB,sCAAtB,sBAAsB,QAajC"}
|
package/dist/functional.utils.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.pick=void 0;const pick=(e,c)=>c.reduce((
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.pick=void 0;const pick=(e,c)=>c.reduce((c,s)=>(Object.assign(c,{[s]:e[s]}),c),{});exports.pick=pick;
|
package/dist/promptBuilder.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";function promptBuilder(e,t){return t?Object.entries(t).reduce((
|
|
1
|
+
"use strict";function promptBuilder(e,t){return t?Object.entries(t).reduce((e,[t,r])=>e.replace(new RegExp(`{{\\s*${t}\\s*}}`,"g"),String(r)),e):e}function createPromptTemplate(e){const t=e.trim();return(...e)=>promptBuilder(t,...e)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.createPromptTemplate=createPromptTemplate;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.GOOGLE_AI_SERVICE_BUILDERS=exports.GOOGLE_AI_MODELS=exports.MIN_CACHE_CONTENT_LENGTH=void 0;const LLMService_typedefs_1=require("../../LLMService.typedefs"),GoogleGenerativeAI_typedefs_1=require("./GoogleGenerativeAI.typedefs"),services_1=require("../../providers/GoogleGenerativeAI/services"),functional_utils_1=require("../../functional.utils");exports.MIN_CACHE_CONTENT_LENGTH=32768;const GOOGLE_AI_AVAILABLE_MODELS={[GoogleGenerativeAI_typedefs_1.GoogleGenerativeAIModelNames.GEMINI_1_5_FLASH]:{name:GoogleGenerativeAI_typedefs_1.GoogleGenerativeAIModelNames.GEMINI_1_5_FLASH,limits:{maxInputTokens:1048576,maxOutputTokens:8192},config:{temperature:.2}},[GoogleGenerativeAI_typedefs_1.GoogleGenerativeAIModelNames.GEMINI_1_5_PRO]:{name:GoogleGenerativeAI_typedefs_1.GoogleGenerativeAIModelNames.GEMINI_1_5_PRO,limits:{maxInputTokens:2097152,maxOutputTokens:8192},config:{temperature:.2}},[GoogleGenerativeAI_typedefs_1.GoogleGenerativeAIModelNames.GEMINI_1_5_PRO_STABLE]:{name:GoogleGenerativeAI_typedefs_1.GoogleGenerativeAIModelNames.GEMINI_1_5_PRO_STABLE,limits:{maxInputTokens:2097152,maxOutputTokens:8192},config:{temperature:.2}},[GoogleGenerativeAI_typedefs_1.GoogleGenerativeAIModelNames.GEMINI_2_0_FLASH]:{name:GoogleGenerativeAI_typedefs_1.GoogleGenerativeAIModelNames.GEMINI_2_0_FLASH,limits:{maxInputTokens:1048576,maxOutputTokens:8192},config:{temperature:.2}},[GoogleGenerativeAI_typedefs_1.GoogleGenerativeAIModelNames.GEMINI_2_0_FLASH_STABLE]:{name:GoogleGenerativeAI_typedefs_1.GoogleGenerativeAIModelNames.GEMINI_2_0_FLASH_STABLE,limits:{maxInputTokens:1048576,maxOutputTokens:8192},config:{temperature:.2}},[GoogleGenerativeAI_typedefs_1.GoogleGenerativeAIModelNames.
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.GOOGLE_AI_SERVICE_BUILDERS=exports.GOOGLE_AI_MODELS=exports.MIN_CACHE_CONTENT_LENGTH=void 0;const LLMService_typedefs_1=require("../../LLMService.typedefs"),GoogleGenerativeAI_typedefs_1=require("./GoogleGenerativeAI.typedefs"),services_1=require("../../providers/GoogleGenerativeAI/services"),functional_utils_1=require("../../functional.utils");exports.MIN_CACHE_CONTENT_LENGTH=32768;const GOOGLE_AI_AVAILABLE_MODELS={[GoogleGenerativeAI_typedefs_1.GoogleGenerativeAIModelNames.GEMINI_1_5_FLASH]:{name:GoogleGenerativeAI_typedefs_1.GoogleGenerativeAIModelNames.GEMINI_1_5_FLASH,limits:{maxInputTokens:1048576,maxOutputTokens:8192},config:{temperature:.2}},[GoogleGenerativeAI_typedefs_1.GoogleGenerativeAIModelNames.GEMINI_1_5_PRO]:{name:GoogleGenerativeAI_typedefs_1.GoogleGenerativeAIModelNames.GEMINI_1_5_PRO,limits:{maxInputTokens:2097152,maxOutputTokens:8192},config:{temperature:.2}},[GoogleGenerativeAI_typedefs_1.GoogleGenerativeAIModelNames.GEMINI_1_5_PRO_STABLE]:{name:GoogleGenerativeAI_typedefs_1.GoogleGenerativeAIModelNames.GEMINI_1_5_PRO_STABLE,limits:{maxInputTokens:2097152,maxOutputTokens:8192},config:{temperature:.2}},[GoogleGenerativeAI_typedefs_1.GoogleGenerativeAIModelNames.GEMINI_2_0_FLASH]:{name:GoogleGenerativeAI_typedefs_1.GoogleGenerativeAIModelNames.GEMINI_2_0_FLASH,limits:{maxInputTokens:1048576,maxOutputTokens:8192},config:{temperature:.2}},[GoogleGenerativeAI_typedefs_1.GoogleGenerativeAIModelNames.GEMINI_2_0_FLASH_STABLE]:{name:GoogleGenerativeAI_typedefs_1.GoogleGenerativeAIModelNames.GEMINI_2_0_FLASH_STABLE,limits:{maxInputTokens:1048576,maxOutputTokens:8192},config:{temperature:.2}},[GoogleGenerativeAI_typedefs_1.GoogleGenerativeAIModelNames.GEMINI_2_5_PRO]:{name:GoogleGenerativeAI_typedefs_1.GoogleGenerativeAIModelNames.GEMINI_2_5_PRO,limits:{maxInputTokens:1048576,maxOutputTokens:65536},config:{temperature:.2}},[GoogleGenerativeAI_typedefs_1.GoogleGenerativeAIModelNames.GEMINI_2_5_FLASH_PREVIEW_TTS]:{name:GoogleGenerativeAI_typedefs_1.GoogleGenerativeAIModelNames.GEMINI_2_5_FLASH_PREVIEW_TTS,limits:{maxInputTokens:8e3,maxOutputTokens:16e3},config:{temperature:.2}},[GoogleGenerativeAI_typedefs_1.GoogleGenerativeAIModelNames.GEMINI_2_5_PRO_PREVIEW_TTS]:{name:GoogleGenerativeAI_typedefs_1.GoogleGenerativeAIModelNames.GEMINI_2_5_PRO_PREVIEW_TTS,limits:{maxInputTokens:8e3,maxOutputTokens:16e3},config:{temperature:.2}}};exports.GOOGLE_AI_MODELS={[LLMService_typedefs_1.LLMPurposes.Completion]:(0,functional_utils_1.pick)(GOOGLE_AI_AVAILABLE_MODELS,[GoogleGenerativeAI_typedefs_1.GoogleGenerativeAIModelNames.GEMINI_1_5_FLASH,GoogleGenerativeAI_typedefs_1.GoogleGenerativeAIModelNames.GEMINI_1_5_PRO,GoogleGenerativeAI_typedefs_1.GoogleGenerativeAIModelNames.GEMINI_2_0_FLASH,GoogleGenerativeAI_typedefs_1.GoogleGenerativeAIModelNames.GEMINI_2_5_PRO]),[LLMService_typedefs_1.LLMPurposes.Assistance]:(0,functional_utils_1.pick)(GOOGLE_AI_AVAILABLE_MODELS,[GoogleGenerativeAI_typedefs_1.GoogleGenerativeAIModelNames.GEMINI_1_5_PRO_STABLE,GoogleGenerativeAI_typedefs_1.GoogleGenerativeAIModelNames.GEMINI_2_0_FLASH_STABLE]),[LLMService_typedefs_1.LLMPurposes.SpeechToText]:(0,functional_utils_1.pick)(GOOGLE_AI_AVAILABLE_MODELS,[GoogleGenerativeAI_typedefs_1.GoogleGenerativeAIModelNames.GEMINI_2_0_FLASH,GoogleGenerativeAI_typedefs_1.GoogleGenerativeAIModelNames.GEMINI_2_5_PRO]),[LLMService_typedefs_1.LLMPurposes.TextToSpeech]:(0,functional_utils_1.pick)(GOOGLE_AI_AVAILABLE_MODELS,[GoogleGenerativeAI_typedefs_1.GoogleGenerativeAIModelNames.GEMINI_2_5_FLASH_PREVIEW_TTS,GoogleGenerativeAI_typedefs_1.GoogleGenerativeAIModelNames.GEMINI_2_5_PRO_PREVIEW_TTS])},exports.GOOGLE_AI_SERVICE_BUILDERS={[LLMService_typedefs_1.LLMPurposes.Completion]:(e,_)=>new services_1.GoogleGenerativeAICompletionService(e,_),[LLMService_typedefs_1.LLMPurposes.Assistance]:(e,_)=>new services_1.GoogleGenerativeAIAssistanceService(e,_),[LLMService_typedefs_1.LLMPurposes.SpeechToText]:(e,_)=>new services_1.GoogleGenerativeAISpeechToTextService(e,_),[LLMService_typedefs_1.LLMPurposes.TextToSpeech]:(e,_)=>new services_1.GoogleGenerativeAITextToSpeechService(e,_)};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GoogleGenerativeAI.constants.js","sourceRoot":"","sources":["../../../src/providers/GoogleGenerativeAI/GoogleGenerativeAI.constants.ts"],"names":[],"mappings":";;;AAAA,+DAM+B;AAC/B,+EAA6E;AAC7E,sEAKiD;AACjD,yDAA0C;AAE7B,QAAA,wBAAwB,GAAG,MAAM,CAAC;AAE/C,MAAM,0BAA0B,GAE5B;IACF,CAAC,0DAA4B,CAAC,gBAAgB,CAAC,EAAE;QAC/C,IAAI,EAAE,0DAA4B,CAAC,gBAAgB;QACnD,MAAM,EAAE;YACN,cAAc,EAAE,SAAS;YACzB,eAAe,EAAE,KAAK;SACvB;QACD,MAAM,EAAE;YACN,WAAW,EAAE,GAAG;SACjB;KACF;IACD,CAAC,0DAA4B,CAAC,cAAc,CAAC,EAAE;QAC7C,IAAI,EAAE,0DAA4B,CAAC,cAAc;QACjD,MAAM,EAAE;YACN,cAAc,EAAE,SAAS;YACzB,eAAe,EAAE,KAAK;SACvB;QACD,MAAM,EAAE;YACN,WAAW,EAAE,GAAG;SACjB;KACF;IACD,CAAC,0DAA4B,CAAC,qBAAqB,CAAC,EAAE;QACpD,IAAI,EAAE,0DAA4B,CAAC,qBAAqB;QACxD,MAAM,EAAE;YACN,cAAc,EAAE,SAAS;YACzB,eAAe,EAAE,KAAK;SACvB;QACD,MAAM,EAAE;YACN,WAAW,EAAE,GAAG;SACjB;KACF;IACD,CAAC,0DAA4B,CAAC,gBAAgB,CAAC,EAAE;QAC/C,IAAI,EAAE,0DAA4B,CAAC,gBAAgB;QACnD,MAAM,EAAE;YACN,cAAc,EAAE,SAAS;YACzB,eAAe,EAAE,KAAK;SACvB;QACD,MAAM,EAAE;YACN,WAAW,EAAE,GAAG;SACjB;KACF;IACD,CAAC,0DAA4B,CAAC,uBAAuB,CAAC,EAAE;QACtD,IAAI,EAAE,0DAA4B,CAAC,uBAAuB;QAC1D,MAAM,EAAE;YACN,cAAc,EAAE,SAAS;YACzB,eAAe,EAAE,KAAK;SACvB;QACD,MAAM,EAAE;YACN,WAAW,EAAE,GAAG;SACjB;KACF;IACD,CAAC,0DAA4B,CAAC,
|
|
1
|
+
{"version":3,"file":"GoogleGenerativeAI.constants.js","sourceRoot":"","sources":["../../../src/providers/GoogleGenerativeAI/GoogleGenerativeAI.constants.ts"],"names":[],"mappings":";;;AAAA,+DAM+B;AAC/B,+EAA6E;AAC7E,sEAKiD;AACjD,yDAA0C;AAE7B,QAAA,wBAAwB,GAAG,MAAM,CAAC;AAE/C,MAAM,0BAA0B,GAE5B;IACF,CAAC,0DAA4B,CAAC,gBAAgB,CAAC,EAAE;QAC/C,IAAI,EAAE,0DAA4B,CAAC,gBAAgB;QACnD,MAAM,EAAE;YACN,cAAc,EAAE,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MAAM,EAAE,OAAO,EAAE,EAAE,CAAC,CAC7C,IAAI,8CAAmC,CAAC,MAAM,EAAE,OAAO,CAAC,CACzD;IACD,CAAC,iCAAW,CAAC,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,CAAC,CAC/C,IAAI,gDAAqC,CAAC,MAAM,EAAE,OAAO,CAAC,CAC3D;IACD,CAAC,iCAAW,CAAC,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,CAAC,CAC/C,IAAI,gDAAqC,CAAC,MAAM,EAAE,OAAO,CAAC,CAC3D;CACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.GoogleGenerativeAIEntity=void 0;const axios_1=__importDefault(require("axios")),LLMService_typedefs_1=require("../../LLMService.typedefs");class GoogleGenerativeAIEntity{static getContentParameters(e){const{model:t,messages:i,instructions:s}=e;return{model:t.name,contents:i,config:{systemInstruction:s,temperature:t.config.temperature}}}static getFileDataParts(e){return e.map(
|
|
1
|
+
"use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.GoogleGenerativeAIEntity=void 0;const axios_1=__importDefault(require("axios")),LLMService_typedefs_1=require("../../LLMService.typedefs");class GoogleGenerativeAIEntity{static getContentParameters(e){const{model:t,messages:i,instructions:s}=e;return{model:t.name,contents:i,config:{systemInstruction:s,temperature:t.config.temperature}}}static getFileDataParts(e){return e.map(e=>({fileData:{fileUri:e.path,mimeType:e.mimeType}}))}static getTextParts(e){return e.map(e=>({text:e}))}static async getContent(e,t){const i=e.role===LLMService_typedefs_1.LLMRoles.Assistant?"model":e.role,s=[];for(const i of e.content)switch(i.type){case LLMService_typedefs_1.LLMMessageContentType.TEXT:s.push({text:i.text});break;case LLMService_typedefs_1.LLMMessageContentType.IMAGE_URL:{const e=await axios_1.default.head(i.image_url.url),a=e.headers["content-type"]?.split(";")[0]??LLMService_typedefs_1.LLMUploadFileMimeTypes.IMAGE_PNG,r=await axios_1.default.get(i.image_url.url,{responseType:"arraybuffer"}),n=new Uint8Array(r.data),o=new Blob([n],{type:a}),l=await t.files.upload({file:o});s.push({fileData:{fileUri:l.uri,mimeType:a}});break}case LLMService_typedefs_1.LLMMessageContentType.IMAGE_FILE:s.push({fileData:{fileUri:i.image_file.path,mimeType:i.image_file.mime_type}})}return"attachments"in e&&e.attachments&&s.push(...this.getFileDataParts(e.attachments)),{role:i,parts:s}}static getCountTokensFn(e){const t=e=>Boolean(e&&"object"==typeof e&&"role"in e&&"parts"in e);return async(i,s)=>{if(!i)return 0;const a=[];Array.isArray(i)?a.push(...i.filter(t)):t(i)&&a.push(i);const r=a.filter(e=>e&&"string"==typeof e.role&&Array.isArray(e.parts));if(0===r.length)return 0;const{totalTokens:n}=await e.models.countTokens({model:s.name,contents:r});return n??0}}static async combineMessagesWithLimit({modelContext:e=[],history:t=[],message:i,model:s,countTokensFn:a,instance:r}){const n=await Promise.all(e.map(e=>GoogleGenerativeAIEntity.getContent(e,r))),o=await Promise.all(t.map(e=>GoogleGenerativeAIEntity.getContent(e,r))),l={role:LLMService_typedefs_1.LLMRoles.User,content:i.content},p=[...n,await GoogleGenerativeAIEntity.getContent(l,r)],c=[...o].reverse();let m=await a(p,s)??0,y=0;for(const e of c){const t=await a(e,s)??0;if(!(m+t<=s.limits.maxInputTokens))break;y+=1,p.splice(-y,0,e),m+=t}return p}static get transcribeLimits(){return{maxFileSize:2*1024**3,supportedMimeTypes:[LLMService_typedefs_1.LLMUploadFileMimeTypes.AUDIO_WAV,LLMService_typedefs_1.LLMUploadFileMimeTypes.AUDIO_MP3,LLMService_typedefs_1.LLMUploadFileMimeTypes.AUDIO_MPEG,LLMService_typedefs_1.LLMUploadFileMimeTypes.AUDIO_WEBM]}}static get transcribeInstructions(){return"Transcribe the audio file to text."}}exports.GoogleGenerativeAIEntity=GoogleGenerativeAIEntity;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GoogleGenerativeAI.entity.js","sourceRoot":"","sources":["../../../src/providers/GoogleGenerativeAI/GoogleGenerativeAI.entity.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAS1B,+DAY+B;AAE/B,MAAa,wBAAwB;IACnC,MAAM,CAAC,oBAAoB,CAAC,OAI3B;QACC,MAAM,EACJ,KAAK,EACL,QAAQ,EACR,YAAY,GACb,GAAG,OAAO,CAAC;QAEZ,OAAO;YACL,KAAK,EAAE,KAAK,CAAC,IAAI;YACjB,QAAQ,EAAE,QAAQ;YAClB,MAAM,EAAE;gBACN,iBAAiB,EAAE,YAAY;gBAC/B,WAAW,EAAE,KAAK,CAAC,MAAM,CAAC,WAAW;aACtC;SACF,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,gBAAgB,CACrB,aAAgC;QAEhC,OAAO,aAAa,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;YAClC,QAAQ,EAAE;gBACR,OAAO,EAAE,IAAI,CAAC,IAAI;gBAClB,QAAQ,EAAE,IAAI,CAAC,QAAQ;aACxB;SACF,CAAC,CAAC,CAAC;IACN,CAAC;IAED,MAAM,CAAC,YAAY,CACjB,QAAkB;QAElB,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;IACxD,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,UAAU,CACrB,OAAoD,EACpD,QAAqB;QAErB,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,KAAK,8BAAQ,CAAC,SAAS;YAC9C,CAAC,CAAC,OAAO;YACT,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC;QAEjB,MAAM,KAAK,GAAW,EAAE,CAAC;QAEzB,KAAK,MAAM,WAAW,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IAAI,CAAC,CAAC;QAEvE,IAAI,aAAa,GAAG,CAAC,CAAC;QAEtB,KAAK,MAAM,UAAU,IAAI,6BAA6B,EAAE,CAAC;YACvD,MAAM,iBAAiB,GAAG,MAAM,aAAa,CAAC,UAAU,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;YAEtE,IAAI,iBAAiB,GAAG,iBAAiB,IAAI,KAAK,CAAC,MAAM,CAAC,cAAc,EAAE,CAAC;gBACzE,aAAa,IAAI,CAAC,CAAC;gBAEnB,aAAa,CAAC,MAAM,CAAC,CAAC,aAAa,EAAE,CAAC,EAAE,UAAU,CAAC,CAAC;gBAEpD,iBAAiB,IAAI,iBAAiB,CAAC;YACzC,CAAC;iBAAM,CAAC;gBACN,MAAM;YACR,CAAC;QACH,CAAC;QAED,OAAO,aAAa,CAAC;IACvB,CAAC;IAED,MAAM,KAAK,gBAAgB;QACzB,OAAO;YACL,WAAW,EAAE,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,OAAO;YACrC,kBAAkB,EAAE;gBAClB,4CAAsB,CAAC,SAAS;gBAChC,4CAAsB,CAAC,SAAS;gBAChC,4CAAsB,CAAC,UAAU;aAClC;SACF,CAAC;IACJ,CAAC;IAED,MAAM,KAAK,sBAAsB;QAC/B,OAAO,oCAAoC,CAAC;IAC9C,CAAC;CACF;
|
|
1
|
+
{"version":3,"file":"GoogleGenerativeAI.entity.js","sourceRoot":"","sources":["../../../src/providers/GoogleGenerativeAI/GoogleGenerativeAI.entity.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAS1B,+DAY+B;AAE/B,MAAa,wBAAwB;IACnC,MAAM,CAAC,oBAAoB,CAAC,OAI3B;QACC,MAAM,EACJ,KAAK,EACL,QAAQ,EACR,YAAY,GACb,GAAG,OAAO,CAAC;QAEZ,OAAO;YACL,KAAK,EAAE,KAAK,CAAC,IAAI;YACjB,QAAQ,EAAE,QAAQ;YAClB,MAAM,EAAE;gBACN,iBAAiB,EAAE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AAC;QACH,CAAC;QAED,OAAO,aAAa,CAAC;IACvB,CAAC;IAED,MAAM,KAAK,gBAAgB;QACzB,OAAO;YACL,WAAW,EAAE,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,OAAO;YACrC,kBAAkB,EAAE;gBAClB,4CAAsB,CAAC,SAAS;gBAChC,4CAAsB,CAAC,SAAS;gBAChC,4CAAsB,CAAC,UAAU;gBACjC,4CAAsB,CAAC,UAAU;aAClC;SACF,CAAC;IACJ,CAAC;IAED,MAAM,KAAK,sBAAsB;QAC/B,OAAO,oCAAoC,CAAC;IAC9C,CAAC;CACF;AA5OD,4DA4OC"}
|
|
@@ -4,7 +4,7 @@ export declare enum GoogleGenerativeAIModelNames {
|
|
|
4
4
|
GEMINI_1_5_PRO_STABLE = "gemini-1.5-pro-002",
|
|
5
5
|
GEMINI_2_0_FLASH = "gemini-2.0-flash",
|
|
6
6
|
GEMINI_2_0_FLASH_STABLE = "gemini-2.0-flash-001",
|
|
7
|
-
|
|
7
|
+
GEMINI_2_5_PRO = "gemini-2.5-pro",
|
|
8
8
|
GEMINI_2_5_FLASH_PREVIEW_TTS = "gemini-2.5-flash-preview-tts",
|
|
9
9
|
GEMINI_2_5_PRO_PREVIEW_TTS = "gemini-2.5-pro-preview-tts"
|
|
10
10
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var GoogleGenerativeAIModelNames,GoogleGenerativeAIRoles;Object.defineProperty(exports,"__esModule",{value:!0}),exports.GoogleGenerativeAIRoles=exports.GoogleGenerativeAIModelNames=void 0,function(e){e.GEMINI_1_5_FLASH="gemini-1.5-flash",e.GEMINI_1_5_PRO="gemini-1.5-pro",e.GEMINI_1_5_PRO_STABLE="gemini-1.5-pro-002",e.GEMINI_2_0_FLASH="gemini-2.0-flash",e.GEMINI_2_0_FLASH_STABLE="gemini-2.0-flash-001",e.
|
|
1
|
+
"use strict";var GoogleGenerativeAIModelNames,GoogleGenerativeAIRoles;Object.defineProperty(exports,"__esModule",{value:!0}),exports.GoogleGenerativeAIRoles=exports.GoogleGenerativeAIModelNames=void 0,function(e){e.GEMINI_1_5_FLASH="gemini-1.5-flash",e.GEMINI_1_5_PRO="gemini-1.5-pro",e.GEMINI_1_5_PRO_STABLE="gemini-1.5-pro-002",e.GEMINI_2_0_FLASH="gemini-2.0-flash",e.GEMINI_2_0_FLASH_STABLE="gemini-2.0-flash-001",e.GEMINI_2_5_PRO="gemini-2.5-pro",e.GEMINI_2_5_FLASH_PREVIEW_TTS="gemini-2.5-flash-preview-tts",e.GEMINI_2_5_PRO_PREVIEW_TTS="gemini-2.5-pro-preview-tts"}(GoogleGenerativeAIModelNames||(exports.GoogleGenerativeAIModelNames=GoogleGenerativeAIModelNames={})),function(e){e.User="user",e.Model="model"}(GoogleGenerativeAIRoles||(exports.GoogleGenerativeAIRoles=GoogleGenerativeAIRoles={}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GoogleGenerativeAI.typedefs.js","sourceRoot":"","sources":["../../../src/providers/GoogleGenerativeAI/GoogleGenerativeAI.typedefs.ts"],"names":[],"mappings":";;;AAAA,IAAY,4BASX;AATD,WAAY,4BAA4B;IACtC,qEAAqC,CAAA;IACrC,iEAAiC,CAAA;IACjC,4EAA4C,CAAA;IAC5C,qEAAqC,CAAA;IACrC,gFAAgD,CAAA;IAChD,
|
|
1
|
+
{"version":3,"file":"GoogleGenerativeAI.typedefs.js","sourceRoot":"","sources":["../../../src/providers/GoogleGenerativeAI/GoogleGenerativeAI.typedefs.ts"],"names":[],"mappings":";;;AAAA,IAAY,4BASX;AATD,WAAY,4BAA4B;IACtC,qEAAqC,CAAA;IACrC,iEAAiC,CAAA;IACjC,4EAA4C,CAAA;IAC5C,qEAAqC,CAAA;IACrC,gFAAgD,CAAA;IAChD,iEAAiC,CAAA;IACjC,6FAA6D,CAAA;IAC7D,yFAAyD,CAAA;AAC3D,CAAC,EATW,4BAA4B,4CAA5B,4BAA4B,QASvC;AAED,IAAY,uBAGX;AAHD,WAAY,uBAAuB;IACjC,wCAAa,CAAA;IACb,0CAAe,CAAA;AACjB,CAAC,EAHW,uBAAuB,uCAAvB,uBAAuB,QAGlC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.GoogleGenerativeAIAssistanceService=void 0;const uuid_1=require("uuid"),genai_1=require("@google/genai"),LLMService_typedefs_1=require("../../../LLMService.typedefs"),services_1=require("../../../services"),GoogleGenerativeAI_typedefs_1=require("../../../providers/GoogleGenerativeAI/GoogleGenerativeAI.typedefs"),GoogleGenerativeAI_entity_1=require("../../../providers/GoogleGenerativeAI/GoogleGenerativeAI.entity"),GoogleGenerativeAI_constants_1=require("../../../providers/GoogleGenerativeAI/GoogleGenerativeAI.constants");class GoogleGenerativeAIAssistanceService extends services_1.LLMAssistanceService{#e=null;cachedContent=new Map;chatSessions=new Map;uploadedFiles=new Map;uncachedFileStorages=new Map;constructor(e,t){super(LLMService_typedefs_1.LLMProviders.GoogleGenerativeAI,e,t)}get instance(){return this.#e||(this.#e=new genai_1.GoogleGenAI({apiKey:this.options.apiKey})),this.#e}async uploadFile(e){try{const{path:t,mimeType:r,name:i}=e,s=this.uploadedFiles.get(t);if(s)return s;const o=await this.instance.files.upload({file:t,config:{mimeType:r,displayName:i}});if(!o.name)throw new Error("Upload result did not return a name");if(!o.uri)throw new Error("Upload result did not return a uri");if(o.error)throw o.error;const n={...e,fileId:o.name,path:o.uri};return this.uploadedFiles.set(t,n),n}catch(t){return this.logger.child("uploadFile").error("Error uploading file",{error:t,file:e}),{error:t}}}async deleteFile(e){this.uploadedFiles.delete(e),await this.instance.files.delete({name:e})}async createFileStorage(e){const{uploadedFiles:t,model:r,instructions:i}=e;try{const e=GoogleGenerativeAI_entity_1.GoogleGenerativeAIEntity.getFileDataParts(t),s=GoogleGenerativeAI_entity_1.GoogleGenerativeAIEntity.getCountTokensFn(this.instance),o=await s(e,r);if(o<GoogleGenerativeAI_constants_1.MIN_CACHE_CONTENT_LENGTH){const e=(0,uuid_1.v4)();return this.uncachedFileStorages.set(e,t),this.logger.child("createFileStorage").info("File storage created without caching (content too small)",{storageId:e,tokenCount:o,minRequired:GoogleGenerativeAI_constants_1.MIN_CACHE_CONTENT_LENGTH}),{storageId:e}}const n=await this.instance.caches.create({model:r.name,config:{contents:[{role:GoogleGenerativeAI_typedefs_1.GoogleGenerativeAIRoles.User,parts:e}],systemInstruction:i,ttl:"1h"}});if(!n.name)throw new Error("Cache result did not return a name");return this.cachedContent.set(n.name,n),{storageId:n.name}}catch(e){return this.logger.child("createFileStorage").error("Error creating file storage",{error:e,uploadedFiles:t,model:r}),{error:e}}}async deleteFileStorage(e){if(""===e)return;this.cachedContent.get(e)&&(this.cachedContent.delete(e),await this.instance.caches.delete({name:e})),this.uncachedFileStorages.delete(e)}async createChat(e){try{const{storageId:t,model:r,instructions:i,history:s,files:o}=e,n=t?this.cachedContent.get(t):void 0,a=t?this.uncachedFileStorages.get(t):void 0,c=s?await Promise.all(s.map(
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.GoogleGenerativeAIAssistanceService=void 0;const uuid_1=require("uuid"),genai_1=require("@google/genai"),LLMService_typedefs_1=require("../../../LLMService.typedefs"),services_1=require("../../../services"),GoogleGenerativeAI_typedefs_1=require("../../../providers/GoogleGenerativeAI/GoogleGenerativeAI.typedefs"),GoogleGenerativeAI_entity_1=require("../../../providers/GoogleGenerativeAI/GoogleGenerativeAI.entity"),GoogleGenerativeAI_constants_1=require("../../../providers/GoogleGenerativeAI/GoogleGenerativeAI.constants");class GoogleGenerativeAIAssistanceService extends services_1.LLMAssistanceService{#e=null;cachedContent=new Map;chatSessions=new Map;uploadedFiles=new Map;uncachedFileStorages=new Map;constructor(e,t){super(LLMService_typedefs_1.LLMProviders.GoogleGenerativeAI,e,t)}get instance(){return this.#e||(this.#e=new genai_1.GoogleGenAI({apiKey:this.options.apiKey})),this.#e}async uploadFile(e){try{const{path:t,mimeType:r,name:i}=e,s=this.uploadedFiles.get(t);if(s)return s;const o=await this.instance.files.upload({file:t,config:{mimeType:r,displayName:i}});if(!o.name)throw new Error("Upload result did not return a name");if(!o.uri)throw new Error("Upload result did not return a uri");if(o.error)throw o.error;const n={...e,fileId:o.name,path:o.uri};return this.uploadedFiles.set(t,n),n}catch(t){return this.logger.child("uploadFile").error("Error uploading file",{error:t,file:e}),{error:t}}}async deleteFile(e){this.uploadedFiles.delete(e),await this.instance.files.delete({name:e})}async createFileStorage(e){const{uploadedFiles:t,model:r,instructions:i}=e;try{const e=GoogleGenerativeAI_entity_1.GoogleGenerativeAIEntity.getFileDataParts(t),s=GoogleGenerativeAI_entity_1.GoogleGenerativeAIEntity.getCountTokensFn(this.instance),o=await s(e,r);if(o<GoogleGenerativeAI_constants_1.MIN_CACHE_CONTENT_LENGTH){const e=(0,uuid_1.v4)();return this.uncachedFileStorages.set(e,t),this.logger.child("createFileStorage").info("File storage created without caching (content too small)",{storageId:e,tokenCount:o,minRequired:GoogleGenerativeAI_constants_1.MIN_CACHE_CONTENT_LENGTH}),{storageId:e}}const n=await this.instance.caches.create({model:r.name,config:{contents:[{role:GoogleGenerativeAI_typedefs_1.GoogleGenerativeAIRoles.User,parts:e}],systemInstruction:i,ttl:"1h"}});if(!n.name)throw new Error("Cache result did not return a name");return this.cachedContent.set(n.name,n),{storageId:n.name}}catch(e){return this.logger.child("createFileStorage").error("Error creating file storage",{error:e,uploadedFiles:t,model:r}),{error:e}}}async deleteFileStorage(e){if(""===e)return;this.cachedContent.get(e)&&(this.cachedContent.delete(e),await this.instance.caches.delete({name:e})),this.uncachedFileStorages.delete(e)}async createChat(e){try{const{storageId:t,model:r,instructions:i,history:s,files:o}=e,n=t?this.cachedContent.get(t):void 0,a=t?this.uncachedFileStorages.get(t):void 0,c=s?await Promise.all(s.map(e=>GoogleGenerativeAI_entity_1.GoogleGenerativeAIEntity.getContent(e,this.instance))):[];if(!n&&o){const e=GoogleGenerativeAI_entity_1.GoogleGenerativeAIEntity.getFileDataParts(o);c.push({role:GoogleGenerativeAI_typedefs_1.GoogleGenerativeAIRoles.User,parts:e})}if(!n&&a){const e=GoogleGenerativeAI_entity_1.GoogleGenerativeAIEntity.getFileDataParts(a);c.push({role:GoogleGenerativeAI_typedefs_1.GoogleGenerativeAIRoles.User,parts:e})}const l=this.instance.chats.create({model:r.name,history:c,config:{systemInstruction:i,temperature:r.config.temperature,...n&&{cachedContent:n.name}}}),d=(0,uuid_1.v4)();return this.chatSessions.set(d,l),Promise.resolve({chatId:d})}catch(t){return this.logger.child("createChat").error("Error creating chat",{error:t,options:e}),Promise.resolve({error:t})}}deleteChat(e){return this.chatSessions.delete(e),Promise.resolve()}createAssistant(){return Promise.resolve({assistantId:""})}deleteAssistant(){return Promise.resolve()}async assistInChat(e){try{const{message:t,chatId:r}=e,i=this.chatSessions.get(r);if(!i)throw new Error("Chat session not found");const s=await GoogleGenerativeAI_entity_1.GoogleGenerativeAIEntity.getContent(t,this.instance);if(!s.parts)return{text:""};return{text:(await i.sendMessage({message:s.parts})).text??""}}catch(t){return this.logger.child("assistInChat").error("Error assisting in chat",{error:t,options:e}),{error:t}}}}exports.GoogleGenerativeAIAssistanceService=GoogleGenerativeAIAssistanceService;
|
package/dist/providers/GoogleGenerativeAI/services/GoogleGenerativeAISpeechToText.service.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.GoogleGenerativeAISpeechToTextService=void 0;const fs_1=require("fs"),genai_1=require("@google/genai"),LLMService_typedefs_1=require("../../../LLMService.typedefs"),services_1=require("../../../services"),GoogleGenerativeAI_entity_1=require("../../../providers/GoogleGenerativeAI/GoogleGenerativeAI.entity"),mime_types_1=__importDefault(require("mime-types"));class GoogleGenerativeAISpeechToTextService extends services_1.LLMSpeechToTextService{#e=null;constructor(e,t){super(LLMService_typedefs_1.LLMProviders.GoogleGenerativeAI,e,t)}get instance(){return this.#e||(this.#e=new genai_1.GoogleGenAI({apiKey:this.options.apiKey})),this.#e}async transcribe(e){try{const{model:t,pathToAudio:i}=e,{maxFileSize:
|
|
1
|
+
"use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.GoogleGenerativeAISpeechToTextService=void 0;const fs_1=require("fs"),genai_1=require("@google/genai"),LLMService_typedefs_1=require("../../../LLMService.typedefs"),services_1=require("../../../services"),GoogleGenerativeAI_entity_1=require("../../../providers/GoogleGenerativeAI/GoogleGenerativeAI.entity"),mime_types_1=__importDefault(require("mime-types"));class GoogleGenerativeAISpeechToTextService extends services_1.LLMSpeechToTextService{#e=null;constructor(e,t){super(LLMService_typedefs_1.LLMProviders.GoogleGenerativeAI,e,t)}get instance(){return this.#e||(this.#e=new genai_1.GoogleGenAI({apiKey:this.options.apiKey})),this.#e}async transcribe(e){try{const{model:t,pathToAudio:i,mimeType:r}=e,{maxFileSize:o,supportedMimeTypes:n}=GoogleGenerativeAI_entity_1.GoogleGenerativeAIEntity.transcribeLimits;if((0,fs_1.statSync)(i).size>o)throw new Error(`File size exceeds the limit of ${o} bytes`);const s=r??mime_types_1.default.lookup(i);if(!s||!n.includes(s))throw new Error(`Unsupported audio file type: ${s}. Supported types are: ${n.join(", ")}`);const a=await this.instance.files.upload({file:i,config:{mimeType:r}});if(!a||!a.uri||!a.mimeType)throw new Error(`Failed to upload audio file, response: ${JSON.stringify(a)}`);return{text:(await this.instance.models.generateContent({model:t.name,contents:(0,genai_1.createUserContent)([(0,genai_1.createPartFromUri)(a.uri,a.mimeType),GoogleGenerativeAI_entity_1.GoogleGenerativeAIEntity.transcribeInstructions]),config:t.config})).text??""}}catch(t){return this.logger.child("transcribe").error("Error transcribing audio",{error:t,options:e}),{error:t}}}}exports.GoogleGenerativeAISpeechToTextService=GoogleGenerativeAISpeechToTextService;
|
package/dist/providers/GoogleGenerativeAI/services/GoogleGenerativeAISpeechToText.service.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GoogleGenerativeAISpeechToText.service.js","sourceRoot":"","sources":["../../../../src/providers/GoogleGenerativeAI/services/GoogleGenerativeAISpeechToText.service.ts"],"names":[],"mappings":";;;;;;AAAA,2BAA8B;AAE9B,yCAIuB;AACvB,+DAK+B;AAC/B,yCAEoB;AACpB,wGAAoG;AACpG,4DAA8B;AAE9B,MAAa,qCACX,SAAQ,iCAAuD;IAC/D,SAAS,GAAuB,IAAI,CAAC;IAErC,YACE,MAAc,EACd,OAA4D;QAE5D,KAAK,CAAC,kCAAY,CAAC,kBAAkB,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IAC1D,CAAC;IAED,IAAc,QAAQ;QACpB,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;YACpB,IAAI,CAAC,SAAS,GAAG,IAAI,mBAAW,CAAC;gBAC/B,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM;aAC5B,CAAC,CAAC;QACL,CAAC;QAED,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAED,KAAK,CAAC,UAAU,CACd,OAAmD;QAEnD,IAAI,CAAC;YACH,MAAM,EACJ,KAAK,EACL,WAAW,
|
|
1
|
+
{"version":3,"file":"GoogleGenerativeAISpeechToText.service.js","sourceRoot":"","sources":["../../../../src/providers/GoogleGenerativeAI/services/GoogleGenerativeAISpeechToText.service.ts"],"names":[],"mappings":";;;;;;AAAA,2BAA8B;AAE9B,yCAIuB;AACvB,+DAK+B;AAC/B,yCAEoB;AACpB,wGAAoG;AACpG,4DAA8B;AAE9B,MAAa,qCACX,SAAQ,iCAAuD;IAC/D,SAAS,GAAuB,IAAI,CAAC;IAErC,YACE,MAAc,EACd,OAA4D;QAE5D,KAAK,CAAC,kCAAY,CAAC,kBAAkB,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IAC1D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,CAAC,0CAA0C,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;YACzF,CAAC;YAED,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,eAAe,CAAC;gBAC1D,KAAK,EAAE,KAAK,CAAC,IAAI;gBACjB,QAAQ,EAAE,IAAA,yBAAiB,EAAC;oBAC1B,IAAA,yBAAiB,EAAC,SAAS,CAAC,GAAG,EAAE,SAAS,CAAC,QAAQ,CAAC;oBACpD,oDAAwB,CAAC,sBAAsB;iBAChD,CAAC;gBACF,MAAM,EAAE,KAAK,CAAC,MAAM;aACrB,CAAC,CAAC;YAEH,OAAO;gBACL,IAAI,EAAE,QAAQ,CAAC,IAAI,IAAI,EAAE;aAC1B,CAAC;QACJ,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,IAAI,CAAC,MAAM;iBACR,KAAK,CAAC,YAAY,CAAC;iBACnB,KAAK,CAAC,0BAA0B,EAAE;gBACjC,KAAK;gBACL,OAAO;aACR,CAAC,CAAC;YAEL,OAAO,EAAE,KAAK,EAAE,CAAC;QACnB,CAAC;IACH,CAAC;CACF;AAtFD,sFAsFC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.OpenAIEntity=void 0;const LLMService_constants_1=require("../../LLMService.constants"),LLMService_typedefs_1=require("../../LLMService.typedefs"),OpenAI_typedefs_1=require("../../providers/OpenAI/OpenAI.typedefs"),js_tiktoken_1=require("js-tiktoken");class OpenAIEntity{static getCountTokensFn(){return e=>{const t=(0,js_tiktoken_1.getEncoding)("o200k_base"),s=e.reduce((
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.OpenAIEntity=void 0;const LLMService_constants_1=require("../../LLMService.constants"),LLMService_typedefs_1=require("../../LLMService.typedefs"),OpenAI_typedefs_1=require("../../providers/OpenAI/OpenAI.typedefs"),js_tiktoken_1=require("js-tiktoken");class OpenAIEntity{static getCountTokensFn(){return e=>{const t=(0,js_tiktoken_1.getEncoding)("o200k_base"),s=e.reduce((e,s)=>{switch(s.type){case LLMService_typedefs_1.LLMMessageContentType.IMAGE_URL:case LLMService_typedefs_1.LLMMessageContentType.IMAGE_FILE:return e+LLMService_constants_1.APPROXIMATE_TOKENS_COUNT_IN_IMAGE;case LLMService_typedefs_1.LLMMessageContentType.TEXT:return e+t.encode(s.text).length;default:return e}},0);return Promise.resolve(s)}}static getChatCompletionMessageParam(e){return e.map(e=>({role:e.role===LLMService_typedefs_1.LLMRoles.User?OpenAI_typedefs_1.OpenAIRoles.User:OpenAI_typedefs_1.OpenAIRoles.Assistant,content:e.content}))}static async combineMessagesWithLimit({modelContext:e=[],history:t=[],message:s,model:n,countTokensFn:i}){const r=[...e];if(t[0]){const e=t[0];r.push(e)}const o=[{role:LLMService_typedefs_1.LLMRoles.User,content:s.content},...t.slice(1).reverse()],p=r.flatMap(e=>e.content);let L=await(i?.(p,n))??0;for(const e of o){const t=L+(await(i?.(e.content,n))??0);if(!(t<=n.limits.maxInputTokens))break;r.push(e),L=t}return r}static get transcribeLimits(){return{maxFileSize:26214400,supportedMimeTypes:[LLMService_typedefs_1.LLMUploadFileMimeTypes.AUDIO_WAV,LLMService_typedefs_1.LLMUploadFileMimeTypes.AUDIO_MP3,LLMService_typedefs_1.LLMUploadFileMimeTypes.AUDIO_MPEG,LLMService_typedefs_1.LLMUploadFileMimeTypes.AUDIO_WEBM]}}}exports.OpenAIEntity=OpenAIEntity;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OpenAI.entity.js","sourceRoot":"","sources":["../../../src/providers/OpenAI/OpenAI.entity.ts"],"names":[],"mappings":";;;AAAA,iEAA2E;AAC3E,+DAU+B;AAC/B,wEAAiE;AACjE,6CAA0C;AAG1C,MAAa,YAAY;IACvB,MAAM,CAAC,gBAAgB;QACrB,OAAO,CACL,gBAAqC,EACpB,EAAE;YACnB,MAAM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BAChC,4CAAsB,CAAC,SAAS;gBAChC,4CAAsB,CAAC,UAAU;gBACjC,4CAAsB,CAAC,UAAU;aAClC;SACF,CAAC;IACJ,CAAC;CACF;AArGD,oCAqGC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.OpenAIAssistanceService=void 0;const fs_1=require("fs"),openai_1=require("openai"),LLMService_typedefs_1=require("../../../LLMService.typedefs"),services_1=require("../../../services"),OpenAI_typedefs_1=require("../../../providers/OpenAI/OpenAI.typedefs");class OpenAIAssistanceService extends services_1.LLMAssistanceService{#e=null;uploadedFiles=new Map;constructor(e,t){super(LLMService_typedefs_1.LLMProviders.OpenAI,e,t)}get instance(){return this.#e||(this.#e=new openai_1.OpenAI(this.options)),this.#e}async uploadFile(e){try{const{path:t}=e,s=this.uploadedFiles.get(t);if(s){if((await this.instance.files.retrieve(s)).id)return{...e,fileId:s}}const r=(0,fs_1.createReadStream)(t),i=await this.instance.files.create({purpose:"assistants",file:r});return await this.instance.files.waitForProcessing(i.id),this.uploadedFiles.set(t,i.id),{...e,fileId:i.id}}catch(t){return this.logger.child("uploadFile").error("Error uploading file",{error:t,file:e}),{error:t}}}async deleteFile(e){await this.instance.files.delete(e),this.uploadedFiles.delete(e)}async createFileStorage(e){const{uploadedFiles:t}=e;try{const e=await this.instance.vectorStores.create({expires_after:{anchor:"last_active_at",days:1}});return await this.instance.vectorStores.fileBatches.createAndPoll(e.id,{file_ids:t.map((
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.OpenAIAssistanceService=void 0;const fs_1=require("fs"),openai_1=require("openai"),LLMService_typedefs_1=require("../../../LLMService.typedefs"),services_1=require("../../../services"),OpenAI_typedefs_1=require("../../../providers/OpenAI/OpenAI.typedefs");class OpenAIAssistanceService extends services_1.LLMAssistanceService{#e=null;uploadedFiles=new Map;constructor(e,t){super(LLMService_typedefs_1.LLMProviders.OpenAI,e,t)}get instance(){return this.#e||(this.#e=new openai_1.OpenAI(this.options)),this.#e}async uploadFile(e){try{const{path:t}=e,s=this.uploadedFiles.get(t);if(s){if((await this.instance.files.retrieve(s)).id)return{...e,fileId:s}}const r=(0,fs_1.createReadStream)(t),i=await this.instance.files.create({purpose:"assistants",file:r});return await this.instance.files.waitForProcessing(i.id),this.uploadedFiles.set(t,i.id),{...e,fileId:i.id}}catch(t){return this.logger.child("uploadFile").error("Error uploading file",{error:t,file:e}),{error:t}}}async deleteFile(e){await this.instance.files.delete(e),this.uploadedFiles.delete(e)}async createFileStorage(e){const{uploadedFiles:t}=e;try{const e=await this.instance.vectorStores.create({expires_after:{anchor:"last_active_at",days:1}});return await this.instance.vectorStores.fileBatches.createAndPoll(e.id,{file_ids:t.map(({fileId:e})=>e)}),{storageId:e.id}}catch(e){return this.logger.child("createFileStorage").error("Error creating file storage",{error:e,uploadedFiles:t}),{error:e}}}async deleteFileStorage(e){await this.instance.vectorStores.delete(e)}async createChat(e){try{const{storageId:t,history:s,files:r}=e,i=t?{tool_resources:{file_search:{vector_store_ids:[t]}}}:{},a=s?.map(e=>({...e,content:e.content,role:e.role===LLMService_typedefs_1.LLMRoles.User?OpenAI_typedefs_1.OpenAIRoles.User:OpenAI_typedefs_1.OpenAIRoles.Assistant}))??[];r&&r.length>0&&a.push({role:OpenAI_typedefs_1.OpenAIRoles.User,content:r.map(e=>({type:LLMService_typedefs_1.LLMMessageContentType.IMAGE_FILE,image_file:{file_id:e.fileId,detail:"high"}}))});return{chatId:(await this.instance.beta.threads.create({messages:a,...i})).id}}catch(t){return this.logger.child("createChat").error("Error creating chat",{error:t,options:e}),{error:t}}}async deleteChat(e){await this.instance.beta.threads.delete(e)}async createAssistant(e){try{const{model:t,instructions:s,storageIds:r,name:i}=e,a=r?.length?{tools:[{type:"file_search"}],tool_resources:{file_search:{vector_store_ids:r}}}:{};return{assistantId:(await this.instance.beta.assistants.create({model:t.name,instructions:s,temperature:t.config.temperature,top_p:t.config.top_p,name:i,...a})).id}}catch(t){return this.logger.child("createAssistant").error("Error creating assistant",{error:t,options:e}),{error:t}}}async deleteAssistant(e){await this.instance.beta.assistants.delete(e)}async assistInChat(e){try{const{message:t,chatId:s,assistantId:r}=e,{attachments:i,content:a,role:n}=t,o=[];i&&i.forEach(e=>{o.push({type:"image_file",image_file:{file_id:e.fileId,detail:"high"}})}),o.push(...a);const c={role:n===LLMService_typedefs_1.LLMRoles.User?OpenAI_typedefs_1.OpenAIRoles.User:OpenAI_typedefs_1.OpenAIRoles.Assistant,content:o};await this.instance.beta.threads.messages.create(s,c);const l=await this.instance.beta.threads.runs.createAndPoll(s,{assistant_id:r}),{status:d}=l;if("completed"!==d)throw new Error(`Thread run did not complete for message, status: ${d}`);const p=(await this.instance.beta.threads.messages.list(s,{run_id:l.id})).data.find(e=>e.role===OpenAI_typedefs_1.OpenAIRoles.Assistant),h=p?.content.find(e=>"text"===e.type&&"text"in e);return{text:h?.text?.value??""}}catch(t){return this.logger.child("assistInChat").error("Error assisting in chat",{error:t,options:e}),{error:t}}}}exports.OpenAIAssistanceService=OpenAIAssistanceService;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.OpenAISpeechToTextService=void 0;const fs_1=require("fs"),openai_1=require("openai"),LLMService_typedefs_1=require("../../../LLMService.typedefs"),services_1=require("../../../services"),OpenAI_entity_1=require("../../../providers/OpenAI/OpenAI.entity"),mime_types_1=__importDefault(require("mime-types"));class OpenAISpeechToTextService extends services_1.LLMSpeechToTextService{#e=null;constructor(e,t){super(LLMService_typedefs_1.LLMProviders.OpenAI,e,t)}get instance(){return this.#e||(this.#e=new openai_1.OpenAI(this.options)),this.#e}async transcribe(e){try{const{model:t,pathToAudio:r}=e,{maxFileSize:
|
|
1
|
+
"use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.OpenAISpeechToTextService=void 0;const fs_1=require("fs"),openai_1=require("openai"),LLMService_typedefs_1=require("../../../LLMService.typedefs"),services_1=require("../../../services"),OpenAI_entity_1=require("../../../providers/OpenAI/OpenAI.entity"),mime_types_1=__importDefault(require("mime-types"));class OpenAISpeechToTextService extends services_1.LLMSpeechToTextService{#e=null;constructor(e,t){super(LLMService_typedefs_1.LLMProviders.OpenAI,e,t)}get instance(){return this.#e||(this.#e=new openai_1.OpenAI(this.options)),this.#e}async transcribe(e){try{const{model:t,pathToAudio:r,mimeType:i}=e,{maxFileSize:s,supportedMimeTypes:n}=OpenAI_entity_1.OpenAIEntity.transcribeLimits;if((0,fs_1.statSync)(r).size>s)throw new Error(`File size exceeds the limit of ${s} bytes`);const o=i??mime_types_1.default.lookup(r);if(!o||!n.includes(o))throw new Error(`Unsupported audio file type: ${o}. Supported types are: ${n.join(", ")}`);const p=(0,fs_1.createReadStream)(r);return{text:await this.instance.audio.transcriptions.create({model:t.name,file:p,response_format:"text"})}}catch(t){return this.logger.child("transcribe").error("Error transcribing audio",{error:t,options:e}),{error:t}}}}exports.OpenAISpeechToTextService=OpenAISpeechToTextService;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OpenAISpeechToText.service.js","sourceRoot":"","sources":["../../../../src/providers/OpenAI/services/OpenAISpeechToText.service.ts"],"names":[],"mappings":";;;;;;AAAA,2BAAgD;AAEhD,mCAAgC;AAChC,+DAK+B;AAC/B,yCAAoD;AACpD,oEAAgE;AAChE,4DAA8B;AAE9B,MAAa,yBACX,SAAQ,iCAA2C;IACnD,SAAS,GAAkB,IAAI,CAAC;IAEhC,YACE,MAAc,EACd,OAAgD;QAEhD,KAAK,CAAC,kCAAY,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9C,CAAC;IAED,IAAc,QAAQ;QACpB,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;YACpB,IAAI,CAAC,SAAS,GAAG,IAAI,eAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC5C,CAAC;QAED,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAED,KAAK,CAAC,UAAU,CACd,OAAmD;QAEnD,IAAI,CAAC;YACH,MAAM,EACJ,KAAK,EACL,WAAW,
|
|
1
|
+
{"version":3,"file":"OpenAISpeechToText.service.js","sourceRoot":"","sources":["../../../../src/providers/OpenAI/services/OpenAISpeechToText.service.ts"],"names":[],"mappings":";;;;;;AAAA,2BAAgD;AAEhD,mCAAgC;AAChC,+DAK+B;AAC/B,yCAAoD;AACpD,oEAAgE;AAChE,4DAA8B;AAE9B,MAAa,yBACX,SAAQ,iCAA2C;IACnD,SAAS,GAAkB,IAAI,CAAC;IAEhC,YACE,MAAc,EACd,OAAgD;QAEhD,KAAK,CAAC,kCAAY,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9C,CAAC;IAED,IAAc,QAAQ;QACpB,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;YACpB,IAAI,CAAC,SAAS,GAAG,IAAI,eAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC5C,CAAC;QAED,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAED,KAAK,CAAC,UAAU,CACd,OAAmD;QAEnD,IAAI,CAAC;YACH,MAAM,EACJ,KAAK,EACL,WAAW,EACX,QAAQ,GACT,GAAG,OAAO,CAAC;YAEZ,MAAM,EACJ,WAAW,EACX,kBAAkB,GACnB,GAAG,4BAAY,CAAC,gBAAgB,CAAC;YAElC,MAAM,QAAQ,GAAG,IAAA,aAAQ,EAAC,WAAW,CAAC,CAAC,IAAI,CAAC;YAE5C,IAAI,QAAQ,GAAG,WAAW,EAAE,CAAC;gBAC3B,MAAM,IAAI,KAAK,CACb,kCAAkC,WAAW,QAAQ,CACtD,CAAC;YACJ,CAAC;YAED,MAAM,gBAAgB,GAAG,QAAQ,IAAI,oBAAI,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;YAE9D,IAAI,CAAC,gBAAgB,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC,gBAAuB,CAAC,EAAE,CAAC;gBAC/E,MAAM,IAAI,KAAK,CACb,gCAAgC,gBAAgB,0BAA0B,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAC1G,CAAC;YACJ,CAAC;YAED,MAAM,SAAS,GAAG,IAAA,qBAAgB,EAAC,WAAW,CAAC,CAAC;YAEhD,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC;gBAC3D,KAAK,EAAE,KAAK,CAAC,IAAI;gBACjB,IAAI,EAAE,SAAS;gBACf,eAAe,EAAE,MAAM;aACxB,CAAC,CAAC;YAEH,OAAO,EAAE,IAAI,EAAE,CAAC;QAClB,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,IAAI,CAAC,MAAM;iBACR,KAAK,CAAC,YAAY,CAAC;iBACnB,KAAK,CAAC,0BAA0B,EAAE;gBACjC,KAAK;gBACL,OAAO;aACR,CAAC,CAAC;YAEL,OAAO,EAAE,KAAK,EAAE,CAAC;QACnB,CAAC;IACH,CAAC;CACF;AAtED,8DAsEC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mate-academy/llm-gateway",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "A gateway package for LLM services.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -11,7 +11,9 @@
|
|
|
11
11
|
"lint:fix": "eslint . --fix",
|
|
12
12
|
"test": "ENABLE_LOGGING=true jest",
|
|
13
13
|
"test:silent": "jest",
|
|
14
|
-
"
|
|
14
|
+
"test:integration": "ENABLE_LOGGING=true jest src/tests/integration --verbose",
|
|
15
|
+
"prepublish-tests": "node scripts/prepublish-tests.js",
|
|
16
|
+
"prepublishOnly": "npm run prepublish-tests && npm run lint:fix && npm run type-check && npm run build",
|
|
15
17
|
"type-check": "tsc --noEmit",
|
|
16
18
|
"postpublish": "npm run clean",
|
|
17
19
|
"clean": "rm -rf ./dist",
|
|
@@ -47,25 +49,29 @@
|
|
|
47
49
|
},
|
|
48
50
|
"devDependencies": {
|
|
49
51
|
"@mate-academy/ts-config": "^1.0.5",
|
|
50
|
-
"@types/
|
|
52
|
+
"@types/glob": "^8.1.0",
|
|
53
|
+
"@types/inquirer": "^9.0.8",
|
|
54
|
+
"@types/jest": "^30.0.0",
|
|
51
55
|
"@types/mime-types": "^3.0.1",
|
|
52
56
|
"@typescript-eslint/eslint-plugin": "^8.33.1",
|
|
53
57
|
"dotenv": "^16.5.0",
|
|
54
|
-
"eslint": "^9.
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
+
"eslint": "^9.29.0",
|
|
59
|
+
"glob": "^11.0.3",
|
|
60
|
+
"inquirer": "^12.6.3",
|
|
61
|
+
"jest": "^30.0.2",
|
|
62
|
+
"terser": "^5.43.1",
|
|
63
|
+
"ts-jest": "^29.4.0",
|
|
58
64
|
"tsc-alias": "^1.8.16",
|
|
59
65
|
"typescript": "^5.8.3",
|
|
60
|
-
"typescript-eslint": "^8.
|
|
66
|
+
"typescript-eslint": "^8.34.1"
|
|
61
67
|
},
|
|
62
68
|
"dependencies": {
|
|
63
|
-
"@google/genai": "^1.
|
|
69
|
+
"@google/genai": "^1.6.0",
|
|
64
70
|
"@mate-academy/core": "^1.10.4",
|
|
65
|
-
"axios": "^1.
|
|
71
|
+
"axios": "^1.10.0",
|
|
66
72
|
"js-tiktoken": "^1.0.20",
|
|
67
73
|
"mime-types": "^3.0.1",
|
|
68
|
-
"openai": "^5.
|
|
74
|
+
"openai": "^5.6.0",
|
|
69
75
|
"uuid": "^11.1.0"
|
|
70
76
|
}
|
|
71
77
|
}
|