@chatluna/v1-shared-adapter 1.0.23 → 1.0.25

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/lib/client.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { ModelInfo } from 'koishi-plugin-chatluna/llm-core/platform/types';
2
2
  export type OpenAIReasoningEffort = 'none' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh';
3
3
  export declare const reasoningEffortModelSuffixes: readonly ["non-thinking", "minimal-thinking", "low-thinking", "medium-thinking", "high-thinking", "xhigh-thinking", "thinking"];
4
- export declare function expandReasoningEffortModelVariants(model: string): string[];
4
+ export declare function expandReasoningEffortModelVariants(model: string, suffixes?: readonly string[]): string[];
5
5
  export declare function parseOpenAIModelNameWithReasoningEffort(modelName: string): {
6
6
  model: string;
7
7
  reasoningEffort?: OpenAIReasoningEffort;
package/lib/index.cjs CHANGED
@@ -61,8 +61,8 @@ var reasoningEffortModelSuffixes = [
61
61
  "xhigh-thinking",
62
62
  "thinking"
63
63
  ];
64
- function expandReasoningEffortModelVariants(model) {
65
- return reasoningEffortModelSuffixes.map((suffix) => `${model}-${suffix}`);
64
+ function expandReasoningEffortModelVariants(model, suffixes = reasoningEffortModelSuffixes) {
65
+ return suffixes.map((suffix) => `${model}-${suffix}`);
66
66
  }
67
67
  __name(expandReasoningEffortModelVariants, "expandReasoningEffortModelVariants");
68
68
  function parseOpenAIModelNameWithReasoningEffort(modelName) {
@@ -346,7 +346,12 @@ async function fetchImageUrl(plugin, content) {
346
346
  }
347
347
  const ext = url.match(/\.([^.?#]+)(?:[?#]|$)/)?.[1]?.toLowerCase();
348
348
  const imageType = (0, import_string.getImageMimeType)(ext);
349
- const buffer = await plugin.fetch(url).then((res) => res.arrayBuffer()).then(Buffer.from);
349
+ const buffer = await plugin.fetch(url).then((res) => {
350
+ if (!res.ok) {
351
+ throw new Error(`Failed to fetch image: ${res.status}`);
352
+ }
353
+ return res.arrayBuffer();
354
+ }).then(Buffer.from);
350
355
  return `data:${imageType};base64,${buffer.toString("base64")}`;
351
356
  }
352
357
  __name(fetchImageUrl, "fetchImageUrl");
@@ -413,6 +418,12 @@ function removeAdditionalProperties(schema) {
413
418
  if (Object.hasOwn(current, "$schema")) {
414
419
  delete current["$schema"];
415
420
  }
421
+ if (Object.hasOwn(current, "const")) {
422
+ if (!Object.hasOwn(current, "enum")) {
423
+ current["enum"] = [current["const"]];
424
+ }
425
+ delete current["const"];
426
+ }
416
427
  for (const key of Object.keys(current)) {
417
428
  const value = current[key];
418
429
  if (value && typeof value === "object") {
package/lib/index.mjs CHANGED
@@ -12,8 +12,8 @@ var reasoningEffortModelSuffixes = [
12
12
  "xhigh-thinking",
13
13
  "thinking"
14
14
  ];
15
- function expandReasoningEffortModelVariants(model) {
16
- return reasoningEffortModelSuffixes.map((suffix) => `${model}-${suffix}`);
15
+ function expandReasoningEffortModelVariants(model, suffixes = reasoningEffortModelSuffixes) {
16
+ return suffixes.map((suffix) => `${model}-${suffix}`);
17
17
  }
18
18
  __name(expandReasoningEffortModelVariants, "expandReasoningEffortModelVariants");
19
19
  function parseOpenAIModelNameWithReasoningEffort(modelName) {
@@ -310,7 +310,12 @@ async function fetchImageUrl(plugin, content) {
310
310
  }
311
311
  const ext = url.match(/\.([^.?#]+)(?:[?#]|$)/)?.[1]?.toLowerCase();
312
312
  const imageType = getImageMimeType(ext);
313
- const buffer = await plugin.fetch(url).then((res) => res.arrayBuffer()).then(Buffer.from);
313
+ const buffer = await plugin.fetch(url).then((res) => {
314
+ if (!res.ok) {
315
+ throw new Error(`Failed to fetch image: ${res.status}`);
316
+ }
317
+ return res.arrayBuffer();
318
+ }).then(Buffer.from);
314
319
  return `data:${imageType};base64,${buffer.toString("base64")}`;
315
320
  }
316
321
  __name(fetchImageUrl, "fetchImageUrl");
@@ -377,6 +382,12 @@ function removeAdditionalProperties(schema) {
377
382
  if (Object.hasOwn(current, "$schema")) {
378
383
  delete current["$schema"];
379
384
  }
385
+ if (Object.hasOwn(current, "const")) {
386
+ if (!Object.hasOwn(current, "enum")) {
387
+ current["enum"] = [current["const"]];
388
+ }
389
+ delete current["const"];
390
+ }
380
391
  for (const key of Object.keys(current)) {
381
392
  const value = current[key];
382
393
  if (value && typeof value === "object") {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@chatluna/v1-shared-adapter",
3
3
  "description": "chatluna shared adapter",
4
- "version": "1.0.23",
4
+ "version": "1.0.25",
5
5
  "main": "lib/index.cjs",
6
6
  "module": "lib/index.mjs",
7
7
  "typings": "lib/index.d.ts",
@@ -70,6 +70,6 @@
70
70
  },
71
71
  "peerDependencies": {
72
72
  "koishi": "^4.18.9",
73
- "koishi-plugin-chatluna": "^1.3.16"
73
+ "koishi-plugin-chatluna": "^1.3.21"
74
74
  }
75
75
  }