@mate-academy/llm-gateway 1.0.4 → 1.1.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.
Files changed (54) hide show
  1. package/dist/LLMService.constants.d.ts +1 -0
  2. package/dist/LLMService.constants.js +1 -16
  3. package/dist/LLMService.constants.js.map +1 -1
  4. package/dist/LLMService.factory.js +1 -71
  5. package/dist/LLMService.typedefs.d.ts +47 -6
  6. package/dist/LLMService.typedefs.js +1 -36
  7. package/dist/LLMService.typedefs.js.map +1 -1
  8. package/dist/functional.utils.js +1 -9
  9. package/dist/index.d.ts +0 -1
  10. package/dist/index.js +1 -23
  11. package/dist/index.js.map +1 -1
  12. package/dist/providers/GoogleGenerativeAI/GoogleGenerativeAI.constants.js +1 -99
  13. package/dist/providers/GoogleGenerativeAI/GoogleGenerativeAI.constants.js.map +1 -1
  14. package/dist/providers/GoogleGenerativeAI/GoogleGenerativeAI.entity.d.ts +10 -4
  15. package/dist/providers/GoogleGenerativeAI/GoogleGenerativeAI.entity.js +1 -42
  16. package/dist/providers/GoogleGenerativeAI/GoogleGenerativeAI.entity.js.map +1 -1
  17. package/dist/providers/GoogleGenerativeAI/GoogleGenerativeAI.typedefs.js +1 -19
  18. package/dist/providers/GoogleGenerativeAI/GoogleGenerativeAIService.factory.js +1 -17
  19. package/dist/providers/GoogleGenerativeAI/GoogleGenerativeAIService.factory.js.map +1 -1
  20. package/dist/providers/GoogleGenerativeAI/index.js +1 -22
  21. package/dist/providers/GoogleGenerativeAI/services/GoogleGenerativeAIAssistance.service.js +1 -211
  22. package/dist/providers/GoogleGenerativeAI/services/GoogleGenerativeAIAssistance.service.js.map +1 -1
  23. package/dist/providers/GoogleGenerativeAI/services/GoogleGenerativeAICompletion.service.js +1 -50
  24. package/dist/providers/GoogleGenerativeAI/services/GoogleGenerativeAICompletion.service.js.map +1 -1
  25. package/dist/providers/GoogleGenerativeAI/services/index.js +1 -19
  26. package/dist/providers/OpenAI/OpenAI.constants.js +1 -44
  27. package/dist/providers/OpenAI/OpenAI.constants.js.map +1 -1
  28. package/dist/providers/OpenAI/OpenAI.entity.d.ts +5 -1
  29. package/dist/providers/OpenAI/OpenAI.entity.js +1 -15
  30. package/dist/providers/OpenAI/OpenAI.entity.js.map +1 -1
  31. package/dist/providers/OpenAI/OpenAI.typedefs.d.ts +1 -0
  32. package/dist/providers/OpenAI/OpenAI.typedefs.js +1 -14
  33. package/dist/providers/OpenAI/OpenAI.typedefs.js.map +1 -1
  34. package/dist/providers/OpenAI/OpenAIService.factory.js +1 -17
  35. package/dist/providers/OpenAI/OpenAIService.factory.js.map +1 -1
  36. package/dist/providers/OpenAI/index.js +1 -22
  37. package/dist/providers/OpenAI/services/OpenAIAssistance.service.js +1 -200
  38. package/dist/providers/OpenAI/services/OpenAIAssistance.service.js.map +1 -1
  39. package/dist/providers/OpenAI/services/OpenAICompletion.service.js +1 -52
  40. package/dist/providers/OpenAI/services/OpenAICompletion.service.js.map +1 -1
  41. package/dist/providers/OpenAI/services/index.js +1 -19
  42. package/dist/providers/index.js +1 -19
  43. package/dist/services/LLMAssistanceService.abstract.js +1 -12
  44. package/dist/services/LLMAssistanceService.abstract.js.map +1 -1
  45. package/dist/services/LLMBaseService.abstract.js +1 -27
  46. package/dist/services/LLMBaseService.abstract.js.map +1 -1
  47. package/dist/services/LLMCompletionService.abstract.js +1 -12
  48. package/dist/services/LLMCompletionService.abstract.js.map +1 -1
  49. package/dist/services/LLMServicePurposeFactory.abstract.js +1 -7
  50. package/dist/services/index.js +1 -21
  51. package/package.json +11 -7
  52. package/dist/LLMService.entity.d.ts +0 -13
  53. package/dist/LLMService.entity.js +0 -38
  54. package/dist/LLMService.entity.js.map +0 -1
