@chatluna/v1-shared-adapter 1.0.14 → 1.0.16

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 CHANGED
@@ -514,15 +514,17 @@ async function* processStreamResponse(requestContext, iterator) {
514
514
  const choice = data.choices?.[0];
515
515
  if (data.usage) {
516
516
  yield new import_outputs.ChatGenerationChunk({
517
- message: new import_messages2.AIMessageChunk(""),
518
- text: "",
519
- generationInfo: {
520
- tokenUsage: {
521
- promptTokens: data.usage.prompt_tokens,
522
- completionTokens: data.usage.completion_tokens,
523
- totalTokens: data.usage.total_tokens
517
+ message: new import_messages2.AIMessageChunk({
518
+ content: "",
519
+ response_metadata: {
520
+ tokenUsage: {
521
+ promptTokens: data.usage.prompt_tokens,
522
+ completionTokens: data.usage.completion_tokens,
523
+ totalTokens: data.usage.total_tokens
524
+ }
524
525
  }
525
- }
526
+ }),
527
+ text: ""
526
528
  });
527
529
  }
528
530
  if (!choice) continue;
package/lib/index.mjs CHANGED
@@ -484,15 +484,17 @@ async function* processStreamResponse(requestContext, iterator) {
484
484
  const choice = data.choices?.[0];
485
485
  if (data.usage) {
486
486
  yield new ChatGenerationChunk({
487
- message: new AIMessageChunk2(""),
488
- text: "",
489
- generationInfo: {
490
- tokenUsage: {
491
- promptTokens: data.usage.prompt_tokens,
492
- completionTokens: data.usage.completion_tokens,
493
- totalTokens: data.usage.total_tokens
487
+ message: new AIMessageChunk2({
488
+ content: "",
489
+ response_metadata: {
490
+ tokenUsage: {
491
+ promptTokens: data.usage.prompt_tokens,
492
+ completionTokens: data.usage.completion_tokens,
493
+ totalTokens: data.usage.total_tokens
494
+ }
494
495
  }
495
- }
496
+ }),
497
+ text: ""
496
498
  });
497
499
  }
498
500
  if (!choice) continue;
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): HumanMessageChunk | AIMessageChunk | SystemMessageChunk | FunctionMessageChunk | ToolMessageChunk | ChatMessageChunk;
13
- export declare function convertDeltaToMessageChunk(delta: Record<string, any>, defaultRole?: ChatCompletionResponseMessageRoleEnum): HumanMessageChunk | AIMessageChunk | SystemMessageChunk | FunctionMessageChunk | ToolMessageChunk | ChatMessageChunk;
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,75 +1,75 @@
1
1
  {
2
- "name": "@chatluna/v1-shared-adapter",
3
- "description": "chatluna shared adapter",
4
- "version": "1.0.14",
5
- "main": "lib/index.cjs",
6
- "module": "lib/index.mjs",
7
- "typings": "lib/index.d.ts",
8
- "files": [
9
- "lib",
10
- "dist"
11
- ],
12
- "exports": {
13
- ".": {
14
- "types": "./lib/index.d.ts",
15
- "import": "./lib/index.mjs",
16
- "require": "./lib/index.cjs"
2
+ "name": "@chatluna/v1-shared-adapter",
3
+ "description": "chatluna shared adapter",
4
+ "version": "1.0.16",
5
+ "main": "lib/index.cjs",
6
+ "module": "lib/index.mjs",
7
+ "typings": "lib/index.d.ts",
8
+ "files": [
9
+ "lib",
10
+ "dist"
11
+ ],
12
+ "exports": {
13
+ ".": {
14
+ "types": "./lib/index.d.ts",
15
+ "import": "./lib/index.mjs",
16
+ "require": "./lib/index.cjs"
17
+ },
18
+ "./package.json": "./package.json"
19
+ },
20
+ "type": "module",
21
+ "author": "dingyi222666 <dingyi222666@foxmail.com>",
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "https://github.com/ChatLunaLab/chatluna.git",
25
+ "directory": "packages/shared-adapter"
26
+ },
27
+ "license": "AGPL-3.0",
28
+ "bugs": {
29
+ "url": "https://github.com/ChatLunaLab/chatluna/issues"
30
+ },
31
+ "homepage": "https://github.com/ChatLunaLab/chatluna/tree/v1-dev/packages/shared-adapter#readme",
32
+ "scripts": {
33
+ "build": "atsc -b"
34
+ },
35
+ "engines": {
36
+ "node": ">=18.0.0"
37
+ },
38
+ "resolutions": {
39
+ "@langchain/core": "0.3.62",
40
+ "js-tiktoken": "npm:@dingyi222666/js-tiktoken@^1.0.21"
17
41
  },
18
- "./package.json": "./package.json"
19
- },
20
- "type": "module",
21
- "author": "dingyi222666 <dingyi222666@foxmail.com>",
22
- "repository": {
23
- "type": "git",
24
- "url": "https://github.com/ChatLunaLab/chatluna.git",
25
- "directory": "packages/shared-adapter"
26
- },
27
- "license": "AGPL-3.0",
28
- "bugs": {
29
- "url": "https://github.com/ChatLunaLab/chatluna/issues"
30
- },
31
- "homepage": "https://github.com/ChatLunaLab/chatluna/tree/v1-dev/packages/shared-adapter#readme",
32
- "scripts": {
33
- "build": "atsc -b"
34
- },
35
- "engines": {
36
- "node": ">=18.0.0"
37
- },
38
- "resolutions": {
39
- "@langchain/core": "0.3.62",
40
- "js-tiktoken": "npm:@dingyi222666/js-tiktoken@^1.0.21"
41
- },
42
- "overrides": {
43
- "@langchain/core": "0.3.62",
44
- "js-tiktoken": "npm:@dingyi222666/js-tiktoken@^1.0.21"
45
- },
46
- "pnpm": {
47
42
  "overrides": {
48
- "@langchain/core": "0.3.62",
49
- "js-tiktoken": "npm:@dingyi222666/js-tiktoken@^1.0.21"
43
+ "@langchain/core": "0.3.62",
44
+ "js-tiktoken": "npm:@dingyi222666/js-tiktoken@^1.0.21"
45
+ },
46
+ "pnpm": {
47
+ "overrides": {
48
+ "@langchain/core": "0.3.62",
49
+ "js-tiktoken": "npm:@dingyi222666/js-tiktoken@^1.0.21"
50
+ }
51
+ },
52
+ "keywords": [
53
+ "chatbot",
54
+ "koishi",
55
+ "plugin",
56
+ "service",
57
+ "chatgpt",
58
+ "gpt",
59
+ "chatluna",
60
+ "adapter"
61
+ ],
62
+ "dependencies": {
63
+ "@langchain/core": "0.3.62",
64
+ "zod": "3.25.76",
65
+ "zod-to-json-schema": "^3.24.6"
66
+ },
67
+ "devDependencies": {
68
+ "atsc": "^2.1.0",
69
+ "koishi": "^4.18.9"
70
+ },
71
+ "peerDependencies": {
72
+ "koishi": "^4.18.9",
73
+ "koishi-plugin-chatluna": "^1.3.0-alpha.77"
50
74
  }
51
- },
52
- "keywords": [
53
- "chatbot",
54
- "koishi",
55
- "plugin",
56
- "service",
57
- "chatgpt",
58
- "gpt",
59
- "chatluna",
60
- "adapter"
61
- ],
62
- "dependencies": {
63
- "@langchain/core": "0.3.62",
64
- "zod": "3.25.76",
65
- "zod-to-json-schema": "^3.24.6"
66
- },
67
- "devDependencies": {
68
- "atsc": "^2.1.0",
69
- "koishi": "^4.18.9"
70
- },
71
- "peerDependencies": {
72
- "koishi": "^4.18.9",
73
- "koishi-plugin-chatluna": "^1.3.0-alpha.60"
74
- }
75
- }
75
+ }