@chatluna/v1-shared-adapter 1.0.24 → 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 +1 -1
- package/lib/index.cjs +8 -3
- package/lib/index.mjs +8 -3
- package/lib/utils.d.ts +2 -2
- package/package.json +2 -2
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
|
|
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) =>
|
|
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");
|
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
|
|
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) =>
|
|
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");
|
package/lib/utils.d.ts
CHANGED
|
@@ -11,5 +11,5 @@ export declare function messageTypeToOpenAIRole(type: MessageType): ChatCompleti
|
|
|
11
11
|
export declare function formatToolsToOpenAITools(tools: StructuredTool[], includeGoogleSearch: boolean): ChatCompletionTool[];
|
|
12
12
|
export declare function formatToolToOpenAITool(tool: StructuredTool): ChatCompletionTool;
|
|
13
13
|
export declare function removeAdditionalProperties(schema: JsonSchema7Type): JsonSchema7Type;
|
|
14
|
-
export declare function convertMessageToMessageChunk(message: ChatCompletionResponseMessage):
|
|
15
|
-
export declare function convertDeltaToMessageChunk(delta: Record<string, any>, defaultRole?: ChatCompletionResponseMessageRoleEnum):
|
|
14
|
+
export declare function convertMessageToMessageChunk(message: ChatCompletionResponseMessage): AIMessageChunk | HumanMessageChunk | SystemMessageChunk | FunctionMessageChunk | ToolMessageChunk | ChatMessageChunk;
|
|
15
|
+
export declare function convertDeltaToMessageChunk(delta: Record<string, any>, defaultRole?: ChatCompletionResponseMessageRoleEnum): AIMessageChunk | HumanMessageChunk | SystemMessageChunk | FunctionMessageChunk | ToolMessageChunk | ChatMessageChunk;
|
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.
|
|
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.
|
|
73
|
+
"koishi-plugin-chatluna": "^1.3.21"
|
|
74
74
|
}
|
|
75
75
|
}
|