@mate-academy/llm-gateway 2.2.1-canary.2 → 2.2.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.
@@ -166,6 +166,10 @@ export interface LLMCompletionMessage {
166
166
  export interface LLMAssistanceMessage {
167
167
  role: LLMRoles;
168
168
  content: LLMAssistanceMessageContent[];
169
+ /**
170
+ * Optional attachments that can be included with the message.
171
+ * Maximum of 10 attachments.
172
+ */
169
173
  attachments?: LLMUploadedFile[];
170
174
  }
171
175
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"LLMService.typedefs.js","sourceRoot":"","sources":["../src/LLMService.typedefs.ts"],"names":[],"mappings":";;;AAkBA;;GAEG;AACH,IAAY,YAGX;AAHD,WAAY,YAAY;IACtB,iCAAiB,CAAA;IACjB,yDAAyC,CAAA;AAC3C,CAAC,EAHW,YAAY,4BAAZ,YAAY,QAGvB;AAkBD;;GAEG;AACH,IAAY,WAKX;AALD,WAAY,WAAW;IACrB,wCAAyB,CAAA;IACzB,wCAAyB,CAAA;IACzB,8CAA+B,CAAA;IAC/B,8CAA+B,CAAA;AACjC,CAAC,EALW,WAAW,2BAAX,WAAW,QAKtB;AAyFD;;GAEG;AACH,IAAY,QAGX;AAHD,WAAY,QAAQ;IAClB,yBAAa,CAAA;IACb,mCAAuB,CAAA;AACzB,CAAC,EAHW,QAAQ,wBAAR,QAAQ,QAGnB;AAED;;GAEG;AACH,IAAY,qBAKX;AALD,WAAY,qBAAqB;IAC/B,sCAAa,CAAA;IACb,gDAAuB,CAAA;IACvB,kDAAyB,CAAA;IACzB,kDAAyB,CAAA;AAC3B,CAAC,EALW,qBAAqB,qCAArB,qBAAqB,QAKhC;AA8GD;;GAEG;AACH,IAAY,sBAcX;AAdD,WAAY,sBAAsB;IAChC,iDAAuB,CAAA;IACvB,mDAAyB,CAAA;IACzB,iDAAuB,CAAA;IACvB,iDAAuB,CAAA;IACvB,mDAAyB,CAAA;IACzB,yDAA+B,CA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A;AAC3B,CAAC,EAdW,sBAAsB,sCAAtB,sBAAsB,QAcjC"}
@@ -1,6 +1,6 @@
1
1
  import { type Logger } from '@mate-academy/core';
2
2
  import { GoogleGenAI } from '@google/genai';
3
- import { type LLMAssistanceOptions, type LLMAssistanceResult, type LLMCompletionMessage, type LLMCreateAssistantOptions, type LLMCreateAssistantResult, type LLMCreateChatOptions, type LLMCreateChatResult, type LLMCreateFileStorageOptions, type LLMCreateFileStorageResult, type LLMInstanceOptions, type LLMModel, LLMProviders, type LLMUploadFileOptions, type LLMUploadFileResult } from '../../../LLMService.typedefs';
3
+ import { type LLMAssistanceOptions, type LLMAssistanceResult, type LLMAssistanceMessage, type LLMCreateAssistantOptions, type LLMCreateAssistantResult, type LLMCreateChatOptions, type LLMCreateChatResult, type LLMCreateFileStorageOptions, type LLMCreateFileStorageResult, type LLMInstanceOptions, type LLMModel, LLMProviders, type LLMUploadFileOptions, type LLMUploadFileResult } from '../../../LLMService.typedefs';
4
4
  import { LLMAssistanceService } from '../../../services';
