@chatluna/v1-shared-adapter 1.0.6 → 1.0.8
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/index.cjs +10 -10
- package/lib/index.mjs +10 -10
- package/lib/utils.d.ts +2 -2
- package/package.json +6 -6
package/lib/index.cjs
CHANGED
|
@@ -513,16 +513,6 @@ async function* processStreamResponse(requestContext, iterator) {
|
|
|
513
513
|
new Error("Error when calling completion, Result: " + chunk)
|
|
514
514
|
);
|
|
515
515
|
}
|
|
516
|
-
if (data.usage) {
|
|
517
|
-
yield new import_outputs.ChatGenerationChunk({
|
|
518
|
-
message: new import_messages2.AIMessageChunk(""),
|
|
519
|
-
text: "",
|
|
520
|
-
generationInfo: {
|
|
521
|
-
tokenUsage: data.usage
|
|
522
|
-
}
|
|
523
|
-
});
|
|
524
|
-
continue;
|
|
525
|
-
}
|
|
526
516
|
const choice = data.choices?.[0];
|
|
527
517
|
if (!choice) continue;
|
|
528
518
|
const { delta } = choice;
|
|
@@ -536,6 +526,16 @@ async function* processStreamResponse(requestContext, iterator) {
|
|
|
536
526
|
message: messageChunk,
|
|
537
527
|
text: messageChunk.content
|
|
538
528
|
});
|
|
529
|
+
if (data.usage) {
|
|
530
|
+
yield new import_outputs.ChatGenerationChunk({
|
|
531
|
+
message: new import_messages2.AIMessageChunk(""),
|
|
532
|
+
text: "",
|
|
533
|
+
generationInfo: {
|
|
534
|
+
tokenUsage: data.usage
|
|
535
|
+
}
|
|
536
|
+
});
|
|
537
|
+
continue;
|
|
538
|
+
}
|
|
539
539
|
} catch (e) {
|
|
540
540
|
if (errorCount > 5) {
|
|
541
541
|
requestContext.modelRequester.logger.error(
|
package/lib/index.mjs
CHANGED
|
@@ -483,16 +483,6 @@ async function* processStreamResponse(requestContext, iterator) {
|
|
|
483
483
|
new Error("Error when calling completion, Result: " + chunk)
|
|
484
484
|
);
|
|
485
485
|
}
|
|
486
|
-
if (data.usage) {
|
|
487
|
-
yield new ChatGenerationChunk({
|
|
488
|
-
message: new AIMessageChunk2(""),
|
|
489
|
-
text: "",
|
|
490
|
-
generationInfo: {
|
|
491
|
-
tokenUsage: data.usage
|
|
492
|
-
}
|
|
493
|
-
});
|
|
494
|
-
continue;
|
|
495
|
-
}
|
|
496
486
|
const choice = data.choices?.[0];
|
|
497
487
|
if (!choice) continue;
|
|
498
488
|
const { delta } = choice;
|
|
@@ -506,6 +496,16 @@ async function* processStreamResponse(requestContext, iterator) {
|
|
|
506
496
|
message: messageChunk,
|
|
507
497
|
text: messageChunk.content
|
|
508
498
|
});
|
|
499
|
+
if (data.usage) {
|
|
500
|
+
yield new ChatGenerationChunk({
|
|
501
|
+
message: new AIMessageChunk2(""),
|
|
502
|
+
text: "",
|
|
503
|
+
generationInfo: {
|
|
504
|
+
tokenUsage: data.usage
|
|
505
|
+
}
|
|
506
|
+
});
|
|
507
|
+
continue;
|
|
508
|
+
}
|
|
509
509
|
} catch (e) {
|
|
510
510
|
if (errorCount > 5) {
|
|
511
511
|
requestContext.modelRequester.logger.error(
|
package/lib/utils.d.ts
CHANGED
|
@@ -9,5 +9,5 @@ export declare function messageTypeToOpenAIRole(type: MessageType): ChatCompleti
|
|
|
9
9
|
export declare function formatToolsToOpenAITools(tools: StructuredTool[], includeGoogleSearch: boolean): ChatCompletionTool[];
|
|
10
10
|
export declare function formatToolToOpenAITool(tool: StructuredTool): ChatCompletionTool;
|
|
11
11
|
export declare function removeAdditionalProperties(schema: JsonSchema7Type): JsonSchema7Type;
|
|
12
|
-
export declare function convertMessageToMessageChunk(message: ChatCompletionResponseMessage):
|
|
13
|
-
export declare function convertDeltaToMessageChunk(delta: Record<string, any>, defaultRole?: ChatCompletionResponseMessageRoleEnum):
|
|
12
|
+
export declare function convertMessageToMessageChunk(message: ChatCompletionResponseMessage): AIMessageChunk | HumanMessageChunk | SystemMessageChunk | FunctionMessageChunk | ToolMessageChunk | ChatMessageChunk;
|
|
13
|
+
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.8",
|
|
5
5
|
"main": "lib/index.cjs",
|
|
6
6
|
"module": "lib/index.mjs",
|
|
7
7
|
"typings": "lib/index.d.ts",
|
|
@@ -37,16 +37,16 @@
|
|
|
37
37
|
},
|
|
38
38
|
"resolutions": {
|
|
39
39
|
"@langchain/core": "0.3.62",
|
|
40
|
-
"js-tiktoken": "npm:@dingyi222666/js-tiktoken@^1.0.
|
|
40
|
+
"js-tiktoken": "npm:@dingyi222666/js-tiktoken@^1.0.21"
|
|
41
41
|
},
|
|
42
42
|
"overrides": {
|
|
43
43
|
"@langchain/core": "0.3.62",
|
|
44
|
-
"js-tiktoken": "npm:@dingyi222666/js-tiktoken@^1.0.
|
|
44
|
+
"js-tiktoken": "npm:@dingyi222666/js-tiktoken@^1.0.21"
|
|
45
45
|
},
|
|
46
46
|
"pnpm": {
|
|
47
47
|
"overrides": {
|
|
48
48
|
"@langchain/core": "0.3.62",
|
|
49
|
-
"js-tiktoken": "npm:@dingyi222666/js-tiktoken@^1.0.
|
|
49
|
+
"js-tiktoken": "npm:@dingyi222666/js-tiktoken@^1.0.21"
|
|
50
50
|
}
|
|
51
51
|
},
|
|
52
52
|
"keywords": [
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
],
|
|
62
62
|
"dependencies": {
|
|
63
63
|
"@langchain/core": "0.3.62",
|
|
64
|
-
"zod": "
|
|
64
|
+
"zod": "3.25.76",
|
|
65
65
|
"zod-to-json-schema": "^3.24.5"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
@@ -70,6 +70,6 @@
|
|
|
70
70
|
},
|
|
71
71
|
"peerDependencies": {
|
|
72
72
|
"koishi": "^4.18.7",
|
|
73
|
-
"koishi-plugin-chatluna": "^1.3.0-alpha.
|
|
73
|
+
"koishi-plugin-chatluna": "^1.3.0-alpha.40"
|
|
74
74
|
}
|
|
75
75
|
}
|