@memberjunction/ai-lmstudio 2.81.0
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/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/dist/models/lm-studio.d.ts +54 -0
- package/dist/models/lm-studio.d.ts.map +1 -0
- package/dist/models/lm-studio.js +310 -0
- package/dist/models/lm-studio.js.map +1 -0
- package/package.json +26 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./models/lm-studio"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAmC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { BaseLLM, ChatParams, ChatResult, ClassifyParams, ClassifyResult, SummarizeParams, SummarizeResult } from '@memberjunction/ai';
|
|
2
|
+
import { LMStudioClient } from '@lmstudio/sdk';
|
|
3
|
+
/**
|
|
4
|
+
* LM Studio implementation of the BaseLLM class
|
|
5
|
+
*/
|
|
6
|
+
export declare class LMStudioLLM extends BaseLLM {
|
|
7
|
+
private _client;
|
|
8
|
+
constructor(apiKey?: string);
|
|
9
|
+
/**
|
|
10
|
+
* Read only getter method to get the LM Studio client instance
|
|
11
|
+
*/
|
|
12
|
+
get LMStudioClient(): LMStudioClient;
|
|
13
|
+
/**
|
|
14
|
+
* Read only getter method to get the LM Studio client instance
|
|
15
|
+
*/
|
|
16
|
+
get client(): LMStudioClient;
|
|
17
|
+
/**
|
|
18
|
+
* LM Studio supports streaming
|
|
19
|
+
*/
|
|
20
|
+
get SupportsStreaming(): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Check if the provider supports thinking models
|
|
23
|
+
* LM Studio can support thinking models depending on the loaded model
|
|
24
|
+
*/
|
|
25
|
+
protected supportsThinkingModels(): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Override SetAdditionalSettings to handle LM Studio specific settings
|
|
28
|
+
*/
|
|
29
|
+
SetAdditionalSettings(settings: Record<string, any>): void;
|
|
30
|
+
/**
|
|
31
|
+
* Implementation of non-streaming chat completion for LM Studio
|
|
32
|
+
*/
|
|
33
|
+
protected nonStreamingChatCompletion(params: ChatParams): Promise<ChatResult>;
|
|
34
|
+
/**
|
|
35
|
+
* Create a streaming request for LM Studio
|
|
36
|
+
*/
|
|
37
|
+
protected createStreamingRequest(params: ChatParams): Promise<any>;
|
|
38
|
+
/**
|
|
39
|
+
* Process a streaming chunk from LM Studio
|
|
40
|
+
*/
|
|
41
|
+
protected processStreamingChunk(chunk: any): {
|
|
42
|
+
content: string;
|
|
43
|
+
finishReason?: string;
|
|
44
|
+
usage?: any;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Create the final response from streaming results for LM Studio
|
|
48
|
+
*/
|
|
49
|
+
protected finalizeStreamingResponse(accumulatedContent: string | null | undefined, lastChunk: any | null | undefined, usage: any | null | undefined): ChatResult;
|
|
50
|
+
SummarizeText(_params: SummarizeParams): Promise<SummarizeResult>;
|
|
51
|
+
ClassifyText(_params: ClassifyParams): Promise<ClassifyResult>;
|
|
52
|
+
}
|
|
53
|
+
export declare function LoadLMStudioLLM(): void;
|
|
54
|
+
//# sourceMappingURL=lm-studio.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lm-studio.d.ts","sourceRoot":"","sources":["../../src/models/lm-studio.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAqC,cAAc,EAAE,cAAc,EAAE,eAAe,EAAE,eAAe,EAA6B,MAAM,oBAAoB,CAAC;AAErM,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C;;GAEG;AACH,qBACa,WAAY,SAAQ,OAAO;IACpC,OAAO,CAAC,OAAO,CAAiB;gBAEpB,MAAM,CAAC,EAAE,MAAM;IAK3B;;OAEG;IACH,IAAW,cAAc,IAAI,cAAc,CAE1C;IAED;;OAEG;IACH,IAAW,MAAM,IAAI,cAAc,CAElC;IAED;;OAEG;IACH,IAAoB,iBAAiB,IAAI,OAAO,CAE/C;IAED;;;OAGG;IACH,SAAS,CAAC,sBAAsB,IAAI,OAAO;IAI3C;;OAEG;IACa,qBAAqB,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI;IAY1E;;OAEG;cACa,0BAA0B,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;IA+HnF;;OAEG;cACa,sBAAsB,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC;IAyDxE;;OAEG;IACH,SAAS,CAAC,qBAAqB,CAAC,KAAK,EAAE,GAAG,GAAG;QACzC,OAAO,EAAE,MAAM,CAAC;QAChB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,KAAK,CAAC,EAAE,GAAG,CAAC;KACf;IAkCD;;OAEG;IACH,SAAS,CAAC,yBAAyB,CAC/B,kBAAkB,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAC7C,SAAS,EAAE,GAAG,GAAG,IAAI,GAAG,SAAS,EACjC,KAAK,EAAE,GAAG,GAAG,IAAI,GAAG,SAAS,GAC9B,UAAU;IAwCA,aAAa,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC;IAIjE,YAAY,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC;CAG9E;AAED,wBAAgB,eAAe,SAE9B"}
|
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.LoadLMStudioLLM = exports.LMStudioLLM = void 0;
|
|
10
|
+
const ai_1 = require("@memberjunction/ai");
|
|
11
|
+
const global_1 = require("@memberjunction/global");
|
|
12
|
+
const sdk_1 = require("@lmstudio/sdk");
|
|
13
|
+
/**
|
|
14
|
+
* LM Studio implementation of the BaseLLM class
|
|
15
|
+
*/
|
|
16
|
+
let LMStudioLLM = class LMStudioLLM extends ai_1.BaseLLM {
|
|
17
|
+
constructor(apiKey) {
|
|
18
|
+
super(apiKey || ''); // LM Studio doesn't require API key for local usage
|
|
19
|
+
this._client = new sdk_1.LMStudioClient();
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Read only getter method to get the LM Studio client instance
|
|
23
|
+
*/
|
|
24
|
+
get LMStudioClient() {
|
|
25
|
+
return this._client;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Read only getter method to get the LM Studio client instance
|
|
29
|
+
*/
|
|
30
|
+
get client() {
|
|
31
|
+
return this.LMStudioClient;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* LM Studio supports streaming
|
|
35
|
+
*/
|
|
36
|
+
get SupportsStreaming() {
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Check if the provider supports thinking models
|
|
41
|
+
* LM Studio can support thinking models depending on the loaded model
|
|
42
|
+
*/
|
|
43
|
+
supportsThinkingModels() {
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Override SetAdditionalSettings to handle LM Studio specific settings
|
|
48
|
+
*/
|
|
49
|
+
SetAdditionalSettings(settings) {
|
|
50
|
+
super.SetAdditionalSettings(settings);
|
|
51
|
+
// Handle LM Studio-specific settings like base URL
|
|
52
|
+
if (settings.baseUrl) {
|
|
53
|
+
// LM Studio client can be configured with custom base URL
|
|
54
|
+
this._client = new sdk_1.LMStudioClient({
|
|
55
|
+
baseUrl: settings.baseUrl
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Implementation of non-streaming chat completion for LM Studio
|
|
61
|
+
*/
|
|
62
|
+
async nonStreamingChatCompletion(params) {
|
|
63
|
+
const startTime = new Date();
|
|
64
|
+
try {
|
|
65
|
+
// Get the model instance
|
|
66
|
+
const model = await this.client.llm.model(params.model);
|
|
67
|
+
// Convert MJ messages to LM Studio format
|
|
68
|
+
const messages = params.messages.map(m => ({
|
|
69
|
+
role: m.role,
|
|
70
|
+
content: Array.isArray(m.content) ?
|
|
71
|
+
m.content.map(block => block.content).join('\n') :
|
|
72
|
+
m.content
|
|
73
|
+
}));
|
|
74
|
+
// Create completion parameters
|
|
75
|
+
const completionParams = {
|
|
76
|
+
messages: messages,
|
|
77
|
+
temperature: params.temperature
|
|
78
|
+
};
|
|
79
|
+
// Add optional parameters
|
|
80
|
+
if (params.maxOutputTokens != null && params.maxOutputTokens > 0) {
|
|
81
|
+
completionParams.maxTokens = params.maxOutputTokens;
|
|
82
|
+
}
|
|
83
|
+
if (params.topP != null) {
|
|
84
|
+
completionParams.topP = params.topP;
|
|
85
|
+
}
|
|
86
|
+
if (params.seed != null) {
|
|
87
|
+
completionParams.seed = params.seed;
|
|
88
|
+
}
|
|
89
|
+
if (params.stopSequences != null && params.stopSequences.length > 0) {
|
|
90
|
+
completionParams.stop = params.stopSequences;
|
|
91
|
+
}
|
|
92
|
+
if (params.frequencyPenalty != null) {
|
|
93
|
+
completionParams.frequencyPenalty = params.frequencyPenalty;
|
|
94
|
+
}
|
|
95
|
+
if (params.presencePenalty != null) {
|
|
96
|
+
completionParams.presencePenalty = params.presencePenalty;
|
|
97
|
+
}
|
|
98
|
+
// LM Studio doesn't support topK in the same way - warn if provided
|
|
99
|
+
if (params.topK != null) {
|
|
100
|
+
console.warn('LM Studio provider may not support topK parameter in the expected way, ignoring');
|
|
101
|
+
}
|
|
102
|
+
// Handle response format
|
|
103
|
+
switch (params.responseFormat) {
|
|
104
|
+
case 'JSON':
|
|
105
|
+
// LM Studio may support JSON mode depending on the model
|
|
106
|
+
completionParams.responseFormat = { type: "json_object" };
|
|
107
|
+
break;
|
|
108
|
+
case 'ModelSpecific':
|
|
109
|
+
completionParams.responseFormat = params.modelSpecificResponseFormat;
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
// Make the completion request
|
|
113
|
+
const response = await model.complete(completionParams);
|
|
114
|
+
const endTime = new Date();
|
|
115
|
+
const choices = [{
|
|
116
|
+
message: {
|
|
117
|
+
role: ai_1.ChatMessageRole.assistant,
|
|
118
|
+
content: response.nonReasoningContent,
|
|
119
|
+
thinking: response.reasoningContent
|
|
120
|
+
},
|
|
121
|
+
finish_reason: 'stop', // LM Studio doesn't provide detailed finish reasons
|
|
122
|
+
index: 0
|
|
123
|
+
}];
|
|
124
|
+
// Create ModelUsage - LM Studio may not provide token counts
|
|
125
|
+
const usage = new ai_1.ModelUsage(0, 0); // Will be updated if available
|
|
126
|
+
// Try to extract usage information if available
|
|
127
|
+
if (response.stats) {
|
|
128
|
+
if (response.stats.promptTokensCount) {
|
|
129
|
+
usage.promptTokens = response.stats.promptTokensCount;
|
|
130
|
+
}
|
|
131
|
+
if (response.stats.predictedTokensCount) {
|
|
132
|
+
usage.completionTokens = response.stats.predictedTokensCount;
|
|
133
|
+
}
|
|
134
|
+
// Note: totalTokens is computed automatically by the getter
|
|
135
|
+
}
|
|
136
|
+
const result = {
|
|
137
|
+
success: true,
|
|
138
|
+
statusText: "OK",
|
|
139
|
+
startTime: startTime,
|
|
140
|
+
endTime: endTime,
|
|
141
|
+
timeElapsed: endTime.getTime() - startTime.getTime(),
|
|
142
|
+
data: {
|
|
143
|
+
choices: choices,
|
|
144
|
+
usage: usage
|
|
145
|
+
},
|
|
146
|
+
errorMessage: "",
|
|
147
|
+
exception: null,
|
|
148
|
+
};
|
|
149
|
+
// Add model-specific response details
|
|
150
|
+
result.modelSpecificResponseDetails = {
|
|
151
|
+
provider: 'lmstudio',
|
|
152
|
+
model: params.model,
|
|
153
|
+
stats: response.stats
|
|
154
|
+
};
|
|
155
|
+
return result;
|
|
156
|
+
}
|
|
157
|
+
catch (error) {
|
|
158
|
+
const endTime = new Date();
|
|
159
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
|
|
160
|
+
return {
|
|
161
|
+
success: false,
|
|
162
|
+
statusText: "Error",
|
|
163
|
+
startTime: startTime,
|
|
164
|
+
endTime: endTime,
|
|
165
|
+
timeElapsed: endTime.getTime() - startTime.getTime(),
|
|
166
|
+
data: {
|
|
167
|
+
choices: [],
|
|
168
|
+
usage: new ai_1.ModelUsage(0, 0)
|
|
169
|
+
},
|
|
170
|
+
errorMessage: errorMessage,
|
|
171
|
+
exception: error,
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Create a streaming request for LM Studio
|
|
177
|
+
*/
|
|
178
|
+
async createStreamingRequest(params) {
|
|
179
|
+
// Initialize streaming state for thinking extraction if supported
|
|
180
|
+
if (this.supportsThinkingModels()) {
|
|
181
|
+
this.initializeThinkingStreamState();
|
|
182
|
+
}
|
|
183
|
+
// Get the model instance
|
|
184
|
+
const model = await this.client.llm.model(params.model);
|
|
185
|
+
// Convert MJ messages to LM Studio format
|
|
186
|
+
const messages = params.messages.map(m => ({
|
|
187
|
+
role: m.role,
|
|
188
|
+
content: Array.isArray(m.content) ?
|
|
189
|
+
m.content.map(block => block.content).join('\n') :
|
|
190
|
+
m.content
|
|
191
|
+
}));
|
|
192
|
+
// Create streaming completion parameters
|
|
193
|
+
const completionParams = {
|
|
194
|
+
messages: messages,
|
|
195
|
+
temperature: params.temperature,
|
|
196
|
+
stream: true
|
|
197
|
+
};
|
|
198
|
+
// Add optional parameters
|
|
199
|
+
if (params.maxOutputTokens != null && params.maxOutputTokens > 0) {
|
|
200
|
+
completionParams.maxTokens = params.maxOutputTokens;
|
|
201
|
+
}
|
|
202
|
+
if (params.topP != null) {
|
|
203
|
+
completionParams.topP = params.topP;
|
|
204
|
+
}
|
|
205
|
+
if (params.seed != null) {
|
|
206
|
+
completionParams.seed = params.seed;
|
|
207
|
+
}
|
|
208
|
+
if (params.stopSequences != null && params.stopSequences.length > 0) {
|
|
209
|
+
completionParams.stop = params.stopSequences;
|
|
210
|
+
}
|
|
211
|
+
if (params.frequencyPenalty != null) {
|
|
212
|
+
completionParams.frequencyPenalty = params.frequencyPenalty;
|
|
213
|
+
}
|
|
214
|
+
if (params.presencePenalty != null) {
|
|
215
|
+
completionParams.presencePenalty = params.presencePenalty;
|
|
216
|
+
}
|
|
217
|
+
// Handle response format
|
|
218
|
+
switch (params.responseFormat) {
|
|
219
|
+
case 'JSON':
|
|
220
|
+
completionParams.responseFormat = { type: "json_object" };
|
|
221
|
+
break;
|
|
222
|
+
case 'ModelSpecific':
|
|
223
|
+
completionParams.responseFormat = params.modelSpecificResponseFormat;
|
|
224
|
+
break;
|
|
225
|
+
}
|
|
226
|
+
return model.complete(completionParams);
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Process a streaming chunk from LM Studio
|
|
230
|
+
*/
|
|
231
|
+
processStreamingChunk(chunk) {
|
|
232
|
+
let content = '';
|
|
233
|
+
let finishReason = undefined;
|
|
234
|
+
// LM Studio streaming format may be different
|
|
235
|
+
// This will need to be adjusted based on actual LM Studio streaming response format
|
|
236
|
+
if (chunk && typeof chunk === 'string') {
|
|
237
|
+
const rawContent = chunk;
|
|
238
|
+
// Process the content with thinking extraction if supported
|
|
239
|
+
content = this.supportsThinkingModels()
|
|
240
|
+
? this.processStreamChunkWithThinking(rawContent)
|
|
241
|
+
: rawContent;
|
|
242
|
+
}
|
|
243
|
+
else if (chunk?.content) {
|
|
244
|
+
const rawContent = chunk.content;
|
|
245
|
+
// Process the content with thinking extraction if supported
|
|
246
|
+
content = this.supportsThinkingModels()
|
|
247
|
+
? this.processStreamChunkWithThinking(rawContent)
|
|
248
|
+
: rawContent;
|
|
249
|
+
}
|
|
250
|
+
// Check for finish reason
|
|
251
|
+
if (chunk?.finished) {
|
|
252
|
+
finishReason = 'stop';
|
|
253
|
+
}
|
|
254
|
+
return {
|
|
255
|
+
content,
|
|
256
|
+
finishReason,
|
|
257
|
+
usage: chunk?.stats || null
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Create the final response from streaming results for LM Studio
|
|
262
|
+
*/
|
|
263
|
+
finalizeStreamingResponse(accumulatedContent, lastChunk, usage) {
|
|
264
|
+
// Extract finish reason from last chunk if available
|
|
265
|
+
let finishReason = 'stop';
|
|
266
|
+
if (lastChunk?.finished) {
|
|
267
|
+
finishReason = 'stop';
|
|
268
|
+
}
|
|
269
|
+
// For LM Studio, we may have usage metrics from the final chunk
|
|
270
|
+
const promptTokens = usage?.promptTokensCount || lastChunk?.stats?.promptTokensCount || 0;
|
|
271
|
+
const completionTokens = usage?.predictedTokensCount || lastChunk?.stats?.predictedTokensCount || 0;
|
|
272
|
+
// Create dates (will be overridden by base class)
|
|
273
|
+
const now = new Date();
|
|
274
|
+
// Create a proper ChatResult instance with constructor params
|
|
275
|
+
const result = new ai_1.ChatResult(true, now, now);
|
|
276
|
+
// Get thinking content from streaming state if available
|
|
277
|
+
const thinkingContent = this.thinkingStreamState?.accumulatedThinking.trim();
|
|
278
|
+
// Set all properties
|
|
279
|
+
result.data = {
|
|
280
|
+
choices: [{
|
|
281
|
+
message: this.addThinkingToMessage({
|
|
282
|
+
role: ai_1.ChatMessageRole.assistant,
|
|
283
|
+
content: accumulatedContent ? accumulatedContent : ''
|
|
284
|
+
}, thinkingContent),
|
|
285
|
+
finish_reason: finishReason,
|
|
286
|
+
index: 0
|
|
287
|
+
}],
|
|
288
|
+
usage: new ai_1.ModelUsage(promptTokens, completionTokens)
|
|
289
|
+
};
|
|
290
|
+
result.statusText = 'success';
|
|
291
|
+
result.errorMessage = null;
|
|
292
|
+
result.exception = null;
|
|
293
|
+
return result;
|
|
294
|
+
}
|
|
295
|
+
async SummarizeText(_params) {
|
|
296
|
+
throw new Error("Method not implemented.");
|
|
297
|
+
}
|
|
298
|
+
async ClassifyText(_params) {
|
|
299
|
+
throw new Error("Method not implemented.");
|
|
300
|
+
}
|
|
301
|
+
};
|
|
302
|
+
exports.LMStudioLLM = LMStudioLLM;
|
|
303
|
+
exports.LMStudioLLM = LMStudioLLM = __decorate([
|
|
304
|
+
(0, global_1.RegisterClass)(ai_1.BaseLLM, "LMStudioLLM")
|
|
305
|
+
], LMStudioLLM);
|
|
306
|
+
function LoadLMStudioLLM() {
|
|
307
|
+
// this does nothing but prevents the class from being removed by the tree shaker
|
|
308
|
+
}
|
|
309
|
+
exports.LoadLMStudioLLM = LoadLMStudioLLM;
|
|
310
|
+
//# sourceMappingURL=lm-studio.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lm-studio.js","sourceRoot":"","sources":["../../src/models/lm-studio.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAqM;AACrM,mDAAuD;AACvD,uCAA+C;AAE/C;;GAEG;AAEI,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,YAAO;IAGpC,YAAY,MAAe;QACvB,KAAK,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,CAAC,oDAAoD;QACzE,IAAI,CAAC,OAAO,GAAG,IAAI,oBAAc,EAAE,CAAC;IACxC,CAAC;IAED;;OAEG;IACH,IAAW,cAAc;QACrB,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAED;;OAEG;IACH,IAAW,MAAM;QACb,OAAO,IAAI,CAAC,cAAc,CAAC;IAC/B,CAAC;IAED;;OAEG;IACH,IAAoB,iBAAiB;QACjC,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;;OAGG;IACO,sBAAsB;QAC5B,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;OAEG;IACa,qBAAqB,CAAC,QAA6B;QAC/D,KAAK,CAAC,qBAAqB,CAAC,QAAQ,CAAC,CAAC;QAEtC,mDAAmD;QACnD,IAAI,QAAQ,CAAC,OAAO,EAAE,CAAC;YACnB,0DAA0D;YAC1D,IAAI,CAAC,OAAO,GAAG,IAAI,oBAAc,CAAC;gBAC9B,OAAO,EAAE,QAAQ,CAAC,OAAO;aAC5B,CAAC,CAAC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
"version": "2.81.0",
|
|
4
|
+
"description": "MemberJunction Wrapper for LM Studio AI - Local Inference Engine",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"/dist"
|
|
9
|
+
],
|
|
10
|
+
"scripts": {
|
|
11
|
+
"start": "ts-node-dev src/index.ts",
|
|
12
|
+
"build": "tsc",
|
|
13
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
14
|
+
},
|
|
15
|
+
"author": "MemberJunction.com",
|
|
16
|
+
"license": "ISC",
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"ts-node-dev": "^2.0.0",
|
|
19
|
+
"typescript": "^5.4.5"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@memberjunction/ai": "2.81.0",
|
|
23
|
+
"@memberjunction/global": "2.81.0",
|
|
24
|
+
"@lmstudio/sdk": "^1.4.0"
|
|
25
|
+
}
|
|
26
|
+
}
|