@nocobase/plugin-ai 2.2.0-beta.17 → 2.2.0-beta.18
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/ai/docs/nocobase/ai-dev/watermark-plugin.md +2 -0
- package/dist/ai/docs/nocobase/api/cli/api/resource/create.md +4 -3
- package/dist/ai/docs/nocobase/plugin-development/build.md +10 -4
- package/dist/ai/docs/nocobase/plugin-development/client/appendix/faq.md +1 -1
- package/dist/ai/docs/nocobase/plugin-development/client/examples/custom-action.md +2 -0
- package/dist/ai/docs/nocobase/plugin-development/client/examples/custom-block.md +2 -0
- package/dist/ai/docs/nocobase/plugin-development/client/examples/custom-field.md +2 -0
- package/dist/ai/docs/nocobase/plugin-development/client/examples/fullstack-plugin.md +2 -0
- package/dist/ai/docs/nocobase/plugin-development/client/examples/settings-page.md +2 -0
- package/dist/ai/docs/nocobase/plugin-development/common/i18n.md +3 -3
- package/dist/ai/docs/nocobase/plugin-development/server/cache.md +1 -1
- package/dist/ai/docs/nocobase/plugin-development/server/collections.md +0 -6
- package/dist/ai/docs/nocobase/plugin-development/server/command.md +2 -2
- package/dist/ai/docs/nocobase/plugin-development/server/context.md +2 -2
- package/dist/ai/docs/nocobase/plugin-development/server/i18n.md +4 -4
- package/dist/ai/docs/nocobase/plugin-development/write-your-first-plugin.md +91 -43
- package/dist/ai/docs/nocobase/users-permissions/sync/index.md +8 -1
- package/dist/ai/docs/nocobase/users-permissions/sync/sources/dingtalk.md +138 -0
- package/dist/ai/docs/nocobase/users-permissions/sync/sources/ldap.md +87 -0
- package/dist/client/{705.19b642db34de438a.js → 705.a4fe26945d175e8a.js} +1 -1
- package/dist/client/index.js +3 -3
- package/dist/client-v2/420.a5b929a5e7f330be.js +10 -0
- package/dist/client-v2/{705.8dc34d43f02f322c.js → 705.f2e1b26a3f000075.js} +1 -1
- package/dist/client-v2/ai-employees/chatbox/hooks/reasoning-stream.d.ts +10 -0
- package/dist/client-v2/ai-employees/chatbox/stores/chat-box.d.ts +0 -2
- package/dist/client-v2/index.js +3 -3
- package/dist/client-v2/llm-providers/forms.d.ts +2 -0
- package/dist/client-v2/llm-providers/index.d.ts +1 -0
- package/dist/client-v2/models/ai-employees/AIEmployeeShortcutModel.d.ts +1 -0
- package/dist/client-v2/repositories/AIConfigRepository.d.ts +2 -0
- package/dist/externalVersion.js +18 -16
- package/dist/locale/en-US.json +3 -4
- package/dist/locale/zh-CN.json +3 -4
- package/dist/node_modules/@langchain/mistralai/package.json +1 -1
- package/dist/node_modules/@langchain/xai/package.json +1 -1
- package/dist/node_modules/fs-extra/package.json +1 -1
- package/dist/node_modules/jsonrepair/package.json +1 -1
- package/dist/node_modules/just-bash/package.json +1 -1
- package/dist/node_modules/nodejs-snowflake/package.json +1 -1
- package/dist/node_modules/openai/package.json +1 -1
- package/dist/node_modules/zod/package.json +1 -1
- package/dist/server/ai-employees/ai-employee.js +40 -24
- package/dist/server/ai-employees/reasoning-stream-state.d.ts +23 -0
- package/dist/server/ai-employees/reasoning-stream-state.js +63 -0
- package/dist/server/llm-providers/common/reasoning.js +18 -10
- package/dist/{client-v2/ai-employees/chatbox/components/DebugPanel.d.ts → server/llm-providers/deepseek/index.d.ts} +2 -2
- package/dist/server/llm-providers/deepseek/index.js +32 -0
- package/dist/server/llm-providers/deepseek/provider.d.ts +57 -0
- package/dist/server/llm-providers/deepseek/provider.js +320 -0
- package/dist/server/llm-providers/deepseek/reasoning.d.ts +83 -0
- package/dist/server/llm-providers/deepseek/reasoning.js +285 -0
- package/dist/server/llm-providers/mistral.d.ts +1 -1
- package/dist/server/llm-providers/provider.d.ts +1 -0
- package/dist/server/llm-providers/provider.js +3 -0
- package/dist/server/llm-providers/shengsuanyun.d.ts +29 -0
- package/dist/server/llm-providers/shengsuanyun.js +114 -0
- package/dist/server/manager/ai-manager.d.ts +3 -0
- package/dist/server/manager/ai-manager.js +7 -2
- package/dist/server/plugin.js +2 -0
- package/dist/server/types/ai-message.type.d.ts +4 -0
- package/dist/swagger/index.d.ts +6 -0
- package/dist/swagger/schemas.d.ts +6 -0
- package/dist/swagger/schemas.js +6 -0
- package/package.json +2 -2
- package/dist/client-v2/420.b2aedb1ff71fca0e.js +0 -10
- package/dist/client-v2/debug-logger.d.ts +0 -52
- package/dist/server/llm-providers/deepseek.d.ts +0 -40
- package/dist/server/llm-providers/deepseek.js +0 -174
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
/**
|
|
10
|
-
* [AI_DEBUG] AI Debug Logger
|
|
11
|
-
*
|
|
12
|
-
* To remove this debug feature, search for "[AI_DEBUG]" in the codebase and delete:
|
|
13
|
-
* 1. This file (debug-logger.ts)
|
|
14
|
-
* 2. All import statements with "[AI_DEBUG]" comment
|
|
15
|
-
* 3. All code blocks with "[AI_DEBUG]" comment
|
|
16
|
-
*/
|
|
17
|
-
export type LogType = 'request' | 'stream_text' | 'stream_search' | 'stream_start' | 'stream_tools' | 'stream_delta' | 'stream_reasoning' | 'stream_error' | 'tool_call' | 'tool_result' | 'error';
|
|
18
|
-
export type LogEntry = {
|
|
19
|
-
id: string;
|
|
20
|
-
type: LogType;
|
|
21
|
-
time: number;
|
|
22
|
-
data: Record<string, unknown>;
|
|
23
|
-
};
|
|
24
|
-
type SessionLog = {
|
|
25
|
-
sessionId: string;
|
|
26
|
-
employeeId?: string;
|
|
27
|
-
employeeName?: string;
|
|
28
|
-
createdAt: number;
|
|
29
|
-
updatedAt: number;
|
|
30
|
-
logs: LogEntry[];
|
|
31
|
-
};
|
|
32
|
-
type DebugData = {
|
|
33
|
-
sessions: SessionLog[];
|
|
34
|
-
};
|
|
35
|
-
type LogListener = (log: LogEntry, sessionId: string) => void;
|
|
36
|
-
declare class AIDebugLogger {
|
|
37
|
-
private listeners;
|
|
38
|
-
subscribe(callback: LogListener): () => void;
|
|
39
|
-
private notifyListeners;
|
|
40
|
-
log(sessionId: string, type: LogType, data: Record<string, unknown>, meta?: {
|
|
41
|
-
employeeId?: string;
|
|
42
|
-
employeeName?: string;
|
|
43
|
-
}): void;
|
|
44
|
-
private getStorage;
|
|
45
|
-
private saveStorage;
|
|
46
|
-
clear(): void;
|
|
47
|
-
clearSession(sessionId: string): void;
|
|
48
|
-
getAll(): DebugData;
|
|
49
|
-
getSession(sessionId: string): SessionLog | undefined;
|
|
50
|
-
}
|
|
51
|
-
export declare const aiDebugLogger: AIDebugLogger;
|
|
52
|
-
export {};
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
import { ChatDeepSeek } from '@langchain/deepseek';
|
|
10
|
-
import { AIMessageChunk, BaseMessage } from '@langchain/core/messages';
|
|
11
|
-
import { LLMProvider, ReasoningOptions, ResolvedReasoningOptions } from './provider';
|
|
12
|
-
import { LLMProviderMeta } from '../manager/ai-manager';
|
|
13
|
-
import { Model } from '@nocobase/database';
|
|
14
|
-
import type OpenAI from 'openai';
|
|
15
|
-
import { AttachmentModel } from '@nocobase/plugin-file-manager';
|
|
16
|
-
declare class ReasoningDeepSeek extends ChatDeepSeek {
|
|
17
|
-
_generate(messages: BaseMessage[], options: any, runManager?: any): Promise<import("@langchain/core/dist/outputs").ChatResult>;
|
|
18
|
-
_streamResponseChunks(messages: BaseMessage[], options: any, runManager?: any): AsyncGenerator<import("@langchain/core/dist/outputs").ChatGenerationChunk, void, unknown>;
|
|
19
|
-
completionWithRetry(request: OpenAI.Chat.ChatCompletionCreateParamsStreaming, requestOptions?: OpenAI.RequestOptions): Promise<AsyncIterable<OpenAI.Chat.Completions.ChatCompletionChunk>>;
|
|
20
|
-
completionWithRetry(request: OpenAI.Chat.ChatCompletionCreateParamsNonStreaming, requestOptions?: OpenAI.RequestOptions): Promise<OpenAI.Chat.Completions.ChatCompletion>;
|
|
21
|
-
}
|
|
22
|
-
export declare class DeepSeekProvider extends LLMProvider {
|
|
23
|
-
chatModel: ChatDeepSeek;
|
|
24
|
-
get baseURL(): string;
|
|
25
|
-
createModel(): ReasoningDeepSeek;
|
|
26
|
-
parseResponseMessage(message: Model): {
|
|
27
|
-
key: any;
|
|
28
|
-
createdAt: any;
|
|
29
|
-
content: any;
|
|
30
|
-
role: any;
|
|
31
|
-
};
|
|
32
|
-
parseReasoningContent(chunk: AIMessageChunk): {
|
|
33
|
-
status: string;
|
|
34
|
-
content: string;
|
|
35
|
-
};
|
|
36
|
-
protected resolveReasoningOptions(reasoning?: ReasoningOptions): ResolvedReasoningOptions;
|
|
37
|
-
protected isApiSupportedAttachment(attachment: AttachmentModel): boolean;
|
|
38
|
-
}
|
|
39
|
-
export declare const deepseekProviderOptions: LLMProviderMeta;
|
|
40
|
-
export {};
|
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
var __create = Object.create;
|
|
11
|
-
var __defProp = Object.defineProperty;
|
|
12
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
13
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
14
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
15
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
16
|
-
var __export = (target, all) => {
|
|
17
|
-
for (var name in all)
|
|
18
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
19
|
-
};
|
|
20
|
-
var __copyProps = (to, from, except, desc) => {
|
|
21
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
22
|
-
for (let key of __getOwnPropNames(from))
|
|
23
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
24
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
25
|
-
}
|
|
26
|
-
return to;
|
|
27
|
-
};
|
|
28
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
29
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
30
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
31
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
32
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
33
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
34
|
-
mod
|
|
35
|
-
));
|
|
36
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
37
|
-
var deepseek_exports = {};
|
|
38
|
-
__export(deepseek_exports, {
|
|
39
|
-
DeepSeekProvider: () => DeepSeekProvider,
|
|
40
|
-
deepseekProviderOptions: () => deepseekProviderOptions
|
|
41
|
-
});
|
|
42
|
-
module.exports = __toCommonJS(deepseek_exports);
|
|
43
|
-
var import_deepseek = require("@langchain/deepseek");
|
|
44
|
-
var import_provider = require("./provider");
|
|
45
|
-
var import_ai_manager = require("../manager/ai-manager");
|
|
46
|
-
var import_lodash = __toESM(require("lodash"));
|
|
47
|
-
var import_reasoning = require("./common/reasoning");
|
|
48
|
-
const DEEPSEEK_REASONING_EFFORTS = /* @__PURE__ */ new Set(["low", "medium", "high"]);
|
|
49
|
-
class ReasoningDeepSeek extends import_deepseek.ChatDeepSeek {
|
|
50
|
-
async _generate(messages, options, runManager) {
|
|
51
|
-
const reasoningMap = (0, import_reasoning.collectReasoningMap)(messages);
|
|
52
|
-
const nextOptions = {
|
|
53
|
-
...options || {},
|
|
54
|
-
[import_reasoning.REASONING_MAP_KEY]: reasoningMap
|
|
55
|
-
};
|
|
56
|
-
return super._generate(messages, nextOptions, runManager);
|
|
57
|
-
}
|
|
58
|
-
async *_streamResponseChunks(messages, options, runManager) {
|
|
59
|
-
const reasoningMap = (options == null ? void 0 : options[import_reasoning.REASONING_MAP_KEY]) instanceof Map ? options[import_reasoning.REASONING_MAP_KEY] : (0, import_reasoning.collectReasoningMap)(messages);
|
|
60
|
-
const nextOptions = {
|
|
61
|
-
...options || {},
|
|
62
|
-
[import_reasoning.REASONING_MAP_KEY]: reasoningMap
|
|
63
|
-
};
|
|
64
|
-
yield* super._streamResponseChunks(messages, nextOptions, runManager);
|
|
65
|
-
}
|
|
66
|
-
async completionWithRetry(request, requestOptions) {
|
|
67
|
-
const reasoningMap = requestOptions == null ? void 0 : requestOptions[import_reasoning.REASONING_MAP_KEY];
|
|
68
|
-
const modelKwargs = requestOptions == null ? void 0 : requestOptions[import_reasoning.MODEL_KWARGS_KEY];
|
|
69
|
-
(0, import_reasoning.patchRequestMessagesReasoning)(request, reasoningMap);
|
|
70
|
-
(0, import_reasoning.patchRequestModelKwargs)(request, modelKwargs);
|
|
71
|
-
if (request.stream) {
|
|
72
|
-
return super.completionWithRetry(request, requestOptions);
|
|
73
|
-
}
|
|
74
|
-
return super.completionWithRetry(request, requestOptions);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
class DeepSeekProvider extends import_provider.LLMProvider {
|
|
78
|
-
get baseURL() {
|
|
79
|
-
return "https://api.deepseek.com";
|
|
80
|
-
}
|
|
81
|
-
createModel() {
|
|
82
|
-
const { apiKey } = this.serviceOptions || {};
|
|
83
|
-
const { responseFormat } = this.modelOptions || {};
|
|
84
|
-
const reasoningOptions = this.resolveReasoningOptions(this.modelReasoningOptions);
|
|
85
|
-
const modelKwargs = {};
|
|
86
|
-
if (responseFormat) {
|
|
87
|
-
modelKwargs["response_format"] = {
|
|
88
|
-
type: responseFormat
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
return new ReasoningDeepSeek({
|
|
92
|
-
apiKey,
|
|
93
|
-
...this.modelOptions,
|
|
94
|
-
...reasoningOptions.modelRequestParams || {},
|
|
95
|
-
modelKwargs: {
|
|
96
|
-
...modelKwargs,
|
|
97
|
-
...reasoningOptions.modelKwargs || {}
|
|
98
|
-
},
|
|
99
|
-
configuration: {
|
|
100
|
-
baseURL: this.getResolvedBaseURL()
|
|
101
|
-
},
|
|
102
|
-
verbose: false
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
parseResponseMessage(message) {
|
|
106
|
-
var _a;
|
|
107
|
-
const result = super.parseResponseMessage(message);
|
|
108
|
-
if (["user", "tool"].includes(result == null ? void 0 : result.role)) {
|
|
109
|
-
return result;
|
|
110
|
-
}
|
|
111
|
-
const { metadata } = (message == null ? void 0 : message.toJSON()) ?? {};
|
|
112
|
-
if (!import_lodash.default.isEmpty((_a = metadata == null ? void 0 : metadata.additional_kwargs) == null ? void 0 : _a.reasoning_content)) {
|
|
113
|
-
result.content = {
|
|
114
|
-
...result.content ?? {},
|
|
115
|
-
reasoning: {
|
|
116
|
-
status: "stop",
|
|
117
|
-
content: metadata == null ? void 0 : metadata.additional_kwargs.reasoning_content
|
|
118
|
-
}
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
return result;
|
|
122
|
-
}
|
|
123
|
-
parseReasoningContent(chunk) {
|
|
124
|
-
var _a;
|
|
125
|
-
if (!import_lodash.default.isEmpty((_a = chunk == null ? void 0 : chunk.additional_kwargs) == null ? void 0 : _a.reasoning_content)) {
|
|
126
|
-
return {
|
|
127
|
-
status: "streaming",
|
|
128
|
-
content: chunk.additional_kwargs.reasoning_content
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
return null;
|
|
132
|
-
}
|
|
133
|
-
resolveReasoningOptions(reasoning) {
|
|
134
|
-
if (!reasoning || reasoning.mode === "default") {
|
|
135
|
-
return {};
|
|
136
|
-
}
|
|
137
|
-
if (reasoning.mode === "off") {
|
|
138
|
-
return {
|
|
139
|
-
modelKwargs: {
|
|
140
|
-
thinking: {
|
|
141
|
-
type: "disabled"
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
if (!DEEPSEEK_REASONING_EFFORTS.has(reasoning.mode)) {
|
|
147
|
-
return {};
|
|
148
|
-
}
|
|
149
|
-
return {
|
|
150
|
-
modelKwargs: {
|
|
151
|
-
thinking: {
|
|
152
|
-
type: "enabled"
|
|
153
|
-
},
|
|
154
|
-
reasoning_effort: reasoning.mode
|
|
155
|
-
}
|
|
156
|
-
};
|
|
157
|
-
}
|
|
158
|
-
isApiSupportedAttachment(attachment) {
|
|
159
|
-
return false;
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
const deepseekProviderOptions = {
|
|
163
|
-
title: "DeepSeek",
|
|
164
|
-
supportedModel: [import_ai_manager.SupportedModel.LLM],
|
|
165
|
-
models: {
|
|
166
|
-
[import_ai_manager.SupportedModel.LLM]: ["deepseek-v4-pro", "deepseek-v4-flash", "deepseek-chat", "deepseek-reasoner"]
|
|
167
|
-
},
|
|
168
|
-
provider: DeepSeekProvider
|
|
169
|
-
};
|
|
170
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
171
|
-
0 && (module.exports = {
|
|
172
|
-
DeepSeekProvider,
|
|
173
|
-
deepseekProviderOptions
|
|
174
|
-
});
|