@@ -6,3 +6,4 @@ export declare const LLM_SERVICE_FACTORIES: {
6
6
  export declare const LLM_SERVICE_MODELS: {
7
7
  [provider in LLMProviders]: LLMProviderModelsByPurpose<LLMPurposes, provider>;
8
8
  };
9
+ export declare const APPROXIMATE_TOKENS_COUNT_IN_IMAGE = 1000;
@@ -1,16 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LLM_SERVICE_MODELS = exports.LLM_SERVICE_FACTORIES = void 0;
4
- const LLMService_typedefs_1 = require("./LLMService.typedefs");
5
- const providers_1 = require("./providers");
6
- const GoogleGenerativeAI_constants_1 = require("./providers/GoogleGenerativeAI/GoogleGenerativeAI.constants");
7
- const OpenAI_constants_1 = require("./providers/OpenAI/OpenAI.constants");
8
- exports.LLM_SERVICE_FACTORIES = {
9
- [LLMService_typedefs_1.LLMProviders.OpenAI]: new providers_1.OpenAIServiceFactory(),
10
- [LLMService_typedefs_1.LLMProviders.GoogleGenerativeAI]: new providers_1.GoogleGenerativeAIServiceFactory(),
11
- };
12
- exports.LLM_SERVICE_MODELS = {
13
- [LLMService_typedefs_1.LLMProviders.OpenAI]: OpenAI_constants_1.OPEN_AI_MODELS,
14
- [LLMService_typedefs_1.LLMProviders.GoogleGenerativeAI]: GoogleGenerativeAI_constants_1.GOOGLE_AI_MODELS,
15
- };
16
- //# sourceMappingURL=LLMService.constants.js.map
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.APPROXIMATE_TOKENS_COUNT_IN_IMAGE=exports.LLM_SERVICE_MODELS=exports.LLM_SERVICE_FACTORIES=void 0;const LLMService_typedefs_1=require("./LLMService.typedefs"),providers_1=require("./providers"),GoogleGenerativeAI_constants_1=require("./providers/GoogleGenerativeAI/GoogleGenerativeAI.constants"),OpenAI_constants_1=require("./providers/OpenAI/OpenAI.constants");exports.LLM_SERVICE_FACTORIES={[LLMService_typedefs_1.LLMProviders.OpenAI]:new providers_1.OpenAIServiceFactory,[LLMService_typedefs_1.LLMProviders.GoogleGenerativeAI]:new providers_1.GoogleGenerativeAIServiceFactory},exports.LLM_SERVICE_MODELS={[LLMService_typedefs_1.LLMProviders.OpenAI]:OpenAI_constants_1.OPEN_AI_MODELS,[LLMService_typedefs_1.LLMProviders.GoogleGenerativeAI]:GoogleGenerativeAI_constants_1.GOOGLE_AI_MODELS},exports.APPROXIMATE_TOKENS_COUNT_IN_IMAGE=1e3;
@@ -1 +1 @@
1
- {"version":3,"file":"LLMService.constants.js","sourceRoot":"","sources":["../src/LLMService.constants.ts"],"names":[],"mappings":";;;AAAA,+DAI+B;AAC/B,2CAAqF;AACrF,8GAA+F;AAC/F,0EAAqE;AAGxD,QAAA,qBAAqB,GAE9B;IACF,CAAC,kCAAY,CAAC,MAAM,CAAC,EAAE,IAAI,gCAAoB,EAAE;IACjD,CAAC,kCAAY,CAAC,kBAAkB,CAAC,EAAE,IAAI,4CAAgC,EAAE;CAC1E,CAAC;AAEW,QAAA,kBAAkB,GAE3B;IACF,CAAC,kCAAY,CAAC,MAAM,CAAC,EAAE,iCAAc;IACrC,CAAC,kCAAY,CAAC,kBAAkB,CAAC,EAAE,+CAAgB;CACpD,CAAC"}
1
+ {"version":3,"file":"LLMService.constants.js","sourceRoot":"","sources":["../src/LLMService.constants.ts"],"names":[],"mappings":";;;AAAA,+DAI+B;AAC/B,2CAAqF;AACrF,8GAA+F;AAC/F,0EAAqE;AAGxD,QAAA,qBAAqB,GAE9B;IACF,CAAC,kCAAY,CAAC,MAAM,CAAC,EAAE,IAAI,gCAAoB,EAAE;IACjD,CAAC,kCAAY,CAAC,kBAAkB,CAAC,EAAE,IAAI,4CAAgC,EAAE;CAC1E,CAAC;AAEW,QAAA,kBAAkB,GAE3B;IACF,CAAC,kCAAY,CAAC,MAAM,CAAC,EAAE,iCAAc;IACrC,CAAC,kCAAY,CAAC,kBAAkB,CAAC,EAAE,+CAAgB;CACpD,CAAC;AAEW,QAAA,iCAAiC,GAAG,IAAI,CAAC"}
@@ -1,71 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LLMServiceFactory = void 0;
4
- const LLMService_typedefs_1 = require("./LLMService.typedefs");
5
- const LLMService_constants_1 = require("./LLMService.constants");
6
- class LLMServiceFactory {
7
- /**
8
- * Gets a service for the specified LLM purpose and provider
9
- *
10
- * @private
11
- * @static
12
- * @template Purpose - The purpose of the LLM service (Completion or Assistance)
13
- * @template Provider - The LLM provider (OpenAI, GoogleGenerativeAI)
14
- * @param {Purpose} purpose - The purpose of the service
15
- * @param {Provider} provider - The LLM provider
16
- * @param {Logger} logger - Logger instance
17
- * @param {LLMInstanceOptions[Provider]} options - Provider-specific options
18
- * @returns {LLMServiceByPurpose<Provider>[Purpose]} The LLM service instance
19
- * @throws {Error} If the provider is not supported
20
- */
21
- static getService(purpose, provider, logger, options) {
22
- switch (provider) {
23
- case LLMService_typedefs_1.LLMProviders.OpenAI:
24
- case LLMService_typedefs_1.LLMProviders.GoogleGenerativeAI:
25
- return LLMService_constants_1.LLM_SERVICE_FACTORIES[provider]
26
- .createService(purpose, logger, options);
27
- default:
28
- throw new Error(`Provider [${provider}] is not supported`);
29
- }
30
- }
31
- /**
32
- * Gets a completion service for the specified LLM provider
33
- *
34
- * @static
35
- * @template Provider - The LLM provider type
36
- * @param {Provider} provider - The LLM provider (OpenAI, GoogleGenerativeAI)
37
- * @param {Logger} logger - Logger instance
38
- * @param {LLMInstanceOptions[Provider]} options - Provider-specific options
39
- * @returns {LLMServiceByPurpose<Provider>[LLMPurposes.Completion]} A completion service instance
40
- */
41
- static getCompletionService(provider, logger, options) {
42
- return this.getService(LLMService_typedefs_1.LLMPurposes.Completion, provider, logger, options);
43
- }
44
- /**
45
- * Gets an assistance service for the specified LLM provider
46
- *
47
- * @static
48
- * @template Provider - The LLM provider type
49
- * @param {Provider} provider - The LLM provider (OpenAI, GoogleGenerativeAI)
50
- * @param {Logger} logger - Logger instance
51
- * @param {LLMInstanceOptions[Provider]} options - Provider-specific options
52
- * @returns {LLMServiceByPurpose<Provider>[LLMPurposes.Assistance]} An assistance service instance
53
- */
54
- static getAssistanceService(provider, logger, options) {
55
- return this.getService(LLMService_typedefs_1.LLMPurposes.Assistance, provider, logger, options);
56
- }
57
- /**
58
- * Resolves the options for the specified provider from an options map
59
- *
60
- * @static
61
- * @template Provider - The LLM provider type
62
- * @param {Provider} provider - The LLM provider to get options for
63
- * @param {Record<Provider, LLMInstanceOptions[Provider]>} options - Map of provider options
64
- * @returns {LLMInstanceOptions[Provider]} The options for the specified provider
65
- */
66
- static resolveProviderOptions(provider, options) {
67
- return options[provider];
68
- }
69
- }
70
- exports.LLMServiceFactory = LLMServiceFactory;
71
- //# sourceMappingURL=LLMService.factory.js.map
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,t,s){switch(r){case LLMService_typedefs_1.LLMProviders.OpenAI:case LLMService_typedefs_1.LLMProviders.GoogleGenerativeAI:return LLMService_constants_1.LLM_SERVICE_FACTORIES[r].createService(e,t,s);default:throw new Error(`Provider [${r}] is not supported`)}}static getCompletionService(e,r,t){return this.getService(LLMService_typedefs_1.LLMPurposes.Completion,e,r,t)}static getAssistanceService(e,r,t){return this.getService(LLMService_typedefs_1.LLMPurposes.Assistance,e,r,t)}static resolveProviderOptions(e,r){return r[e]}}exports.LLMServiceFactory=LLMServiceFactory;
@@ -100,12 +100,40 @@ export declare enum LLMRoles {
100
100
  User = "user",
101
101
  Assistant = "assistant"
102
102
  }
