@ever-works/lm-studio-plugin 1.0.5 → 1.0.7
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.cjs +71 -44
- package/dist/index.js +72 -45
- package/package.json +7 -7
package/dist/index.cjs
CHANGED
|
@@ -20774,7 +20774,7 @@ function normalizeObjects(node2, strict) {
|
|
|
20774
20774
|
}
|
|
20775
20775
|
}
|
|
20776
20776
|
function toStructuredOutputJsonSchema(schema, strict) {
|
|
20777
|
-
const jsonSchema = external_exports.toJSONSchema(schema, {
|
|
20777
|
+
const { ...jsonSchema } = external_exports.toJSONSchema(schema, {
|
|
20778
20778
|
target: "draft-07",
|
|
20779
20779
|
io: "input",
|
|
20780
20780
|
unrepresentable: "any"
|
|
@@ -20935,19 +20935,22 @@ async function safeFetchWithDnsPin(rawUrl, init, options) {
|
|
|
20935
20935
|
}
|
|
20936
20936
|
return fetch(rawUrl, init);
|
|
20937
20937
|
}
|
|
20938
|
+
function namesParam(msg, param) {
|
|
20939
|
+
return [`'${param}'`, `"${param}"`, `\`${param}\``].some((quoted) => msg.includes(quoted));
|
|
20940
|
+
}
|
|
20938
20941
|
var AiOperations = class {
|
|
20939
20942
|
constructor(defaultConfig) {
|
|
20940
20943
|
this.defaultConfig = defaultConfig;
|
|
20941
20944
|
this.rejectedParams = /* @__PURE__ */ new Map();
|
|
20942
20945
|
}
|
|
20943
20946
|
/**
|
|
20944
|
-
* Create a chat completion using LangChain's
|
|
20947
|
+
* Create a chat completion using LangChain's Chat Completions model.
|
|
20945
20948
|
* Plain text only — for structured JSON output, use `askJson` instead.
|
|
20946
20949
|
*/
|
|
20947
20950
|
async createChatCompletion(options, configOverrides) {
|
|
20948
20951
|
const config2 = this.mergeConfig(configOverrides);
|
|
20949
20952
|
const model = options.model || config2.model;
|
|
20950
|
-
return this.withParamRetry(model, async (skip) => {
|
|
20953
|
+
return this.withParamRetry(this.paramCacheKey(config2, model), async (skip) => {
|
|
20951
20954
|
const baseLlm = this.createChatModel(config2, model, options, skip);
|
|
20952
20955
|
const llm = this.bindTools(baseLlm, options, skip);
|
|
20953
20956
|
const tracker = new TokenUsageTracker();
|
|
@@ -20992,7 +20995,7 @@ var AiOperations = class {
|
|
|
20992
20995
|
async askJson(prompt, schema, configOverrides, options) {
|
|
20993
20996
|
const config2 = this.mergeConfig(configOverrides);
|
|
20994
20997
|
const model = config2.model;
|
|
20995
|
-
return this.withParamRetry(model, async (skip) => {
|
|
20998
|
+
return this.withParamRetry(this.paramCacheKey(config2, model), async (skip) => {
|
|
20996
20999
|
const llm = this.createChatModel(
|
|
20997
21000
|
config2,
|
|
20998
21001
|
model,
|
|
@@ -21015,20 +21018,21 @@ var AiOperations = class {
|
|
|
21015
21018
|
const config2 = this.mergeConfig(configOverrides);
|
|
21016
21019
|
const model = options.model || config2.model;
|
|
21017
21020
|
const messages = this.toLangChainMessages(options.messages);
|
|
21018
|
-
const
|
|
21021
|
+
const cacheKey = this.paramCacheKey(config2, model);
|
|
21022
|
+
const skip = new Set(this.rejectedParams.get(cacheKey));
|
|
21019
21023
|
let stream;
|
|
21020
|
-
|
|
21021
|
-
|
|
21022
|
-
|
|
21023
|
-
|
|
21024
|
-
|
|
21025
|
-
|
|
21026
|
-
|
|
21027
|
-
|
|
21028
|
-
|
|
21029
|
-
|
|
21030
|
-
|
|
21031
|
-
|
|
21024
|
+
for (; ; ) {
|
|
21025
|
+
try {
|
|
21026
|
+
const baseLlm = this.createChatModel(config2, model, options, skip);
|
|
21027
|
+
const llm = this.bindTools(baseLlm, options, skip);
|
|
21028
|
+
stream = await llm.stream(messages);
|
|
21029
|
+
break;
|
|
21030
|
+
} catch (error62) {
|
|
21031
|
+
const param = this.nextRejectedParam(error62, skip);
|
|
21032
|
+
if (!param) throw error62;
|
|
21033
|
+
skip.add(param);
|
|
21034
|
+
this.rejectedParams.set(cacheKey, new Set(skip));
|
|
21035
|
+
}
|
|
21032
21036
|
}
|
|
21033
21037
|
let hadToolCalls = false;
|
|
21034
21038
|
let isFirstChunk = true;
|
|
@@ -21149,10 +21153,18 @@ var AiOperations = class {
|
|
|
21149
21153
|
const TIMEOUT_MS = 15e3;
|
|
21150
21154
|
try {
|
|
21151
21155
|
const config2 = this.mergeConfig(configOverrides);
|
|
21152
|
-
const
|
|
21156
|
+
const model = modelOverride ?? config2.model;
|
|
21153
21157
|
let timeoutHandle;
|
|
21154
21158
|
await Promise.race([
|
|
21155
|
-
|
|
21159
|
+
// Same rejected-parameter retry as a real request, so a model
|
|
21160
|
+
// that refuses a default parameter (e.g. `temperature` on
|
|
21161
|
+
// Claude 4.7+) does not fail validation that real calls pass.
|
|
21162
|
+
this.withParamRetry(
|
|
21163
|
+
this.paramCacheKey(config2, model),
|
|
21164
|
+
(skip) => this.createChatModel(config2, model, void 0, skip).invoke([
|
|
21165
|
+
new messages.HumanMessage('Respond with just "OK" to confirm you are working.')
|
|
21166
|
+
])
|
|
21167
|
+
).then((r) => {
|
|
21156
21168
|
clearTimeout(timeoutHandle);
|
|
21157
21169
|
return r;
|
|
21158
21170
|
}),
|
|
@@ -21228,7 +21240,7 @@ var AiOperations = class {
|
|
|
21228
21240
|
/**
|
|
21229
21241
|
* Security (SSRF): lexically reject a user-supplied `baseURL` that targets a
|
|
21230
21242
|
* private / loopback / link-local / cloud-metadata host before it is handed
|
|
21231
|
-
* to LangChain's
|
|
21243
|
+
* to LangChain's ChatOpenAICompletions / OpenAIEmbeddings (whose internal fetch we
|
|
21232
21244
|
* cannot route through `safeFetchWithDnsPin`). Undefined `baseURL` means the
|
|
21233
21245
|
* provider's hosted default endpoint is used — that is always allowed.
|
|
21234
21246
|
* DNS-rebinding is only partially covered here (lexical-only); the raw
|
|
@@ -21250,7 +21262,7 @@ var AiOperations = class {
|
|
|
21250
21262
|
modelKwargs.response_format = options.responseFormat;
|
|
21251
21263
|
}
|
|
21252
21264
|
const temperature = skip?.has("temperature") ? void 0 : options?.temperature ?? config2.temperature;
|
|
21253
|
-
return new openai.
|
|
21265
|
+
return new openai.ChatOpenAICompletions({
|
|
21254
21266
|
apiKey: config2.apiKey,
|
|
21255
21267
|
model,
|
|
21256
21268
|
temperature,
|
|
@@ -21261,25 +21273,36 @@ var AiOperations = class {
|
|
|
21261
21273
|
}
|
|
21262
21274
|
/**
|
|
21263
21275
|
* Generic retry: if the API rejects an unsupported parameter, rebuild
|
|
21264
|
-
* the model without it and retry once
|
|
21265
|
-
*
|
|
21276
|
+
* the model without it and retry, once per newly rejected parameter (a
|
|
21277
|
+
* request can be refused for `temperature`, then for a forced
|
|
21278
|
+
* `tool_choice`). Handles temperature, reasoning, etc. across all
|
|
21279
|
+
* providers/models in one place.
|
|
21266
21280
|
*
|
|
21267
|
-
* Uses a per-model cache so the same param is never sent twice.
|
|
21281
|
+
* Uses a per-endpoint-and-model cache so the same param is never sent twice.
|
|
21268
21282
|
*/
|
|
21269
|
-
async withParamRetry(
|
|
21270
|
-
const skip = new Set(this.rejectedParams.get(
|
|
21271
|
-
|
|
21272
|
-
|
|
21273
|
-
|
|
21274
|
-
|
|
21275
|
-
|
|
21283
|
+
async withParamRetry(cacheKey, operation) {
|
|
21284
|
+
const skip = new Set(this.rejectedParams.get(cacheKey));
|
|
21285
|
+
for (; ; ) {
|
|
21286
|
+
try {
|
|
21287
|
+
return await operation(skip);
|
|
21288
|
+
} catch (error62) {
|
|
21289
|
+
const param = this.nextRejectedParam(error62, skip);
|
|
21290
|
+
if (!param) throw error62;
|
|
21276
21291
|
skip.add(param);
|
|
21277
|
-
this.rejectedParams.set(
|
|
21278
|
-
return operation(skip);
|
|
21292
|
+
this.rejectedParams.set(cacheKey, new Set(skip));
|
|
21279
21293
|
}
|
|
21280
|
-
throw error62;
|
|
21281
21294
|
}
|
|
21282
21295
|
}
|
|
21296
|
+
/** The param to leave out on the next attempt, or `undefined` when a retry cannot help. */
|
|
21297
|
+
nextRejectedParam(error62, skip) {
|
|
21298
|
+
let param = this.parseRejectedParam(error62);
|
|
21299
|
+
if (param === "tool_choice" && skip.has("tool_choice")) param = "tools";
|
|
21300
|
+
return param && !skip.has(param) ? param : void 0;
|
|
21301
|
+
}
|
|
21302
|
+
/** Key for {@link rejectedParams}: the endpoint and the model. */
|
|
21303
|
+
paramCacheKey(config2, model) {
|
|
21304
|
+
return `${config2.baseURL ?? ""}|${model}`;
|
|
21305
|
+
}
|
|
21283
21306
|
mapTokenUsage(tracker) {
|
|
21284
21307
|
const usage = tracker.usage;
|
|
21285
21308
|
if (usage.totalTokens === 0) return void 0;
|
|
@@ -21290,9 +21313,11 @@ var AiOperations = class {
|
|
|
21290
21313
|
};
|
|
21291
21314
|
}
|
|
21292
21315
|
/**
|
|
21293
|
-
* Bind tools to
|
|
21294
|
-
*
|
|
21295
|
-
*
|
|
21316
|
+
* Bind tools to the chat model when tool definitions are provided.
|
|
21317
|
+
*
|
|
21318
|
+
* The tools ride along as call options (`withConfig`), already in OpenAI's
|
|
21319
|
+
* `{ type: 'function', function }` shape, so the request carries them exactly
|
|
21320
|
+
* as written. LangChain 1.x removed `Runnable.bind()`, which did the same.
|
|
21296
21321
|
*/
|
|
21297
21322
|
bindTools(llm, options, skip) {
|
|
21298
21323
|
if (!options?.tools?.length || skip?.has("tools")) {
|
|
@@ -21306,20 +21331,22 @@ var AiOperations = class {
|
|
|
21306
21331
|
parameters: t.function.parameters ?? {}
|
|
21307
21332
|
}
|
|
21308
21333
|
}));
|
|
21309
|
-
const
|
|
21310
|
-
|
|
21311
|
-
|
|
21334
|
+
const callOptions = { tools };
|
|
21335
|
+
const forced = options.toolChoice === "required" || typeof options.toolChoice === "object";
|
|
21336
|
+
if (options.toolChoice && !(forced && skip?.has("tool_choice"))) {
|
|
21337
|
+
callOptions.tool_choice = options.toolChoice;
|
|
21312
21338
|
}
|
|
21313
|
-
return llm.
|
|
21339
|
+
return llm.withConfig(callOptions);
|
|
21314
21340
|
}
|
|
21315
21341
|
parseRejectedParam(error62) {
|
|
21316
21342
|
if (!(error62 instanceof Error)) return void 0;
|
|
21317
21343
|
const msg = error62.message.toLowerCase();
|
|
21318
|
-
if (msg
|
|
21319
|
-
if (msg
|
|
21344
|
+
if (namesParam(msg, "temperature")) return "temperature";
|
|
21345
|
+
if (namesParam(msg, "reasoning") || namesParam(msg, "reasoning_effort")) return "reasoning";
|
|
21320
21346
|
if (msg.includes("json_schema") || msg.includes("response_format") || msg.includes("structured output"))
|
|
21321
21347
|
return "structured_output";
|
|
21322
|
-
if (msg.includes("
|
|
21348
|
+
if (msg.includes("tool_choice")) return "tool_choice";
|
|
21349
|
+
if (namesParam(msg, "tools")) return "tools";
|
|
21323
21350
|
return void 0;
|
|
21324
21351
|
}
|
|
21325
21352
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { OpenAIEmbeddings,
|
|
1
|
+
import { OpenAIEmbeddings, ChatOpenAICompletions } from '@langchain/openai';
|
|
2
2
|
import { HumanMessage, ToolMessage, AIMessage, SystemMessage } from '@langchain/core/messages';
|
|
3
3
|
import { BaseCallbackHandler } from '@langchain/core/callbacks/base';
|
|
4
4
|
import { isIP } from 'net';
|
|
@@ -20750,7 +20750,7 @@ function normalizeObjects(node2, strict) {
|
|
|
20750
20750
|
}
|
|
20751
20751
|
}
|
|
20752
20752
|
function toStructuredOutputJsonSchema(schema, strict) {
|
|
20753
|
-
const jsonSchema = external_exports.toJSONSchema(schema, {
|
|
20753
|
+
const { ...jsonSchema } = external_exports.toJSONSchema(schema, {
|
|
20754
20754
|
target: "draft-07",
|
|
20755
20755
|
io: "input",
|
|
20756
20756
|
unrepresentable: "any"
|
|
@@ -20911,19 +20911,22 @@ async function safeFetchWithDnsPin(rawUrl, init, options) {
|
|
|
20911
20911
|
}
|
|
20912
20912
|
return fetch(rawUrl, init);
|
|
20913
20913
|
}
|
|
20914
|
+
function namesParam(msg, param) {
|
|
20915
|
+
return [`'${param}'`, `"${param}"`, `\`${param}\``].some((quoted) => msg.includes(quoted));
|
|
20916
|
+
}
|
|
20914
20917
|
var AiOperations = class {
|
|
20915
20918
|
constructor(defaultConfig) {
|
|
20916
20919
|
this.defaultConfig = defaultConfig;
|
|
20917
20920
|
this.rejectedParams = /* @__PURE__ */ new Map();
|
|
20918
20921
|
}
|
|
20919
20922
|
/**
|
|
20920
|
-
* Create a chat completion using LangChain's
|
|
20923
|
+
* Create a chat completion using LangChain's Chat Completions model.
|
|
20921
20924
|
* Plain text only — for structured JSON output, use `askJson` instead.
|
|
20922
20925
|
*/
|
|
20923
20926
|
async createChatCompletion(options, configOverrides) {
|
|
20924
20927
|
const config2 = this.mergeConfig(configOverrides);
|
|
20925
20928
|
const model = options.model || config2.model;
|
|
20926
|
-
return this.withParamRetry(model, async (skip) => {
|
|
20929
|
+
return this.withParamRetry(this.paramCacheKey(config2, model), async (skip) => {
|
|
20927
20930
|
const baseLlm = this.createChatModel(config2, model, options, skip);
|
|
20928
20931
|
const llm = this.bindTools(baseLlm, options, skip);
|
|
20929
20932
|
const tracker = new TokenUsageTracker();
|
|
@@ -20968,7 +20971,7 @@ var AiOperations = class {
|
|
|
20968
20971
|
async askJson(prompt, schema, configOverrides, options) {
|
|
20969
20972
|
const config2 = this.mergeConfig(configOverrides);
|
|
20970
20973
|
const model = config2.model;
|
|
20971
|
-
return this.withParamRetry(model, async (skip) => {
|
|
20974
|
+
return this.withParamRetry(this.paramCacheKey(config2, model), async (skip) => {
|
|
20972
20975
|
const llm = this.createChatModel(
|
|
20973
20976
|
config2,
|
|
20974
20977
|
model,
|
|
@@ -20991,20 +20994,21 @@ var AiOperations = class {
|
|
|
20991
20994
|
const config2 = this.mergeConfig(configOverrides);
|
|
20992
20995
|
const model = options.model || config2.model;
|
|
20993
20996
|
const messages = this.toLangChainMessages(options.messages);
|
|
20994
|
-
const
|
|
20997
|
+
const cacheKey = this.paramCacheKey(config2, model);
|
|
20998
|
+
const skip = new Set(this.rejectedParams.get(cacheKey));
|
|
20995
20999
|
let stream;
|
|
20996
|
-
|
|
20997
|
-
|
|
20998
|
-
|
|
20999
|
-
|
|
21000
|
-
|
|
21001
|
-
|
|
21002
|
-
|
|
21003
|
-
|
|
21004
|
-
|
|
21005
|
-
|
|
21006
|
-
|
|
21007
|
-
|
|
21000
|
+
for (; ; ) {
|
|
21001
|
+
try {
|
|
21002
|
+
const baseLlm = this.createChatModel(config2, model, options, skip);
|
|
21003
|
+
const llm = this.bindTools(baseLlm, options, skip);
|
|
21004
|
+
stream = await llm.stream(messages);
|
|
21005
|
+
break;
|
|
21006
|
+
} catch (error62) {
|
|
21007
|
+
const param = this.nextRejectedParam(error62, skip);
|
|
21008
|
+
if (!param) throw error62;
|
|
21009
|
+
skip.add(param);
|
|
21010
|
+
this.rejectedParams.set(cacheKey, new Set(skip));
|
|
21011
|
+
}
|
|
21008
21012
|
}
|
|
21009
21013
|
let hadToolCalls = false;
|
|
21010
21014
|
let isFirstChunk = true;
|
|
@@ -21125,10 +21129,18 @@ var AiOperations = class {
|
|
|
21125
21129
|
const TIMEOUT_MS = 15e3;
|
|
21126
21130
|
try {
|
|
21127
21131
|
const config2 = this.mergeConfig(configOverrides);
|
|
21128
|
-
const
|
|
21132
|
+
const model = modelOverride ?? config2.model;
|
|
21129
21133
|
let timeoutHandle;
|
|
21130
21134
|
await Promise.race([
|
|
21131
|
-
|
|
21135
|
+
// Same rejected-parameter retry as a real request, so a model
|
|
21136
|
+
// that refuses a default parameter (e.g. `temperature` on
|
|
21137
|
+
// Claude 4.7+) does not fail validation that real calls pass.
|
|
21138
|
+
this.withParamRetry(
|
|
21139
|
+
this.paramCacheKey(config2, model),
|
|
21140
|
+
(skip) => this.createChatModel(config2, model, void 0, skip).invoke([
|
|
21141
|
+
new HumanMessage('Respond with just "OK" to confirm you are working.')
|
|
21142
|
+
])
|
|
21143
|
+
).then((r) => {
|
|
21132
21144
|
clearTimeout(timeoutHandle);
|
|
21133
21145
|
return r;
|
|
21134
21146
|
}),
|
|
@@ -21204,7 +21216,7 @@ var AiOperations = class {
|
|
|
21204
21216
|
/**
|
|
21205
21217
|
* Security (SSRF): lexically reject a user-supplied `baseURL` that targets a
|
|
21206
21218
|
* private / loopback / link-local / cloud-metadata host before it is handed
|
|
21207
|
-
* to LangChain's
|
|
21219
|
+
* to LangChain's ChatOpenAICompletions / OpenAIEmbeddings (whose internal fetch we
|
|
21208
21220
|
* cannot route through `safeFetchWithDnsPin`). Undefined `baseURL` means the
|
|
21209
21221
|
* provider's hosted default endpoint is used — that is always allowed.
|
|
21210
21222
|
* DNS-rebinding is only partially covered here (lexical-only); the raw
|
|
@@ -21226,7 +21238,7 @@ var AiOperations = class {
|
|
|
21226
21238
|
modelKwargs.response_format = options.responseFormat;
|
|
21227
21239
|
}
|
|
21228
21240
|
const temperature = skip?.has("temperature") ? void 0 : options?.temperature ?? config2.temperature;
|
|
21229
|
-
return new
|
|
21241
|
+
return new ChatOpenAICompletions({
|
|
21230
21242
|
apiKey: config2.apiKey,
|
|
21231
21243
|
model,
|
|
21232
21244
|
temperature,
|
|
@@ -21237,25 +21249,36 @@ var AiOperations = class {
|
|
|
21237
21249
|
}
|
|
21238
21250
|
/**
|
|
21239
21251
|
* Generic retry: if the API rejects an unsupported parameter, rebuild
|
|
21240
|
-
* the model without it and retry once
|
|
21241
|
-
*
|
|
21252
|
+
* the model without it and retry, once per newly rejected parameter (a
|
|
21253
|
+
* request can be refused for `temperature`, then for a forced
|
|
21254
|
+
* `tool_choice`). Handles temperature, reasoning, etc. across all
|
|
21255
|
+
* providers/models in one place.
|
|
21242
21256
|
*
|
|
21243
|
-
* Uses a per-model cache so the same param is never sent twice.
|
|
21257
|
+
* Uses a per-endpoint-and-model cache so the same param is never sent twice.
|
|
21244
21258
|
*/
|
|
21245
|
-
async withParamRetry(
|
|
21246
|
-
const skip = new Set(this.rejectedParams.get(
|
|
21247
|
-
|
|
21248
|
-
|
|
21249
|
-
|
|
21250
|
-
|
|
21251
|
-
|
|
21259
|
+
async withParamRetry(cacheKey, operation) {
|
|
21260
|
+
const skip = new Set(this.rejectedParams.get(cacheKey));
|
|
21261
|
+
for (; ; ) {
|
|
21262
|
+
try {
|
|
21263
|
+
return await operation(skip);
|
|
21264
|
+
} catch (error62) {
|
|
21265
|
+
const param = this.nextRejectedParam(error62, skip);
|
|
21266
|
+
if (!param) throw error62;
|
|
21252
21267
|
skip.add(param);
|
|
21253
|
-
this.rejectedParams.set(
|
|
21254
|
-
return operation(skip);
|
|
21268
|
+
this.rejectedParams.set(cacheKey, new Set(skip));
|
|
21255
21269
|
}
|
|
21256
|
-
throw error62;
|
|
21257
21270
|
}
|
|
21258
21271
|
}
|
|
21272
|
+
/** The param to leave out on the next attempt, or `undefined` when a retry cannot help. */
|
|
21273
|
+
nextRejectedParam(error62, skip) {
|
|
21274
|
+
let param = this.parseRejectedParam(error62);
|
|
21275
|
+
if (param === "tool_choice" && skip.has("tool_choice")) param = "tools";
|
|
21276
|
+
return param && !skip.has(param) ? param : void 0;
|
|
21277
|
+
}
|
|
21278
|
+
/** Key for {@link rejectedParams}: the endpoint and the model. */
|
|
21279
|
+
paramCacheKey(config2, model) {
|
|
21280
|
+
return `${config2.baseURL ?? ""}|${model}`;
|
|
21281
|
+
}
|
|
21259
21282
|
mapTokenUsage(tracker) {
|
|
21260
21283
|
const usage = tracker.usage;
|
|
21261
21284
|
if (usage.totalTokens === 0) return void 0;
|
|
@@ -21266,9 +21289,11 @@ var AiOperations = class {
|
|
|
21266
21289
|
};
|
|
21267
21290
|
}
|
|
21268
21291
|
/**
|
|
21269
|
-
* Bind tools to
|
|
21270
|
-
*
|
|
21271
|
-
*
|
|
21292
|
+
* Bind tools to the chat model when tool definitions are provided.
|
|
21293
|
+
*
|
|
21294
|
+
* The tools ride along as call options (`withConfig`), already in OpenAI's
|
|
21295
|
+
* `{ type: 'function', function }` shape, so the request carries them exactly
|
|
21296
|
+
* as written. LangChain 1.x removed `Runnable.bind()`, which did the same.
|
|
21272
21297
|
*/
|
|
21273
21298
|
bindTools(llm, options, skip) {
|
|
21274
21299
|
if (!options?.tools?.length || skip?.has("tools")) {
|
|
@@ -21282,20 +21307,22 @@ var AiOperations = class {
|
|
|
21282
21307
|
parameters: t.function.parameters ?? {}
|
|
21283
21308
|
}
|
|
21284
21309
|
}));
|
|
21285
|
-
const
|
|
21286
|
-
|
|
21287
|
-
|
|
21310
|
+
const callOptions = { tools };
|
|
21311
|
+
const forced = options.toolChoice === "required" || typeof options.toolChoice === "object";
|
|
21312
|
+
if (options.toolChoice && !(forced && skip?.has("tool_choice"))) {
|
|
21313
|
+
callOptions.tool_choice = options.toolChoice;
|
|
21288
21314
|
}
|
|
21289
|
-
return llm.
|
|
21315
|
+
return llm.withConfig(callOptions);
|
|
21290
21316
|
}
|
|
21291
21317
|
parseRejectedParam(error62) {
|
|
21292
21318
|
if (!(error62 instanceof Error)) return void 0;
|
|
21293
21319
|
const msg = error62.message.toLowerCase();
|
|
21294
|
-
if (msg
|
|
21295
|
-
if (msg
|
|
21320
|
+
if (namesParam(msg, "temperature")) return "temperature";
|
|
21321
|
+
if (namesParam(msg, "reasoning") || namesParam(msg, "reasoning_effort")) return "reasoning";
|
|
21296
21322
|
if (msg.includes("json_schema") || msg.includes("response_format") || msg.includes("structured output"))
|
|
21297
21323
|
return "structured_output";
|
|
21298
|
-
if (msg.includes("
|
|
21324
|
+
if (msg.includes("tool_choice")) return "tool_choice";
|
|
21325
|
+
if (namesParam(msg, "tools")) return "tools";
|
|
21299
21326
|
return void 0;
|
|
21300
21327
|
}
|
|
21301
21328
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ever-works/lm-studio-plugin",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"description": "LM Studio AI provider plugin for Ever Works platform",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Ever Co. LTD",
|
|
@@ -32,9 +32,9 @@
|
|
|
32
32
|
"test:watch": "vitest"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@ever-works/plugin": "^1.2.
|
|
36
|
-
"@langchain/openai": "^
|
|
37
|
-
"@langchain/core": "^
|
|
35
|
+
"@ever-works/plugin": "^1.2.15",
|
|
36
|
+
"@langchain/openai": "^1.7.1",
|
|
37
|
+
"@langchain/core": "^1.3.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@types/node": "^26.6.4",
|
|
@@ -71,8 +71,8 @@
|
|
|
71
71
|
"url": "https://github.com/ever-works/ever-works/issues"
|
|
72
72
|
},
|
|
73
73
|
"everworksRelease": {
|
|
74
|
-
"contentHash": "sha256:
|
|
75
|
-
"commit": "
|
|
76
|
-
"source": "https://github.com/ever-works/ever-works/tree/
|
|
74
|
+
"contentHash": "sha256:11aaf9d7399a01c0451aa188bee6620801012785027c69f26a58fc6682141d11",
|
|
75
|
+
"commit": "fe7305a350776ba5d206efb483149855c58f1344",
|
|
76
|
+
"source": "https://github.com/ever-works/ever-works/tree/fe7305a350776ba5d206efb483149855c58f1344/packages/plugins/lm-studio"
|
|
77
77
|
}
|
|
78
78
|
}
|