@mate-academy/llm-gateway 1.1.0 → 1.1.1-canary.2
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.constants.d.ts +1 -0
- package/dist/LLMService.constants.js +1 -1
- package/dist/LLMService.constants.js.map +1 -1
- package/dist/LLMService.typedefs.d.ts +47 -6
- package/dist/LLMService.typedefs.js +1 -1
- package/dist/LLMService.typedefs.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/providers/GoogleGenerativeAI/GoogleGenerativeAI.entity.d.ts +10 -4
- package/dist/providers/GoogleGenerativeAI/GoogleGenerativeAI.entity.js +1 -1
- package/dist/providers/GoogleGenerativeAI/GoogleGenerativeAI.entity.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/GoogleGenerativeAICompletion.service.js +1 -1
- package/dist/providers/GoogleGenerativeAI/services/GoogleGenerativeAICompletion.service.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 +5 -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 +1 -0
- 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/OpenAICompletion.service.js +1 -1
- package/dist/providers/OpenAI/services/OpenAICompletion.service.js.map +1 -1
- package/package.json +8 -7
- package/dist/LLMService.entity.d.ts +0 -13
- package/dist/LLMService.entity.js +0 -1
- package/dist/LLMService.entity.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),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};
|
|
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"}
|
|
@@ -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
|
|
134
|
+
export interface LLMCompletionMessage {
|
|
107
135
|
role: LLMRoles;
|
|
108
|
-
content:
|
|
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:
|
|
160
|
+
message: LLMCompletionMessage;
|
|
133
161
|
model: LLMModel<Provider>;
|
|
134
|
-
history?:
|
|
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
|
|
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> = (
|
|
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 +1 @@
|
|
|
1
|
-
"use strict";var LLMProviders,LLMPurposes,LLMRoles,LLMUploadFileMimeTypes;Object.defineProperty(exports,"__esModule",{value:!0}),exports.LLMUploadFileMimeTypes=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.PNG="image/png",e.PLAIN_TEXT="text/plain"}(LLMUploadFileMimeTypes||(exports.LLMUploadFileMimeTypes=LLMUploadFileMimeTypes={}));
|
|
1
|
+
"use strict";var LLMProviders,LLMPurposes,LLMRoles,LLMMessageContentType,LLMUploadFileMimeTypes;Object.defineProperty(exports,"__esModule",{value:!0}),exports.LLMUploadFileMimeTypes=exports.LLMMessageContentType=exports.LLMRoles=exports.LLMPurposes=exports.LLMProviders=void 0,function(e){e.OpenAI="OpenAI",e.GoogleGenerativeAI="GoogleGenerativeAI"}(LLMProviders||(exports.LLMProviders=LLMProviders={})),function(e){e.Completion="completion",e.Assistance="assistance"}(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;
|
|
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"}
|
package/dist/index.d.ts
CHANGED
package/dist/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("./LLMService.constants"),exports),__exportStar(require("./LLMService.
|
|
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,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yDAAuC;AACvC,uDAAqC;AACrC,wDAAsC;AACtC,8CAA4B;AAC5B,6CAA2B"}
|
|
@@ -1,8 +1,14 @@
|
|
|
1
|
-
import { type Part, type GoogleGenAI, type
|
|
2
|
-
import { type
|
|
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(
|
|
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
|
|
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 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.GoogleGenerativeAIEntity=void 0;class GoogleGenerativeAIEntity{static getContentParameters(e
|
|
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":"
|
|
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,CAAC,oBAAoB,CAAC,OAI3B;QACC,MAAM,EACJ,KAAK,EACL,QAAQ,EACR,YAAY,GACb,GAAG,OAAO,CAAC;QAEZ,OAAO;YACL,KAAK,EAAE,KAAK,CAAC,IAAI;YACjB,QAAQ,EAAE,QAAQ;YAClB,MAAM,EAAE;gBACN,iBAAiB,EAAE,YAAY;gBAC/B,WAAW,EAAE,KAAK,CAAC,MAAM,CAAC,WAAW;aACtC;SACF,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,gBAAgB,CACrB,aAAgC;QAEhC,OAAO,aAAa,CAAC,GAAG,CAAC,CAAC,I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zB,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 +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,s=this.chatSessions.get(r);if(!s)throw new Error("Chat session not found");return{text:(await s.sendMessage({message:
|
|
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,s=this.chatSessions.get(r);if(!s)throw new Error("Chat session not found");const i=await GoogleGenerativeAI_entity_1.GoogleGenerativeAIEntity.getContent(t,this.instance);if(!i.parts)return{text:""};return{text:(await s.sendMessage({message:i.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,IAAI,GACL,GAAG,IAAI,CAAC;YAET,MAAM,YAAY,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YAElD,IAAI,YAAY,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gBACjD,OAAO,EAAE,
|
|
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,IAAI,GACL,GAAG,IAAI,CAAC;YAET,MAAM,YAAY,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YAElD,IAAI,YAAY,EAAE,CAAC;gBACjB,OAAO,YAAY,CAAC;YACtB,CAAC;YAED,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC;gBACpD,IAAI,EAAE,IAAI;gBACV,MAAM,EAAE;oBACN,QAAQ;oBACR,WAA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C,WAAW,CAAC;gBACjD,OAAO,EAAE,cAAc,CAAC,KAAK;aAC9B,CAAC,CAAC;YAEH,OAAO;gBACL,IAAI,EAAE,YAAY,CAAC,IAAI,IAAI,EAAE;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;AAlSD,kFAkSC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.GoogleGenerativeAICompletionService=void 0;const genai_1=require("@google/genai"),LLMService_typedefs_1=require("../../../LLMService.typedefs"),services_1=require("../../../services"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.GoogleGenerativeAICompletionService=void 0;const genai_1=require("@google/genai"),LLMService_typedefs_1=require("../../../LLMService.typedefs"),services_1=require("../../../services"),GoogleGenerativeAI_entity_1=require("../../../providers/GoogleGenerativeAI/GoogleGenerativeAI.entity");class GoogleGenerativeAICompletionService extends services_1.LLMCompletionService{#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 sendMessage(e){try{const{model:t,message:i,history:n=[],instructions:o}=e,r=GoogleGenerativeAI_entity_1.GoogleGenerativeAIEntity.getCountTokensFn(this.instance),s=await GoogleGenerativeAI_entity_1.GoogleGenerativeAIEntity.combineMessagesWithLimit({history:n,message:i,model:t,countTokensFn:r,instance:this.instance});return{text:(await this.instance.models.generateContent(GoogleGenerativeAI_entity_1.GoogleGenerativeAIEntity.getContentParameters({model:t,messages:s,instructions:o}))).text??""}}catch(t){return this.logger.child("sendMessage").error("Error sending message",{error:t,options:e}),{error:t}}}}exports.GoogleGenerativeAICompletionService=GoogleGenerativeAICompletionService;
|
package/dist/providers/GoogleGenerativeAI/services/GoogleGenerativeAICompletion.service.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GoogleGenerativeAICompletion.service.js","sourceRoot":"","sources":["../../../../src/providers/GoogleGenerativeAI/services/GoogleGenerativeAICompletion.service.ts"],"names":[],"mappings":";;;AACA,yCAA4C;AAC5C,+DAK+B;AAC/B,yCAEoB;AACpB,
|
|
1
|
+
{"version":3,"file":"GoogleGenerativeAICompletion.service.js","sourceRoot":"","sources":["../../../../src/providers/GoogleGenerativeAI/services/GoogleGenerativeAICompletion.service.ts"],"names":[],"mappings":";;;AACA,yCAA4C;AAC5C,+DAK+B;AAC/B,yCAEoB;AACpB,wGAAoG;AAEpG,MAAa,mCACX,SAAQ,+BAAqD;IAC7D,SAAS,GAAuB,IAAI,CAAC;IAErC,YACE,MAAc,EACd,OAA4D;QAE5D,KAAK,CAAC,kCAAY,CAAC,kBAAkB,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IAC1D,CAAC;IAED,IAAc,QAAQ;QACpB,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;YACpB,IAAI,CAAC,SAAS,GAAG,IAAI,mBAAW,CAAC;gBAC/B,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM;aAC5B,CAAC,CAAC;QACL,CAAC;QAED,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAED,KAAK,CAAC,WAAW,CACf,OAAoD;QAEpD,IAAI,CAAC;YACH,MAAM,EACJ,KAAK,EACL,OAAO,EACP,OAAO,GAAG,EAAE,EACZ,YAAY,GACb,GAAG,OAAO,CAAC;YAEZ,MAAM,aAAa,GAAG,oDAAwB;iBAC3C,gBAAgB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAEnC,MAAM,gBAAgB,GAAG,MAAM,oDAAwB,CAAC,wBAAwB,CAAC;gBAC/E,OAAO;gBACP,OAAO;gBACP,KAAK;gBACL,aAAa;gBACb,QAAQ,EAAE,IAAI,CAAC,QAAQ;aACxB,CAAC,CAAC;YAEH,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,eAAe,CACvD,oDAAwB,CAAC,oBAAoB,CAAC;gBAC5C,KAAK;gBACL,QAAQ,EAAE,gBAAgB;gBAC1B,YAAY;aACb,CAAC,CACH,CAAC;YAEF,OAAO;gBACL,IAAI,EAAE,MAAM,CAAC,IAAI,IAAI,EAAE;aACxB,CAAC;QACJ,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,IAAI,CAAC,MAAM;iBACR,KAAK,CAAC,aAAa,CAAC;iBACpB,KAAK,CAAC,uBAAuB,EAAE;gBAC9B,KAAK;gBACL,OAAO;aACR,CAAC,CAAC;YAEL,OAAO,EAAE,KAAK,EAAE,CAAC;QACnB,CAAC;IACH,CAAC;CACF;AAjED,kFAiEC"}
|
|
@@ -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_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_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}}};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 +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,yCAGoB;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,OAAO;YACvB,eAAe,EAAE,MAAM;SACxB;QACD,MAAM,EAAE;YACN,WAAW,EAAE,GAAG;SACjB;KACF;IACD,CAAC,kCAAgB,CAAC,OAAO,CAAC,EAAE;QAC1B,IAAI,EAAE,kCAAgB,CAAC,OAAO;QAC9B,MAAM,EAAE;YACN,cAAc,EAAE,SAAS;YACzB,eAAe,EAAE,MAAM;SACxB;QACD,MAAM,EAAE;YACN,WAAW,EAAE,GAAG;SACjB;KACF;CACF,CAAC;AAEW,QAAA,cAAc,GAGvB;IACF,CAAC,iCAAW,CAAC,UAAU,CAAC,EAAE,IAAA,uBAAI,EAC5B,wBAAwB,EACxB;QACE,kCAAgB,CAAC,UAAU;QAC3B,kCAAgB,CAAC,OAAO;KACzB,CACF;IACD,CAAC,iCAAW,CAAC,UAAU,CAAC,EAAE,IAAA,uBAAI,EAC5B,wBAAwB,EACxB;QACE,kCAAgB,CAAC,UAAU;QAC3B,kCAAgB,CAAC,OAAO;KACzB,CACF;CACF,CAAC;AAEW,QAAA,wBAAwB,GAIjC;IACF,CAAC,iCAAW,CAAC,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,CAAC,CAC7C,IAAI,kCAAuB,CAAC,MAAM,EAAE,OAAO,CAAC,CAC7C;IACD,CAAC,iCAAW,CAAC,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,CAAC,CAC7C,IAAI,kCAAuB,CAAC,MAAM,EAAE,OAAO,CAAC,CAC7C;CACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"OpenAI.constants.js","sourceRoot":"","sources":["../../../src/providers/OpenAI/OpenAI.constants.ts"],"names":[],"mappings":";;;AAAA,+DAM+B;AAC/B,wEAAsE;AACtE,yCAGoB;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,OAAO;YACvB,eAAe,EAAE,MAAM;SACxB;QACD,MAAM,EAAE;YACN,WAAW,EAAE,GAAG;SACjB;KACF;IACD,CAAC,kCAAgB,CAAC,eAAe,CAAC,EAAE;QAClC,IAAI,EAAE,kCAAgB,CAAC,eAAe;QACtC,MAAM,EAAE;YACN,cAAc,EAAE,OAAO;YACvB,eAAe,EAAE,MAAM;SACxB;QACD,MAAM,EAAE;YACN,WAAW,EAAE,GAAG;SACjB;KACF;IACD,CAAC,kCAAgB,CAAC,OAAO,CAAC,EAAE;QAC1B,IAAI,EAAE,kCAAgB,CAAC,OAAO;QAC9B,MAAM,EAAE;YACN,cAAc,EAAE,SAAS;YACzB,eAAe,EAAE,MAAM;SACxB;QACD,MAAM,EAAE;YACN,WAAW,EAAE,GAAG;SACjB;KACF;CACF,CAAC;AAEW,QAAA,cAAc,GAGvB;IACF,CAAC,iCAAW,CAAC,UAAU,CAAC,EAAE,IAAA,uBAAI,EAC5B,wBAAwB,EACxB;QACE,kCAAgB,CAAC,UAAU;QAC3B,kCAAgB,CAAC,eAAe;QAChC,kCAAgB,CAAC,OAAO;KACzB,CACF;IACD,CAAC,iCAAW,CAAC,UAAU,CAAC,EAAE,IAAA,uBAAI,EAC5B,wBAAwB,EACxB;QACE,kCAAgB,CAAC,UAAU;QAC3B,kCAAgB,CAAC,OAAO;KACzB,CACF;CACF,CAAC;AAEW,QAAA,wBAAwB,GAIjC;IACF,CAAC,iCAAW,CAAC,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,CAAC,CAC7C,IAAI,kCAAuB,CAAC,MAAM,EAAE,OAAO,CAAC,CAC7C;IACD,CAAC,iCAAW,CAAC,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,CAAC,CAC7C,IAAI,kCAAuB,CAAC,MAAM,EAAE,OAAO,CAAC,CAC7C;CACF,CAAC"}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import { type CombineMessagesOptions, type LLMCompletionMessage, type LLMCountTokensFunction, type LLMMessageContent, type LLMProviders } from '../../LLMService.typedefs';
|
|
2
|
+
import { type ChatCompletionMessageParam } from 'openai/resources/chat';
|
|
1
3
|
export declare class OpenAIEntity {
|
|
2
|
-
static getCountTokensFn(): (
|
|
4
|
+
static getCountTokensFn(): (messagesContents: LLMMessageContent[]) => Promise<number>;
|
|
5
|
+
static getChatCompletionMessageParam(messages: LLMCompletionMessage[]): ChatCompletionMessageParam[];
|
|
6
|
+
static combineMessagesWithLimit({ modelContext, history, message, model, countTokensFn, }: CombineMessagesOptions<LLMProviders.OpenAI, LLMCountTokensFunction<LLMProviders.OpenAI, LLMMessageContent[]>>): Promise<LLMCompletionMessage[]>;
|
|
3
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.OpenAIEntity=void 0;const js_tiktoken_1=require("js-tiktoken");class OpenAIEntity{static getCountTokensFn(){return e=>{const t=(0,js_tiktoken_1.getEncoding)("o200k_base"),
|
|
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:o}){const r=[...e];if(t[0]){const e=t[0];r.push(e)}const i=[{role:LLMService_typedefs_1.LLMRoles.User,content:s.content},...t.slice(1).reverse()],c=r.map((e=>e.content));let p=await(o?.(c,n))??0;for(const e of i){const t=p+(await(o?.([e.content],n))??0);if(!(t<=n.limits.maxInputTokens))break;r.push(e),p=t}return r}}exports.OpenAIEntity=OpenAIEntity;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OpenAI.entity.js","sourceRoot":"","sources":["../../../src/providers/OpenAI/OpenAI.entity.ts"],"names":[],"mappings":";;;AAAA,6CAA0C;
|
|
1
|
+
{"version":3,"file":"OpenAI.entity.js","sourceRoot":"","sources":["../../../src/providers/OpenAI/Op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.OpenAIModelNames=void 0,function(e){e.GPT_4_OMNI="gpt-4o",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"}(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,gBAIX;AAJD,WAAY,gBAAgB;IAC1B,yCAAqB,CAAA;IACrB,mDAA+B,CAAA;IAC/B,uCAAmB,CAAA;AACrB,CAAC,EAJW,gBAAgB,gCAAhB,gBAAgB,QAI3B;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.del(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.del(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.del(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.del(e)}async assistInChat(e){try{const{message:t,chatId:s,assistantId:r}=e,i={
|
|
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.del(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.del(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.del(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.del(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,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,C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;aACrB,CAAC,CAAC;YAEH,OAAO;gBACL,WAAW,EAAE,SAAS,CAAC,EAAE;aAC1B,CAAC;QACJ,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,IAAI,CAAC,MAAM;iBACR,KAAK,CAAC,iBAAiB,CAAC;iBACxB,KAAK,CAAC,0BAA0B,EAAE;gBACjC,KAAK;gBACL,OAAO;aACR,CAAC,CAAC;YAEL,OAAO,EAAE,KAAK,EAAE,CAAC;QACnB,CAAC;IACH,CAAC;IAED,KAAK,CAAC,eAAe,CACnB,WAAmB;QAEnB,MAAM,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IACvD,CAAC;IAED,KAAK,CAAC,YAAY,CAChB,OAAkD;QAElD,IAAI,CAAC;YACH,MAAM,EACJ,OAAO,EACP,MAAM,EACN,WAAW,GACZ,GAAG,OAAO,CAAC;YAEZ,MAAM,iBAAiB,GAAG;gBACxB,
|
|
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;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,KAAK,CAAC,oDAAoD,MAAM,EAAE,CAAC,CAAC;YAChF,CAAC;YAED,MAAM,iBAAiB,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CACtE,MAAM,EACN;gBACE,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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.OpenAICompletionService=void 0;const openai_1=require("openai"),LLMService_typedefs_1=require("../../../LLMService.typedefs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.OpenAICompletionService=void 0;const openai_1=require("openai"),LLMService_typedefs_1=require("../../../LLMService.typedefs"),services_1=require("../../../services"),OpenAI_entity_1=require("../../../providers/OpenAI/OpenAI.entity");class OpenAICompletionService extends services_1.LLMCompletionService{#e=null;constructor(e,n){super(LLMService_typedefs_1.LLMProviders.OpenAI,e,n)}get instance(){return this.#e||(this.#e=new openai_1.OpenAI(this.options)),this.#e}async sendMessage(e){try{const{model:n,message:t,history:s=[]}=e,i=OpenAI_entity_1.OpenAIEntity.getCountTokensFn(),r=await OpenAI_entity_1.OpenAIEntity.combineMessagesWithLimit({history:s,message:t,model:n,countTokensFn:i,instance:this.instance}),o=OpenAI_entity_1.OpenAIEntity.getChatCompletionMessageParam(r),c=await this.instance.chat.completions.create({model:n.name,messages:o,n:1,...n.config});return{text:c.choices[0]?.message.content??""}}catch(n){return this.logger.child("sendMessage").error("Error sending message",{error:n,options:e}),{error:n}}}}exports.OpenAICompletionService=OpenAICompletionService;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OpenAICompletion.service.js","sourceRoot":"","sources":["../../../../src/providers/OpenAI/services/OpenAICompletion.service.ts"],"names":[],"mappings":";;;AACA,mCAAgC;AAChC,+DAK+B;AAC/B,
|
|
1
|
+
{"version":3,"file":"OpenAICompletion.service.js","sourceRoot":"","sources":["../../../../src/providers/OpenAI/services/OpenAICompletion.service.ts"],"names":[],"mappings":";;;AACA,mCAAgC;AAChC,+DAK+B;AAC/B,yCAEoB;AACpB,oEAAgE;AAEhE,MAAa,uBACX,SAAQ,+BAAyC;IACjD,SAAS,GAAkB,IAAI,CAAC;IAEhC,YACE,MAAc,EACd,OAAgD;QAEhD,KAAK,CAAC,kCAAY,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9C,CAAC;IAED,IAAc,QAAQ;QACpB,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;YACpB,IAAI,CAAC,SAAS,GAAG,IAAI,eAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC5C,CAAC;QAED,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAED,KAAK,CAAC,WAAW,CACf,OAAoD;QAEpD,IAAI,CAAC;YACH,MAAM,EACJ,KAAK,EACL,OAAO,EACP,OAAO,GAAG,EAAE,GACb,GAAG,OAAO,CAAC;YAEZ,MAAM,aAAa,GAAG,4BAAY,CAAC,gBAAgB,EAAE,CAAC;YAEtD,MAAM,gBAAgB,GAAG,MAAM,4BAAY,CAAC,wBAAwB,CAAC;gBACnE,OAAO;gBACP,OAAO;gBACP,KAAK;gBACL,aAAa;gBACb,QAAQ,EAAE,IAAI,CAAC,QAAQ;aACxB,CAAC,CAAC;YAEH,MAAM,0BAA0B,GAAG,4BAAY;iBAC5C,6BAA6B,CAAC,gBAAgB,CAAC,CAAC;YAEnD,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC;gBAC7D,KAAK,EAAE,KAAK,CAAC,IAAI;gBACjB,QAAQ,EAAE,0BAA0B;gBACpC,CAAC,EAAE,CAAC;gBACJ,GAAG,KAAK,CAAC,MAAM;aAChB,CAAC,CAAC;YAEH,OAAO;gBACL,IAAI,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,IAAI,EAAE;aACnD,CAAC;QACJ,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,IAAI,CAAC,MAAM;iBACR,KAAK,CAAC,aAAa,CAAC;iBACpB,KAAK,CAAC,uBAAuB,EAAE;gBAC9B,KAAK;gBACL,OAAO;aACR,CAAC,CAAC;YAEL,OAAO,EAAE,KAAK,EAAE,CAAC;QACnB,CAAC;IACH,CAAC;CACF;AA/DD,0DA+DC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mate-academy/llm-gateway",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.1-canary.2",
|
|
4
4
|
"description": "A gateway package for LLM services.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -44,18 +44,19 @@
|
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@mate-academy/ts-config": "^1.0.5",
|
|
47
|
-
"@typescript-eslint/eslint-plugin": "^8.32.
|
|
48
|
-
"eslint": "^9.
|
|
49
|
-
"terser": "^5.39.
|
|
47
|
+
"@typescript-eslint/eslint-plugin": "^8.32.1",
|
|
48
|
+
"eslint": "^9.27.0",
|
|
49
|
+
"terser": "^5.39.2",
|
|
50
50
|
"tsc-alias": "^1.8.16",
|
|
51
51
|
"typescript": "^5.8.3",
|
|
52
|
-
"typescript-eslint": "^8.32.
|
|
52
|
+
"typescript-eslint": "^8.32.1"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@google/genai": "^0.
|
|
55
|
+
"@google/genai": "^0.15.0",
|
|
56
56
|
"@mate-academy/core": "^1.10.4",
|
|
57
|
+
"axios": "^1.9.0",
|
|
57
58
|
"js-tiktoken": "^1.0.20",
|
|
58
|
-
"openai": "^4.
|
|
59
|
+
"openai": "^4.100.0",
|
|
59
60
|
"uuid": "^11.1.0"
|
|
60
61
|
}
|
|
61
62
|
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { type LLMCountTokensFunction, type LLMMessage, type LLMModel, type LLMProviders } from './LLMService.typedefs';
|
|
2
|
-
interface CombineMessagesOptions<Provider extends LLMProviders> {
|
|
3
|
-
modelContext?: LLMMessage[];
|
|
4
|
-
history?: LLMMessage[];
|
|
5
|
-
message: string;
|
|
6
|
-
model: LLMModel<Provider>;
|
|
7
|
-
countTokensFn?: LLMCountTokensFunction<Provider>;
|
|
8
|
-
}
|
|
9
|
-
export declare class LLMServiceEntity {
|
|
10
|
-
private static countTokensFallback;
|
|
11
|
-
static combineMessagesWithLimit<Provider extends LLMProviders>({ modelContext, history, message, model, countTokensFn, }: CombineMessagesOptions<Provider>): Promise<LLMMessage[]>;
|
|
12
|
-
}
|
|
13
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.LLMServiceEntity=void 0;const LLMService_typedefs_1=require("./LLMService.typedefs");class LLMServiceEntity{static countTokensFallback(e){const t=e.join("").split(/[\s,.;!?(){}[\]<>%&]+/).filter(Boolean).flatMap((e=>e.split(/(?<=[a-z])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])|(?<=[a-zA-Z])(?=\d)|(?<=[\d])(?=[a-zA-Z])/)));return Promise.resolve(t.length)}static async combineMessagesWithLimit({modelContext:e=[],history:t=[],message:s,model:o,countTokensFn:i=this.countTokensFallback}){const n=[...e];if(t[0]){const e=t[0];n.push(e)}const c=[{role:LLMService_typedefs_1.LLMRoles.User,content:s},...t.slice(1).reverse()],r=n.map((e=>e.content));let a=await i(r,o);for(const e of c){const t=a+await i([e.content],o);if(!(t<=o.limits.maxInputTokens))break;n.push(e),a=t}return n}}exports.LLMServiceEntity=LLMServiceEntity;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LLMService.entity.js","sourceRoot":"","sources":["../src/LLMService.entity.ts"],"names":[],"mappings":";;;AAAA,+DAM+B;AAU/B,MAAa,gBAAgB;IACnB,MAAM,CAAC,mBAAmB,CAAC,QAAkB;QACnD,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAClC,MAAM,WAAW,GAAG,OAAO,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAC3E,MAAM,aAAa,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CACnD,KAAK,CAAC,KAAK,CACT,wFAAwF,CACzF,CACF,CAAC,CAAC;QAEH,OAAO,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;IAC/C,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,wBAAwB,CAAgC,EACnE,YAAY,GAAG,EAAE,EACjB,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