103
+ /**
104
+ * Possible content types for messages in an LLM conversation.
105
+ */
106
+ export declare enum LLMMessageContentType {
107
+ TEXT = "text",
108
+ IMAGE_URL = "image_url"
109
+ }
110
+ /**
111
+ * Represents a text message in an LLM conversation.
112
+ */
113
+ export interface LLMMessageTextContent {
114
+ type: LLMMessageContentType.TEXT;
115
+ text: string;
116
+ }
117
+ /**
118
+ * Represents an image message in an LLM conversation.
119
+ */
120
+ export interface LLMMessageImageUrlContent {
121
+ type: LLMMessageContentType.IMAGE_URL;
122
+ image_url: {
123
+ url: string;
124
+ };
125
+ detail?: 'auto' | 'low' | 'high';
126
+ }
127
+ /**
128
+ * Union type for all possible message content types in an LLM conversation.
129
+ */
130
+ export type LLMMessageContent = LLMMessageTextContent | LLMMessageImageUrlContent;
103
131
  /**
104
132
  * Represents a message in an LLM conversation.
105
133
  */
106
- export interface LLMMessage {
134
+ export interface LLMCompletionMessage {
107
135
  role: LLMRoles;
108
- content: string;
136
+ content: LLMMessageContent;
109
137
  }
110
138
  /**
111
139
  * Represents an error that occurred during an LLM request.
@@ -129,9 +157,9 @@ export type LLMCompletionResult = LLMRequestResult<{
129
157
  * @template Provider - The LLM provider type
130
158
  */
131
159
  export interface LLMSendMessageOptions<Provider extends LLMProviders> {
132
- message: LLMMessage;
160
+ message: LLMCompletionMessage;
133
161
  model: LLMModel<Provider>;
134
- history?: LLMMessage[];
162
+ history?: LLMCompletionMessage[];
135
163
  instructions?: string;
136
164
  }
137
165
  /**
@@ -221,7 +249,7 @@ export type LLMCreateChatResult = LLMRequestResult<LLMCreatedChat>;
221
249
  /**
222
250
  * Extends LLMMessage with attachment and instruction capabilities for assistance services.
223
251
  */
224
- export interface LLMAssistanceMessage extends LLMMessage {
252
+ export interface LLMAssistanceMessage extends LLMCompletionMessage {
225
253
  attachment?: LLMUploadFileResult;
226
254
  instructions?: string;
227
255
  }
@@ -248,4 +276,17 @@ export type LLMAssistanceResult = LLMRequestResult<{
248
276
  * @param model - The LLM model to use for token counting
249
277
  * @returns Promise resolving to the number of tokens
250
278
  */
251
- export type LLMCountTokensFunction<Provider extends LLMProviders> = (messages: string[], model: LLMModel<Provider>) => Promise<number>;
279
+ export type LLMCountTokensFunction<Provider extends LLMProviders, ContentType> = (messagesContents: ContentType, model: LLMModel<Provider>) => Promise<number>;
280
+ /**
281
+ * Options for combining messages with a limit on the number of tokens.
282
+ * @template Provider - The LLM provider type
283
+ * @template F - Function type for counting tokens
284
+ */
285
+ export interface CombineMessagesOptions<Provider extends LLMProviders, F extends LLMCountTokensFunction<Provider, any[]>> {
286
+ modelContext?: LLMCompletionMessage[];
287
+ history?: LLMCompletionMessage[];
288
+ message: LLMCompletionMessage;
289
+ model: LLMModel<Provider>;
290
+ instance: LLMInstances[Provider];
291
+ countTokensFn: F;
292
+ }
@@ -1,36 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LLMUploadFileMimeTypes = exports.LLMRoles = exports.LLMPurposes = exports.LLMProviders = void 0;
4
- /**
5
- * Enum of supported LLM providers.
6
- */
7
- var LLMProviders;
8
- (function (LLMProviders) {
9
- LLMProviders["OpenAI"] = "OpenAI";
10
- LLMProviders["GoogleGenerativeAI"] = "GoogleGenerativeAI";
11
- })(LLMProviders || (exports.LLMProviders = LLMProviders = {}));
12
- /**
13
- * Supported service purposes/types that the LLM gateway provides.
14
- */
15
- var LLMPurposes;
16
- (function (LLMPurposes) {
17
- LLMPurposes["Completion"] = "completion";
18
- LLMPurposes["Assistance"] = "assistance";
19
- })(LLMPurposes || (exports.LLMPurposes = LLMPurposes = {}));
20
- /**
21
- * Roles that can be assigned to messages in an LLM conversation.
22
- */
23
- var LLMRoles;
24
- (function (LLMRoles) {
25
- LLMRoles["User"] = "user";
26
- LLMRoles["Assistant"] = "assistant";
27
- })(LLMRoles || (exports.LLMRoles = LLMRoles = {}));
28
- /**
29
- * Supported MIME types for files that can be uploaded to LLM services.
30
- */
31
- var LLMUploadFileMimeTypes;
32
- (function (LLMUploadFileMimeTypes) {
33
- LLMUploadFileMimeTypes["PNG"] = "image/png";
34
- LLMUploadFileMimeTypes["PLAIN_TEXT"] = "text/plain";
35
- })(LLMUploadFileMimeTypes || (exports.LLMUploadFileMimeTypes = LLMUploadFileMimeTypes = {}));
36
- //# sourceMappingURL=LLMService.typedefs.js.map
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.PNG="image/png",e.PLAIN_TEXT="text/plain"}(LLMUploadFileMimeTypes||(exports.LLMUploadFileMimeTypes=LLMUploadFileMimeTypes={}));
@@ -1 +1 @@
1
- {"version":3,"file":"LLMService.typedefs.js","sourceRoot":"","sources":["../src/LLMService.typedefs.ts"],"names":[],"mappings":";;;AAQA;;GAEG;AACH,IAAY,YAGX;AAHD,WAAY,YAAY;IACtB,iCAAiB,CAAA;IACjB,yDAAyC,CAAA;AAC3C,CAAC,EAHW,YAAY,4BAAZ,YAAY,QAGvB;AAkBD;;GAEG;AACH,IAAY,WAGX;AAHD,WAAY,WAAW;IACrB,wCAAyB,CAAA;IACzB,wCAAyB,CAAA;AAC3B,CAAC,EAHW,WAAW,2BAAX,WAAW,QAGtB;AAqFD;;GAEG;AACH,IAAY,QAGX;AAHD,WAAY,QAAQ;IAClB,yBAAa,CAAA;IACb,mCAAuB,CAAA;AACzB,CAAC,EAHW,QAAQ,wBAAR,QAAQ,QAGnB;AAqCD;;GAEG;AACH,IAAY,sBAGX;AAHD,WAAY,sBAAsB;IAChC,2CAAiB,CAAA;IACjB,mDAAyB,CAAA;AAC3B,CAAC,EAHW,sBAAsB,sCAAtB,sBAAsB,QAGjC"}
1
+ {"version":3,"file":"LLMService.typedefs.js","sourceRoot":"","sources":["../src/LLMService.typedefs.ts"],"names":[],"mappings":";;;AAQA;;GAEG;AACH,IAAY,YAGX;AAHD,WAAY,YAAY;IACtB,iCAAiB,CAAA;IACjB,yDAAyC,CAAA;AAC3C,CAAC,EAHW,YAAY,4BAAZ,YAAY,QAGvB;AAkBD;;GAEG;AACH,IAAY,WAGX;AAHD,WAAY,WAAW;IACrB,wCAAyB,CAAA;IACzB,wCAAyB,CAAA;AAC3B,CAAC,EAHW,WAAW,2BAAX,WAAW,QAGtB;AAqFD;;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;AA+DD;;GAEG;AACH,IAAY,sBAGX;AAHD,WAAY,sBAAsB;IAChC,2CAAiB,CAAA;IACjB,mDAAyB,CAAA;AAC3B,CAAC,EAHW,sBAAsB,sCAAtB,sBAAsB,QAGjC"}
@@ -1,9 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.pick = void 0;
4
- const pick = (obj, keys) => (keys.reduce((acc, key) => {
5
- Object.assign(acc, { [key]: obj[key] });
6
- return acc;
7
- }, {}));
8
- exports.pick = pick;
9
- //# sourceMappingURL=functional.utils.js.map
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.pick=void 0;const pick=(e,c)=>c.reduce(((c,s)=>(Object.assign(c,{[s]:e[s]}),c)),{});exports.pick=pick;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  export * from './LLMService.constants';
2
- export * from './LLMService.entity';
3
2
  export * from './LLMService.factory';
4
3
  export * from './LLMService.typedefs';
5
4
  export * from './providers';
package/dist/index.js CHANGED
@@ -1,23 +1 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./LLMService.constants"), exports);
18
- __exportStar(require("./LLMService.entity"), exports);
19
- __exportStar(require("./LLMService.factory"), exports);
20
- __exportStar(require("./LLMService.typedefs"), exports);
21
- __exportStar(require("./providers"), exports);
22
- __exportStar(require("./services"), exports);
23
- //# sourceMappingURL=index.js.map
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("./LLMService.constants"),exports),__exportStar(require("./LLMService.factory"),exports),__exportStar(require("./LLMService.typedefs"),exports),__exportStar(require("./providers"),exports),__exportStar(require("./services"),exports);
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yDAAuC;AACvC,sDAAoC;AACpC,uDAAqC;AACrC,wDAAsC;AACtC,8CAA4B;AAC5B,6CAA2B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yDAAuC;AACvC,uDAAqC;AACrC,wDAAsC;AACtC,8CAA4B;AAC5B,6CAA2B"}
@@ -1,99 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GOOGLE_AI_SERVICE_BUILDERS = exports.GOOGLE_AI_MODELS = exports.MIN_CACHE_CONTENT_LENGTH = void 0;
4
- const LLMService_typedefs_1 = require("../../LLMService.typedefs");
5
- const GoogleGenerativeAI_typedefs_1 = require("./GoogleGenerativeAI.typedefs");
6
- const services_1 = require("../../providers/GoogleGenerativeAI/services");
7
- const functional_utils_1 = require("../../functional.utils");
8
- exports.MIN_CACHE_CONTENT_LENGTH = 32_768;
9
- const GOOGLE_AI_AVAILABLE_MODELS = {
10
- [GoogleGenerativeAI_typedefs_1.GoogleGenerativeAIModelNames.GEMINI_1_5_FLASH]: {
11
- name: GoogleGenerativeAI_typedefs_1.GoogleGenerativeAIModelNames.GEMINI_1_5_FLASH,
12
- limits: {
13
- maxInputTokens: 1_048_576,
14
- maxOutputTokens: 8_192,
15
- },
16
- config: {
17
- temperature: 0.2,
18
- },
19
- },
20
- [GoogleGenerativeAI_typedefs_1.GoogleGenerativeAIModelNames.GEMINI_1_5_FLASH_STABLE]: {
21
- name: GoogleGenerativeAI_typedefs_1.GoogleGenerativeAIModelNames.GEMINI_1_5_FLASH_STABLE,
22
- limits: {
23
- maxInputTokens: 1_048_576,
24
- maxOutputTokens: 8_192,
25
- },
26
- config: {
27
- temperature: 0.2,
28
- },
29
- },
30
- [GoogleGenerativeAI_typedefs_1.GoogleGenerativeAIModelNames.GEMINI_1_5_PRO]: {
31
- name: GoogleGenerativeAI_typedefs_1.GoogleGenerativeAIModelNames.GEMINI_1_5_PRO,
32
- limits: {
33
- maxInputTokens: 2_097_152,
34
- maxOutputTokens: 8_192,
35
- },
36
- config: {
37
- temperature: 0.2,
38
- },
39
- },
40
- [GoogleGenerativeAI_typedefs_1.GoogleGenerativeAIModelNames.GEMINI_1_5_PRO_STABLE]: {
41
- name: GoogleGenerativeAI_typedefs_1.GoogleGenerativeAIModelNames.GEMINI_1_5_PRO_STABLE,
42
- limits: {
43
- maxInputTokens: 2_097_152,
44
- maxOutputTokens: 8_192,
45
- },
46
- config: {
47
- temperature: 0.2,
48
- },
49
- },
50
- [GoogleGenerativeAI_typedefs_1.GoogleGenerativeAIModelNames.GEMINI_2_0_FLASH]: {
51
- name: GoogleGenerativeAI_typedefs_1.GoogleGenerativeAIModelNames.GEMINI_2_0_FLASH,
52
- limits: {
53
- maxInputTokens: 1_048_576,
54
- maxOutputTokens: 8_192,
55
- },
56
- config: {
57
- temperature: 0.2,
58
- },
59
- },
60
- [GoogleGenerativeAI_typedefs_1.GoogleGenerativeAIModelNames.GEMINI_2_0_FLASH_STABLE]: {
61
- name: GoogleGenerativeAI_typedefs_1.GoogleGenerativeAIModelNames.GEMINI_2_0_FLASH_STABLE,
62
- limits: {
63
- maxInputTokens: 1_048_576,
64
- maxOutputTokens: 8_192,
65
- },
66
- config: {
67
- temperature: 0.2,
68
- },
69
- },
70
- [GoogleGenerativeAI_typedefs_1.GoogleGenerativeAIModelNames.GEMINI_2_5_PRO_PREVIEW]: {
71
- name: GoogleGenerativeAI_typedefs_1.GoogleGenerativeAIModelNames.GEMINI_2_5_PRO_PREVIEW,
72
- limits: {
73
- maxInputTokens: 1_048_576,
74
- maxOutputTokens: 65_536,
75
- },
76
- config: {
77
- temperature: 0.2,
78
- },
79
- },
80
- };
81
- exports.GOOGLE_AI_MODELS = {
82
- [LLMService_typedefs_1.LLMPurposes.Completion]: (0, functional_utils_1.pick)(GOOGLE_AI_AVAILABLE_MODELS, [
83
- GoogleGenerativeAI_typedefs_1.GoogleGenerativeAIModelNames.GEMINI_1_5_FLASH,
84
- GoogleGenerativeAI_typedefs_1.GoogleGenerativeAIModelNames.GEMINI_1_5_PRO,
85
- GoogleGenerativeAI_typedefs_1.GoogleGenerativeAIModelNames.GEMINI_2_0_FLASH,
86
- GoogleGenerativeAI_typedefs_1.GoogleGenerativeAIModelNames.GEMINI_2_5_PRO_PREVIEW,
87
- ]),
88
- // Stable models are used for assistance as they support additional methods
89
- [LLMService_typedefs_1.LLMPurposes.Assistance]: (0, functional_utils_1.pick)(GOOGLE_AI_AVAILABLE_MODELS, [
90
- GoogleGenerativeAI_typedefs_1.GoogleGenerativeAIModelNames.GEMINI_1_5_FLASH_STABLE,
91
- GoogleGenerativeAI_typedefs_1.GoogleGenerativeAIModelNames.GEMINI_1_5_PRO_STABLE,
92
- GoogleGenerativeAI_typedefs_1.GoogleGenerativeAIModelNames.GEMINI_2_0_FLASH_STABLE,
93
- ]),
94
- };
95
- exports.GOOGLE_AI_SERVICE_BUILDERS = {
96
- [LLMService_typedefs_1.LLMPurposes.Completion]: (logger, options) => (new services_1.GoogleGenerativeAICompletionService(logger, options)),
97
- [LLMService_typedefs_1.LLMPurposes.Assistance]: (logger, options) => (new services_1.GoogleGenerativeAIAssistanceService(logger, options)),
98
- };
99
- //# sourceMappingURL=GoogleGenerativeAI.constants.js.map
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_FLASH_STABLE]:{name:GoogleGenerativeAI_typedefs_1.GoogleGenerativeAIModelNames.GEMINI_1_5_FLASH_STABLE,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}}};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_FLASH_STABLE,GoogleGenerativeAI_typedefs_1.GoogleGenerativeAIModelNames.GEMINI_1_5_PRO_STABLE,GoogleGenerativeAI_typedefs_1.GoogleGenerativeAIModelNames.GEMINI_2_0_FLASH_STABLE])},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,_)};
@@ -1 +1 @@
1
- {"version":3,"file":"GoogleGenerativeAI.constants.js","sourceRoot":"","sources":["../../../src/providers/GoogleGenerativeAI/GoogleGenerativeAI.constants.ts"],"names":[],"mappings":";;;AAAA,mEAMmC;AACnC,+EAA6E;AAC7E,0EAGqD;AACrD,6DAA8C;AAEjC,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,uBAAuB,CAAC,EAAE;QACtD,IAAI,EAAE,0DAA4B,CAAC,uBAAuB;QAC1D,MAAM,EAAE;YACN,cAAc,EAAE,SAAS;YACzB,eAAe,EAAE,KAAK;SACvB;QACD,MAAM,EAAE;YACN,WAAW,EAA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AC3C,0DAA4B,CAAC,gBAAgB;QAC7C,0DAA4B,CAAC,sBAAsB;KACpD,CACF;IACD,2EAA2E;IAC3E,CAAC,iCAAW,CAAC,UAAU,CAAC,EAAE,IAAA,uBAAI,EAC5B,0BAA0B,EAC1B;QACE,0DAA4B,CAAC,uBAAuB;QACpD,0DAA4B,CAAC,qBAAqB;QAClD,0DAA4B,CAAC,uBAAuB;KACrD,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;CACF,CAAC"}
1
+ {"version":3,"file":"GoogleGenerativeAI.constants.js","sourceRoot":"","sources":["../../../src/providers/GoogleGenerativeAI/GoogleGenerativeAI.constants.ts"],"names":[],"mappings":";;;AAAA,+DAM+B;AAC/B,+EAA6E;AAC7E,sEAGiD;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,uBAAuB,CAAC,EAAE;QACtD,IAAI,EAAE,0DAA4B,CAAC,uBAAuB;QAC1D,MAAM,EAAE;YACN,cAAc,EAAE,SAAS;YACzB,eAAe,EAAE,KAAK;SACvB;QACD,MAAM,EAAE;YACN,WAA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AAc;QAC3C,0DAA4B,CAAC,gBAAgB;QAC7C,0DAA4B,CAAC,sBAAsB;KACpD,CACF;IACD,2EAA2E;IAC3E,CAAC,iCAAW,CAAC,UAAU,CAAC,EAAE,IAAA,uBAAI,EAC5B,0BAA0B,EAC1B;QACE,0DAA4B,CAAC,uBAAuB;QACpD,0DAA4B,CAAC,qBAAqB;QAClD,0DAA4B,CAAC,uBAAuB;KACrD,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;CACF,CAAC"}
@@ -1,8 +1,14 @@
1
- import { type Part, type GoogleGenAI, type ContentListUnion, type GenerateContentParameters } from '@google/genai';
2
- import { type LLMMessage, type LLMModel, type LLMProviders, type LLMUploadedFile } from '../../LLMService.typedefs';
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';
3
3
  export declare class GoogleGenerativeAIEntity {
4
- static getContentParameters(model: LLMModel<LLMProviders.GoogleGenerativeAI>, messages: LLMMessage[], instructions?: string): GenerateContentParameters;
4
+ static getContentParameters(options: {
5
+ model: LLMModel<LLMProviders.GoogleGenerativeAI>;
6
+ messages: Content[];
7
+ instructions?: string;
8
+ }): GenerateContentParameters;
5
9
  static getFileDataParts(uploadedFiles: LLMUploadedFile[]): Pick<Part, 'fileData'>[];
6
10
  static getTextParts(messages: string[]): Pick<Part, 'text'>[];
7
- static getCountTokensFn(instance: GoogleGenAI): (contents: ContentListUnion, model: LLMModel<LLMProviders.GoogleGenerativeAI>) => Promise<number>;
11
+ static getContent(message: LLMCompletionMessage, instance: GoogleGenAI): Promise<Content>;
12
+ static getCountTokensFn(instance: GoogleGenAI): LLMCountTokensFunction<LLMProviders.GoogleGenerativeAI, ContentListUnion>;
13
+ static combineMessagesWithLimit({ modelContext, history, message, model, countTokensFn, instance, }: CombineMessagesOptions<LLMProviders.GoogleGenerativeAI, LLMCountTokensFunction<LLMProviders.GoogleGenerativeAI, ContentListUnion>>): Promise<Content[]>;
8
14
  }