5
5
  export declare class GoogleGenerativeAIAssistanceService extends LLMAssistanceService<LLMProviders.GoogleGenerativeAI> {
6
6
  #private;
@@ -19,5 +19,5 @@ export declare class GoogleGenerativeAIAssistanceService extends LLMAssistanceSe
19
19
  createAssistant(options: LLMCreateAssistantOptions<LLMProviders.GoogleGenerativeAI>): Promise<LLMCreateAssistantResult>;
20
20
  deleteAssistant(): Promise<void>;
21
21
  assistInChat(options: LLMAssistanceOptions): Promise<LLMAssistanceResult>;
22
- countTokens(messages: LLMCompletionMessage[], model: LLMModel<LLMProviders.GoogleGenerativeAI>): Promise<number>;
22
+ countTokens(messages: LLMAssistanceMessage[], model: LLMModel<LLMProviders.GoogleGenerativeAI>): Promise<number>;
23
23
  }
@@ -1,6 +1,6 @@
1
1
  import { type Logger } from '@mate-academy/core';
2
2
  import { OpenAI } from 'openai';
3
- import { type LLMAssistanceOptions, type LLMAssistanceResult, type LLMCompletionMessage, type LLMCreateAssistantOptions, type LLMCreateAssistantResult, type LLMCreateChatOptions, type LLMCreateChatResult, type LLMCreateFileStorageOptions, type LLMCreateFileStorageResult, type LLMInstanceOptions, LLMProviders, type LLMUploadFileOptions, type LLMUploadFileResult } from '../../../LLMService.typedefs';
3
+ import { type LLMAssistanceOptions, type LLMAssistanceResult, type LLMAssistanceMessage, type LLMCreateAssistantOptions, type LLMCreateAssistantResult, type LLMCreateChatOptions, type LLMCreateChatResult, type LLMCreateFileStorageOptions, type LLMCreateFileStorageResult, type LLMInstanceOptions, LLMProviders, type LLMUploadFileOptions, type LLMUploadFileResult } from '../../../LLMService.typedefs';
4
4
  import { LLMAssistanceService } from '../../../services';
5
5
  export declare class OpenAIAssistanceService extends LLMAssistanceService<LLMProviders.OpenAI> {
6
6
  #private;
@@ -16,5 +16,5 @@ export declare class OpenAIAssistanceService extends LLMAssistanceService<LLMPro
16
16
  createAssistant(options: LLMCreateAssistantOptions<LLMProviders.OpenAI>): Promise<LLMCreateAssistantResult>;
17
17
  deleteAssistant(assistantId: string): Promise<void>;
18
18
  assistInChat(options: LLMAssistanceOptions): Promise<LLMAssistanceResult>;
19
- countTokens(messages: LLMCompletionMessage[]): Promise<number>;
19
+ countTokens(messages: LLMAssistanceMessage[]): Promise<number>;
20
20
  }
