@mate-academy/llm-gateway 1.0.0 → 1.0.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/README.md +178 -0
- package/dist/LLMService.constants.d.ts +2 -2
- package/dist/LLMService.constants.js.map +1 -1
- package/dist/LLMService.entity.d.ts +1 -1
- package/dist/LLMService.factory.d.ts +2 -2
- package/dist/LLMService.factory.js.map +1 -1
- package/dist/LLMService.typedefs.d.ts +8 -8
- package/dist/LLMService.typedefs.js.map +1 -1
- package/dist/providers/GoogleGenerativeAI/GoogleGenerativeAI.constants.d.ts +1 -1
- package/dist/providers/GoogleGenerativeAI/GoogleGenerativeAI.entity.d.ts +2 -2
- package/dist/providers/GoogleGenerativeAI/GoogleGenerativeAIService.factory.d.ts +2 -2
- package/dist/providers/GoogleGenerativeAI/services/GoogleGenerativeAIAssistance.service.d.ts +2 -2
- package/dist/providers/GoogleGenerativeAI/services/GoogleGenerativeAICompletion.service.d.ts +2 -2
- package/dist/providers/OpenAI/OpenAI.constants.d.ts +1 -1
- package/dist/providers/OpenAI/OpenAIService.factory.d.ts +2 -2
- package/dist/providers/OpenAI/services/OpenAIAssistance.service.d.ts +2 -2
- package/dist/providers/OpenAI/services/OpenAICompletion.service.d.ts +2 -2
- package/dist/providers/OpenAI/services/OpenAICompletion.service.js.map +1 -1
- package/dist/services/LLMAssistanceService.abstract.d.ts +2 -2
- package/dist/services/LLMBaseService.abstract.d.ts +2 -2
- package/dist/services/LLMCompletionService.abstract.d.ts +2 -2
- package/dist/services/LLMServicePurposeFactory.abstract.d.ts +2 -2
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
# LLM Gateway
|
|
2
|
+
|
|
3
|
+
A standardized interface for interacting with various Large Language Model (LLM) providers.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
The `@mate-academy/llm-gateway` package provides a unified way to work with different LLM providers like OpenAI and Google Generative AI. It abstracts the implementation details of each provider, allowing you to easily switch between them without changing your application code.
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install @mate-academy/llm-gateway
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Features
|
|
16
|
+
|
|
17
|
+
- Support for multiple LLM providers (OpenAI, Google Generative AI)
|
|
18
|
+
- Standardized completion service interface
|
|
19
|
+
- Standardized assistance service interface
|
|
20
|
+
- Factory pattern for easy provider selection
|
|
21
|
+
- Consistent logging across all providers
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
### Basic Setup
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
import {
|
|
29
|
+
LLMProviders,
|
|
30
|
+
LLMServiceFactory,
|
|
31
|
+
LLMCompletionService,
|
|
32
|
+
LLMAssistanceService
|
|
33
|
+
} from '@mate-academy/llm-gateway';
|
|
34
|
+
|
|
35
|
+
// Define provider options
|
|
36
|
+
const llmProviderOptions = LLMServiceFactory.resolveProviderOptions(
|
|
37
|
+
LLMProviders.OpenAI, // chosen provider
|
|
38
|
+
{
|
|
39
|
+
[LLMProviders.OpenAI]: {
|
|
40
|
+
apiKey: 'your-openai-api-key',
|
|
41
|
+
organization: 'your-organization-id', // optional
|
|
42
|
+
baseURL: 'https://api.openai.com/v1', // optional
|
|
43
|
+
},
|
|
44
|
+
[LLMProviders.GoogleGenerativeAI]: {
|
|
45
|
+
apiKey: 'your-google-ai-api-key',
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
// Get completion service
|
|
51
|
+
const completionService = LLMServiceFactory.getCompletionService(
|
|
52
|
+
LLMProviders.OpenAI,
|
|
53
|
+
logger, // your logger instance
|
|
54
|
+
llmProviderOptions,
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
// Get assistance service
|
|
58
|
+
const assistanceService = LLMServiceFactory.getAssistanceService(
|
|
59
|
+
LLMProviders.OpenAI,
|
|
60
|
+
logger, // your logger instance
|
|
61
|
+
llmProviderOptions,
|
|
62
|
+
);
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Real-world Example
|
|
66
|
+
|
|
67
|
+
Here's how you might integrate the LLM Gateway in a use case class:
|
|
68
|
+
|
|
69
|
+
```typescript
|
|
70
|
+
import {
|
|
71
|
+
LLMProviders,
|
|
72
|
+
LLMServiceFactory,
|
|
73
|
+
LLMCompletionService,
|
|
74
|
+
LLMAssistanceService,
|
|
75
|
+
} from '@mate-academy/llm-gateway';
|
|
76
|
+
|
|
77
|
+
class MyUseCase {
|
|
78
|
+
private llmCompletionService: LLMCompletionService<LLMProviders>;
|
|
79
|
+
private llmAssistanceService: LLMAssistanceService<LLMProviders>;
|
|
80
|
+
|
|
81
|
+
constructor(logger, config) {
|
|
82
|
+
const llmProviderOptions = LLMServiceFactory.resolveProviderOptions(
|
|
83
|
+
config.llmProvider,
|
|
84
|
+
{
|
|
85
|
+
[LLMProviders.OpenAI]: {
|
|
86
|
+
apiKey: config.openAIApiKey,
|
|
87
|
+
organization: config.openAIOrgId,
|
|
88
|
+
baseURL: config.openAIBaseUrl,
|
|
89
|
+
},
|
|
90
|
+
[LLMProviders.GoogleGenerativeAI]: {
|
|
91
|
+
apiKey: config.googleAIApiKey,
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
this.llmCompletionService = LLMServiceFactory.getCompletionService(
|
|
97
|
+
config.llmProvider,
|
|
98
|
+
logger,
|
|
99
|
+
llmProviderOptions,
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
this.llmAssistanceService = LLMServiceFactory.getAssistanceService(
|
|
103
|
+
config.llmProvider,
|
|
104
|
+
logger,
|
|
105
|
+
llmProviderOptions,
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
async processRequest(prompt) {
|
|
110
|
+
// Use completion service
|
|
111
|
+
const completion = await this.llmCompletionService.complete({
|
|
112
|
+
prompt,
|
|
113
|
+
maxTokens: 500,
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
return completion;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## API Reference
|
|
122
|
+
|
|
123
|
+
### LLMProviders
|
|
124
|
+
|
|
125
|
+
Enum of supported LLM providers:
|
|
126
|
+
|
|
127
|
+
```typescript
|
|
128
|
+
enum LLMProviders {
|
|
129
|
+
OpenAI = 'openai',
|
|
130
|
+
GoogleGenerativeAI = 'google',
|
|
131
|
+
// other providers may be added in the future
|
|
132
|
+
}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### LLMServiceFactory
|
|
136
|
+
|
|
137
|
+
Factory class for creating LLM service instances.
|
|
138
|
+
|
|
139
|
+
#### Methods
|
|
140
|
+
|
|
141
|
+
- `resolveProviderOptions(provider, optionsMap)`: Resolves the options for the specified provider
|
|
142
|
+
- `getCompletionService(provider, logger, options)`: Creates a completion service instance
|
|
143
|
+
- `getAssistanceService(provider, logger, options)`: Creates an assistance service instance
|
|
144
|
+
|
|
145
|
+
### LLMCompletionService
|
|
146
|
+
|
|
147
|
+
Interface for text completion services.
|
|
148
|
+
|
|
149
|
+
#### Methods
|
|
150
|
+
|
|
151
|
+
- `complete(params)`: Generate a completion for the given prompt
|
|
152
|
+
|
|
153
|
+
### LLMAssistanceService
|
|
154
|
+
|
|
155
|
+
Interface for chat/assistance services.
|
|
156
|
+
|
|
157
|
+
#### Methods
|
|
158
|
+
|
|
159
|
+
- `createAssistant(params)`: Create a new assistant
|
|
160
|
+
- `getAssistant(assistantId)`: Retrieve an existing assistant
|
|
161
|
+
- `createThread(params)`: Create a new thread
|
|
162
|
+
- `addMessage(threadId, params)`: Add a message to a thread
|
|
163
|
+
- `runAssistant(params)`: Run an assistant on a thread
|
|
164
|
+
- `getRunResult(params)`: Get the result of an assistant run
|
|
165
|
+
|
|
166
|
+
## Supported Providers
|
|
167
|
+
|
|
168
|
+
### OpenAI
|
|
169
|
+
|
|
170
|
+
Supports both completion and assistance APIs. For more information, see [OpenAI API documentation](https://platform.openai.com/docs/api-reference).
|
|
171
|
+
|
|
172
|
+
### Google Generative AI
|
|
173
|
+
|
|
174
|
+
Supports completion API through Google's Generative AI models. For more information, see [Google Generative AI documentation](https://ai.google.dev/docs).
|
|
175
|
+
|
|
176
|
+
## License
|
|
177
|
+
|
|
178
|
+
[MIT](LICENSE)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { LLMProviderModelsByPurpose, LLMProviders, LLMPurposes } from './LLMService.typedefs';
|
|
2
|
-
import { LLMServicePurposeFactory } from './services/LLMServicePurposeFactory.abstract';
|
|
1
|
+
import { type LLMProviderModelsByPurpose, LLMProviders, type LLMPurposes } from './LLMService.typedefs';
|
|
2
|
+
import { type LLMServicePurposeFactory } from './services/LLMServicePurposeFactory.abstract';
|
|
3
3
|
export declare const LLM_SERVICE_FACTORIES: {
|
|
4
4
|
[provider in LLMProviders]: LLMServicePurposeFactory<provider>;
|
|
5
5
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LLMService.constants.js","sourceRoot":"","sources":["../src/LLMService.constants.ts"],"names":[],"mappings":";;;AAAA,+
|
|
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,4 +1,4 @@
|
|
|
1
|
-
import { LLMCountTokensFunction, LLMMessage, LLMModel, LLMProviders } from './LLMService.typedefs';
|
|
1
|
+
import { type LLMCountTokensFunction, type LLMMessage, type LLMModel, type LLMProviders } from './LLMService.typedefs';
|
|
2
2
|
interface CombineMessagesOptions<Provider extends LLMProviders> {
|
|
3
3
|
modelContext?: LLMMessage[];
|
|
4
4
|
history?: LLMMessage[];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Logger } from '@mate-academy/core';
|
|
2
|
-
import { LLMInstanceOptions, LLMProviders, LLMPurposes, LLMServiceByPurpose } from './LLMService.typedefs';
|
|
1
|
+
import { type Logger } from '@mate-academy/core';
|
|
2
|
+
import { type LLMInstanceOptions, LLMProviders, LLMPurposes, type LLMServiceByPurpose } from './LLMService.typedefs';
|
|
3
3
|
export declare class LLMServiceFactory {
|
|
4
4
|
private static getService;
|
|
5
5
|
static getCompletionService<Provider extends LLMProviders>(provider: Provider, logger: Logger, options: LLMInstanceOptions[Provider]): LLMServiceByPurpose<Provider>[LLMPurposes.Completion];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LLMService.factory.js","sourceRoot":"","sources":["../src/LLMService.factory.ts"],"names":[],"mappings":";;;AACA,+DAK+B;AAC/B,iEAA+D;AAE/D,MAAa,iBAAiB;
|
|
1
|
+
{"version":3,"file":"LLMService.factory.js","sourceRoot":"","sources":["../src/LLMService.factory.ts"],"names":[],"mappings":";;;AACA,+DAK+B;AAC/B,iEAA+D;AAE/D,MAAa,iBAAiB;IAepB,MAAM,CAAC,UAAU,CAIvB,OAAgB,EAChB,QAAkB,EAClB,MAAc,EACd,OAAqC;QAErC,QAAQ,QAAQ,EAAE,CAAC;YACjB,KAAK,kCAAY,CAAC,MAAM,CAAC;YACzB,KAAK,kCAAY,CAAC,kBAAkB;gBAClC,OAAO,4CAAqB,CAAC,QAAQ,CAAC;qBACnC,aAAa,CACZ,OAAO,EACP,MAAM,EACN,OAAO,CACR,CAAC;YAEN;gBACE,MAAM,IAAI,KAAK,CAAC,aAAa,QAAQ,oBAAoB,CAAC,CAAC;QAC/D,CAAC;IACH,CAAC;IAYD,MAAM,CAAC,oBAAoB,CACzB,QAAkB,EAClB,MAAc,EACd,OAAqC;QAErC,OAAO,IAAI,CAAC,UAAU,CAAC,iCAAW,CAAC,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IAC5E,CAAC;IAYD,MAAM,CAAC,oBAAoB,CACzB,QAAkB,EAClB,MAAc,EACd,OAAqC;QAErC,OAAO,IAAI,CAAC,UAAU,CAAC,iCAAW,CAAC,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IAC5E,CAAC;IAWD,MAAM,CAAC,sBAAsB,CAC3B,QAAkB,EAClB,OAAuD;QAEvD,OAAO,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC3B,CAAC;CACF;AA1FD,8CA0FC"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Logger } from '@mate-academy/core';
|
|
2
|
-
import { ClientOptions, OpenAI } from 'openai';
|
|
3
|
-
import { GoogleGenAI } from '@google/genai';
|
|
4
|
-
import { OpenAIModelNames } from './providers/OpenAI/OpenAI.typedefs';
|
|
5
|
-
import { GoogleGenerativeAIModelNames } from './providers/GoogleGenerativeAI/GoogleGenerativeAI.typedefs';
|
|
6
|
-
import { LLMCompletionService } from './services/LLMCompletionService.abstract';
|
|
7
|
-
import { LLMAssistanceService } from './services/LLMAssistanceService.abstract';
|
|
1
|
+
import { type Logger } from '@mate-academy/core';
|
|
2
|
+
import { type ClientOptions, type OpenAI } from 'openai';
|
|
3
|
+
import { type GoogleGenAI } from '@google/genai';
|
|
4
|
+
import { type OpenAIModelNames } from './providers/OpenAI/OpenAI.typedefs';
|
|
5
|
+
import { type GoogleGenerativeAIModelNames } from './providers/GoogleGenerativeAI/GoogleGenerativeAI.typedefs';
|
|
6
|
+
import { type LLMCompletionService } from './services/LLMCompletionService.abstract';
|
|
7
|
+
import { type LLMAssistanceService } from './services/LLMAssistanceService.abstract';
|
|
8
8
|
export declare enum LLMProviders {
|
|
9
9
|
OpenAI = "OpenAI",
|
|
10
10
|
GoogleGenerativeAI = "GoogleGenerativeAI"
|
|
@@ -56,7 +56,7 @@ export interface LLMMessage {
|
|
|
56
56
|
content: string;
|
|
57
57
|
}
|
|
58
58
|
export type LLMRequestError = Error;
|
|
59
|
-
export type LLMRequestResult<
|
|
59
|
+
export type LLMRequestResult<R> = R | {
|
|
60
60
|
error: LLMRequestError;
|
|
61
61
|
};
|
|
62
62
|
export type LLMCompletionResult = LLMRequestResult<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LLMService.typedefs.js","sourceRoot":"","sources":["../src/LLMService.typedefs.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"LLMService.typedefs.js","sourceRoot":"","sources":["../src/LLMService.typedefs.ts"],"names":[],"mappings":";;;AAWA,IAAY,YAGX;AAHD,WAAY,YAAY;IACtB,iCAAiB,CAAA;IACjB,yDAAyC,CAAA;AAC3C,CAAC,EAHW,YAAY,4BAAZ,YAAY,QAGvB;AAqBD,IAAY,WAGX;AAHD,WAAY,WAAW;IACrB,wCAAyB,CAAA;IACzB,wCAAyB,CAAA;AAC3B,CAAC,EAHW,WAAW,2BAAX,WAAW,QAGtB;AAwFD,IAAY,QAGX;AAHD,WAAY,QAAQ;IAClB,yBAAa,CAAA;IACb,mCAAuB,CAAA;AACzB,CAAC,EAHW,QAAQ,wBAAR,QAAQ,QAGnB;AAwCD,IAAY,sBAGX;AAHD,WAAY,sBAAsB;IAChC,2CAAiB,CAAA;IACjB,mDAAyB,CAAA;AAC3B,CAAC,EAHW,sBAAsB,sCAAtB,sBAAsB,QAGjC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LLMProviderModelsByPurpose, LLMProviders, LLMPurposes, LLMServiceBuilder } from '../../LLMService.typedefs';
|
|
1
|
+
import { type LLMProviderModelsByPurpose, type LLMProviders, LLMPurposes, type LLMServiceBuilder } from '../../LLMService.typedefs';
|
|
2
2
|
export declare const MIN_CACHE_CONTENT_LENGTH = 32768;
|
|
3
3
|
export declare const GOOGLE_AI_MODELS: LLMProviderModelsByPurpose<LLMPurposes, LLMProviders.GoogleGenerativeAI>;
|
|
4
4
|
export declare const GOOGLE_AI_SERVICE_BUILDERS: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Part, GoogleGenAI, ContentListUnion, GenerateContentParameters } from '@google/genai';
|
|
2
|
-
import { LLMMessage, LLMModel, LLMProviders, LLMUploadedFile } from '../../LLMService.typedefs';
|
|
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';
|
|
3
3
|
export declare class GoogleGenerativeAIEntity {
|
|
4
4
|
static getContentParameters(model: LLMModel<LLMProviders.GoogleGenerativeAI>, messages: LLMMessage[], instructions?: string): GenerateContentParameters;
|
|
5
5
|
static getFileDataParts(uploadedFiles: LLMUploadedFile[]): Pick<Part, 'fileData'>[];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Logger } from '@mate-academy/core';
|
|
2
|
-
import { LLMInstanceOptions, LLMProviders, LLMPurposes, LLMServiceByPurpose } from '../../LLMService.typedefs';
|
|
1
|
+
import { type Logger } from '@mate-academy/core';
|
|
2
|
+
import { type LLMInstanceOptions, LLMProviders, type LLMPurposes, type LLMServiceByPurpose } from '../../LLMService.typedefs';
|
|
3
3
|
import { LLMServicePurposeFactory } from '../../services';
|
|
4
4
|
export declare class GoogleGenerativeAIServiceFactory extends LLMServicePurposeFactory<LLMProviders.GoogleGenerativeAI> {
|
|
5
5
|
createService<Purpose extends LLMPurposes>(purpose: Purpose, logger: Logger, options: LLMInstanceOptions[LLMProviders.GoogleGenerativeAI]): LLMServiceByPurpose<LLMProviders.GoogleGenerativeAI>[Purpose];
|
package/dist/providers/GoogleGenerativeAI/services/GoogleGenerativeAIAssistance.service.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Logger } from '@mate-academy/core';
|
|
1
|
+
import { type Logger } from '@mate-academy/core';
|
|
2
2
|
import { GoogleGenAI } from '@google/genai';
|
|
3
|
-
import { LLMAssistanceOptions, LLMAssistanceResult, LLMCreateAssistantResult, LLMCreateChatOptions, LLMCreateChatResult, LLMCreateFileStorageOptions, LLMCreateFileStorageResult, LLMInstanceOptions, LLMProviders, LLMUploadFile, LLMUploadFileResult } from '../../../LLMService.typedefs';
|
|
3
|
+
import { type LLMAssistanceOptions, type LLMAssistanceResult, type LLMCreateAssistantResult, type LLMCreateChatOptions, type LLMCreateChatResult, type LLMCreateFileStorageOptions, type LLMCreateFileStorageResult, type LLMInstanceOptions, LLMProviders, type LLMUploadFile, type LLMUploadFileResult } from '../../../LLMService.typedefs';
|
|
4
4
|
import { LLMAssistanceService } from '../../../services';
|
|
5
5
|
export declare class GoogleGenerativeAIAssistanceService extends LLMAssistanceService<LLMProviders.GoogleGenerativeAI> {
|
|
6
6
|
#private;
|
package/dist/providers/GoogleGenerativeAI/services/GoogleGenerativeAICompletion.service.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Logger } from '@mate-academy/core';
|
|
1
|
+
import { type Logger } from '@mate-academy/core';
|
|
2
2
|
import { GoogleGenAI } from '@google/genai';
|
|
3
|
-
import { LLMCompletionResult, LLMInstanceOptions, LLMProviders, LLMSendMessageOptions } from '../../../LLMService.typedefs';
|
|
3
|
+
import { type LLMCompletionResult, type LLMInstanceOptions, LLMProviders, type LLMSendMessageOptions } from '../../../LLMService.typedefs';
|
|
4
4
|
import { LLMCompletionService } from '../../../services';
|
|
5
5
|
export declare class GoogleGenerativeAICompletionService extends LLMCompletionService<LLMProviders.GoogleGenerativeAI> {
|
|
6
6
|
#private;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LLMProviderModelsByPurpose, LLMProviders, LLMPurposes, LLMServiceBuilder } from '../../LLMService.typedefs';
|
|
1
|
+
import { type LLMProviderModelsByPurpose, type LLMProviders, LLMPurposes, type LLMServiceBuilder } from '../../LLMService.typedefs';
|
|
2
2
|
export declare const OPEN_AI_MODELS: LLMProviderModelsByPurpose<LLMPurposes, LLMProviders.OpenAI>;
|
|
3
3
|
export declare const OPEN_AI_SERVICE_BUILDERS: {
|
|
4
4
|
[purpose in LLMPurposes]: (LLMServiceBuilder<LLMProviders.OpenAI, purpose> | null);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Logger } from '@mate-academy/core';
|
|
2
|
-
import { LLMInstanceOptions, LLMProviders, LLMPurposes, LLMServiceByPurpose } from '../../LLMService.typedefs';
|
|
1
|
+
import { type Logger } from '@mate-academy/core';
|
|
2
|
+
import { type LLMInstanceOptions, LLMProviders, type LLMPurposes, type LLMServiceByPurpose } from '../../LLMService.typedefs';
|
|
3
3
|
import { LLMServicePurposeFactory } from '../../services';
|
|
4
4
|
export declare class OpenAIServiceFactory extends LLMServicePurposeFactory<LLMProviders.OpenAI> {
|
|
5
5
|
createService<Purpose extends LLMPurposes>(purpose: Purpose, logger: Logger, options: LLMInstanceOptions[LLMProviders.OpenAI]): LLMServiceByPurpose<LLMProviders.OpenAI>[Purpose];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Logger } from '@mate-academy/core';
|
|
1
|
+
import { type Logger } from '@mate-academy/core';
|
|
2
2
|
import { OpenAI } from 'openai';
|
|
3
|
-
import { LLMAssistanceOptions, LLMAssistanceResult, LLMCreateAssistantOptions, LLMCreateAssistantResult, LLMCreateChatOptions, LLMCreateChatResult, LLMCreateFileStorageOptions, LLMCreateFileStorageResult, LLMInstanceOptions, LLMProviders, LLMUploadFile, LLMUploadFileResult } from '../../../LLMService.typedefs';
|
|
3
|
+
import { type LLMAssistanceOptions, type LLMAssistanceResult, type LLMCreateAssistantOptions, type LLMCreateAssistantResult, type LLMCreateChatOptions, type LLMCreateChatResult, type LLMCreateFileStorageOptions, type LLMCreateFileStorageResult, type LLMInstanceOptions, LLMProviders, type LLMUploadFile, type LLMUploadFileResult } from '../../../LLMService.typedefs';
|
|
4
4
|
import { LLMAssistanceService } from '../../../services';
|
|
5
5
|
export declare class OpenAIAssistanceService extends LLMAssistanceService<LLMProviders.OpenAI> {
|
|
6
6
|
#private;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Logger } from '@mate-academy/core';
|
|
1
|
+
import { type Logger } from '@mate-academy/core';
|
|
2
2
|
import { OpenAI } from 'openai';
|
|
3
|
-
import { LLMCompletionResult, LLMInstanceOptions, LLMProviders, LLMSendMessageOptions } from '../../../LLMService.typedefs';
|
|
3
|
+
import { type LLMCompletionResult, type LLMInstanceOptions, LLMProviders, type LLMSendMessageOptions } from '../../../LLMService.typedefs';
|
|
4
4
|
import { LLMCompletionService } from '../../../services';
|
|
5
5
|
export declare class OpenAICompletionService extends LLMCompletionService<LLMProviders.OpenAI> {
|
|
6
6
|
#private;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OpenAICompletion.service.js","sourceRoot":"","sources":["../../../../src/providers/OpenAI/services/OpenAICompletion.service.ts"],"names":[],"mappings":";;;AACA,mCAAgC;AAChC,sEAKsC;AACtC,kEAA8D;AAC9D,gDAE2B;AAC3B,oDAAgD;AAEhD,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,
|
|
1
|
+
{"version":3,"file":"OpenAICompletion.service.js","sourceRoot":"","sources":["../../../../src/providers/OpenAI/services/OpenAICompletion.service.ts"],"names":[],"mappings":";;;AACA,mCAAgC;AAChC,sEAKsC;AACtC,kEAA8D;AAC9D,gDAE2B;AAC3B,oDAAgD;AAEhD,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,oCAAgB,CAAC,wBAAwB,CAAC;gBACvE,OAAO;gBACP,OAAO,EAAE,OAAO,CAAC,OAAO;gBACxB,KAAK;gBACL,aAAa;aACd,CAAC,CAAC;YAEH,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC;gBAC7D,KAAK,EAAE,KAAK,CAAC,IAAI;gBACjB,QAAQ,EAAE,gBAAgB;gBAC1B,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;AA3DD,0DA2DC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Logger } from '@mate-academy/core';
|
|
2
|
-
import { LLMAssistanceOptions, LLMAssistanceResult, LLMCreateAssistantOptions, LLMCreateAssistantResult, LLMCreateChatOptions, LLMCreateChatResult, LLMCreateFileStorageOptions, LLMCreateFileStorageResult, LLMInstanceOptions, LLMProviders, LLMPurposes, LLMUploadFile, LLMUploadFileResult } from '../LLMService.typedefs';
|
|
1
|
+
import { type Logger } from '@mate-academy/core';
|
|
2
|
+
import { type LLMAssistanceOptions, type LLMAssistanceResult, type LLMCreateAssistantOptions, type LLMCreateAssistantResult, type LLMCreateChatOptions, type LLMCreateChatResult, type LLMCreateFileStorageOptions, type LLMCreateFileStorageResult, type LLMInstanceOptions, type LLMProviders, LLMPurposes, type LLMUploadFile, 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]);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Logger } from '@mate-academy/core';
|
|
2
|
-
import { LLMInstanceOptions, LLMInstances, LLMProviderAvailableModels, LLMProviders, LLMPurposes } from '../LLMService.typedefs';
|
|
1
|
+
import { type Logger } from '@mate-academy/core';
|
|
2
|
+
import { type LLMInstanceOptions, type LLMInstances, type LLMProviderAvailableModels, type LLMProviders, type LLMPurposes } from '../LLMService.typedefs';
|
|
3
3
|
export declare abstract class LLMBaseService<Purpose extends LLMPurposes, Provider extends LLMProviders> {
|
|
4
4
|
readonly provider: Provider;
|
|
5
5
|
readonly serviceName: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Logger } from '@mate-academy/core';
|
|
2
|
-
import { LLMPurposes, LLMProviders, LLMSendMessageOptions, LLMCompletionResult, LLMInstanceOptions } from '../LLMService.typedefs';
|
|
1
|
+
import { type Logger } from '@mate-academy/core';
|
|
2
|
+
import { LLMPurposes, type LLMProviders, type LLMSendMessageOptions, type LLMCompletionResult, type LLMInstanceOptions } from '../LLMService.typedefs';
|
|
3
3
|
import { LLMBaseService } from '../services';
|
|
4
4
|
export declare abstract class LLMCompletionService<Provider extends LLMProviders> extends LLMBaseService<LLMPurposes.Completion, Provider> {
|
|
5
5
|
constructor(provider: Provider, logger: Logger, options: LLMInstanceOptions[Provider]);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Logger } from '@mate-academy/core';
|
|
2
|
-
import { LLMInstanceOptions, LLMProviders, LLMPurposes, LLMServiceByPurpose } from '../LLMService.typedefs';
|
|
1
|
+
import { type Logger } from '@mate-academy/core';
|
|
2
|
+
import { type LLMInstanceOptions, type LLMProviders, type LLMPurposes, type LLMServiceByPurpose } from '../LLMService.typedefs';
|
|
3
3
|
export declare abstract class LLMServicePurposeFactory<Provider extends LLMProviders> {
|
|
4
4
|
abstract createService<Purpose extends LLMPurposes>(purpose: Purpose, logger: Logger, options: LLMInstanceOptions[Provider]): LLMServiceByPurpose<Provider>[Purpose];
|
|
5
5
|
}
|