@@ -1,42 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GoogleGenerativeAIEntity = void 0;
4
- class GoogleGenerativeAIEntity {
5
- static getContentParameters(model, messages, instructions) {
6
- return {
7
- model: model.name,
8
- contents: messages.map((message) => ({
9
- parts: [{
10
- text: message.content,
11
- }],
12
- role: message.role,
13
- })),
14
- config: {
15
- systemInstruction: instructions,
16
- temperature: model.config.temperature,
17
- },
18
- };
19
- }
20
- static getFileDataParts(uploadedFiles) {
21
- return uploadedFiles.map((file) => ({
22
- fileData: {
23
- fileUri: file.path,
24
- mimeType: file.mimeType,
25
- },
26
- }));
27
- }
28
- static getTextParts(messages) {
29
- return messages.map((message) => ({ text: message }));
30
- }
31
- static getCountTokensFn(instance) {
32
- return async (contents, model) => {
33
- const tokenCount = await instance.models.countTokens({
34
- model: model.name,
35
- contents,
36
- });
37
- return tokenCount.totalTokens ?? 0;
38
- };
39
- }
40
- }
41
- exports.GoogleGenerativeAIEntity = GoogleGenerativeAIEntity;
42
- //# sourceMappingURL=GoogleGenerativeAI.entity.js.map
1
+ "use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.GoogleGenerativeAIEntity=void 0;const axios_1=__importDefault(require("axios")),LLMService_typedefs_1=require("../../LLMService.typedefs");class GoogleGenerativeAIEntity{static getContentParameters(e){const{model:t,messages:n,instructions:s}=e;return{model:t.name,contents:n,config:{systemInstruction:s,temperature:t.config.temperature}}}static getFileDataParts(e){return e.map((e=>({fileData:{fileUri:e.path,mimeType:e.mimeType}})))}static getTextParts(e){return e.map((e=>({text:e})))}static async getContent(e,t){const n=e.role;if(e.content.type===LLMService_typedefs_1.LLMMessageContentType.TEXT)return{role:n,parts:[{text:e.content.text}]};if(e.content.type===LLMService_typedefs_1.LLMMessageContentType.IMAGE_URL){const s=await axios_1.default.head(e.content.image_url.url),a=s.headers["content-type"]?.split(";")[0]??LLMService_typedefs_1.LLMUploadFileMimeTypes.PNG,o=await axios_1.default.get(e.content.image_url.url,{responseType:"arraybuffer"}),i=new Uint8Array(o.data),r=new Blob([i],{type:a});return{role:n,parts:[{fileData:{fileUri:(await t.files.upload({file:r})).name,mimeType:a}}]}}return{}}static getCountTokensFn(e){return async(t,n)=>(await e.models.countTokens({model:n.name,contents:t})).totalTokens??0}static async combineMessagesWithLimit({modelContext:e=[],history:t=[],message:n,model:s,countTokensFn:a,instance:o}){const i=await Promise.all(e.map((e=>GoogleGenerativeAIEntity.getContent(e,o))));if(t[0]){const e=t[0];i.push(e)}const r=[{role:LLMService_typedefs_1.LLMRoles.User,content:n.content},...t.slice(1).reverse()];let l=await a(i,s)??0;for(const e of r){const t=l+(await a(e,s)??0);if(!(t<=s.limits.maxInputTokens))break;i.push(e),l=t}return i}}exports.GoogleGenerativeAIEntity=GoogleGenerativeAIEntity;
@@ -1 +1 @@
1
- {"version":3,"file":"GoogleGenerativeAI.entity.js","sourceRoot":"","sources":["../../../src/providers/GoogleGenerativeAI/GoogleGenerativeAI.entity.ts"],"names":[],"mappings":";;;AAaA,MAAa,wBAAwB;IACnC,MAAM,CAAC,oBAAoB,CACzB,KAAgD,EAChD,QAAsB,EACtB,YAAqB;QAErB,OAAO;YACL,KAAK,EAAE,KAAK,CAAC,IAAI;YACjB,QAAQ,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;gBACnC,KAAK,EAAE,CAAC;wBACN,IAAI,EAAE,OAAO,CAAC,OAAO;qBACtB,CAAC;gBACF,IAAI,EAAE,OAAO,CAAC,IAAI;aACnB,CAAC,CAAC;YACH,MAAM,EAAE;gBACN,iBAAiB,EAAE,YAAY;gBAC/B,WAAW,EAAE,KAAK,CAAC,MAAM,CAAC,WAAW;aACtC;SACF,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,gBAAgB,CACrB,aAAgC;QAEhC,OAAO,aAAa,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;YAClC,QAAQ,EAAE;gBACR,OAAO,EAAE,IAAI,CAAC,IAAI;gBAClB,QAAQ,EAAE,IAAI,CAAC,QAAQ;aACxB;SACF,CAAC,CAAC,CAAC;IACN,CAAC;IAED,MAAM,CAAC,YAAY,CACjB,QAAkB;QAElB,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;IACxD,CAAC;IAED,MAAM,CAAC,gBAAgB,CACrB,QAAqB;QAErB,OAAO,KAAK,EACV,QAA0B,EAC1B,KAAgD,EAC/B,EAAE;YACnB,MAAM,UAAU,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC,WAAW,CAAC;gBACnD,KAAK,EAAE,KAAK,CAAC,IAAI;gBACjB,QAAQ;aACT,CAAC,CAAC;YAEH,OAAO,UAAU,CAAC,WAAW,IAAI,CAAC,CAAC;QACrC,CAAC,CAAC;IACJ,CAAC;CACF;AArDD,4DAqDC"}
1
+ {"version":3,"file":"GoogleGenerativeAI.entity.js","sourceRoot":"","sources":["../../../src/providers/GoogleGenerativeAI/GoogleGenerativeAI.entity.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAQ1B,+DAU+B;AAE/B,MAAa,wBAAwB;IACnC,MAAM,CAA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;QACC,MAAM,gBAAgB,GAAc,MAAM,OAAO,CAAC,GAAG,CACnD,YAAY,CAAC,GAAG,CACd,CAAC,OAAO,EAAE,EAAE,CAAC,wBAAwB,CAAC,UAAU,CAC9C,OAAO,EACP,QAAQ,CACT,CACF,CACF,CAAC;QAEF,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;YACf,MAAM,mBAAmB,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;YAEvC,gBAAgB,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;QAC7C,CAAC;QAED,MAAM,kBAAkB,GAAG;YACzB,EAAE,IAAI,EAAE,8BAAQ,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE;YACjD,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE;SAC9B,CAAC;QAEF,IAAI,UAAU,GAAG,MAAM,aAAa,CAAC,gBAAgB,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QAEnE,KAAK,MAAM,GAAG,IAAI,kBAAkB,EAAE,CAAC;YACrC,MAAM,cAAc,GAAG,UAAU,GAAG,CAClC,MAAM,aAAa,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC,CACrC,CAAC;YAEF,IAAI,cAAc,IAAI,KAAK,CAAC,MAAM,CAAC,cAAc,EAAE,CAAC;gBAClD,gBAAgB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;gBAC3B,UAAU,GAAG,cAAc,CAAC;YAC9B,CAAC;iBAAM,CAAC;gBACN,MAAM;YACR,CAAC;QACH,CAAC;QAED,OAAO,gBAAgB,CAAC;IAC1B,CAAC;CACF;AAtJD,4DAsJC"}
@@ -1,19 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GoogleGenerativeAIRoles = exports.GoogleGenerativeAIModelNames = void 0;
4
- var GoogleGenerativeAIModelNames;
5
- (function (GoogleGenerativeAIModelNames) {
6
- GoogleGenerativeAIModelNames["GEMINI_1_5_FLASH"] = "gemini-1.5-flash";
7
- GoogleGenerativeAIModelNames["GEMINI_1_5_FLASH_STABLE"] = "gemini-1.5-flash-001";
8
- GoogleGenerativeAIModelNames["GEMINI_1_5_PRO"] = "gemini-1.5-pro";
9
- GoogleGenerativeAIModelNames["GEMINI_1_5_PRO_STABLE"] = "gemini-1.5-pro-002";
10
- GoogleGenerativeAIModelNames["GEMINI_2_0_FLASH"] = "gemini-2.0-flash";
11
- GoogleGenerativeAIModelNames["GEMINI_2_0_FLASH_STABLE"] = "gemini-2.0-flash-001";
12
- GoogleGenerativeAIModelNames["GEMINI_2_5_PRO_PREVIEW"] = "gemini-2.5-pro-preview-03-25";
13
- })(GoogleGenerativeAIModelNames || (exports.GoogleGenerativeAIModelNames = GoogleGenerativeAIModelNames = {}));
14
- var GoogleGenerativeAIRoles;
15
- (function (GoogleGenerativeAIRoles) {
16
- GoogleGenerativeAIRoles["User"] = "user";
17
- GoogleGenerativeAIRoles["Model"] = "model";
18
- })(GoogleGenerativeAIRoles || (exports.GoogleGenerativeAIRoles = GoogleGenerativeAIRoles = {}));
19
- //# sourceMappingURL=GoogleGenerativeAI.typedefs.js.map
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_FLASH_STABLE="gemini-1.5-flash-001",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-03-25"}(GoogleGenerativeAIModelNames||(exports.GoogleGenerativeAIModelNames=GoogleGenerativeAIModelNames={})),function(e){e.User="user",e.Model="model"}(GoogleGenerativeAIRoles||(exports.GoogleGenerativeAIRoles=GoogleGenerativeAIRoles={}));
@@ -1,17 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GoogleGenerativeAIServiceFactory = void 0;
4
- const LLMService_typedefs_1 = require("../../LLMService.typedefs");
5
- const services_1 = require("../../services");
6
- const GoogleGenerativeAI_constants_1 = require("./GoogleGenerativeAI.constants");
7
- class GoogleGenerativeAIServiceFactory extends services_1.LLMServicePurposeFactory {
8
- createService(purpose, logger, options) {
9
- const serviceBuilder = GoogleGenerativeAI_constants_1.GOOGLE_AI_SERVICE_BUILDERS[purpose];
10
- if (!serviceBuilder) {
11
- throw new Error(`Purpose [${purpose}] is not supported for [${LLMService_typedefs_1.LLMProviders.GoogleGenerativeAI}] service`);
12
- }
13
- return serviceBuilder(logger, options);
14
- }
15
- }
16
- exports.GoogleGenerativeAIServiceFactory = GoogleGenerativeAIServiceFactory;
17
- //# sourceMappingURL=GoogleGenerativeAIService.factory.js.map
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.GoogleGenerativeAIServiceFactory=void 0;const LLMService_typedefs_1=require("../../LLMService.typedefs"),services_1=require("../../services"),GoogleGenerativeAI_constants_1=require("../../providers/GoogleGenerativeAI/GoogleGenerativeAI.constants");class GoogleGenerativeAIServiceFactory extends services_1.LLMServicePurposeFactory{createService(e,r,o){const t=GoogleGenerativeAI_constants_1.GOOGLE_AI_SERVICE_BUILDERS[e];if(!t)throw new Error(`Purpose [${e}] is not supported for [${LLMService_typedefs_1.LLMProviders.GoogleGenerativeAI}] service`);return t(r,o)}}exports.GoogleGenerativeAIServiceFactory=GoogleGenerativeAIServiceFactory;
@@ -1 +1 @@
1
- {"version":3,"file":"GoogleGenerativeAIService.factory.js","sourceRoot":"","sources":["../../../src/providers/GoogleGenerativeAI/GoogleGenerativeAIService.factory.ts"],"names":[],"mappings":";;;AACA,mEAKmC;AACnC,6CAA0D;AAC1D,iFAA4E;AAE5E,MAAa,gCAAiC,SAAQ,mCAErD;IACC,aAAa,CAGX,OAAgB,EAChB,MAAc,EACd,OAA4D;QAE5D,MAAM,cAAc,GAAG,yDAA0B,CAAC,OAAO,CAAC,CAAC;QAE3D,IAAI,CAAC,cAAc,EAAE,CAAC;YACpB,MAAM,IAAI,KAAK,CAAC,YAAY,OAAO,2BAA2B,kCAAY,CAAC,kBAAkB,WAAW,CAAC,CAAC;QAC5G,CAAC;QAED,OAAO,cAAc,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACzC,CAAC;CACF;AAlBD,4EAkBC"}
1
+ {"version":3,"file":"GoogleGenerativeAIService.factory.js","sourceRoot":"","sources":["../../../src/providers/GoogleGenerativeAI/GoogleGenerativeAIService.factory.ts"],"names":[],"mappings":";;;AACA,+DAK+B;AAC/B,yCAAsD;AACtD,8GAAyG;AAEzG,MAAa,gCAAiC,SAAQ,mCAErD;IACC,aAAa,CAGX,OAAgB,EAChB,MAAc,EACd,OAA4D;QAE5D,MAAM,cAAc,GAAG,yDAA0B,CAAC,OAAO,CAAC,CAAC;QAE3D,IAAI,CAAC,cAAc,EAAE,CAAC;YACpB,MAAM,IAAI,KAAK,CAAC,YAAY,OAAO,2BAA2B,kCAAY,CAAC,kBAAkB,WAAW,CAAC,CAAC;QAC5G,CAAC;QAED,OAAO,cAAc,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACzC,CAAC;CACF;AAlBD,4EAkBC"}
@@ -1,22 +1 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./GoogleGenerativeAI.constants"), exports);
18
- __exportStar(require("./GoogleGenerativeAI.typedefs"), exports);
19
- __exportStar(require("./GoogleGenerativeAI.entity"), exports);
20
- __exportStar(require("./GoogleGenerativeAIService.factory"), exports);
21
- __exportStar(require("./services"), exports);
22
- //# sourceMappingURL=index.js.map
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("./GoogleGenerativeAI.constants"),exports),__exportStar(require("./GoogleGenerativeAI.typedefs"),exports),__exportStar(require("./GoogleGenerativeAI.entity"),exports),__exportStar(require("./GoogleGenerativeAIService.factory"),exports),__exportStar(require("./services"),exports);