@@ -1 +1 @@
1
- "use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.OpenAISpeechToTextService=void 0;const fs_1=require("fs"),openai_1=require("openai"),LLMService_typedefs_1=require("../../../LLMService.typedefs"),services_1=require("../../../services"),OpenAI_entity_1=require("../../../providers/OpenAI/OpenAI.entity"),mime_types_1=__importDefault(require("mime-types"));class OpenAISpeechToTextService extends services_1.LLMSpeechToTextService{#e=null;constructor(e,r){super(LLMService_typedefs_1.LLMProviders.OpenAI,e,r)}get instance(){return this.#e||(this.#e=new openai_1.OpenAI(this.options)),this.#e}async transcribe(e){try{const{model:r,pathToAudio:t,mimeType:i,abortSignal:o}=e,{maxFileSize:s,supportedMimeTypes:n}=OpenAI_entity_1.OpenAIEntity.transcribeLimits,c=(0,fs_1.statSync)(t).size;if(console.log(`Transcribing audio file: ${t} with size: ${c} bytes`),c>s)throw new Error(`File size exceeds the limit of ${s} bytes`);const a=i??mime_types_1.default.lookup(t);if(console.log(`Resolved MIME type: ${a}`),!a||!n.includes(a))throw new Error(`Unsupported audio file type: ${a}. Supported types are: ${n.join(", ")}`);const p=(0,fs_1.createReadStream)(t,{signal:o});console.log(`Audio file stream created for: ${t}`,{audioFile:p});const l=await this.instance.audio.transcriptions.create({model:r.name,file:p,response_format:"json"},{signal:o});if(console.log(`Transcription completed for: ${t}`,{text:l.text}),o?.aborted)throw console.log(`Transcription aborted for: ${t}`),new Error("Transcription aborted");return{text:l.text}}catch(r){return this.logger.child("transcribe").error("Error transcribing audio",{error:r,options:e}),console.error(`Error transcribing audio file: ${e.pathToAudio}`,r),{error:r}}}}exports.OpenAISpeechToTextService=OpenAISpeechToTextService;
1
+ "use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.OpenAISpeechToTextService=void 0;const fs_1=require("fs"),openai_1=require("openai"),LLMService_typedefs_1=require("../../../LLMService.typedefs"),services_1=require("../../../services"),OpenAI_entity_1=require("../../../providers/OpenAI/OpenAI.entity"),mime_types_1=__importDefault(require("mime-types"));class OpenAISpeechToTextService extends services_1.LLMSpeechToTextService{#e=null;constructor(e,t){super(LLMService_typedefs_1.LLMProviders.OpenAI,e,t)}get instance(){return this.#e||(this.#e=new openai_1.OpenAI(this.options)),this.#e}async transcribe(e){try{const{model:t,pathToAudio:r,mimeType:i,abortSignal:s}=e,{maxFileSize:n,supportedMimeTypes:o}=OpenAI_entity_1.OpenAIEntity.transcribeLimits;if((0,fs_1.statSync)(r).size>n)throw new Error(`File size exceeds the limit of ${n} bytes`);const p=i??mime_types_1.default.lookup(r);if(!p||!o.includes(p))throw new Error(`Unsupported audio file type: ${p}. Supported types are: ${o.join(", ")}`);const c=(0,fs_1.createReadStream)(r,{signal:s}),a=await this.instance.audio.transcriptions.create({model:t.name,file:c,response_format:"json"},{signal:s});if(s?.aborted)throw new Error("Transcription aborted");return{text:a.text}}catch(t){return this.logger.child("transcribe").error("Error transcribing audio",{error:t,options:e}),{error:t}}}}exports.OpenAISpeechToTextService=OpenAISpeechToTextService;
@@ -1 +1 @@
1
- {"version":3,"file":"OpenAISpeechToText.service.js","sourceRoot":"","sources":["../../../../src/providers/OpenAI/services/OpenAISpeechToText.service.ts"],"names":[],"mappings":";;;;;;AAAA,2BAAgD;AAEhD,mCAAgC;AAChC,+DAK+B;AAC/B,yCAAoD;AACpD,oEAAgE;AAChE,4DAA8B;AAE9B,MAAa,yBACX,SAAQ,iCAA2C;IACnD,SAAS,GAAkB,IAAI,CAAC;IAEhC,YACE,MAAc,EACd,OAAgD;QAEhD,KAAK,CAAC,kCAAY,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9C,CAAC;IAED,IAAc,QAAQ;QACpB,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;YACpB,IAAI,CAAC,SAAS,GAAG,IAAI,eAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC5C,CAAC;QAED,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAED,KAAK,CAAC,UAAU,CACd,OAAmD;QAEnD,IAAI,CAAC;YACH,MAAM,EACJ,KAAK,EACL,WAAW,EACX,QAAQ,EACR,WAAW,GACZ,GAAG,OAAO,CAAC;YAEZ,MAAM,EACJ,WAAW,EACX,kBAAkB,GACnB,GAAG,4BAAY,CAAC,gBAAgB,CAAC;YAElC,MAAM,QAAQ,GAAG,IAAA,aAAQ,EAAC,WAAW,CAAC,CAAC,IAAI,CAAC;YAE5C,OAAO,CAAC,GAAG,CAAC,4BAA4B,WAAW,eAAe,QAAQ,QAAQ,CAAC,CAAC;YAEpF,IA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I,EAAE,CAAC;QACjC,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,IAAI,CAAC,MAAM;iBACR,KAAK,CAAC,YAAY,CAAC;iBACnB,KAAK,CAAC,0BAA0B,EAAE;gBACjC,KAAK;gBACL,OAAO;aACR,CAAC,CAAC;YAEL,OAAO,CAAC,KAAK,CAAC,kCAAkC,OAAO,CAAC,WAAW,EAAE,EAAE,KAAK,CAAC,CAAC;YAE9E,OAAO,EAAE,KAAK,EAAE,CAAC;QACnB,CAAC;IACH,CAAC;CACF;AAzFD,8DAyFC"}
1
+ {"version":3,"file":"OpenAISpeechToText.service.js","sourceRoot":"","sources":["../../../../src/providers/OpenAI/services/OpenAISpeechToText.service.ts"],"names":[],"mappings":";;;;;;AAAA,2BAAgD;AAEhD,mCAAgC;AAChC,+DAK+B;AAC/B,yCAAoD;AACpD,oEAAgE;AAChE,4DAA8B;AAE9B,MAAa,yBACX,SAAQ,iCAA2C;IACnD,SAAS,GAAkB,IAAI,CAAC;IAEhC,YACE,MAAc,EACd,OAAgD;QAEhD,KAAK,CAAC,kCAAY,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9C,CAAC;IAED,IAAc,QAAQ;QACpB,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;YACpB,IAAI,CAAC,SAAS,GAAG,IAAI,eAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC5C,CAAC;QAED,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAED,KAAK,CAAC,UAAU,CACd,OAAmD;QAEnD,IAAI,CAAC;YACH,MAAM,EACJ,KAAK,EACL,WAAW,EACX,QAAQ,EACR,WAAW,GACZ,GAAG,OAAO,CAAC;YAEZ,MAAM,EACJ,WAAW,EACX,kBAAkB,GACnB,GAAG,4BAAY,CAAC,gBAAgB,CAAC;YAElC,MAAM,QAAQ,GAAG,IAAA,aAAQ,EAAC,WAAW,CAAC,CAAC,IAAI,CAAC;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type LLMAssistanceOptions, type LLMAssistanceResult, type LLMCompletionMessage, type LLMCreateAssistantOptions, type LLMCreateAssistantResult, type LLMCreateChatOptions, type LLMCreateChatResult, type LLMCreateFileStorageOptions, type LLMCreateFileStorageResult, type LLMInstanceOptions, type LLMModel, type LLMProviders, LLMPurposes, type LLMUploadFileOptions, type LLMUploadFileResult } from '../LLMService.typedefs';
2
+ import { type LLMAssistanceOptions, type LLMAssistanceResult, type LLMAssistanceMessage, type LLMCreateAssistantOptions, type LLMCreateAssistantResult, type LLMCreateChatOptions, type LLMCreateChatResult, type LLMCreateFileStorageOptions, type LLMCreateFileStorageResult, type LLMInstanceOptions, type LLMModel, type LLMProviders, LLMPurposes, type LLMUploadFileOptions, type LLMUploadFileResult } from '../LLMService.typedefs';
3
3
  import { LLMBaseService } from '../services';
4
4
  export declare abstract class LLMAssistanceService<Provider extends LLMProviders> extends LLMBaseService<LLMPurposes.Assistance, Provider> {
5
5
  constructor(provider: Provider, logger: Logger, options: LLMInstanceOptions[Provider]);
@@ -12,7 +12,7 @@ export declare abstract class LLMAssistanceService<Provider extends LLMProviders
12
12
  abstract createChat(options: LLMCreateChatOptions<Provider>): Promise<LLMCreateChatResult>;
13
13
  abstract deleteChat(chatId: string): Promise<void>;
14
14
  abstract assistInChat(options: LLMAssistanceOptions): Promise<LLMAssistanceResult>;
15
- abstract countTokens(messages: LLMCompletionMessage[], model: LLMModel<Provider>): Promise<number>;
15
+ abstract countTokens(messages: LLMAssistanceMessage[], model: LLMModel<Provider>): Promise<number>;
16
16
  protected isImageFile(file: LLMUploadFileOptions): boolean;
17
17
  protected isNotImageFile: (file: LLMUploadFileOptions) => boolean;
18
18
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mate-academy/llm-gateway",
3
- "version": "2.2.1-canary.2",
3
+ "version": "2.2.2",
4
4
  "description": "A gateway package for LLM services.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",