@mate-academy/llm-gateway 1.2.0 → 1.2.1-canary.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/LLMService.factory.d.ts +22 -0
- package/dist/LLMService.factory.js +1 -1
- package/dist/LLMService.factory.js.map +1 -1
- package/dist/LLMService.typedefs.d.ts +71 -15
- package/dist/LLMService.typedefs.js +1 -1
- package/dist/LLMService.typedefs.js.map +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.d.ts +4 -2
- 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 +3 -2
- 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/GoogleGenerativeAIAssistance.service.js.map +1 -1
- package/dist/providers/GoogleGenerativeAI/services/GoogleGenerativeAISpeechToText.service.d.ts +10 -0
- package/dist/providers/GoogleGenerativeAI/services/GoogleGenerativeAISpeechToText.service.js +1 -0
- package/dist/providers/GoogleGenerativeAI/services/GoogleGenerativeAISpeechToText.service.js.map +1 -0
- package/dist/providers/GoogleGenerativeAI/services/GoogleGenerativeAITextToSpeech.service.d.ts +10 -0
- package/dist/providers/GoogleGenerativeAI/services/GoogleGenerativeAITextToSpeech.service.js +1 -0
- package/dist/providers/GoogleGenerativeAI/services/GoogleGenerativeAITextToSpeech.service.js.map +1 -0
- package/dist/providers/GoogleGenerativeAI/services/index.d.ts +2 -0
- package/dist/providers/GoogleGenerativeAI/services/index.js +1 -1
- package/dist/providers/GoogleGenerativeAI/services/index.js.map +1 -1
- package/dist/providers/OpenAI/OpenAI.constants.js +1 -1
- package/dist/providers/OpenAI/OpenAI.constants.js.map +1 -1
- package/dist/providers/OpenAI/OpenAI.entity.d.ts +2 -1
- package/dist/providers/OpenAI/OpenAI.entity.js +1 -1
- package/dist/providers/OpenAI/OpenAI.entity.js.map +1 -1
- package/dist/providers/OpenAI/OpenAI.typedefs.d.ts +5 -1
- package/dist/providers/OpenAI/OpenAI.typedefs.js +1 -1
- package/dist/providers/OpenAI/OpenAI.typedefs.js.map +1 -1
- package/dist/providers/OpenAI/services/OpenAIAssistance.service.js +1 -1
- package/dist/providers/OpenAI/services/OpenAIAssistance.service.js.map +1 -1
- package/dist/providers/OpenAI/services/OpenAISpeechToText.service.d.ts +10 -0
- package/dist/providers/OpenAI/services/OpenAISpeechToText.service.js +1 -0
- package/dist/providers/OpenAI/services/OpenAISpeechToText.service.js.map +1 -0
- package/dist/providers/OpenAI/services/OpenAITextToSpeech.service.d.ts +10 -0
- package/dist/providers/OpenAI/services/OpenAITextToSpeech.service.js +1 -0
- package/dist/providers/OpenAI/services/OpenAITextToSpeech.service.js.map +1 -0
- package/dist/providers/OpenAI/services/index.d.ts +2 -0
- package/dist/providers/OpenAI/services/index.js +1 -1
- package/dist/providers/OpenAI/services/index.js.map +1 -1
- package/dist/services/LLMSpeechToTextService.abstract.d.ts +7 -0
- package/dist/services/LLMSpeechToTextService.abstract.js +1 -0
- package/dist/services/LLMSpeechToTextService.abstract.js.map +1 -0
- package/dist/services/LLMTextToSpeechService.abstract.d.ts +7 -0
- package/dist/services/LLMTextToSpeechService.abstract.js +1 -0
- package/dist/services/LLMTextToSpeechService.abstract.js.map +1 -0
- package/dist/services/index.d.ts +2 -0
- package/dist/services/index.js +1 -1
- package/dist/services/index.js.map +1 -1
- package/dist/tests/helpers.d.ts +19 -0
- package/dist/tests/helpers.js +1 -0
- package/dist/tests/helpers.js.map +1 -0
- package/dist/tests/integration/LLMAssistance.service.integration.test.d.ts +1 -0
- package/dist/tests/integration/LLMAssistance.service.integration.test.js +1 -0
- package/dist/tests/integration/LLMAssistance.service.integration.test.js.map +1 -0
- package/dist/tests/integration/LLMCompletion.service.integration.test.d.ts +1 -0
- package/dist/tests/integration/LLMCompletion.service.integration.test.js +1 -0
- package/dist/tests/integration/LLMCompletion.service.integration.test.js.map +1 -0
- package/dist/tests/integration/LLMSpeechToText.service.integration.test.d.ts +1 -0
- package/dist/tests/integration/LLMSpeechToText.service.integration.test.js +1 -0
- package/dist/tests/integration/LLMSpeechToText.service.integration.test.js.map +1 -0
- package/dist/tests/integration/LLMTextToSpeech.service.integration.test.d.ts +1 -0
- package/dist/tests/integration/LLMTextToSpeech.service.integration.test.js +1 -0
- package/dist/tests/integration/LLMTextToSpeech.service.integration.test.js.map +1 -0
- package/dist/tests/setup.d.ts +1 -0
- package/dist/tests/setup.js +1 -0
- package/dist/tests/setup.js.map +1 -0
- package/package.json +17 -8
|
@@ -38,6 +38,28 @@ export declare class LLMServiceFactory {
|
|
|
38
38
|
* @returns {LLMServiceByPurpose<Provider>[LLMPurposes.Assistance]} An assistance service instance
|
|
39
39
|
*/
|
|
40
40
|
static getAssistanceService<Provider extends LLMProviders>(provider: Provider, logger: Logger, options: LLMInstanceOptions[Provider]): LLMServiceByPurpose<Provider>[LLMPurposes.Assistance];
|
|
41
|
+
/**
|
|
42
|
+
* Gets a speech-to-text service for the specified LLM provider
|
|
43
|
+
*
|
|
44
|
+
* @static
|
|
45
|
+
* @template Provider - The LLM provider type
|
|
46
|
+
* @param {Provider} provider - The LLM provider (OpenAI, GoogleGenerativeAI)
|
|
47
|
+
* @param {Logger} logger - Logger instance
|
|
48
|
+
* @param {LLMInstanceOptions[Provider]} options - Provider-specific options
|
|
49
|
+
* @returns {LLMServiceByPurpose<Provider>[LLMPurposes.SpeechToText]} A speech-to-text service instance
|
|
50
|
+
*/
|
|
51
|
+
static getSpeechToTextService<Provider extends LLMProviders>(provider: Provider, logger: Logger, options: LLMInstanceOptions[Provider]): LLMServiceByPurpose<Provider>[LLMPurposes.SpeechToText];
|
|
52
|
+
/**
|
|
53
|
+
* Gets a text-to-speech service for the specified LLM provider
|
|
54
|
+
*
|
|
55
|
+
* @static
|
|
56
|
+
* @template Provider - The LLM provider type
|
|
57
|
+
* @param {Provider} provider - The LLM provider (OpenAI, GoogleGenerativeAI)
|
|
58
|
+
* @param {Logger} logger - Logger instance
|
|
59
|
+
* @param {LLMInstanceOptions[Provider]} options - Provider-specific options
|
|
60
|
+
* @returns {LLMServiceByPurpose<Provider>[LLMPurposes.TextToSpeech]} A text-to-speech service instance
|
|
61
|
+
*/
|
|
62
|
+
static getTextToSpeechService<Provider extends LLMProviders>(provider: Provider, logger: Logger, options: LLMInstanceOptions[Provider]): LLMServiceByPurpose<Provider>[LLMPurposes.TextToSpeech];
|
|
41
63
|
/**
|
|
42
64
|
* Resolves the options for the specified provider from an options map
|
|
43
65
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.LLMServiceFactory=void 0;const LLMService_typedefs_1=require("./LLMService.typedefs"),LLMService_constants_1=require("./LLMService.constants");class LLMServiceFactory{static getService(e,r,
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.LLMServiceFactory=void 0;const LLMService_typedefs_1=require("./LLMService.typedefs"),LLMService_constants_1=require("./LLMService.constants");class LLMServiceFactory{static getService(e,t,r,s){switch(t){case LLMService_typedefs_1.LLMProviders.OpenAI:case LLMService_typedefs_1.LLMProviders.GoogleGenerativeAI:return LLMService_constants_1.LLM_SERVICE_FACTORIES[t].createService(e,r,s);default:throw new Error(`Provider [${t}] is not supported`)}}static getCompletionService(e,t,r){return this.getService(LLMService_typedefs_1.LLMPurposes.Completion,e,t,r)}static getAssistanceService(e,t,r){return this.getService(LLMService_typedefs_1.LLMPurposes.Assistance,e,t,r)}static getSpeechToTextService(e,t,r){return this.getService(LLMService_typedefs_1.LLMPurposes.SpeechToText,e,t,r)}static getTextToSpeechService(e,t,r){return this.getService(LLMService_typedefs_1.LLMPurposes.TextToSpeech,e,t,r)}static resolveProviderOptions(e,t){return t[e]}}exports.LLMServiceFactory=LLMServiceFactory;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LLMService.factory.js","sourceRoot":"","sources":["../src/LLMService.factory.ts"],"names":[],"mappings":";;;AACA,+DAK+B;AAC/B,iEAA+D;AAE/D,MAAa,iBAAiB;IAC5B;;;;;;;;;;;;;OAaG;IACK,MAAM,CAAC,UAAU,CAIvB,OAAgB,EAChB,QAAkB,EAClB,MAAc,EACd,OAAqC;QAErC,QAAQ,QAAQ,EAAE,CAAC;YACjB,KAAK,kCAAY,CAAC,MAAM,CAAC;YACzB,KAAK,kCAAY,CAAC,kBAAkB;gBAClC,OAAO,4CAAqB,CAAC,QAAQ,CAAC;qBACnC,aAAa,CACZ,OAAO,EACP,MAAM,EACN,OAAO,CACR,CAAC;YAEN;gBACE,MAAM,IAAI,KAAK,CAAC,aAAa,QAAQ,oBAAoB,CAAC,CAAC;QAC/D,CAAC;IACH,CAAC;IAED;;;;;;;;;OASG;IACH,MAAM,CAAC,oBAAoB,CACzB,QAAkB,EAClB,MAAc,EACd,OAAqC;QAErC,OAAO,IAAI,CAAC,UAAU,CAAC,iCAAW,CAAC,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IAC5E,CAAC;IAED;;;;;;;;;OASG;IACH,MAAM,CAAC,oBAAoB,CACzB,QAAkB,EAClB,MAAc,EACd,OAAqC;QAErC,OAAO,IAAI,CAAC,UAAU,CAAC,iCAAW,CAAC,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IAC5E,CAAC;IAED;;;;;;;;OAQG;IACH,MAAM,CAAC,sBAAsB,CAC3B,QA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ASG;IACH,MAAM,CAAC,sBAAsB,CAC3B,QAAkB,EAClB,MAAc,EACd,OAAqC;QAErC,OAAO,IAAI,CAAC,UAAU,CAAC,iCAAW,CAAC,YAAY,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9E,CAAC;IAED;;;;;;;;OAQG;IACH,MAAM,CAAC,sBAAsB,CAC3B,QAAkB,EAClB,OAAuD;QAEvD,OAAO,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC3B,CAAC;CACF;AA9HD,8CA8HC"}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { type Logger } from '@mate-academy/core';
|
|
2
2
|
import { type ClientOptions, type OpenAI } from 'openai';
|
|
3
|
-
import { type
|
|
3
|
+
import { type SpeechCreateParams } from 'openai/resources/audio/speech';
|
|
4
|
+
import { type GoogleGenAIOptions, type GoogleGenAI, type GenerateContentConfig } from '@google/genai';
|
|
4
5
|
import { type OpenAIModelNames } from './providers/OpenAI/OpenAI.typedefs';
|
|
5
6
|
import { type GoogleGenerativeAIModelNames } from './providers/GoogleGenerativeAI/GoogleGenerativeAI.typedefs';
|
|
6
7
|
import { type LLMCompletionService } from './services/LLMCompletionService.abstract';
|
|
7
8
|
import { type LLMAssistanceService } from './services/LLMAssistanceService.abstract';
|
|
9
|
+
import { type LLMSpeechToTextService } from './services/LLMSpeechToTextService.abstract';
|
|
10
|
+
import { type LLMTextToSpeechService } from './services/LLMTextToSpeechService.abstract';
|
|
8
11
|
/**
|
|
9
12
|
* Enum of supported LLM providers.
|
|
10
13
|
*/
|
|
@@ -24,16 +27,16 @@ export type LLMInstances = {
|
|
|
24
27
|
*/
|
|
25
28
|
export type LLMInstanceOptions = {
|
|
26
29
|
[LLMProviders.OpenAI]: ClientOptions;
|
|
27
|
-
[LLMProviders.GoogleGenerativeAI]:
|
|
28
|
-
apiKey: string;
|
|
29
|
-
};
|
|
30
|
+
[LLMProviders.GoogleGenerativeAI]: GoogleGenAIOptions;
|
|
30
31
|
};
|
|
31
32
|
/**
|
|
32
33
|
* Supported service purposes/types that the LLM gateway provides.
|
|
33
34
|
*/
|
|
34
35
|
export declare enum LLMPurposes {
|
|
35
36
|
Completion = "completion",
|
|
36
|
-
Assistance = "assistance"
|
|
37
|
+
Assistance = "assistance",
|
|
38
|
+
SpeechToText = "speech_to_text",
|
|
39
|
+
TextToSpeech = "text_to_speech"
|
|
37
40
|
}
|
|
38
41
|
/**
|
|
39
42
|
* Maps each LLM purpose to its corresponding service implementation for a specific provider.
|
|
@@ -42,6 +45,8 @@ export declare enum LLMPurposes {
|
|
|
42
45
|
export type LLMServiceByPurpose<Provider extends LLMProviders> = {
|
|
43
46
|
[LLMPurposes.Completion]: LLMCompletionService<Provider>;
|
|
44
47
|
[LLMPurposes.Assistance]: LLMAssistanceService<Provider>;
|
|
48
|
+
[LLMPurposes.SpeechToText]: LLMSpeechToTextService<Provider>;
|
|
49
|
+
[LLMPurposes.TextToSpeech]: LLMTextToSpeechService<Provider>;
|
|
45
50
|
};
|
|
46
51
|
/**
|
|
47
52
|
* Function type for building an LLM service instance for a specific provider and purpose.
|
|
@@ -70,7 +75,9 @@ export interface LLMConfig {
|
|
|
70
75
|
* Maps a provider to all available models it can access.
|
|
71
76
|
* @template Provider - The LLM provider type
|
|
72
77
|
*/
|
|
73
|
-
export type LLMProviderAvailableModels<Provider extends LLMProviders> =
|
|
78
|
+
export type LLMProviderAvailableModels<Provider extends LLMProviders> = {
|
|
79
|
+
[ModelName in LLMModelName[Provider]]: LLMModel<Provider, ModelName>;
|
|
80
|
+
};
|
|
74
81
|
/**
|
|
75
82
|
* Maps service purposes to the available models for a specific provider.
|
|
76
83
|
* @template Purpose - The service purpose type
|
|
@@ -88,8 +95,8 @@ export type LLMModelName = {
|
|
|
88
95
|
* Represents an LLM model with its configuration and limitations.
|
|
89
96
|
* @template Provider - The LLM provider type
|
|
90
97
|
*/
|
|
91
|
-
export interface LLMModel<Provider extends LLMProviders> {
|
|
92
|
-
name:
|
|
98
|
+
export interface LLMModel<Provider extends LLMProviders, ModelName extends LLMModelName[Provider] = LLMModelName[Provider]> {
|
|
99
|
+
name: ModelName;
|
|
93
100
|
limits: LLMLimits;
|
|
94
101
|
config: LLMConfig;
|
|
95
102
|
}
|
|
@@ -141,9 +148,9 @@ export interface LLMCompletionMessage {
|
|
|
141
148
|
export type LLMRequestError = Error;
|
|
142
149
|
/**
|
|
143
150
|
* Generic result type for LLM requests that can either succeed or fail.
|
|
144
|
-
* @template
|
|
151
|
+
* @template ResponseType - The type of the successful result
|
|
145
152
|
*/
|
|
146
|
-
export type LLMRequestResult<
|
|
153
|
+
export type LLMRequestResult<ResponseType> = ResponseType | {
|
|
147
154
|
error: LLMRequestError;
|
|
148
155
|
};
|
|
149
156
|
/**
|
|
@@ -162,12 +169,22 @@ export interface LLMSendMessageOptions<Provider extends LLMProviders> {
|
|
|
162
169
|
history?: LLMCompletionMessage[];
|
|
163
170
|
instructions?: string;
|
|
164
171
|
}
|
|
172
|
+
/**
|
|
173
|
+
* Limits for files that can be uploaded to LLM services.
|
|
174
|
+
*/
|
|
175
|
+
export type LLMFileLimits = {
|
|
176
|
+
maxFileSize: number;
|
|
177
|
+
supportedMimeTypes: LLMUploadFileMimeTypes[];
|
|
178
|
+
};
|
|
165
179
|
/**
|
|
166
180
|
* Supported MIME types for files that can be uploaded to LLM services.
|
|
167
181
|
*/
|
|
168
182
|
export declare enum LLMUploadFileMimeTypes {
|
|
169
|
-
|
|
170
|
-
PLAIN_TEXT = "text/plain"
|
|
183
|
+
IMAGE_PNG = "image/png",
|
|
184
|
+
PLAIN_TEXT = "text/plain",
|
|
185
|
+
AUDIO_MP3 = "audio/mp3",
|
|
186
|
+
AUDIO_MPEG = "audio/mpeg",
|
|
187
|
+
AUDIO_WAV = "audio/wav"
|
|
171
188
|
}
|
|
172
189
|
/**
|
|
173
190
|
* Represents a file to be uploaded to an LLM service.
|
|
@@ -280,13 +297,52 @@ export type LLMCountTokensFunction<Provider extends LLMProviders, ContentType> =
|
|
|
280
297
|
/**
|
|
281
298
|
* Options for combining messages with a limit on the number of tokens.
|
|
282
299
|
* @template Provider - The LLM provider type
|
|
283
|
-
* @template
|
|
300
|
+
* @template TokenCountFunction - Function type for counting tokens
|
|
284
301
|
*/
|
|
285
|
-
export interface CombineMessagesOptions<Provider extends LLMProviders,
|
|
302
|
+
export interface CombineMessagesOptions<Provider extends LLMProviders, TokenCountFunction extends LLMCountTokensFunction<Provider, any[]>> {
|
|
286
303
|
modelContext?: LLMCompletionMessage[];
|
|
287
304
|
history?: LLMCompletionMessage[];
|
|
288
305
|
message: LLMCompletionMessage;
|
|
289
306
|
model: LLMModel<Provider>;
|
|
290
307
|
instance: LLMInstances[Provider];
|
|
291
|
-
countTokensFn:
|
|
308
|
+
countTokensFn: TokenCountFunction;
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Options for transcribing audio to text using an LLM service.
|
|
312
|
+
* @template Provider - The LLM provider type
|
|
313
|
+
*/
|
|
314
|
+
export interface LLMTranscribeOptions<Provider extends LLMProviders> {
|
|
315
|
+
pathToAudio: string;
|
|
316
|
+
model: LLMModel<Provider>;
|
|
292
317
|
}
|
|
318
|
+
/**
|
|
319
|
+
* Result type for LLM transcription requests.
|
|
320
|
+
*/
|
|
321
|
+
export type LLMTranscribeResult = LLMRequestResult<{
|
|
322
|
+
text: string;
|
|
323
|
+
}>;
|
|
324
|
+
/**
|
|
325
|
+
* Provider-specific options for creating speech from text.
|
|
326
|
+
*/
|
|
327
|
+
export type LLMSpeechOptions = {
|
|
328
|
+
[LLMProviders.OpenAI]: Pick<SpeechCreateParams, 'voice' | 'speed' | 'response_format'>;
|
|
329
|
+
[LLMProviders.GoogleGenerativeAI]: Pick<GenerateContentConfig, 'speechConfig'>;
|
|
330
|
+
};
|
|
331
|
+
/**
|
|
332
|
+
* Options for creating speech from text using an LLM service.
|
|
333
|
+
* @template Provider - The LLM provider type
|
|
334
|
+
*/
|
|
335
|
+
export interface LLMCreateSpeechOptions<Provider extends LLMProviders> {
|
|
336
|
+
text: string;
|
|
337
|
+
model: LLMModel<Provider>;
|
|
338
|
+
instructions?: string;
|
|
339
|
+
speechOptions?: LLMSpeechOptions[Provider];
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* Result type for LLM speech creation requests.
|
|
343
|
+
* Contains the generated audio buffer and its MIME type.
|
|
344
|
+
*/
|
|
345
|
+
export type LLMCreateSpeechResult = LLMRequestResult<{
|
|
346
|
+
audio: ArrayBufferLike;
|
|
347
|
+
mimeType: string | null;
|
|
348
|
+
}>;
|
|
@@ -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"}(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"}(LLMMessageContentType||(exports.LLMMessageContentType=LLMMessageContentType={})),function(e){e.
|
|
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"}(LLMMessageContentType||(exports.LLMMessageContentType=LLMMessageContentType={})),function(e){e.IMAGE_PNG="image/png",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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LLMService.typedefs.js","sourceRoot":"","sources":["../src/LLMService.typedefs.ts"],"names":[],"mappings":";;;
|
|
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,qBAGX;AAHD,WAAY,qBAAqB;IAC/B,sCAAa,CAAA;IACb,gDAAuB,CAAA;AACzB,CAAC,EAHW,qBAAqB,qCAArB,qBAAqB,QAGhC;AAuED;;GAEG;AACH,IAAY,sBAMX;AAND,WAAY,sBAAsB;IAChC,iDAAuB,CAAA;IACvB,mDAAyB,CAAA;IACzB,iDAAuB,CAAA;IACvB,mDAAyB,CAAA;IACzB,iDAAuB,CAAA;AACzB,CAAC,EANW,sBAAsB,sCAAtB,sBAAsB,QAMjC"}
|
|
@@ -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.
|
|
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_PREVIEW]:{name:GoogleGenerativeAI_typedefs_1.GoogleGenerativeAIModelNames.GEMINI_2_5_PRO_PREVIEW,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_PREVIEW]),[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_PREVIEW]),[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,
|
|
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,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AA2E;IAC3E,CAAC,iCAAW,CAAC,UAAU,CAAC,EAAE,IAAA,uBAAI,EAC5B,0BAA0B,EAC1B;QACE,0DAA4B,CAAC,qBAAqB;QAClD,0DAA4B,CAAC,uBAAuB;KACrD,CACF;IACD,CAAC,iCAAW,CAAC,YAAY,CAAC,EAAE,IAAA,uBAAI,EAC9B,0BAA0B,EAC1B;QACE,0DAA4B,CAAC,gBAAgB;QAC7C,0DAA4B,CAAC,sBAAsB;KACpD,CACF;IACD,CAAC,iCAAW,CAAC,YAAY,CAAC,EAAE,IAAA,uBAAI,EAC9B,0BAA0B,EAC1B;QACE,0DAA4B,CAAC,4BAA4B;QACzD,0DAA4B,CAAC,0BAA0B;KACxD,CACF;CACF,CAAC;AAEW,QAAA,0BAA0B,GAInC;IACF,CAAC,iCAAW,CAAC,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,CAAC,CAC7C,IAAI,8CAAmC,CAAC,MAAM,EAAE,OAAO,CAAC,CACzD;IACD,CAAC,iCAAW,CAAC,UAAU,CAAC,EAAE,CAAC,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,5 +1,5 @@
|
|
|
1
1
|
import { type Part, type GoogleGenAI, type GenerateContentParameters, type Content, type ContentListUnion } from '@google/genai';
|
|
2
|
-
import { type CombineMessagesOptions, type LLMCountTokensFunction, type LLMCompletionMessage, type LLMModel, type LLMProviders, type LLMUploadedFile } from '../../LLMService.typedefs';
|
|
2
|
+
import { type CombineMessagesOptions, type LLMCountTokensFunction, type LLMCompletionMessage, type LLMModel, type LLMProviders, type LLMUploadedFile, type LLMFileLimits } from '../../LLMService.typedefs';
|
|
3
3
|
export declare class GoogleGenerativeAIEntity {
|
|
4
4
|
static getContentParameters(options: {
|
|
5
5
|
model: LLMModel<LLMProviders.GoogleGenerativeAI>;
|
|
@@ -8,7 +8,9 @@ export declare class GoogleGenerativeAIEntity {
|
|
|
8
8
|
}): GenerateContentParameters;
|
|
9
9
|
static getFileDataParts(uploadedFiles: LLMUploadedFile[]): Pick<Part, 'fileData'>[];
|
|
10
10
|
static getTextParts(messages: string[]): Pick<Part, 'text'>[];
|
|
11
|
-
static getContent(message: LLMCompletionMessage, instance: GoogleGenAI): Promise<Content>;
|
|
11
|
+
static getContent(message: LLMCompletionMessage, instance: GoogleGenAI, model: LLMModel<LLMProviders.GoogleGenerativeAI>): Promise<Content>;
|
|
12
12
|
static getCountTokensFn(instance: GoogleGenAI): LLMCountTokensFunction<LLMProviders.GoogleGenerativeAI, ContentListUnion>;
|
|
13
13
|
static combineMessagesWithLimit({ modelContext, history, message, model, countTokensFn, instance, }: CombineMessagesOptions<LLMProviders.GoogleGenerativeAI, LLMCountTokensFunction<LLMProviders.GoogleGenerativeAI, ContentListUnion>>): Promise<Content[]>;
|
|
14
|
+
static get transcribeLimits(): LLMFileLimits;
|
|
15
|
+
static get transcribeInstructions(): string;
|
|
14
16
|
}
|
|
@@ -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:
|
|
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"),GoogleGenerativeAI_typedefs_1=require("../../providers/GoogleGenerativeAI/GoogleGenerativeAI.typedefs");class GoogleGenerativeAIEntity{static getContentParameters(e){const{model:t,messages:r,instructions:i}=e;return{model:t.name,contents:r,config:{systemInstruction:i,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,r){const i=e.role===LLMService_typedefs_1.LLMRoles.Assistant&&r.name===GoogleGenerativeAI_typedefs_1.GoogleGenerativeAIModelNames.GEMINI_2_5_PRO_PREVIEW?"model":e.role;if(e.content.type===LLMService_typedefs_1.LLMMessageContentType.TEXT)return{role:i,parts:[{text:e.content.text}]};if(e.content.type===LLMService_typedefs_1.LLMMessageContentType.IMAGE_URL){const r=await axios_1.default.head(e.content.image_url.url),n=r.headers["content-type"]?.split(";")[0]??LLMService_typedefs_1.LLMUploadFileMimeTypes.IMAGE_PNG,o=await axios_1.default.get(e.content.image_url.url,{responseType:"arraybuffer"}),s=new Uint8Array(o.data),a=new Blob([s],{type:n});return{role:i,parts:[{fileData:{fileUri:(await t.files.upload({file:a})).uri,mimeType:n}}]}}return{role:i,parts:[]}}static getCountTokensFn(e){const t=e=>Boolean(e&&"object"==typeof e&&"role"in e&&"parts"in e);return async(r,i)=>{if(!r)return 0;const n=[];Array.isArray(r)?n.push(...r.filter(t)):t(r)&&n.push(r);const o=n.filter((e=>e&&"string"==typeof e.role&&Array.isArray(e.parts)));if(0===o.length)return 0;const{totalTokens:s}=await e.models.countTokens({model:i.name,contents:o});return s??0}}static async combineMessagesWithLimit({modelContext:e=[],history:t=[],message:r,model:i,countTokensFn:n,instance:o}){const s=await Promise.all(e.map((e=>GoogleGenerativeAIEntity.getContent(e,o,i)))),a=await Promise.all(t.map((e=>GoogleGenerativeAIEntity.getContent(e,o,i)))),l={role:LLMService_typedefs_1.LLMRoles.User,content:r.content},p=[...s,await GoogleGenerativeAIEntity.getContent(l,o,i)],c=[...a].reverse();let y=await n(p,i)??0,u=0;for(const e of c){const t=await n(e,i)??0;if(!(y+t<=i.limits.maxInputTokens))break;u+=1,p.splice(-u,0,e),y+=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]}}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;
|
|
1
|
+
{"version":3,"file":"GoogleGenerativeAI.entity.js","sourceRoot":"","sources":["../../../src/providers/GoogleGenerativeAI/GoogleGenerativeAI.entity.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAS1B,+DAW+B;AAC/B,4GAA0G;AAE1G,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,CAA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gemini-1.5-flash",
|
|
3
|
-
GEMINI_1_5_FLASH_STABLE = "gemini-1.5-flash-001",
|
|
4
3
|
GEMINI_1_5_PRO = "gemini-1.5-pro",
|
|
5
4
|
GEMINI_1_5_PRO_STABLE = "gemini-1.5-pro-002",
|
|
6
5
|
GEMINI_2_0_FLASH = "gemini-2.0-flash",
|
|
7
6
|
GEMINI_2_0_FLASH_STABLE = "gemini-2.0-flash-001",
|
|
8
|
-
GEMINI_2_5_PRO_PREVIEW = "gemini-2.5-pro-preview-
|
|
7
|
+
GEMINI_2_5_PRO_PREVIEW = "gemini-2.5-pro-preview-06-05",
|
|
8
|
+
GEMINI_2_5_FLASH_PREVIEW_TTS = "gemini-2.5-flash-preview-tts",
|
|
9
|
+
GEMINI_2_5_PRO_PREVIEW_TTS = "gemini-2.5-pro-preview-tts"
|
|
9
10
|
}
|
|
10
11
|
export declare enum GoogleGenerativeAIRoles {
|
|
11
12
|
User = "user",
|
|
@@ -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.
|
|
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_PREVIEW="gemini-2.5-pro-preview-06-05",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,
|
|
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,uFAAuD,CAAA;IACvD,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;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:s}=e,i=this.uploadedFiles.get(t);if(i)return i;const o=await this.instance.files.upload({file:t,config:{mimeType:r,displayName:s}});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:s}=e;try{const e=GoogleGenerativeAI_entity_1.GoogleGenerativeAIEntity.getFileDataParts(t),i=GoogleGenerativeAI_entity_1.GoogleGenerativeAIEntity.getCountTokensFn(this.instance);if(await i(e,r)<GoogleGenerativeAI_constants_1.MIN_CACHE_CONTENT_LENGTH)return{storageId:""};const o=await this.instance.caches.create({model:r.name,config:{contents:[{role:GoogleGenerativeAI_typedefs_1.GoogleGenerativeAIRoles.User,parts:e}],systemInstruction:s,ttl:"1h"}});if(!o.name)throw new Error("Cache result did not return a name");return this.cachedContent.set(o.name,o),{storageId:o.name}}catch(e){return this.logger.child("createFileStorage").error("Error creating file storage",{error:e,uploadedFiles:t,model:r}),{error:e}}}async deleteFileStorage(e){""!==e&&(this.cachedContent.delete(e),await this.instance.caches.delete({name:e}))}createChat(e){try{const{storageId:t,model:r,instructions:s,history:i,files:o}=e,n=t?this.cachedContent.get(t):void 0,a=i?[{role:GoogleGenerativeAI_typedefs_1.GoogleGenerativeAIRoles.User,parts:GoogleGenerativeAI_entity_1.GoogleGenerativeAIEntity.getTextParts(i)}]:[];if(!n&&o){const e=GoogleGenerativeAI_entity_1.GoogleGenerativeAIEntity.getFileDataParts(o);a.push({role:GoogleGenerativeAI_typedefs_1.GoogleGenerativeAIRoles.User,parts:e})}const l=this.instance.chats.create({model:r.name,history:a,config:{systemInstruction:s,temperature:r.config.temperature,...n&&{cachedContent:n.name}}}),c=(0,uuid_1.v4)();return this.chatSessions.set(c,l),Promise.resolve({chatId:c})}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,
|
|
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;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:s}=e,i=this.uploadedFiles.get(t);if(i)return i;const o=await this.instance.files.upload({file:t,config:{mimeType:r,displayName:s}});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:s}=e;try{const e=GoogleGenerativeAI_entity_1.GoogleGenerativeAIEntity.getFileDataParts(t),i=GoogleGenerativeAI_entity_1.GoogleGenerativeAIEntity.getCountTokensFn(this.instance);if(await i(e,r)<GoogleGenerativeAI_constants_1.MIN_CACHE_CONTENT_LENGTH)return{storageId:""};const o=await this.instance.caches.create({model:r.name,config:{contents:[{role:GoogleGenerativeAI_typedefs_1.GoogleGenerativeAIRoles.User,parts:e}],systemInstruction:s,ttl:"1h"}});if(!o.name)throw new Error("Cache result did not return a name");return this.cachedContent.set(o.name,o),{storageId:o.name}}catch(e){return this.logger.child("createFileStorage").error("Error creating file storage",{error:e,uploadedFiles:t,model:r}),{error:e}}}async deleteFileStorage(e){""!==e&&(this.cachedContent.delete(e),await this.instance.caches.delete({name:e}))}createChat(e){try{const{storageId:t,model:r,instructions:s,history:i,files:o}=e,n=t?this.cachedContent.get(t):void 0,a=i?[{role:GoogleGenerativeAI_typedefs_1.GoogleGenerativeAIRoles.User,parts:GoogleGenerativeAI_entity_1.GoogleGenerativeAIEntity.getTextParts(i)}]:[];if(!n&&o){const e=GoogleGenerativeAI_entity_1.GoogleGenerativeAIEntity.getFileDataParts(o);a.push({role:GoogleGenerativeAI_typedefs_1.GoogleGenerativeAIRoles.User,parts:e})}const l=this.instance.chats.create({model:r.name,history:a,config:{systemInstruction:s,temperature:r.config.temperature,...n&&{cachedContent:n.name}}}),c=(0,uuid_1.v4)();return this.chatSessions.set(c,l),Promise.resolve({chatId:c})}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,model:s}=e,i=this.chatSessions.get(r);if(!i)throw new Error("Chat session not found");const o=await GoogleGenerativeAI_entity_1.GoogleGenerativeAIEntity.getContent(t,this.instance,s);if(!o.parts)return{text:""};return{text:(await i.sendMessage({message:o.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/GoogleGenerativeAIAssistance.service.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GoogleGenerativeAIAssistance.service.js","sourceRoot":"","sources":["../../../../src/providers/GoogleGenerativeAI/services/GoogleGenerativeAIAssistance.service.ts"],"names":[],"mappings":";;;AACA,+BAAoC;AACpC,yCAKuB;AACvB,+DAa+B;AAC/B,yCAAkD;AAClD,4GAAqG;AACrG,wGAAoG;AACpG,8GAAuG;AAEvG,MAAa,mCACX,SAAQ,+BAAqD;IAC7D,SAAS,GAAuB,IAAI,CAAC;IAE7B,aAAa,GAA+B,IAAI,GAAG,EAAE,CAAC;IAEtD,YAAY,GAAsB,IAAI,GAAG,EAAE,CAAC;IAE5C,aAAa,GAAiC,IAAI,GAAG,EAAE,CAAC;IAEhE,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,CAAC,IAAmB;QAClC,IAAI,CAAC;YACH,MAAM,EACJ,IAAI,EACJ,QAAQ,EACR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KAAK,CAAC,IAAI;gBACjB,OAAO;gBACP,MAAM,EAAE;oBACN,iBAAiB,EAAE,YAAY;oBAC/B,WAAW,EAAE,KAAK,CAAC,MAAM,CAAC,WAAW;oBACrC,GAAG,CAAC,aAAa,IAAI,EAAE,aAAa,EAAE,aAAa,CAAC,IAAI,EAAE,CAAC;iBAC5D;aACF,CAAC,CAAC;YAEH,MAAM,MAAM,GAAG,IAAA,SAAM,GAAE,CAAC;YAExB,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;YAE3C,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;QACrC,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,IAAI,CAAC,MAAM;iBACR,KAAK,CAAC,YAAY,CAAC;iBACnB,KAAK,CAAC,qBAAqB,EAAE;gBAC5B,KAAK;gBACL,OAAO;aACR,CAAC,CAAC;YAEL,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;QACpC,CAAC;IACH,CAAC;IAED,UAAU,CACR,MAAc;QAEd,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAEjC,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;IAED,eAAe;QACb,wEAAwE;QACxE,OAAO,OAAO,CAAC,OAAO,CAAC;YACrB,WAAW,EAAE,EAAE;SAChB,CAAC,CAAC;IACL,CAAC;IAED,eAAe;QACb,wEAAwE;QACxE,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;IAED,KAAK,CAAC,YAAY,CAChB,OAA8D;QAE9D,IAAI,CAAC;YACH,MAAM,EACJ,OAAO,EACP,MAAM,
|
|
1
|
+
{"version":3,"file":"GoogleGenerativeAIAssistance.service.js","sourceRoot":"","sources":["../../../../src/providers/GoogleGenerativeAI/services/GoogleGenerativeAIAssistance.service.ts"],"names":[],"mappings":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E;aAC9B,CAAC;QACJ,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,IAAI,CAAC,MAAM;iBACR,KAAK,CAAC,cAAc,CAAC;iBACrB,KAAK,CAAC,yBAAyB,EAAE;gBAChC,KAAK;gBACL,OAAO;aACR,CAAC,CAAC;YAEL,OAAO,EAAE,KAAK,EAAE,CAAC;QACnB,CAAC;IACH,CAAC;CACF;AApSD,kFAoSC"}
|
package/dist/providers/GoogleGenerativeAI/services/GoogleGenerativeAISpeechToText.service.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type Logger } from '@mate-academy/core';
|
|
2
|
+
import { GoogleGenAI } from '@google/genai';
|
|
3
|
+
import { LLMProviders, type LLMInstanceOptions, type LLMTranscribeOptions, type LLMTranscribeResult } from '../../../LLMService.typedefs';
|
|
4
|
+
import { LLMSpeechToTextService } from '../../../services';
|
|
5
|
+
export declare class GoogleGenerativeAISpeechToTextService extends LLMSpeechToTextService<LLMProviders.GoogleGenerativeAI> {
|
|
6
|
+
#private;
|
|
7
|
+
constructor(logger: Logger, options: LLMInstanceOptions[LLMProviders.GoogleGenerativeAI]);
|
|
8
|
+
protected get instance(): GoogleGenAI;
|
|
9
|
+
transcribe(options: LLMTranscribeOptions<typeof this.provider>): Promise<LLMTranscribeResult>;
|
|
10
|
+
}
|
|
@@ -0,0 +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:r,supportedMimeTypes:o}=GoogleGenerativeAI_entity_1.GoogleGenerativeAIEntity.transcribeLimits;if((0,fs_1.statSync)(i).size>r)throw new Error(`File size exceeds the limit of ${r} bytes`);const n=mime_types_1.default.lookup(i);if(!n||!o.includes(n))throw new Error(`Unsupported audio file type: ${n}. Supported types are: ${o.join(", ")}`);const s=await this.instance.files.upload({file:i,config:{mimeType:n}});if(!s||!s.uri||!s.mimeType)throw new Error(`Failed to upload audio file, response: ${JSON.stringify(s)}`);return{text:(await this.instance.models.generateContent({model:t.name,contents:(0,genai_1.createUserContent)([(0,genai_1.createPartFromUri)(s.uri,s.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
ADDED
|
@@ -0,0 +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,IAA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AC;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;AArFD,sFAqFC"}
|
package/dist/providers/GoogleGenerativeAI/services/GoogleGenerativeAITextToSpeech.service.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type Logger } from '@mate-academy/core';
|
|
2
|
+
import { GoogleGenAI } from '@google/genai';
|
|
3
|
+
import { LLMProviders, type LLMCreateSpeechOptions, type LLMCreateSpeechResult, type LLMInstanceOptions } from '../../../LLMService.typedefs';
|
|
4
|
+
import { LLMTextToSpeechService } from '../../../services';
|
|
5
|
+
export declare class GoogleGenerativeAITextToSpeechService extends LLMTextToSpeechService<LLMProviders.GoogleGenerativeAI> {
|
|
6
|
+
#private;
|
|
7
|
+
constructor(logger: Logger, options: LLMInstanceOptions[LLMProviders.GoogleGenerativeAI]);
|
|
8
|
+
protected get instance(): GoogleGenAI;
|
|
9
|
+
createSpeech(options: LLMCreateSpeechOptions<typeof this.provider>): Promise<LLMCreateSpeechResult>;
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.GoogleGenerativeAITextToSpeechService=void 0;const genai_1=require("@google/genai"),LLMService_typedefs_1=require("../../../LLMService.typedefs"),services_1=require("../../../services");class GoogleGenerativeAITextToSpeechService extends services_1.LLMTextToSpeechService{#e=null;constructor(e,t){super(LLMService_typedefs_1.LLMProviders.GoogleGenerativeAI,e,t)}get instance(){return this.#e||(this.#e=new genai_1.GoogleGenAI(this.options)),this.#e}async createSpeech(e){try{const{text:t,model:r,instructions:i,speechOptions:o}=e,s=await this.instance.models.generateContent({model:r.name,contents:t,config:{...r.config,systemInstruction:i,responseModalities:["AUDIO"],speechConfig:o?.speechConfig}}),n=s.candidates?.[0]?.content?.parts?.[0]?.inlineData?.data;if(!n)throw new Error("No audio data received from the model");return{audio:Buffer.from(n,"base64").buffer,mimeType:LLMService_typedefs_1.LLMUploadFileMimeTypes.AUDIO_WAV}}catch(t){return this.logger.child("createSpeech").error("Error creating speech",{error:t,options:e}),{error:t}}}}exports.GoogleGenerativeAITextToSpeechService=GoogleGenerativeAITextToSpeechService;
|
package/dist/providers/GoogleGenerativeAI/services/GoogleGenerativeAITextToSpeech.service.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GoogleGenerativeAITextToSpeech.service.js","sourceRoot":"","sources":["../../../../src/providers/GoogleGenerativeAI/services/GoogleGenerativeAITextToSpeech.service.ts"],"names":[],"mappings":";;;AACA,yCAA4C;AAC5C,+DAM+B;AAC/B,yCAAoD;AAEpD,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,CA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CAAC;QACnB,CAAC;IACH,CAAC;CACF;AAjED,sFAiEC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var __createBinding=this&&this.__createBinding||(Object.create?function(e,t,
|
|
1
|
+
"use strict";var __createBinding=this&&this.__createBinding||(Object.create?function(e,r,t,o){void 0===o&&(o=t);var i=Object.getOwnPropertyDescriptor(r,t);i&&!("get"in i?!r.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return r[t]}}),Object.defineProperty(e,o,i)}:function(e,r,t,o){void 0===o&&(o=t),e[o]=r[t]}),__exportStar=this&&this.__exportStar||function(e,r){for(var t in e)"default"===t||Object.prototype.hasOwnProperty.call(r,t)||__createBinding(r,e,t)};Object.defineProperty(exports,"__esModule",{value:!0}),__exportStar(require("./GoogleGenerativeAICompletion.service"),exports),__exportStar(require("./GoogleGenerativeAIAssistance.service"),exports),__exportStar(require("./GoogleGenerativeAISpeechToText.service"),exports),__exportStar(require("./GoogleGenerativeAITextToSpeech.service"),exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/providers/GoogleGenerativeAI/services/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yEAAuD;AACvD,yEAAuD"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/providers/GoogleGenerativeAI/services/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yEAAuD;AACvD,yEAAuD;AACvD,2EAAyD;AACzD,2EAAyD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.OPEN_AI_SERVICE_BUILDERS=exports.OPEN_AI_MODELS=void 0;const LLMService_typedefs_1=require("../../LLMService.typedefs"),OpenAI_typedefs_1=require("../../providers/OpenAI/OpenAI.typedefs"),services_1=require("./services"),functional_utils_1=require("../../functional.utils"),OPEN_AI_AVAILABLE_MODELS={[OpenAI_typedefs_1.OpenAIModelNames.GPT_4_OMNI]:{name:OpenAI_typedefs_1.OpenAIModelNames.GPT_4_OMNI,limits:{maxInputTokens:128e3,maxOutputTokens:16384},config:{temperature:.2}},[OpenAI_typedefs_1.OpenAIModelNames.GPT_4_OMNI_MINI]:{name:OpenAI_typedefs_1.OpenAIModelNames.GPT_4_OMNI_MINI,limits:{maxInputTokens:128e3,maxOutputTokens:16384},config:{temperature:.5}},[OpenAI_typedefs_1.OpenAIModelNames.GPT_4_1]:{name:OpenAI_typedefs_1.OpenAIModelNames.GPT_4_1,limits:{maxInputTokens:1047576,maxOutputTokens:32768},config:{temperature:.2}}};exports.OPEN_AI_MODELS={[LLMService_typedefs_1.LLMPurposes.Completion]:(0,functional_utils_1.pick)(OPEN_AI_AVAILABLE_MODELS,[OpenAI_typedefs_1.OpenAIModelNames.GPT_4_OMNI,OpenAI_typedefs_1.OpenAIModelNames.GPT_4_OMNI_MINI,OpenAI_typedefs_1.OpenAIModelNames.GPT_4_1]),[LLMService_typedefs_1.LLMPurposes.Assistance]:(0,functional_utils_1.pick)(OPEN_AI_AVAILABLE_MODELS,[OpenAI_typedefs_1.OpenAIModelNames.GPT_4_OMNI,OpenAI_typedefs_1.OpenAIModelNames.GPT_4_1])},exports.OPEN_AI_SERVICE_BUILDERS={[LLMService_typedefs_1.LLMPurposes.Completion]:(e,_)=>new services_1.OpenAICompletionService(e,_),[LLMService_typedefs_1.LLMPurposes.Assistance]:(e,_)=>new services_1.OpenAIAssistanceService(e,_)};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.OPEN_AI_SERVICE_BUILDERS=exports.OPEN_AI_MODELS=void 0;const LLMService_typedefs_1=require("../../LLMService.typedefs"),OpenAI_typedefs_1=require("../../providers/OpenAI/OpenAI.typedefs"),services_1=require("./services"),functional_utils_1=require("../../functional.utils"),OPEN_AI_AVAILABLE_MODELS={[OpenAI_typedefs_1.OpenAIModelNames.GPT_4_OMNI]:{name:OpenAI_typedefs_1.OpenAIModelNames.GPT_4_OMNI,limits:{maxInputTokens:128e3,maxOutputTokens:16384},config:{temperature:.2}},[OpenAI_typedefs_1.OpenAIModelNames.GPT_4_OMNI_MINI]:{name:OpenAI_typedefs_1.OpenAIModelNames.GPT_4_OMNI_MINI,limits:{maxInputTokens:128e3,maxOutputTokens:16384},config:{temperature:.5}},[OpenAI_typedefs_1.OpenAIModelNames.GPT_4_1]:{name:OpenAI_typedefs_1.OpenAIModelNames.GPT_4_1,limits:{maxInputTokens:1047576,maxOutputTokens:32768},config:{temperature:.2}},[OpenAI_typedefs_1.OpenAIModelNames.GPT_4_OMNI_TRANSCRIBE]:{name:OpenAI_typedefs_1.OpenAIModelNames.GPT_4_OMNI_TRANSCRIBE,limits:{maxInputTokens:16e3,maxOutputTokens:2e3},config:{temperature:.2}},[OpenAI_typedefs_1.OpenAIModelNames.GPT_4_OMNI_MINI_TRANSCRIBE]:{name:OpenAI_typedefs_1.OpenAIModelNames.GPT_4_OMNI_MINI_TRANSCRIBE,limits:{maxInputTokens:16e3,maxOutputTokens:2e3},config:{temperature:.2}},[OpenAI_typedefs_1.OpenAIModelNames.GPT_4_OMNI_MINI_TTS]:{name:OpenAI_typedefs_1.OpenAIModelNames.GPT_4_OMNI_MINI_TTS,limits:{maxInputTokens:2e3,maxOutputTokens:1/0},config:{temperature:.2}},[OpenAI_typedefs_1.OpenAIModelNames.TTS_1]:{name:OpenAI_typedefs_1.OpenAIModelNames.TTS_1,limits:{maxInputTokens:2e3,maxOutputTokens:1/0},config:{temperature:.2}}};exports.OPEN_AI_MODELS={[LLMService_typedefs_1.LLMPurposes.Completion]:(0,functional_utils_1.pick)(OPEN_AI_AVAILABLE_MODELS,[OpenAI_typedefs_1.OpenAIModelNames.GPT_4_OMNI,OpenAI_typedefs_1.OpenAIModelNames.GPT_4_OMNI_MINI,OpenAI_typedefs_1.OpenAIModelNames.GPT_4_1]),[LLMService_typedefs_1.LLMPurposes.Assistance]:(0,functional_utils_1.pick)(OPEN_AI_AVAILABLE_MODELS,[OpenAI_typedefs_1.OpenAIModelNames.GPT_4_OMNI,OpenAI_typedefs_1.OpenAIModelNames.GPT_4_1]),[LLMService_typedefs_1.LLMPurposes.TextToSpeech]:(0,functional_utils_1.pick)(OPEN_AI_AVAILABLE_MODELS,[OpenAI_typedefs_1.OpenAIModelNames.GPT_4_OMNI_MINI_TTS,OpenAI_typedefs_1.OpenAIModelNames.TTS_1]),[LLMService_typedefs_1.LLMPurposes.SpeechToText]:(0,functional_utils_1.pick)(OPEN_AI_AVAILABLE_MODELS,[OpenAI_typedefs_1.OpenAIModelNames.GPT_4_OMNI_TRANSCRIBE,OpenAI_typedefs_1.OpenAIModelNames.GPT_4_OMNI_MINI_TRANSCRIBE])},exports.OPEN_AI_SERVICE_BUILDERS={[LLMService_typedefs_1.LLMPurposes.Completion]:(e,_)=>new services_1.OpenAICompletionService(e,_),[LLMService_typedefs_1.LLMPurposes.Assistance]:(e,_)=>new services_1.OpenAIAssistanceService(e,_),[LLMService_typedefs_1.LLMPurposes.SpeechToText]:(e,_)=>new services_1.OpenAISpeechToTextService(e,_),[LLMService_typedefs_1.LLMPurposes.TextToSpeech]:(e,_)=>new services_1.OpenAITextToSpeechService(e,_)};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OpenAI.constants.js","sourceRoot":"","sources":["../../../src/providers/OpenAI/OpenAI.constants.ts"],"names":[],"mappings":";;;AAAA,+DAM+B;AAC/B,wEAAsE;AACtE,
|
|
1
|
+
{"version":3,"file":"OpenAI.constants.js","sourceRoot":"","sources":["../../../src/providers/OpenAI/OpenAI.constants.ts"],"names":[],"mappings":";;;AAAA,+DAM+B;AAC/B,wEAAsE;AACtE,yCAKoB;AACpB,yDAA0C;AAE1C,MAAM,wBAAwB,GAE1B;IACF,CAAC,kCAAgB,CAAC,UAAU,CAAC,EAAE;QAC7B,IAAI,EAAE,kCAAgB,CAAC,UAAU;QACjC,MAAM,EAAE;YACN,cAAc,EAAE,OA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AC,iCAAW,CAAC,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,CAAC,CAC/C,IAAI,oCAAyB,CAAC,MAAM,EAAE,OAAO,CAAC,CAC/C;CACF,CAAC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { type CombineMessagesOptions, type LLMCompletionMessage, type LLMCountTokensFunction, type LLMMessageContent, type LLMProviders } from '../../LLMService.typedefs';
|
|
1
|
+
import { type CombineMessagesOptions, type LLMCompletionMessage, type LLMCountTokensFunction, type LLMMessageContent, type LLMProviders, type LLMFileLimits } from '../../LLMService.typedefs';
|
|
2
2
|
import { type ChatCompletionMessageParam } from 'openai/resources/chat';
|
|
3
3
|
export declare class OpenAIEntity {
|
|
4
4
|
static getCountTokensFn(): (messagesContents: LLMMessageContent[]) => Promise<number>;
|
|
5
5
|
static getChatCompletionMessageParam(messages: LLMCompletionMessage[]): ChatCompletionMessageParam[];
|
|
6
6
|
static combineMessagesWithLimit({ modelContext, history, message, model, countTokensFn, }: CombineMessagesOptions<LLMProviders.OpenAI, LLMCountTokensFunction<LLMProviders.OpenAI, LLMMessageContent[]>>): Promise<LLMCompletionMessage[]>;
|
|
7
|
+
static get transcribeLimits(): LLMFileLimits;
|
|
7
8
|
}
|
|
@@ -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(((e,s)=>s.type===LLMService_typedefs_1.LLMMessageContentType.IMAGE_URL?e+LLMService_constants_1.APPROXIMATE_TOKENS_COUNT_IN_IMAGE:s.type===LLMService_typedefs_1.LLMMessageContentType.TEXT?e+t.encode(s.text).length: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:
|
|
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)=>s.type===LLMService_typedefs_1.LLMMessageContentType.IMAGE_URL?e+LLMService_constants_1.APPROXIMATE_TOKENS_COUNT_IN_IMAGE:s.type===LLMService_typedefs_1.LLMMessageContentType.TEXT?e+t.encode(s.text).length: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 o=[...e];if(t[0]){const e=t[0];o.push(e)}const r=[{role:LLMService_typedefs_1.LLMRoles.User,content:s.content},...t.slice(1).reverse()],p=o.map((e=>e.content));let c=await(i?.(p,n))??0;for(const e of r){const t=c+(await(i?.([e.content],n))??0);if(!(t<=n.limits.maxInputTokens))break;o.push(e),c=t}return o}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]}}}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,+
|
|
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,OAAO,GAAG,IAAA,yBAAW,EAAC,YAAY,CAAC,CAAC;YAC1C,MAAM,MAAM,GAAG,gBAAgB,CAAC,MAAM,CACpC,CAAC,GAAG,EAAE,QAAQ,EAAE,EAAE;gBAChB,IAAI,QAAQ,CAAC,IAAI,KAAK,2CAAqB,CAAC,SAAS,EAAE,CAAC;oBACtD,OAAO,GAAG,GAAG,wDAAiC,CAAC;gBACjD,CAAC;gBAED,IAAI,QAAQ,CAAC,IAAI,KAAK,2CAAqB,CAAC,IAAI,EAAE,CAAC;oBACjD,OAAO,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC;gBACpD,CAAC;gBAED,OAAO,GAAG,CAAC;YACb,CAAC,EACD,CAAC,CACF,CAAC;YAEF,OAAO,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACjC,CAAC,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,6BAA6B,CAClC,QAAgC;QAEhC,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE;YAC9B,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,KAAK,8BAAQ,CAAC,IAAI;gBACzC,CAAC,CAAC,6BAAW,CAAC,IAAI;gBAClB,C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,GAAG,cAAc,CAAC;YAC9B,CAAC;iBAAM,CAAC;gBACN,MAAM;YACR,CAAC;QACH,CAAC;QAED,OAAO,gBAAgB,CAAC;IAC1B,CAAC;IAED,MAAM,KAAK,gBAAgB;QACzB,OAAO;YACL,WAAW,EAAE,EAAE,GAAG,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,QAAQ;YACvC,kBAAkB,EAAE;gBAClB,4CAAsB,CAAC,SAAS;gBAChC,4CAAsB,CAAC,SAAS;gBAChC,4CAAsB,CAAC,UAAU;aAClC;SACF,CAAC;IACJ,CAAC;CACF;AA/FD,oCA+FC"}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
export declare enum OpenAIModelNames {
|
|
2
2
|
GPT_4_OMNI = "gpt-4o",
|
|
3
3
|
GPT_4_OMNI_MINI = "gpt-4o-mini",
|
|
4
|
-
GPT_4_1 = "gpt-4.1"
|
|
4
|
+
GPT_4_1 = "gpt-4.1",
|
|
5
|
+
GPT_4_OMNI_TRANSCRIBE = "gpt-4o-transcribe",
|
|
6
|
+
GPT_4_OMNI_MINI_TRANSCRIBE = "gpt-4o-mini-transcribe",
|
|
7
|
+
TTS_1 = "tts-1",
|
|
8
|
+
GPT_4_OMNI_MINI_TTS = "gpt-4o-mini-tts"
|
|
5
9
|
}
|
|
6
10
|
export declare enum OpenAIRoles {
|
|
7
11
|
User = "user",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var OpenAIModelNames,OpenAIRoles;Object.defineProperty(exports,"__esModule",{value:!0}),exports.OpenAIRoles=exports.OpenAIModelNames=void 0,function(e){e.GPT_4_OMNI="gpt-4o",e.GPT_4_OMNI_MINI="gpt-4o-mini",e.GPT_4_1="gpt-4.1"}(OpenAIModelNames||(exports.OpenAIModelNames=OpenAIModelNames={})),function(e){e.User="user",e.Assistant="assistant"}(OpenAIRoles||(exports.OpenAIRoles=OpenAIRoles={}));
|
|
1
|
+
"use strict";var OpenAIModelNames,OpenAIRoles;Object.defineProperty(exports,"__esModule",{value:!0}),exports.OpenAIRoles=exports.OpenAIModelNames=void 0,function(e){e.GPT_4_OMNI="gpt-4o",e.GPT_4_OMNI_MINI="gpt-4o-mini",e.GPT_4_1="gpt-4.1",e.GPT_4_OMNI_TRANSCRIBE="gpt-4o-transcribe",e.GPT_4_OMNI_MINI_TRANSCRIBE="gpt-4o-mini-transcribe",e.TTS_1="tts-1",e.GPT_4_OMNI_MINI_TTS="gpt-4o-mini-tts"}(OpenAIModelNames||(exports.OpenAIModelNames=OpenAIModelNames={})),function(e){e.User="user",e.Assistant="assistant"}(OpenAIRoles||(exports.OpenAIRoles=OpenAIRoles={}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OpenAI.typedefs.js","sourceRoot":"","sources":["../../../src/providers/OpenAI/OpenAI.typedefs.ts"],"names":[],"mappings":";;;AAAA,IAAY,
|
|
1
|
+
{"version":3,"file":"OpenAI.typedefs.js","sourceRoot":"","sources":["../../../src/providers/OpenAI/OpenAI.typedefs.ts"],"names":[],"mappings":";;;AAAA,IAAY,gBAQX;AARD,WAAY,gBAAgB;IAC1B,yCAAqB,CAAA;IACrB,mDAA+B,CAAA;IAC/B,uCAAmB,CAAA;IACnB,+DAA2C,CAAA;IAC3C,yEAAqD,CAAA;IACrD,mCAAe,CAAA;IACf,2DAAuC,CAAA;AACzC,CAAC,EARW,gBAAgB,gCAAhB,gBAAgB,QAQ3B;AAED,IAAY,WAGX;AAHD,WAAY,WAAW;IACrB,4BAAa,CAAA;IACb,sCAAuB,CAAA;AACzB,CAAC,EAHW,WAAW,2BAAX,WAAW,QAGtB"}
|
|
@@ -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.
|
|
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}=e,s=t?{tool_resources:{file_search:{vector_store_ids:[t]}}}:{};return{chatId:(await this.instance.beta.threads.create({...s})).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}=e,i=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,...i})).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,i={role:t.role===LLMService_typedefs_1.LLMRoles.User?OpenAI_typedefs_1.OpenAIRoles.User:OpenAI_typedefs_1.OpenAIRoles.Assistant,content:[t.content]};await this.instance.beta.threads.messages.create(s,i);const a=await this.instance.beta.threads.runs.createAndPoll(s,{assistant_id:r}),{status:n}=a;if("completed"!==n)throw new Error(`Thread run did not complete for message, status: ${n}`);const o=(await this.instance.beta.threads.messages.list(s,{run_id:a.id})).data.find((e=>e.role===OpenAI_typedefs_1.OpenAIRoles.Assistant)),c=o?.content.find((e=>"text"===e.type&&"text"in e));return{text:c?.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
|
-
{"version":3,"file":"OpenAIAssistance.service.js","sourceRoot":"","sources":["../../../../src/providers/OpenAI/services/OpenAIAssistance.service.ts"],"names":[],"mappings":";;;AAAA,2BAAsC;AAEtC,mCAAgC;AAChC,+DAc+B;AAC/B,yCAAkD;AAClD,wEAA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AAI,EAAE,YAAY,CAAC,EAAE,CAAC,CAAC;YAE9C,OAAO;gBACL,GAAG,IAAI;gBACP,MAAM,EAAE,YAAY,CAAC,EAAE;aACxB,CAAC;QACJ,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,IAAI,CAAC,MAAM;iBACR,KAAK,CAAC,YAAY,CAAC;iBACnB,KAAK,CAAC,sBAAsB,EAAE;gBAC7B,KAAK;gBACL,IAAI;aACL,CAAC,CAAC;YAEL,OAAO,EAAE,KAAK,EAAE,CAAC;QACnB,CAAC;IACH,CAAC;IAED,KAAK,CAAC,UAAU,CACd,MAAc;QAEd,MAAM,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,
|
|
1
|
+
{"version":3,"file":"OpenAIAssistance.service.js","sourceRoot":"","sources":["../../../../src/providers/OpenAI/services/OpenAIAssistance.service.ts"],"names":[],"mappings":";;;AAAA,2BAAsC;AAEtC,mCAAgC;AAChC,+DAc+B;AAC/B,yCAAkD;AAClD,wEAAiE;AAEjE,MAAa,uBACX,SAAQ,+BAAyC;IACjD,SAAS,GAAkB,IAAI,CAAC;IAExB,aAAa,GAAwB,IAAI,GAAG,EAAE,CAAC;IAEvD,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,CAAC,IAAmB;QAClC,IAAI,CAAC;YACH,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC;YAEtB,MAAM,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,CA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ACE,MAAM,EAAE,SAAS,CAAC,EAAE;aACrB,CACF,CAAC;YAEF,MAAM,iBAAiB,GAAG,iBAAiB,CAAC,IAAI,CAAC,IAAI,CACnD,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,KAAK,6BAAW,CAAC,SAAS,CACpD,CAAC;YAEF,MAAM,WAAW,GAAG,iBAAiB,EAAE,OAAO;iBAC3C,IAAI,CACH,CAAC,OAAO,EAAmD,EAAE,CAAC,CAC5D,OAAO,CAAC,IAAI,KAAK,MAAM,IAAI,MAAM,IAAI,OAAO,CAC7C,CACF,CAAC;YAEJ,OAAO;gBACL,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,KAAK,IAAI,EAAE;aACrC,CAAC;QACJ,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,IAAI,CAAC,MAAM;iBACR,KAAK,CAAC,cAAc,CAAC;iBACrB,KAAK,CAAC,yBAAyB,EAAE;gBAChC,KAAK;gBACL,OAAO;aACR,CAAC,CAAC;YAEL,OAAO,EAAE,KAAK,EAAE,CAAC;QACnB,CAAC;IACH,CAAC;CACF;AA1RD,0DA0RC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type Logger } from '@mate-academy/core';
|
|
2
|
+
import { OpenAI } from 'openai';
|
|
3
|
+
import { LLMProviders, type LLMInstanceOptions, type LLMTranscribeOptions, type LLMTranscribeResult } from '../../../LLMService.typedefs';
|
|
4
|
+
import { LLMSpeechToTextService } from '../../../services';
|
|
5
|
+
export declare class OpenAISpeechToTextService extends LLMSpeechToTextService<LLMProviders.OpenAI> {
|
|
6
|
+
#private;
|
|
7
|
+
constructor(logger: Logger, options: LLMInstanceOptions[LLMProviders.OpenAI]);
|
|
8
|
+
protected get instance(): OpenAI;
|
|
9
|
+
transcribe(options: LLMTranscribeOptions<typeof this.provider>): Promise<LLMTranscribeResult>;
|
|
10
|
+
}
|
|
@@ -0,0 +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:i,supportedMimeTypes:s}=OpenAI_entity_1.OpenAIEntity.transcribeLimits;if((0,fs_1.statSync)(r).size>i)throw new Error(`File size exceeds the limit of ${i} bytes`);const n=mime_types_1.default.lookup(r);if(!n||!s.includes(n))throw new Error(`Unsupported audio file type: ${n}. Supported types are: ${s.join(", ")}`);const o=(0,fs_1.createReadStream)(r);return{text:await this.instance.audio.transcriptions.create({model:t.name,file:o,response_format:"text"})}}catch(t){return this.logger.child("transcribe").error("Error transcribing audio",{error:t,options:e}),{error:t}}}}exports.OpenAISpeechToTextService=OpenAISpeechToTextService;
|
|
@@ -0,0 +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,I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B,KAAK,CAAC,0BAA0B,EAAE;gBACjC,KAAK;gBACL,OAAO;aACR,CAAC,CAAC;YAEL,OAAO,EAAE,KAAK,EAAE,CAAC;QACnB,CAAC;IACH,CAAC;CACF;AArED,8DAqEC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type Logger } from '@mate-academy/core';
|
|
2
|
+
import { OpenAI } from 'openai';
|
|
3
|
+
import { LLMProviders, type LLMCreateSpeechOptions, type LLMCreateSpeechResult, type LLMInstanceOptions } from '../../../LLMService.typedefs';
|
|
4
|
+
import { LLMTextToSpeechService } from '../../../services';
|
|
5
|
+
export declare class OpenAITextToSpeechService extends LLMTextToSpeechService<LLMProviders.OpenAI> {
|
|
6
|
+
#private;
|
|
7
|
+
constructor(logger: Logger, options: LLMInstanceOptions[LLMProviders.OpenAI]);
|
|
8
|
+
protected get instance(): OpenAI;
|
|
9
|
+
createSpeech(options: LLMCreateSpeechOptions<typeof this.provider>): Promise<LLMCreateSpeechResult>;
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.OpenAITextToSpeechService=void 0;const openai_1=require("openai"),LLMService_typedefs_1=require("../../../LLMService.typedefs"),services_1=require("../../../services");class OpenAITextToSpeechService extends services_1.LLMTextToSpeechService{#e=null;constructor(e,r){super(LLMService_typedefs_1.LLMProviders.OpenAI,e,r)}get instance(){return this.#e||(this.#e=new openai_1.OpenAI(this.options)),this.#e}async createSpeech(e){try{const{text:r,model:t,instructions:s,speechOptions:i}=e,c=await this.instance.audio.speech.create({model:t.name,input:r,instructions:s,voice:i?.voice||"alloy",response_format:i?.response_format,speed:i?.speed});return{audio:await c.arrayBuffer(),mimeType:c.headers.get("Content-Type")}}catch(r){return this.logger.child("createSpeech").error("Error creating speech",{error:r,options:e}),{error:r}}}}exports.OpenAITextToSpeechService=OpenAITextToSpeechService;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file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CAAC,cAAc,CAAC;iBACrB,KAAK,CAAC,uBAAuB,EAAE;gBAC9B,KAAK;gBACL,OAAO;aACR,CAAC,CAAC;YAEL,OAAO,EAAE,KAAK,EAAE,CAAC;QACnB,CAAC;IACH,CAAC;CACF;AAzDD,8DAyDC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var __createBinding=this&&this.__createBinding||(Object.create?function(e,t,
|
|
1
|
+
"use strict";var __createBinding=this&&this.__createBinding||(Object.create?function(e,r,t,i){void 0===i&&(i=t);var o=Object.getOwnPropertyDescriptor(r,t);o&&!("get"in o?!r.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return r[t]}}),Object.defineProperty(e,i,o)}:function(e,r,t,i){void 0===i&&(i=t),e[i]=r[t]}),__exportStar=this&&this.__exportStar||function(e,r){for(var t in e)"default"===t||Object.prototype.hasOwnProperty.call(r,t)||__createBinding(r,e,t)};Object.defineProperty(exports,"__esModule",{value:!0}),__exportStar(require("./OpenAICompletion.service"),exports),__exportStar(require("./OpenAIAssistance.service"),exports),__exportStar(require("./OpenAISpeechToText.service"),exports),__exportStar(require("./OpenAITextToSpeech.service"),exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/providers/OpenAI/services/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6DAA2C;AAC3C,6DAA2C"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/providers/OpenAI/services/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6DAA2C;AAC3C,6DAA2C;AAC3C,+DAA6C;AAC7C,+DAA6C"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type Logger } from '@mate-academy/core';
|
|
2
|
+
import { LLMPurposes, type LLMProviders, type LLMTranscribeOptions, type LLMTranscribeResult, type LLMInstanceOptions } from '../LLMService.typedefs';
|
|
3
|
+
import { LLMBaseService } from '../services';
|
|
4
|
+
export declare abstract class LLMSpeechToTextService<Provider extends LLMProviders> extends LLMBaseService<LLMPurposes.SpeechToText, Provider> {
|
|
5
|
+
constructor(provider: Provider, logger: Logger, options: LLMInstanceOptions[Provider]);
|
|
6
|
+
abstract transcribe(options: LLMTranscribeOptions<Provider>): Promise<LLMTranscribeResult>;
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.LLMSpeechToTextService=void 0;const LLMService_typedefs_1=require("../LLMService.typedefs"),services_1=require("../services");class LLMSpeechToTextService extends services_1.LLMBaseService{constructor(e,r,c){super(e,"SpeechToTextService",LLMService_typedefs_1.LLMPurposes.SpeechToText,r,c)}}exports.LLMSpeechToTextService=LLMSpeechToTextService;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LLMSpeechToTextService.abstract.js","sourceRoot":"","sources":["../../src/services/LLMSpeechToTextService.abstract.ts"],"names":[],"mappings":";;;AACA,+DAM+B;AAC/B,yCAA4C;AAE5C,MAAsB,sBAGpB,SAAQ,yBAAkD;IAC1D,YACE,QAAkB,EAClB,MAAc,EACd,OAAqC;QAErC,KAAK,CACH,QAAQ,EACR,qBAAqB,EACrB,iCAAW,CAAC,YAAY,EACxB,MAAM,EACN,OAAO,CACR,CAAC;IACJ,CAAC;CAKF;AArBD,wDAqBC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type Logger } from '@mate-academy/core';
|
|
2
|
+
import { LLMPurposes, type LLMProviders, type LLMCreateSpeechOptions, type LLMCreateSpeechResult, type LLMInstanceOptions } from '../LLMService.typedefs';
|
|
3
|
+
import { LLMBaseService } from '../services';
|
|
4
|
+
export declare abstract class LLMTextToSpeechService<Provider extends LLMProviders> extends LLMBaseService<LLMPurposes.TextToSpeech, Provider> {
|
|
5
|
+
constructor(provider: Provider, logger: Logger, options: LLMInstanceOptions[Provider]);
|
|
6
|
+
abstract createSpeech(options: LLMCreateSpeechOptions<Provider>): Promise<LLMCreateSpeechResult>;
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.LLMTextToSpeechService=void 0;const LLMService_typedefs_1=require("../LLMService.typedefs"),services_1=require("../services");class LLMTextToSpeechService extends services_1.LLMBaseService{constructor(e,r,c){super(e,"TextToSpeechService",LLMService_typedefs_1.LLMPurposes.TextToSpeech,r,c)}}exports.LLMTextToSpeechService=LLMTextToSpeechService;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LLMTextToSpeechService.abstract.js","sourceRoot":"","sources":["../../src/services/LLMTextToSpeechService.abstract.ts"],"names":[],"mappings":";;;AACA,+DAM+B;AAC/B,yCAA4C;AAE5C,MAAsB,sBAGpB,SAAQ,yBAAkD;IAC1D,YACE,QAAkB,EAClB,MAAc,EACd,OAAqC;QAErC,KAAK,CACH,QAAQ,EACR,qBAAqB,EACrB,iCAAW,CAAC,YAAY,EACxB,MAAM,EACN,OAAO,CACR,CAAC;IACJ,CAAC;CAKF;AArBD,wDAqBC"}
|
package/dist/services/index.d.ts
CHANGED
|
@@ -2,3 +2,5 @@ export * from './LLMBaseService.abstract';
|
|
|
2
2
|
export * from './LLMCompletionService.abstract';
|
|
3
3
|
export * from './LLMServicePurposeFactory.abstract';
|
|
4
4
|
export * from './LLMAssistanceService.abstract';
|
|
5
|
+
export * from './LLMSpeechToTextService.abstract';
|
|
6
|
+
export * from './LLMTextToSpeechService.abstract';
|
package/dist/services/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var __createBinding=this&&this.__createBinding||(Object.create?function(e,r,t,i){void 0===i&&(i=t);var o=Object.getOwnPropertyDescriptor(r,t);o&&!("get"in o?!r.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return r[t]}}),Object.defineProperty(e,i,o)}:function(e,r,t,i){void 0===i&&(i=t),e[i]=r[t]}),__exportStar=this&&this.__exportStar||function(e,r){for(var t in e)"default"===t||Object.prototype.hasOwnProperty.call(r,t)||__createBinding(r,e,t)};Object.defineProperty(exports,"__esModule",{value:!0}),__exportStar(require("./LLMBaseService.abstract"),exports),__exportStar(require("./LLMCompletionService.abstract"),exports),__exportStar(require("./LLMServicePurposeFactory.abstract"),exports),__exportStar(require("./LLMAssistanceService.abstract"),exports);
|
|
1
|
+
"use strict";var __createBinding=this&&this.__createBinding||(Object.create?function(e,r,t,i){void 0===i&&(i=t);var o=Object.getOwnPropertyDescriptor(r,t);o&&!("get"in o?!r.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return r[t]}}),Object.defineProperty(e,i,o)}:function(e,r,t,i){void 0===i&&(i=t),e[i]=r[t]}),__exportStar=this&&this.__exportStar||function(e,r){for(var t in e)"default"===t||Object.prototype.hasOwnProperty.call(r,t)||__createBinding(r,e,t)};Object.defineProperty(exports,"__esModule",{value:!0}),__exportStar(require("./LLMBaseService.abstract"),exports),__exportStar(require("./LLMCompletionService.abstract"),exports),__exportStar(require("./LLMServicePurposeFactory.abstract"),exports),__exportStar(require("./LLMAssistanceService.abstract"),exports),__exportStar(require("./LLMSpeechToTextService.abstract"),exports),__exportStar(require("./LLMTextToSpeechService.abstract"),exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4DAA0C;AAC1C,kEAAgD;AAChD,sEAAoD;AACpD,kEAAgD"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4DAA0C;AAC1C,kEAAgD;AAChD,sEAAoD;AACpD,kEAAgD;AAChD,oEAAkD;AAClD,oEAAkD"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { LLMProviders, type LLMInstanceOptions, type LLMProviderAvailableModels, type LLMPurposes } from '../LLMService.typedefs';
|
|
2
|
+
import type { Logger } from '@mate-academy/core';
|
|
3
|
+
export declare const mockLogger: Logger;
|
|
4
|
+
type TestConfig = {
|
|
5
|
+
[Provider in LLMProviders]: {
|
|
6
|
+
provider: Provider;
|
|
7
|
+
availableModels: Partial<LLMProviderAvailableModels<Provider>>;
|
|
8
|
+
clientOptions: LLMInstanceOptions[Provider];
|
|
9
|
+
requireCredentials: () => void;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
export declare const resolveTestConfig: (purpose: LLMPurposes) => TestConfig;
|
|
13
|
+
export declare const hasText: (result: any) => result is {
|
|
14
|
+
text: string;
|
|
15
|
+
};
|
|
16
|
+
export declare const hasError: (result: any) => result is {
|
|
17
|
+
error: any;
|
|
18
|
+
};
|
|
19
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.hasError=exports.hasText=exports.resolveTestConfig=exports.mockLogger=void 0;const LLMService_typedefs_1=require("../LLMService.typedefs"),providers_1=require("../providers"),globals_1=require("@jest/globals");function hasOpenAICredentials(){return!!(process.env.OPENAI_SECRET_API_KEY&&"OPENAI_SECRET_API_KEY"!==process.env.OPENAI_SECRET_API_KEY&&process.env.OPENAI_SECRET_API_KEY.length>10)}function hasGoogleAICredentials(){return!!(process.env.GOOGLE_GENERATIVE_AI_API_KEY&&"GOOGLE_GENERATIVE_AI_API_KEY"!==process.env.GOOGLE_GENERATIVE_AI_API_KEY&&process.env.GOOGLE_GENERATIVE_AI_API_KEY.length>10)}function requireOpenAICredentials(){if(!hasOpenAICredentials())throw new Error("OpenAI credentials required for integration tests. Please set OPENAI_SECRET_API_KEY environment variable. You can find the proper keys in .env.file.sample")}function requireGoogleAICredentials(){if(!hasGoogleAICredentials())throw new Error("Google Generative AI credentials required for integration tests. Please set GOOGLE_GENERATIVE_AI_API_KEY environment variable. You can find the proper keys in .env.file.sample")}const ENABLE_LOGGING="true"===process.env.ENABLE_LOGGING;exports.mockLogger={info:globals_1.jest.fn(((e,r)=>ENABLE_LOGGING&&console.log("[INFO]",e,r))),error:globals_1.jest.fn(((e,r)=>ENABLE_LOGGING&&console.log("[ERROR]",e,r))),warn:globals_1.jest.fn(((e,r)=>ENABLE_LOGGING&&console.log("[WARN]",e,r))),debug:globals_1.jest.fn(((e,r)=>ENABLE_LOGGING&&console.log("[DEBUG]",e,r))),child:globals_1.jest.fn((()=>exports.mockLogger))};const resolveTestConfig=e=>({[LLMService_typedefs_1.LLMProviders.OpenAI]:{provider:LLMService_typedefs_1.LLMProviders.OpenAI,availableModels:providers_1.OPEN_AI_MODELS[e],clientOptions:{apiKey:process.env.OPENAI_SECRET_API_KEY,organization:process.env.OPENAI_ORG_ID,baseURL:process.env.OPENAI_BASE_URL},requireCredentials:requireOpenAICredentials},[LLMService_typedefs_1.LLMProviders.GoogleGenerativeAI]:{provider:LLMService_typedefs_1.LLMProviders.GoogleGenerativeAI,availableModels:providers_1.GOOGLE_AI_MODELS[e],clientOptions:{apiKey:process.env.GOOGLE_GENERATIVE_AI_API_KEY},requireCredentials:requireGoogleAICredentials}});exports.resolveTestConfig=resolveTestConfig;const hasText=e=>"text"in e;exports.hasText=hasText;const hasError=e=>"error"in e;exports.hasError=hasError;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/tests/helpers.ts"],"names":[],"mappings":";;;AAAA,+DAK+B;AAC/B,2CAA+D;AAC/D,2CAAqC;AAGrC;;;GAGG;AACH,SAAS,oBAAoB;IAC3B,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,qBAAqB;QACpD,OAAO,CAAC,GAAG,CAAC,qBAAqB,KAAK,uBAAuB;QAC7D,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC,MAAM,GAAG,EAAE,CAAC;IAEhD,OAAO,CAAC,CAAC,YAAY,CAAC;AACxB,CAAC;AAED;;;GAGG;AACH,SAAS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ict";Object.defineProperty(exports,"__esModule",{value:!0});const globals_1=require("@jest/globals"),index_1=require("../../index"),helpers_1=require("../../tests/helpers"),fs_1=require("fs"),path_1=require("path"),os_1=require("os"),testConfig=(0,helpers_1.resolveTestConfig)(index_1.LLMPurposes.Assistance);(0,globals_1.describe)("LLM Assistance Service",(()=>{Object.values(testConfig).forEach((e=>{const{provider:s,availableModels:t,clientOptions:a,requireCredentials:o}=e;(0,globals_1.describe)(`${s} Provider`,(()=>{let e;(0,globals_1.beforeAll)((()=>{o(),e=index_1.LLMServiceFactory.getAssistanceService(s,helpers_1.mockLogger,a)})),(0,globals_1.beforeEach)((()=>{globals_1.jest.clearAllMocks()})),(0,globals_1.describe)("Service Initialization",(()=>{(0,globals_1.it)("should create assistance service instance",(()=>{(0,globals_1.expect)(e).toBeDefined(),(0,globals_1.expect)(e.provider).toBe(s)}))})),Object.values(t).forEach((a=>{const o=a.name;(0,globals_1.describe)(`Model: ${o}`,(()=>{const a=t[o];(0,globals_1.describe)("File Management",(()=>{(0,globals_1.it)("should upload a text file successfully",(async()=>{const s="This is a test file content for LLM assistance integration tests.",t=(0,os_1.tmpdir)(),a=(0,path_1.join)(t,`test-file-${Date.now()}.txt`);(0,fs_1.writeFileSync)(a,s);const o={name:"test-file.txt",path:a,mimeType:index_1.LLMUploadFileMimeTypes.PLAIN_TEXT,content:s};let i;try{i=await e.uploadFile(o),(0,globals_1.expect)((0,helpers_1.hasError)(i)).toBe(!1),(0,helpers_1.hasError)(i)||((0,globals_1.expect)(i.fileId).toBeDefined(),(0,globals_1.expect)(i.name).toBe(o.name),(0,globals_1.expect)(i.mimeType).toBe(o.mimeType))}finally{(0,fs_1.unlinkSync)(a)}})),(0,globals_1.it)("should handle file upload errors gracefully",(async()=>{const s={name:"invalid-file.txt",path:"",mimeType:index_1.LLMUploadFileMimeTypes.PLAIN_TEXT,content:"test content"},t=await e.uploadFile(s);(0,globals_1.expect)(t).toBeDefined(),(0,helpers_1.hasError)(t)&&(0,globals_1.expect)(t.error).toBeDefined()}))})),(0,globals_1.describe)("File Storage Management",(()=>{(0,globals_1.it)("should create file storage with uploaded files",(async()=>{const s="Content for file storage test.",t=(0,os_1.tmpdir)(),o=(0,path_1.join)(t,`storage-test-file-${Date.now()}.txt`);(0,fs_1.writeFileSync)(o,s);const i={name:"storage-test-file.txt",path:o,mimeType:index_1.LLMUploadFileMimeTypes.PLAIN_TEXT,content:s};let l;try{if(l=await e.uploadFile(i),(0,helpers_1.hasError)(l))throw new Error('File upload failed in "should create file storage with uploaded files"');{const s=await e.createFileStorage({uploadedFiles:[l],model:a,instructions:"Test instructions with files"});(0,globals_1.expect)((0,helpers_1.hasError)(s)).toBe(!1),(0,helpers_1.hasError)(s)||(0,globals_1.expect)(s.storageId).toBeDefined()}}finally{(0,fs_1.unlinkSync)(o)}}))})),(0,globals_1.describe)("Assistant Management",(()=>{(0,globals_1.it)("should create an assistant successfully",(async()=>{const s=await e.createFileStorage({uploadedFiles:[],model:a,instructions:"Base instructions for assistant"});if(!(0,helpers_1.hasError)(s)){const t=await e.createAssistant({model:a,instructions:"You are a helpful assistant for testing purposes.",storageIds:[s.storageId]});(0,globals_1.expect)((0,helpers_1.hasError)(t)).toBe(!1),(0,helpers_1.hasError)(t)||(0,globals_1.expect)(t.assistantId).toBeDefined()}})),(0,globals_1.it)("should create an assistant without storage",(async()=>{const s=await e.createAssistant({model:a,instructions:"You are a simple assistant without file storage."});(0,globals_1.expect)((0,helpers_1.hasError)(s)).toBe(!1),(0,helpers_1.hasError)(s)||(0,globals_1.expect)(s.assistantId).toBeDefined()}))})),(0,globals_1.describe)("Chat Management",(()=>{(0,globals_1.it)("should create a chat successfully",(async()=>{const s=await e.createChat({model:a,instructions:"Chat instructions for testing"});(0,globals_1.expect)((0,helpers_1.hasError)(s)).toBe(!1),(0,helpers_1.hasError)(s)||(0,globals_1.expect)(s.chatId).toBeDefined()})),(0,globals_1.it)("should create a chat with file storage",(async()=>{const s=await e.createFileStorage({uploadedFiles:[],model:a,instructions:"Storage for chat test"});if(!(0,helpers_1.hasError)(s)){const t=await e.createChat({model:a,instructions:"Chat with file storage",storageId:s.storageId});(0,globals_1.expect)((0,helpers_1.hasError)(t)).toBe(!1),(0,helpers_1.hasError)(t)||(0,globals_1.expect)(t.chatId).toBeDefined()}}))})),(0,globals_1.describe)("Chat Assistance",(()=>{(0,globals_1.it)("should assist in chat with simple message",(async()=>{const s=await e.createAssistant({model:a,instructions:'You are a test assistant. Respond with "TEST SUCCESS" to any message.'});if(!(0,helpers_1.hasError)(s)){const t=await e.createChat({model:a,instructions:'You are a test assistant. Respond with "TEST SUCCESS" to any message.'});if(!(0,helpers_1.hasError)(t)){const o=await e.assistInChat({model:a,message:{role:index_1.LLMRoles.User,content:{type:index_1.LLMMessageContentType.TEXT,text:"Hello, this is a test message."}},chatId:t.chatId,assistantId:s.assistantId});(0,globals_1.expect)((0,helpers_1.hasText)(o)).toBe(!0),(0,helpers_1.hasText)(o)&&(0,globals_1.expect)(o.text).toMatch(/test success/i)}}})),(0,globals_1.it)("should handle multiple messages in conversation",(async()=>{const s=await e.createAssistant({model:a,instructions:"You are a helpful assistant. Keep responses concise."});if(!(0,helpers_1.hasError)(s)){const t=await e.createChat({model:a,instructions:"Conversational test chat"});if(!(0,helpers_1.hasError)(t)){const o=await e.assistInChat({model:a,message:{role:index_1.LLMRoles.User,content:{type:index_1.LLMMessageContentType.TEXT,text:"My name is Test User."}},chatId:t.chatId,assistantId:s.assistantId});if((0,globals_1.expect)((0,helpers_1.hasText)(o)).toBe(!0),(0,helpers_1.hasText)(o)){(0,globals_1.expect)(o.text).toBeDefined();const i=await e.assistInChat({model:a,message:{role:index_1.LLMRoles.User,content:{type:index_1.LLMMessageContentType.TEXT,text:"What is my name?"}},chatId:t.chatId,assistantId:s.assistantId});(0,globals_1.expect)((0,helpers_1.hasText)(i)).toBe(!0),(0,helpers_1.hasText)(i)&&(0,globals_1.expect)(i.text).toMatch(/test[\s]*user/i)}}}})),(0,globals_1.it)("should assist with file-based context",(async()=>{const s="ASSISTANT_TEST_123",t=`This file contains important information: The secret code is ${s}.`,o=(0,os_1.tmpdir)(),i=(0,path_1.join)(o,`context-file-${Date.now()}.txt`);(0,fs_1.writeFileSync)(i,t);const l={name:"context-file.txt",path:i,mimeType:index_1.LLMUploadFileMimeTypes.PLAIN_TEXT,content:t};let r;try{if(r=await e.uploadFile(l),(0,helpers_1.hasError)(r))throw new Error('File upload failed in "should assist with file-based context"');{const t=await e.createFileStorage({uploadedFiles:[r],model:a,instructions:"Use the uploaded files to answer questions"});if((0,helpers_1.hasError)(t))throw new Error('File storage creation failed in "should assist with file-based context"');{const o=await e.createAssistant({model:a,instructions:"You are an assistant that can access uploaded files. Use the file content to answer questions.",storageIds:[t.storageId]});if((0,helpers_1.hasError)(o))throw new Error('Assistant creation failed in "should assist with file-based context"');{const i=await e.createChat({model:a,instructions:"Chat with file context",storageId:t.storageId,files:[r]});if((0,helpers_1.hasError)(i))throw new Error('Chat creation failed in "should assist with file-based context"');{const t=await e.assistInChat({model:a,message:{role:index_1.LLMRoles.User,content:{type:index_1.LLMMessageContentType.TEXT,text:"What is the secret code mentioned in the uploaded file?"}},chatId:i.chatId,assistantId:o.assistantId});(0,globals_1.expect)((0,helpers_1.hasText)(t)).toBe(!0),(0,helpers_1.hasText)(t)&&(0,globals_1.expect)(t.text).toMatch(new RegExp(s,"i"))}}}}}finally{(0,fs_1.unlinkSync)(i)}}))})),(0,globals_1.describe)("Error Handling",(()=>{(0,globals_1.it)("should handle invalid chat ID gracefully",(async()=>{const s=await e.createAssistant({model:a,instructions:"Test assistant"});if((0,helpers_1.hasError)(s))throw new Error("Assistant creation failed");{const t=await e.assistInChat({model:a,message:{role:index_1.LLMRoles.User,content:{type:index_1.LLMMessageContentType.TEXT,text:"Test message"}},chatId:"invalid-chat-id",assistantId:s.assistantId});(0,globals_1.expect)((0,helpers_1.hasError)(t)).toBe(!0)}})),s===index_1.LLMProviders.OpenAI&&(0,globals_1.it)("should handle invalid assistant ID gracefully",(async()=>{const s=await e.createChat({model:a,instructions:"Test chat"});if((0,helpers_1.hasError)(s))throw new Error("Chat creation failed");{const t=await e.assistInChat({model:a,message:{role:index_1.LLMRoles.User,content:{type:index_1.LLMMessageContentType.TEXT,text:"Test message"}},chatId:s.chatId,assistantId:"invalid-assistant-id"});(0,globals_1.expect)((0,helpers_1.hasError)(t)).toBe(!0)}}))}))}))}))}))}))}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LLMAssistance.service.integration.test.js","sourceRoot":"","sources":["../../../src/tests/integration/LLMAssistance.service.integration.test.ts"],"names":[],"mappings":";;AAAA,2CAOuB;AACvB,mCAQiB;AACjB,6CAKyB;AACzB,2BAA+C;AAC/C,+BAA4B;AAC5B,2BAA4B;AAE5B,MAAM,UAAU,GAAG,IAAA,2BAAiB,EAAC,mBAAW,CAAC,UAAU,CAAC,CAAC;AAE7D,IAAA,kBAAQ,EAAC,wBAAwB,EAAE,GAAG,EAAE;IACtC,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QACzC,MAAM,EACJ,QAAQ,EACR,eAAe,EACf,aAAa,EACb,kBAAkB,GACnB,GAAG,IAAI,CAAC;QAET,IAAA,kBAAQ,EAAC,GAAG,QAAQ,WAAW,EAAE,GAAG,EAAE;YACpC,IAAI,OAA8C,CAAC;YAEnD,IAAA,mBAAS,EAAC,GAAG,EAAE;gBACb,kBAAkB,EAAE,CAAC;gBAErB,OAAO,GAAG,yBAAiB,CAAC,oBAAoB,CAC9C,QAAQ,EACR,oBAAU,EACV,aAAa,CACd,CAAC;YACJ,CAAC,CAAC,CAAC;YAEH,IAAA,oBAAU,EAAC,GAAG,EAAE;gBACd,cAAI,CAAC,aAAa,EAAE,CAAC;YACvB,CAAC,CAAC,CAAC;YAEH,IAAA,kBAAQ,EAAC,wBAAwB,EAAE,GAAG,EAAE;gBACtC,IAAA,YAAE,EAAC,2CA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("../../index"),helpers_1=require("../../tests/helpers"),testConfig=(0,helpers_1.resolveTestConfig)(index_1.LLMPurposes.Completion);(0,globals_1.describe)("LLM Completion Service",(()=>{Object.values(testConfig).forEach((e=>{const{provider:s,availableModels:t,clientOptions:o,requireCredentials:l}=e;(0,globals_1.describe)(`${s} Provider`,(()=>{let e;(0,globals_1.beforeAll)((()=>{l(),e=index_1.LLMServiceFactory.getCompletionService(s,helpers_1.mockLogger,o)})),(0,globals_1.beforeEach)((()=>{globals_1.jest.clearAllMocks()})),(0,globals_1.describe)("Service Initialization",(()=>{(0,globals_1.it)("should create completion service instance",(()=>{(0,globals_1.expect)(e).toBeDefined(),(0,globals_1.expect)(e.provider).toBe(s)}))})),Object.values(t).forEach((s=>{const o=s.name;(0,globals_1.describe)(`Model: ${o}`,(()=>{const s=t[o];(0,globals_1.it)("should send a simple message and receive a response",(async()=>{const t=await e.sendMessage({model:s,message:{role:index_1.LLMRoles.User,content:{type:index_1.LLMMessageContentType.TEXT,text:'Hello, this is a test message for LLM completion. Respond with a single word - "OK".'}}});(0,globals_1.expect)((0,helpers_1.hasText)(t)).toBe(!0),(0,helpers_1.hasText)(t)&&(0,globals_1.expect)(t.text).toMatch(/OK/i)})),(0,globals_1.it)("should handle message with history",(async()=>{const t=await e.sendMessage({model:s,message:{role:index_1.LLMRoles.User,content:{type:index_1.LLMMessageContentType.TEXT,text:'Continue the conversation, respond with a single word - "SUCCESS".'}},history:[{role:index_1.LLMRoles.User,content:{type:index_1.LLMMessageContentType.TEXT,text:'Hello, this is a test message for LLM completion. Respond with a single word - "FAILURE".'}},{role:index_1.LLMRoles.Assistant,content:{type:index_1.LLMMessageContentType.TEXT,text:"FAILURE"}}]});(0,globals_1.expect)((0,helpers_1.hasText)(t)).toBe(!0),(0,helpers_1.hasText)(t)&&(0,globals_1.expect)(t.text).toMatch(/SUCCESS/i)})),(0,globals_1.it)("should handle custom instructions",(async()=>{const t=await e.sendMessage({model:s,message:{role:index_1.LLMRoles.User,content:{type:index_1.LLMMessageContentType.TEXT,text:"My name is John"}},instructions:"You are an assistant that always responds with a greeting. Always include user's name in your response, like this: \"Hi, {{name}}!\". Important: replace {{name}} with the user's name."});(0,globals_1.expect)((0,helpers_1.hasText)(t)).toBe(!0),(0,helpers_1.hasText)(t)&&(0,globals_1.expect)(t.text).toMatch(/John/i)})),(0,globals_1.it)("should support image URLs in messages",(async()=>{const t=await e.sendMessage({model:s,instructions:"Analyze the image and describe its content. If it contains text, include it in your response.",message:{role:index_1.LLMRoles.User,content:{type:index_1.LLMMessageContentType.IMAGE_URL,image_url:{url:"https://dev-media.mate.academy/llm-gateway-test-image.png"}}}});(0,globals_1.expect)((0,helpers_1.hasText)(t)).toBe(!0),(0,helpers_1.hasText)(t)&&(0,globals_1.expect)(t.text).toMatch(/learn/i)}))}))}))}))}))}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LLMCompletion.service.integration.test.js","sourceRoot":"","sources":["../../../src/tests/integration/LLMCompletion.service.integration.test.ts"],"names":[],"mappings":";;AAAA,2CAOuB;AACvB,mCAMiB;AACjB,6CAIyB;AAEzB,MAAM,UAAU,GAAG,IAAA,2BAAiB,EAAC,mBAAW,CAAC,UAAU,CAAC,CAAC;AAE7D,IAAA,kBAAQ,EAAC,wBAAwB,EAAE,GAAG,EAAE;IACtC,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QACzC,MAAM,EACJ,QAAQ,EACR,eAAe,EACf,aAAa,EACb,kBAAkB,GACnB,GAAG,IAAI,CAAC;QAGT,IAAA,kBAAQ,EAAC,GAAG,QAAQ,WAAW,EAAE,GAAG,EAAE;YACpC,IAAI,OAA8C,CAAC;YAEnD,IAAA,mBAAS,EAAC,GAAG,EAAE;gBACb,kBAAkB,EAAE,CAAC;gBAErB,OAAO,GAAG,yBAAiB,CAAC,oBAAoB,CAC9C,QAAQ,EACR,oBAAU,EACV,aAAa,CACd,CA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LAAyL;yBACxM,CAAC,CAAC;wBAEH,IAAA,gBAAM,EAAC,IAAA,iBAAO,EAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;wBAEnC,IAAI,IAAA,iBAAO,EAAC,MAAM,CAAC,EAAE,CAAC;4BACpB,IAAA,gBAAM,EAAC,MAAM,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;wBACvC,CAAC;oBACH,CAAC,CAAC,CAAC;oBAEH,IAAA,YAAE,EAAC,uCAAuC,EAAE,KAAK,IAAI,EAAE;wBACrD,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,WAAW,CAAC;4BACvC,KAAK;4BACL,YAAY,EAAE,+FAA+F;4BAC7G,OAAO,EAAE;gCACP,IAAI,EAAE,gBAAQ,CAAC,IAAI;gCACnB,OAAO,EAAE;oCACP,IAAI,EAAE,6BAAqB,CAAC,SAAS;oCACrC,SAAS,EAAE;wCACT,GAAG,EAAE,2DAA2D;qCACjE;iCACF;6BACF;yBACF,CAAC,CAAC;wBAEH,IAAA,gBAAM,EAAC,IAAA,iBAAO,EAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;wBAEnC,IAAI,IAAA,iBAAO,EAAC,MAAM,CAAC,EAAE,CAAC;4BACpB,IAAA,gBAAM,EAAC,MAAM,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;wBACxC,CAAC;oBACH,CAAC,CAAC,CAAC;gBACL,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const globals_1=require("@jest/globals"),path_1=require("path"),index_1=require("../../index"),helpers_1=require("../../tests/helpers"),testConfig=(0,helpers_1.resolveTestConfig)(index_1.LLMPurposes.SpeechToText);(0,globals_1.describe)("LLM Speech To Text Service",(()=>{Object.values(testConfig).forEach((e=>{const{provider:t,availableModels:o,clientOptions:l,requireCredentials:s}=e;(0,globals_1.describe)(`${t} Provider`,(()=>{let e;(0,globals_1.beforeAll)((()=>{s(),e=index_1.LLMServiceFactory.getSpeechToTextService(t,helpers_1.mockLogger,l)})),(0,globals_1.beforeEach)((()=>{globals_1.jest.clearAllMocks()})),(0,globals_1.describe)("Service Initialization",(()=>{(0,globals_1.it)("should create speech-to-text service instance",(()=>{(0,globals_1.expect)(e).toBeDefined(),(0,globals_1.expect)(e.provider).toBe(t)}))})),Object.values(o).forEach((t=>{const l=t.name;(0,globals_1.describe)(`Model: ${l}`,(()=>{const t=o[l];(0,globals_1.it)('should transcribe audio file and return text containing "learn to code"',(async()=>{const o=(0,path_1.join)(__dirname,"..","stt.mp3"),l=await e.transcribe({pathToAudio:o,model:t});(0,globals_1.expect)((0,helpers_1.hasText)(l)).toBe(!0),(0,helpers_1.hasText)(l)&&(0,globals_1.expect)(l.text).toMatch(/learn.*to.*code/i)})),(0,globals_1.it)("should handle invalid audio file path",(async()=>{const o=(0,path_1.join)(__dirname,"..","nonexistent.mp3"),l=await e.transcribe({pathToAudio:o,model:t});(0,globals_1.expect)((0,helpers_1.hasError)(l)).toBe(!0)}))}))}))}))}))}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LLMSpeechToText.service.integration.test.js","sourceRoot":"","sources":["../../../src/tests/integration/LLMSpeechToText.service.integration.test.ts"],"names":[],"mappings":";;AAAA,2CAOuB;AACvB,+BAA4B;AAC5B,mCAIiB;AACjB,6CAKyB;AAEzB,MAAM,UAAU,GAAG,IAAA,2BAAiB,EAAC,mBAAW,CAAC,YAAY,CAAC,CAAC;AAE/D,IAAA,kBAAQ,EAAC,4BAA4B,EAAE,GAAG,EAAE;IAC1C,MAAM,CAAC,MAAM,CAA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AAG,MAAM,OAAO,CAAC,UAAU,CAAC;4BACtC,WAAW,EAAE,aAAa;4BAC1B,KAAK;yBACN,CAAC,CAAC;wBAEH,IAAA,gBAAM,EAAC,IAAA,iBAAO,EAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;wBAEnC,IAAI,IAAA,iBAAO,EAAC,MAAM,CAAC,EAAE,CAAC;4BACpB,IAAA,gBAAM,EAAC,MAAM,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC;wBAClD,CAAC;oBACH,CAAC,CAAC,CAAC;oBAEH,IAAA,YAAE,EAAC,uCAAuC,EAAE,KAAK,IAAI,EAAE;wBACrD,MAAM,WAAW,GAAG,IAAA,WAAI,EAAC,SAAS,EAAE,IAAI,EAAE,iBAAiB,CAAC,CAAC;wBAE7D,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,UAAU,CAAC;4BACtC,WAAW,EAAE,WAAW;4BACxB,KAAK;yBACN,CAAC,CAAC;wBAEH,IAAA,gBAAM,EAAC,IAAA,kBAAQ,EAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;oBACtC,CAAC,CAAC,CAAC;gBACL,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const globals_1=require("@jest/globals"),index_1=require("../../index"),helpers_1=require("../../tests/helpers"),testConfig=(0,helpers_1.resolveTestConfig)(index_1.LLMPurposes.TextToSpeech);(0,globals_1.describe)("LLM Text To Speech Service",(()=>{Object.values(testConfig).forEach((e=>{const{provider:t,availableModels:o,clientOptions:s,requireCredentials:l}=e;(0,globals_1.describe)(`${t} Provider`,(()=>{let e;(0,globals_1.beforeAll)((()=>{l(),e=index_1.LLMServiceFactory.getTextToSpeechService(t,helpers_1.mockLogger,s)})),(0,globals_1.beforeEach)((()=>{globals_1.jest.clearAllMocks()})),(0,globals_1.describe)("Service Initialization",(()=>{(0,globals_1.it)("should create text-to-speech service instance",(()=>{(0,globals_1.expect)(e).toBeDefined(),(0,globals_1.expect)(e.provider).toBe(t)}))})),Object.values(o).forEach((t=>{const s=t.name;(0,globals_1.describe)(`Model: ${s}`,(()=>{const t=o[s];(0,globals_1.it)("should convert text to speech and return audio file path",(async()=>{const o=await e.createSpeech({text:"Hello, this is a test of text to speech functionality.",model:t});(0,globals_1.expect)((0,helpers_1.hasError)(o)).toBe(!1),(0,helpers_1.hasError)(o)||(0,globals_1.expect)(o.audio).toBeDefined()}))}))}))}))}))}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LLMTextToSpeech.service.integration.test.js","sourceRoot":"","sources":["../../../src/tests/integration/LLMTextToSpeech.service.integration.test.ts"],"names":[],"mappings":";;AAAA,2CAOuB;AACvB,mCAIiB;AACjB,6CAIyB;AAEzB,MAAM,UAAU,GAAG,IAAA,2BAAiB,EAAC,mBAAW,CAAC,YAAY,CAAC,CAAC;AAE/D,IAAA,kBAAQ,EAAC,4BAA4B,EAAE,GAAG,EAAE;IAC1C,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QACzC,MAAM,EACJ,QAAQ,EACR,eAAe,EACf,aAAa,EACb,kBAAkB,GACnB,GAAG,IAAI,CAAC;QAET,IAAA,kBAAQ,EAAC,GAAG,QAAQ,WAAW,EAAE,GAAG,EAAE;YACpC,IAAI,OAAgD,CAAC;YAErD,IAAA,mBAAS,EAAC,GAAG,EAAE;gBACb,kBAAkB,EAAE,CAAC;gBAErB,OAAO,GAAG,yBAAiB,CAAC,sBAAsB,CAChD,QAAQ,EACR,oBAAU,EACV,aAAa,CACd,CAAC;YACJ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AAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0});const globals_1=require("@jest/globals"),dotenv_1=require("dotenv"),path_1=__importDefault(require("path")),envPath=path_1.default.resolve(__dirname,"../../../..",".env.file");(0,dotenv_1.config)({path:envPath}),globals_1.jest.setTimeout(45e3);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup.js","sourceRoot":"","sources":["../../src/tests/setup.ts"],"names":[],"mappings":";;;;;AAAA,2CAAqC;AACrC,mCAAgC;AAChC,gDAAwB;AAExB,gEAAgE;AAChE,MAAM,OAAO,GAAG,cAAI,CAAC,OAAO,CAAC,SAAS,EAAE,aAAa,EAAE,WAAW,CAAC,CAAC;AACpE,IAAA,eAAM,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;AAE1B,4CAA4C;AAC5C,cAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mate-academy/llm-gateway",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.1-canary.1",
|
|
4
4
|
"description": "A gateway package for LLM services.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -9,7 +9,10 @@
|
|
|
9
9
|
"minify": "find dist -type f -name \"*.js\" -exec terser {} -c -m -o {} \\;",
|
|
10
10
|
"lint": "eslint .",
|
|
11
11
|
"lint:fix": "eslint . --fix",
|
|
12
|
-
"
|
|
12
|
+
"test": "ENABLE_LOGGING=true jest",
|
|
13
|
+
"test:silent": "jest",
|
|
14
|
+
"prepublishOnly": "npm run lint:fix && npm run type-check && npm run build",
|
|
15
|
+
"type-check": "tsc --noEmit",
|
|
13
16
|
"postpublish": "npm run clean",
|
|
14
17
|
"clean": "rm -rf ./dist",
|
|
15
18
|
"patch": "npm version patch && npm publish",
|
|
@@ -44,19 +47,25 @@
|
|
|
44
47
|
},
|
|
45
48
|
"devDependencies": {
|
|
46
49
|
"@mate-academy/ts-config": "^1.0.5",
|
|
47
|
-
"@
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
+
"@types/jest": "^29.5.14",
|
|
51
|
+
"@types/mime-types": "^3.0.1",
|
|
52
|
+
"@typescript-eslint/eslint-plugin": "^8.33.1",
|
|
53
|
+
"dotenv": "^16.5.0",
|
|
54
|
+
"eslint": "^9.28.0",
|
|
55
|
+
"jest": "^29.7.0",
|
|
56
|
+
"terser": "^5.41.0",
|
|
57
|
+
"ts-jest": "^29.3.4",
|
|
50
58
|
"tsc-alias": "^1.8.16",
|
|
51
59
|
"typescript": "^5.8.3",
|
|
52
|
-
"typescript-eslint": "^8.
|
|
60
|
+
"typescript-eslint": "^8.33.1"
|
|
53
61
|
},
|
|
54
62
|
"dependencies": {
|
|
55
|
-
"@google/genai": "^
|
|
63
|
+
"@google/genai": "^1.4.0",
|
|
56
64
|
"@mate-academy/core": "^1.10.4",
|
|
57
65
|
"axios": "^1.9.0",
|
|
58
66
|
"js-tiktoken": "^1.0.20",
|
|
59
|
-
"
|
|
67
|
+
"mime-types": "^3.0.1",
|
|
68
|
+
"openai": "^5.1.1",
|
|
60
69
|
"uuid": "^11.1.0"
|
|
61
70
|
}
|
|
62
71
|
}
|