@nocobase/plugin-ai 2.0.0-beta.6 → 2.0.0-beta.7

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.
Files changed (65) hide show
  1. package/dist/client/6a4c1ee12f864e38.js +10 -0
  2. package/dist/client/index.js +1 -1
  3. package/dist/collections/ai-employees.d.ts +1 -0
  4. package/dist/collections/ai-employees.js +4 -0
  5. package/dist/externalVersion.js +11 -11
  6. package/dist/locale/en-US.json +2 -0
  7. package/dist/locale/zh-CN.json +2 -0
  8. package/dist/node_modules/@langchain/anthropic/package.json +1 -1
  9. package/dist/node_modules/@langchain/core/package.json +1 -1
  10. package/dist/node_modules/@langchain/deepseek/package.json +1 -1
  11. package/dist/node_modules/@langchain/google-genai/LICENSE +6 -6
  12. package/dist/node_modules/@langchain/google-genai/dist/_virtual/rolldown_runtime.cjs +25 -0
  13. package/dist/node_modules/@langchain/google-genai/dist/chat_models.cjs +680 -842
  14. package/dist/node_modules/@langchain/google-genai/dist/chat_models.d.cts +581 -0
  15. package/dist/node_modules/@langchain/google-genai/dist/chat_models.d.ts +196 -157
  16. package/dist/node_modules/@langchain/google-genai/dist/chat_models.js +678 -837
  17. package/dist/node_modules/@langchain/google-genai/dist/embeddings.cjs +97 -151
  18. package/dist/node_modules/@langchain/google-genai/dist/embeddings.d.cts +104 -0
  19. package/dist/node_modules/@langchain/google-genai/dist/embeddings.d.ts +76 -70
  20. package/dist/node_modules/@langchain/google-genai/dist/embeddings.js +93 -144
  21. package/dist/node_modules/@langchain/google-genai/dist/index.cjs +252 -18
  22. package/dist/node_modules/@langchain/google-genai/dist/index.d.cts +3 -0
  23. package/dist/node_modules/@langchain/google-genai/dist/index.d.ts +3 -2
  24. package/dist/node_modules/@langchain/google-genai/dist/index.js +4 -2
  25. package/dist/node_modules/@langchain/google-genai/dist/output_parsers.cjs +47 -75
  26. package/dist/node_modules/@langchain/google-genai/dist/output_parsers.js +47 -72
  27. package/dist/node_modules/@langchain/google-genai/dist/profiles.cjs +345 -0
  28. package/dist/node_modules/@langchain/google-genai/dist/profiles.js +344 -0
  29. package/dist/node_modules/@langchain/google-genai/dist/types.d.cts +17 -0
  30. package/dist/node_modules/@langchain/google-genai/dist/types.d.ts +16 -2
  31. package/dist/node_modules/@langchain/google-genai/dist/utils/common.cjs +419 -551
  32. package/dist/node_modules/@langchain/google-genai/dist/utils/common.js +417 -545
  33. package/dist/node_modules/@langchain/google-genai/dist/utils/tools.cjs +65 -102
  34. package/dist/node_modules/@langchain/google-genai/dist/utils/tools.js +64 -99
  35. package/dist/node_modules/@langchain/google-genai/dist/utils/zod_to_genai_parameters.cjs +31 -49
  36. package/dist/node_modules/@langchain/google-genai/dist/utils/zod_to_genai_parameters.js +29 -45
  37. package/dist/node_modules/@langchain/google-genai/package.json +1 -1
  38. package/dist/node_modules/@langchain/ollama/package.json +1 -1
  39. package/dist/node_modules/@langchain/openai/package.json +1 -1
  40. package/dist/node_modules/nodejs-snowflake/package.json +1 -1
  41. package/dist/node_modules/zod/package.json +1 -1
  42. package/dist/node_modules/zod-to-json-schema/package.json +1 -1
  43. package/dist/server/ai-employees/ai-employee.js +5 -2
  44. package/dist/server/llm-providers/anthropic.js +4 -5
  45. package/dist/server/llm-providers/provider.js +5 -1
  46. package/dist/server/manager/ai-chat-conversation.js +3 -2
  47. package/dist/server/manager/built-in-manager.js +3 -3
  48. package/dist/server/migrations/20260107000000-reset-builtin-about.d.ts +14 -0
  49. package/dist/server/migrations/20260107000000-reset-builtin-about.js +48 -0
  50. package/dist/server/resource/ai.js +8 -2
  51. package/dist/server/resource/aiEmployees.d.ts +0 -1
  52. package/dist/server/resource/aiEmployees.js +0 -15
  53. package/dist/server/types/ai-message.type.d.ts +2 -0
  54. package/package.json +3 -3
  55. package/dist/client/a7f0550514128d80.js +0 -10
  56. package/dist/node_modules/@langchain/google-genai/dist/output_parsers.d.ts +0 -20
  57. package/dist/node_modules/@langchain/google-genai/dist/types.cjs +0 -2
  58. package/dist/node_modules/@langchain/google-genai/dist/types.js +0 -1
  59. package/dist/node_modules/@langchain/google-genai/dist/utils/common.d.ts +0 -22
  60. package/dist/node_modules/@langchain/google-genai/dist/utils/tools.d.ts +0 -10
  61. package/dist/node_modules/@langchain/google-genai/dist/utils/zod_to_genai_parameters.d.ts +0 -14
  62. package/dist/node_modules/@langchain/google-genai/index.cjs +0 -252
  63. package/dist/node_modules/@langchain/google-genai/index.d.cts +0 -1
  64. package/dist/node_modules/@langchain/google-genai/index.d.ts +0 -1
  65. package/dist/node_modules/@langchain/google-genai/index.js +0 -1
@@ -1 +1 @@
1
- {"name":"zod-to-json-schema","version":"3.24.3","description":"Converts Zod schemas to Json Schemas","types":"./dist/types/index.d.ts","main":"./dist/cjs/index.js","module":"./dist/esm/index.js","exports":{"import":{"types":"./dist/types/index.d.ts","default":"./dist/esm/index.js"},"require":{"types":"./dist/types/index.d.ts","default":"./dist/cjs/index.js"}},"scripts":{"build:test":"npm --prefix ./dist-test test","build:types":"tsc -p tsconfig.types.json","build:cjs":"tsc -p tsconfig.cjs.json && tsx postcjs.ts","build:esm":"tsc -p tsconfig.esm.json && tsx postesm.ts","build":"npm i && npm run gen && npm test && rimraf ./dist && npm run build:types && npm run build:cjs && npm run build:esm && npm run build:test","dry":"npm run build && npm pub --dry-run","test:watch":"tsx watch test/index.ts","test:gen":"tsx test/createIndex.ts","test":"tsx test/index.ts","gen":"tsx createIndex.ts"},"c8":{"exclude":["createIndex.ts","postcjs.ts","postesm.ts","test"]},"keywords":["zod","json","schema","open","api","conversion"],"author":"Stefan Terdell","contributors":["Hammad Asif (https://github.com/mrhammadasif)","Noah Rosenzweig (https://github.com/Noah2610)","John Wright (https://github.com/johngeorgewright)","Krzysztof Ciombor (https://github.com/krzysztofciombor)","Yuta Mombetsu (https://github.com/mokocm)","Tom Arad (https://github.com/tomarad)","Isaac Way (https://github.com/iway1)","Andreas Berger (https://github.com/Andy2003)","Jan Potoms (https://github.com/Janpot)","Santiago Cammi (https://github.com/scammi)","Philipp Burckhardt (https://github.com/Planeshifter)","Bram del Canho (https://github.com/Bram-dc)","Gilad Hecht (https://github.com/gthecht)","Colin McDonnell (https://github.com/colinhacks)","Spappz (https://github.com/Spappz)","Jacob Lee (https://github.com/jacoblee93)","Brett Zamir (https://github.com/brettz9)","Isaiah Marc Sanchez (https://github.com/imsanchez)","Mitchell Merry (https://github.com/mitchell-merry)","Enzo Monjardín (https://github.com/enzomonjardin)","Víctor Hernández (https://github.com/NanezX)"],"repository":{"type":"git","url":"https://github.com/StefanTerdell/zod-to-json-schema"},"license":"ISC","peerDependencies":{"zod":"^3.24.1"},"devDependencies":{"@types/json-schema":"^7.0.9","@types/node":"^20.9.0","ajv":"^8.6.3","ajv-errors":"^3.0.0","ajv-formats":"^2.1.1","fast-diff":"^1.3.0","local-ref-resolver":"^0.2.0","rimraf":"^3.0.2","tsx":"^4.19.0","typescript":"^5.1.3","zod":"^3.24.1"},"_lastModified":"2026-01-07T00:02:12.454Z"}
1
+ {"name":"zod-to-json-schema","version":"3.24.3","description":"Converts Zod schemas to Json Schemas","types":"./dist/types/index.d.ts","main":"./dist/cjs/index.js","module":"./dist/esm/index.js","exports":{"import":{"types":"./dist/types/index.d.ts","default":"./dist/esm/index.js"},"require":{"types":"./dist/types/index.d.ts","default":"./dist/cjs/index.js"}},"scripts":{"build:test":"npm --prefix ./dist-test test","build:types":"tsc -p tsconfig.types.json","build:cjs":"tsc -p tsconfig.cjs.json && tsx postcjs.ts","build:esm":"tsc -p tsconfig.esm.json && tsx postesm.ts","build":"npm i && npm run gen && npm test && rimraf ./dist && npm run build:types && npm run build:cjs && npm run build:esm && npm run build:test","dry":"npm run build && npm pub --dry-run","test:watch":"tsx watch test/index.ts","test:gen":"tsx test/createIndex.ts","test":"tsx test/index.ts","gen":"tsx createIndex.ts"},"c8":{"exclude":["createIndex.ts","postcjs.ts","postesm.ts","test"]},"keywords":["zod","json","schema","open","api","conversion"],"author":"Stefan Terdell","contributors":["Hammad Asif (https://github.com/mrhammadasif)","Noah Rosenzweig (https://github.com/Noah2610)","John Wright (https://github.com/johngeorgewright)","Krzysztof Ciombor (https://github.com/krzysztofciombor)","Yuta Mombetsu (https://github.com/mokocm)","Tom Arad (https://github.com/tomarad)","Isaac Way (https://github.com/iway1)","Andreas Berger (https://github.com/Andy2003)","Jan Potoms (https://github.com/Janpot)","Santiago Cammi (https://github.com/scammi)","Philipp Burckhardt (https://github.com/Planeshifter)","Bram del Canho (https://github.com/Bram-dc)","Gilad Hecht (https://github.com/gthecht)","Colin McDonnell (https://github.com/colinhacks)","Spappz (https://github.com/Spappz)","Jacob Lee (https://github.com/jacoblee93)","Brett Zamir (https://github.com/brettz9)","Isaiah Marc Sanchez (https://github.com/imsanchez)","Mitchell Merry (https://github.com/mitchell-merry)","Enzo Monjardín (https://github.com/enzomonjardin)","Víctor Hernández (https://github.com/NanezX)"],"repository":{"type":"git","url":"https://github.com/StefanTerdell/zod-to-json-schema"},"license":"ISC","peerDependencies":{"zod":"^3.24.1"},"devDependencies":{"@types/json-schema":"^7.0.9","@types/node":"^20.9.0","ajv":"^8.6.3","ajv-errors":"^3.0.0","ajv-formats":"^2.1.1","fast-diff":"^1.3.0","local-ref-resolver":"^0.2.0","rimraf":"^3.0.2","tsx":"^4.19.0","typescript":"^5.1.3","zod":"^3.24.1"},"_lastModified":"2026-01-09T02:29:56.490Z"}
@@ -193,6 +193,9 @@ class AIEmployee {
193
193
  if (gathered == null ? void 0 : gathered.response_metadata) {
194
194
  values.metadata.response_metadata = gathered.response_metadata;
195
195
  }
196
+ if (gathered == null ? void 0 : gathered.additional_kwargs) {
197
+ values.metadata.additional_kwargs = gathered.additional_kwargs;
198
+ }
196
199
  const aiMessage = await this.aiChatConversation.withTransaction(async (conversation, transaction) => {
197
200
  if (messageId) {
198
201
  await conversation.removeMessages({ messageId });
@@ -291,7 +294,7 @@ Field: ${field.name}, Title: ${(_a = field.options.uiSchema) == null ? void 0 :
291
294
  aiEmployee: this.employee.username
292
295
  }
293
296
  });
294
- let systemMessage = await (0, import_utils.parseVariables)(this.ctx, this.employee.about);
297
+ let systemMessage = await (0, import_utils.parseVariables)(this.ctx, this.employee.about ?? this.employee.defaultPrompt);
295
298
  const dataSourceMessage = this.getEmployeeDataSourceContext();
296
299
  if (dataSourceMessage) {
297
300
  systemMessage = `${systemMessage}
@@ -319,7 +322,7 @@ ${workContextBackground.join("\n")}`;
319
322
  return (0, import_prompts.getSystemPrompt)({
320
323
  aiEmployee: {
321
324
  nickname: this.employee.nickname,
322
- about: this.employee.about
325
+ about: this.employee.about ?? this.employee.defaultPrompt
323
326
  },
324
327
  task: {
325
328
  background
@@ -61,7 +61,7 @@ class AnthropicProvider extends import_provider.LLMProvider {
61
61
  });
62
62
  }
63
63
  async listModels() {
64
- var _a;
64
+ var _a, _b, _c, _d, _e;
65
65
  const options = this.serviceOptions || {};
66
66
  const apiKey = options.apiKey;
67
67
  let baseURL = options.baseURL || this.baseURL;
@@ -75,9 +75,6 @@ class AnthropicProvider extends import_provider.LLMProvider {
75
75
  baseURL = baseURL.slice(0, -1);
76
76
  }
77
77
  try {
78
- if (baseURL && baseURL.endsWith("/")) {
79
- baseURL = baseURL.slice(0, -1);
80
- }
81
78
  const res = await import_axios.default.get(`${baseURL}/models`, {
82
79
  headers: {
83
80
  "x-api-key": apiKey,
@@ -88,7 +85,9 @@ class AnthropicProvider extends import_provider.LLMProvider {
88
85
  models: (_a = res == null ? void 0 : res.data) == null ? void 0 : _a.data
89
86
  };
90
87
  } catch (e) {
91
- return { code: 500, errMsg: e.message };
88
+ const status = ((_b = e.response) == null ? void 0 : _b.status) || 500;
89
+ const errorMsg = ((_e = (_d = (_c = e.response) == null ? void 0 : _c.data) == null ? void 0 : _d.error) == null ? void 0 : _e.message) || e.message;
90
+ return { code: status, errMsg: `Anthropic API Error: ${errorMsg}` };
92
91
  }
93
92
  }
94
93
  parseResponseMessage(message) {
@@ -88,6 +88,7 @@ class LLMProvider {
88
88
  return chain.streamEvents(context.messages, options);
89
89
  }
90
90
  async listModels() {
91
+ var _a, _b, _c, _d;
91
92
  const options = this.serviceOptions || {};
92
93
  const apiKey = options.apiKey;
93
94
  let baseURL = options.baseURL || this.baseURL;
@@ -111,7 +112,10 @@ class LLMProvider {
111
112
  });
112
113
  return { models: res == null ? void 0 : res.data.data };
113
114
  } catch (e) {
114
- return { code: 500, errMsg: e.message };
115
+ const status = ((_a = e.response) == null ? void 0 : _a.status) || 500;
116
+ const data = (_b = e.response) == null ? void 0 : _b.data;
117
+ const errorMsg = ((_c = data == null ? void 0 : data.error) == null ? void 0 : _c.message) || (data == null ? void 0 : data.message) || (typeof (data == null ? void 0 : data.error) === "string" ? data.error : void 0) || (typeof data === "string" ? data : void 0) || ((_d = e.response) == null ? void 0 : _d.statusText) || e.message;
118
+ return { code: status, errMsg: errorMsg };
115
119
  }
116
120
  }
117
121
  parseResponseMessage(message) {
@@ -145,7 +145,7 @@ class AIChatConversationImpl {
145
145
  };
146
146
  }
147
147
  async formatMessages(messages, options) {
148
- var _a, _b, _c;
148
+ var _a, _b, _c, _d;
149
149
  const formattedMessages = [];
150
150
  const { provider, workContextHandler } = options;
151
151
  const truncate = (text, maxLen = 5e4) => {
@@ -197,7 +197,8 @@ class AIChatConversationImpl {
197
197
  formattedMessages.push({
198
198
  role: "assistant",
199
199
  content,
200
- tool_calls: msg.toolCalls
200
+ tool_calls: msg.toolCalls,
201
+ additional_kwargs: (_d = msg.metadata) == null ? void 0 : _d.additional_kwargs
201
202
  });
202
203
  }
203
204
  return formattedMessages;
@@ -88,7 +88,7 @@ class BuiltInManager {
88
88
  aiEmployee.position = position;
89
89
  aiEmployee.bio = bio;
90
90
  aiEmployee.greeting = greeting;
91
- aiEmployee.about = aiEmployee.about ?? about;
91
+ aiEmployee.defaultPrompt = about;
92
92
  const builtInSkills = ((_a = builtInEmployeeInfo.skillSettings) == null ? void 0 : _a.skills) ?? [];
93
93
  const skillSettings = aiEmployee.skillSettings ?? {};
94
94
  const skills = skillSettings.skills ?? [];
@@ -119,7 +119,7 @@ class BuiltInManager {
119
119
  if (!p) {
120
120
  continue;
121
121
  }
122
- const { nickname, avatar, position, bio, greeting, about } = p;
122
+ const { nickname, avatar, position, bio, greeting } = p;
123
123
  await aiEmployeesRepo.create({
124
124
  values: {
125
125
  username,
@@ -128,7 +128,7 @@ class BuiltInManager {
128
128
  avatar,
129
129
  bio,
130
130
  greeting,
131
- about,
131
+ about: null,
132
132
  skillSettings,
133
133
  enableKnowledgeBase: false,
134
134
  knowledgeBase: DEFAULT_KNOWLEDGE_BASE,
@@ -0,0 +1,14 @@
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 { Migration } from '@nocobase/server';
10
+ export default class extends Migration {
11
+ on: string;
12
+ appVersion: string;
13
+ up(): Promise<void>;
14
+ }
@@ -0,0 +1,48 @@
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 __defProp = Object.defineProperty;
11
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
+ var __getOwnPropNames = Object.getOwnPropertyNames;
13
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
14
+ var __export = (target, all) => {
15
+ for (var name in all)
16
+ __defProp(target, name, { get: all[name], enumerable: true });
17
+ };
18
+ var __copyProps = (to, from, except, desc) => {
19
+ if (from && typeof from === "object" || typeof from === "function") {
20
+ for (let key of __getOwnPropNames(from))
21
+ if (!__hasOwnProp.call(to, key) && key !== except)
22
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
+ }
24
+ return to;
25
+ };
26
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
+ var reset_builtin_about_exports = {};
28
+ __export(reset_builtin_about_exports, {
29
+ default: () => reset_builtin_about_default
30
+ });
31
+ module.exports = __toCommonJS(reset_builtin_about_exports);
32
+ var import_server = require("@nocobase/server");
33
+ class reset_builtin_about_default extends import_server.Migration {
34
+ on = "afterSync";
35
+ appVersion = "<2.0.0-beta.7";
36
+ async up() {
37
+ const repo = this.db.getRepository("aiEmployees");
38
+ await repo.update({
39
+ filter: {
40
+ builtIn: true
41
+ },
42
+ values: {
43
+ about: null
44
+ }
45
+ });
46
+ this.app.logger.info("Reset built-in AI employees about to null");
47
+ }
48
+ }
@@ -97,7 +97,10 @@ const aiResource = {
97
97
  const res = await provider.listModels();
98
98
  if (res.errMsg) {
99
99
  ctx.log.error(res.errMsg);
100
- ctx.throw(500, ctx.t("Get models list failed, you can enter a model name manually."));
100
+ ctx.throw(
101
+ res.code || 500,
102
+ `${ctx.t("Get models list failed, you can enter a model name manually.")} ${res.errMsg}`
103
+ );
101
104
  }
102
105
  ctx.body = res.models || [];
103
106
  }
@@ -118,7 +121,10 @@ const aiResource = {
118
121
  const res = await providerClient.listModels();
119
122
  if (res.errMsg) {
120
123
  ctx.log.error(res.errMsg);
121
- ctx.throw(500, ctx.t("Get models list failed, you can enter a model name manually."));
124
+ ctx.throw(
125
+ res.code || 500,
126
+ `${ctx.t("Get models list failed, you can enter a model name manually.")} ${res.errMsg}`
127
+ );
122
128
  }
123
129
  const models = res.models || [];
124
130
  if (model) {
@@ -12,4 +12,3 @@ export declare const create: (ctx: Context, next: Next) => Promise<void>;
12
12
  export declare const listByUser: (ctx: Context, next: Next) => Promise<any>;
13
13
  export declare const updateUserPrompt: (ctx: Context, next: Next) => Promise<any>;
14
14
  export declare const getTemplates: (ctx: Context, next: Next) => Promise<void>;
15
- export declare const getBuiltInDefault: (ctx: Context, next: Next) => Promise<void>;
@@ -37,7 +37,6 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
37
37
  var aiEmployees_exports = {};
38
38
  __export(aiEmployees_exports, {
39
39
  create: () => create,
40
- getBuiltInDefault: () => getBuiltInDefault,
41
40
  getTemplates: () => getTemplates,
42
41
  list: () => list,
43
42
  listByUser: () => listByUser,
@@ -206,23 +205,9 @@ const getTemplates = async (ctx, next) => {
206
205
  ctx.body = Object.values(templates).map((template) => template[locale]);
207
206
  await next();
208
207
  };
209
- const getBuiltInDefault = async (ctx, next) => {
210
- const { filterByTk } = ctx.action.params || {};
211
- if (!filterByTk) {
212
- ctx.throw(400);
213
- }
214
- const plugin = ctx.app.pm.get("ai");
215
- const builtInManager = plugin.builtInManager;
216
- const locale = ctx.getCurrentLocale();
217
- const temp = { username: filterByTk };
218
- builtInManager.setupBuiltInInfo(locale, temp);
219
- ctx.body = { about: temp.about };
220
- await next();
221
- };
222
208
  // Annotate the CommonJS export names for ESM import in node:
223
209
  0 && (module.exports = {
224
210
  create,
225
- getBuiltInDefault,
226
211
  getTemplates,
227
212
  list,
228
213
  listByUser,
@@ -37,6 +37,8 @@ export type AIMessageMetadata = {
37
37
  model: string;
38
38
  provider: string;
39
39
  usage_metadata?: any;
40
+ response_metadata?: any;
41
+ additional_kwargs?: Record<string, unknown>;
40
42
  toolCall?: AIToolCall;
41
43
  autoCallTools?: string[];
42
44
  autoCall?: boolean;
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "description": "Create AI employees with diverse skills to collaborate with humans, build systems, and handle business operations.",
7
7
  "description.ru-RU": "Поддержка интеграции с AI-сервисами: предоставляются AI-узлы для рабочих процессов, расширяя возможности бизнес-обработки.",
8
8
  "description.zh-CN": "创建各种技能的 AI 员工,与人类协同,搭建系统,处理业务。",
9
- "version": "2.0.0-beta.6",
9
+ "version": "2.0.0-beta.7",
10
10
  "main": "dist/server/index.js",
11
11
  "homepage": "https://docs.nocobase.com/handbook/action-ai",
12
12
  "homepage.ru-RU": "https://docs-ru.nocobase.com/handbook/action-ai",
@@ -26,7 +26,7 @@
26
26
  "@langchain/anthropic": "^0.3.23",
27
27
  "@langchain/core": "^0.3.61",
28
28
  "@langchain/deepseek": "^0.0.2",
29
- "@langchain/google-genai": "^0.2.16",
29
+ "@langchain/google-genai": "^1.0.3",
30
30
  "@langchain/ollama": "^0.1.1",
31
31
  "@langchain/openai": "^0.6.13",
32
32
  "@nocobase/ai-employee-avatars": "^1.0.2",
@@ -47,5 +47,5 @@
47
47
  "keywords": [
48
48
  "AI"
49
49
  ],
50
- "gitHead": "c360083cbb1273e5522c09d1dd0696ee83fba8b5"
50
+ "gitHead": "17b6e4042a4814e38b256c7b3ae34e6d0b08fd57"
51
51
  }
@@ -1,10 +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
- "use strict";(self.webpackChunk_nocobase_plugin_ai=self.webpackChunk_nocobase_plugin_ai||[]).push([["862"],{7839:function(e,t,n){n.r(t),n.d(t,{Employees:function(){return ey}});var r=n(8156),o=n.n(r),l=n(2721),a=n(3772),i=n(3990),c=n(3505),s=n(7097),u=n(5800),p=function(e){var t,n=(0,a.usePlugin)(u.default).aiManager.llmProviders.get(e);return null==n||null==(t=n.components)?void 0:t.ModelSettingsForm},m=(0,c.observer)(function(){var e,t,n,r,l=(0,c.useForm)(),i=(0,a.useAPIClient)(),s=(0,a.useRequest)(function(){var e,t;return i.resource("llmServices").get({filterByTk:null==(t=l.values)||null==(e=t.modelSettings)?void 0:e.llmService}).then(function(e){var t;return null==e||null==(t=e.data)?void 0:t.data})},{ready:!!(null==(t=l.values)||null==(e=t.modelSettings)?void 0:e.llmService),refreshDeps:[null==(r=l.values)||null==(n=r.modelSettings)?void 0:n.llmService]}),u=s.data,m=s.loading,d=p(null==u?void 0:u.provider);return m?null:d?o().createElement(d,null):null},{displayName:"AIEmployeeModelOptionsForm"}),d=function(){var e=(0,i.NT)();return o().createElement(a.SchemaComponent,{scope:{t:e},components:{ModelOptions:m},schema:{type:"object",name:"modelSettings",properties:{llmService:{type:"string",title:'{{t("LLM service")}}',required:!0,"x-decorator":"FormItem","x-component":"RemoteSelect","x-component-props":{manual:!1,fieldNames:{label:"title",value:"name"},service:{resource:"llmServices",action:"list",params:{fields:["title","name"]}}}},settings:{type:"void","x-component":"ModelOptions"}}}})},f=n(9527),y=n.n(f),v=n(4964);function b(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function g(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var l=[],a=!0,i=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(l.push(n.value),!t||l.length!==t);a=!0);}catch(e){i=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(i)throw r}}return l}}(e,t)||function(e,t){if(e){if("string"==typeof e)return b(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return b(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function x(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function h(){var e=x(["\n border-color: "," !important;\n "]);return h=function(){return e},e}function S(){var e=x(["\n cursor: pointer;\n &:hover {\n border-color: "," !important;\n }\n "]);return S=function(){return e},e}function E(){var e=x(["\n border: 2px solid "," !important;\n "]);return E=function(){return e},e}function A(){var e=x(["\n cursor: pointer;\n &:hover {\n border: 2px solid "," !important;\n }\n "]);return A=function(){return e},e}var w=function(e){var t=e.srcs,n=e.size,r=void 0===n?"large":n,i=e.selectable,c=e.highlightItem,s=e.onClick,u=(0,a.useToken)().token,p=(0,a.useUploadStyles)(),m=(p.wrapSSR,p.hashId,p.componentCls);return null==t||t.map(function(e,t){var n=g(e,2),r=n[0],l=n[1];return o().createElement("div",{key:t,className:"".concat(m,"-list-picture-card-container ").concat(m,"-list-item-container")},o().createElement("div",{onClick:function(){return s&&s(l)},className:y()("".concat(m,"-list-item"),"".concat(m,"-list-item-done"),"".concat(m,"-list-item-list-type-picture-card"),c===l?(0,v.css)(h(),u.colorPrimary):"",i?(0,v.css)(S(),u.colorPrimary):"")},o().createElement("div",{className:"".concat(m,"-list-item-info")},o().createElement("span",{key:"thumbnail",className:"".concat(m,"-list-item-thumbnail")},o().createElement("img",{src:r,className:"".concat(m,"-list-item-image")})))))}),o().createElement(l.List,{grid:{gutter:16,column:10},itemLayout:"horizontal",dataSource:t,renderItem:function(e){var t=g(e,2),n=t[0],a=t[1];return o().createElement(l.List.Item,null,o().createElement(l.Avatar,{size:"small"===r?45:80,className:y()(c===a?(0,v.css)(E(),u.colorPrimary):"",i?(0,v.css)(A(),u.colorPrimary):""),src:n,onClick:function(){return s&&s(a)}}))}})},k=function(e){var t=e.disabled,n=(0,c.useField)(),l=Object.keys(s.n)[0],a=g(o().useState(l),2),i=a[0],u=a[1];(0,r.useEffect)(function(){n.value||n.setInitialValue(l)},[n]),(0,r.useEffect)(function(){n.value&&u(n.value)},[n.value]);var p=(0,r.useMemo)(function(){return Object.keys(s.n).map(function(e){return{seed:e,uri:(0,s.a)(e)}})},[]);return o().createElement(o().Fragment,null,o().createElement("div",{style:{marginBottom:"16px"}},o().createElement(w,{srcs:i?[[(0,s.a)(i),i]]:[]})),!0!==t?o().createElement(w,{srcs:p.map(function(e){return[e.uri,e.seed]}),size:"small",selectable:!0,highlightItem:i,onClick:function(e){return n.value=e}}):o().createElement(o().Fragment,null))},P=n(4632),C=function(e){var t=e.edit,n=(0,i.NT)(),r=(0,a.useCollectionRecordData)(),l=null==r?void 0:r.builtIn;return o().createElement(a.SchemaComponent,{scope:{t:n},components:{AvatarSelect:k,Switch:P.Switch},schema:{type:"void",properties:{username:{type:"string",title:'{{t("Username")}}',"x-decorator":"FormItem","x-component":"Input",required:!0,"x-disabled":t},nickname:{type:"string",title:'{{t("Nickname")}}',"x-disabled":l,"x-decorator":"FormItem","x-component":"Input",required:!0},enabled:{type:"boolean",title:'{{t("Enabled")}}',"x-decorator":"FormItem","x-component":"Switch",default:!0,required:!0},position:{type:"string",title:'{{t("Position")}}',"x-disabled":l,"x-decorator":"FormItem","x-component":"Input",description:n("Position description"),"x-component-props":{placeholder:n("Position placeholder")}},avatar:{type:"string",title:'{{t("Avatar")}}',"x-decorator":"FormItem","x-component":"AvatarSelect","x-component-props":{disabled:l}},bio:{type:"string",title:'{{t("Bio")}}',"x-disabled":l,"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{placeholder:n("Bio placeholder")}},greeting:{type:"string",title:'{{t("Greeting message")}}',"x-disabled":l,"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{placeholder:n("Greeting message placeholder")}}}}})};function I(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function O(){var e=I(["\n position: relative;\n "]);return O=function(){return e},e}function T(){var e=I(["\n position: absolute;\n right: 0;\n top: 0;\n z-index: 1;\n "]);return T=function(){return e},e}var j=function(e){var t=e.className,n=(0,a.useCollectionRecordData)(),r=null==n?void 0:n.builtIn,s=(0,i.NT)(),u=(0,c.useForm)(),p=(0,a.useAPIClient)(),m=(0,a.useRequest)(function(){return p.resource("aiEmployees").getBuiltInDefault({filterByTk:null==n?void 0:n.username})},{manual:!0,onSuccess:function(e){var t,n,r=null==e||null==(n=e.data)||null==(t=n.data)?void 0:t.about;"string"==typeof r&&(u.setValuesIn("about",r),l.message.success(s("Reset successfully")))}}).run;return r?o().createElement("div",{className:t},o().createElement(l.Button,{type:"link",size:"small",onClick:function(){return m()}},s("Reset to default"))):null},F=function(){var e=(0,i.NT)(),t=(0,a.useCurrentUserVariable)({maxDepth:3,noDisabled:!0}).currentUserSettings,n=(0,a.useCurrentRoleVariable)({noDisabled:!0}).currentRoleSettings,r=(0,a.useDatetimeVariable)({noDisabled:!0}).datetimeSettings;return[t,n,{key:"$nLang",value:"$nLang",label:e("Current language")},r]},B=function(){var e=(0,i.NT)();return o().createElement(l.Alert,{style:{marginBottom:16},message:e("Role setting description"),type:"info"})},N=function(){var e=(0,i.NT)(),t=F();return o().createElement(a.SchemaComponent,{scope:{t:e},components:{ResetButton:j,Description:B},schema:{type:"void",properties:{desc:{type:"void","x-component":"Description"},aboutWrap:{type:"void","x-component":"div","x-component-props":{className:(0,v.css)(O())},properties:{about:{type:"string",title:'{{t("Role setting")}}',required:!0,"x-decorator":"FormItem","x-component":"Variable.RawTextArea","x-component-props":{scope:t,placeholder:e("Role setting placeholder"),autoSize:{minRows:15}}},resetAbout:{type:"void","x-component":"ResetButton","x-component-props":{className:(0,v.css)(T())}}}}}}})},R={name:"aiEmployees",fields:[{name:"username",type:"string",primaryKey:!0},{name:"nickname",type:"string",interface:"input"},{name:"position",type:"string",interface:"input"},{name:"avatar",type:"string",interface:"image"},{name:"bio",type:"text",interface:"textarea"},{name:"about",type:"text",interface:"textarea"},{name:"greeting",type:"text",interface:"textarea"},{name:"chatSettings",type:"jsonb"},{name:"skillSettings",type:"jsonb"},{name:"modelSettings",type:"jsonb"},{name:"dataSourceSettings",type:"jsonb"},{name:"enableKnowledgeBase",type:"boolean",allowNull:!1,defaultValue:!1},{name:"knowledgeBasePrompt",type:"text"},{name:"knowledgeBase",type:"jsonb"},{name:"enabled",type:"boolean",interface:"switch",allowNull:!1,defaultValue:!0},{name:"builtIn",type:"boolean",allowNull:!1,defaultValue:!1}]},D=n(482);function M(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function z(e){return function(e){if(Array.isArray(e))return M(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||V(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function V(e,t){if(e){if("string"==typeof e)return M(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return M(e,t)}}var L=function(e){var t=e.title,n=e.description,r=e.schema,s=(0,i.NT)(),u=(0,a.useToken)().token;return o().createElement(l.Card,{size:"small",style:{minWidth:"300px",maxWidth:"400px"},title:o().createElement(o().Fragment,null,o().createElement("div",{style:{marginTop:"4px"}},c.Schema.compile(t,{t:s})),o().createElement("div",{style:{color:u.colorTextSecondary,fontSize:u.fontSizeSM,fontWeight:400,whiteSpace:"pre-wrap"}},c.Schema.compile(n,{t:s})))},o().createElement(o().Fragment,null,o().createElement("div",{style:{fontWeight:u.fontWeightStrong}},s("Parameters")),o().createElement(l.List,{itemLayout:"vertical",dataSource:Object.entries((null==r?void 0:r.properties)||{}),size:"small",renderItem:function(e){var t,n=function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var l=[],a=!0,i=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(l.push(n.value),l.length!==t);a=!0);}catch(e){i=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(i)throw r}}return l}}(e,2)||V(e,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),a=n[0],i=n[1];return o().createElement(l.List.Item,{key:a},o().createElement("div",null,o().createElement("span",{style:{fontWeight:u.fontWeightStrong}},i.title||a),o().createElement("span",{style:{color:u.colorTextSecondary,fontSize:u.fontSizeSM,marginLeft:"4px"}},i.type),(null==(t=r.required)?void 0:t.includes(a))&&o().createElement("span",{style:{color:u.colorError,fontSize:u.fontSizeSM,marginLeft:"4px"}},s("Required"))),o().createElement("div",{style:{color:u.colorTextSecondary,fontSize:u.fontSizeSM}},i.description))}})))},K=function(e){var t,n=e.name,r=e.title,s=e.description,u=e.isRoot,p=(0,i.NT)(),m=(0,a.useToken)().token,d=null==(t=(0,c.useField)().value)?void 0:t.find(function(e){return e.name===n});return o().createElement("div",{style:{minWidth:"150px",maxWidth:"300px"}},o().createElement("div",{style:{display:"flex",justifyContent:"space-between"}},o().createElement("div",null,c.Schema.compile(r,{t:p})),!u&&o().createElement("div",null,o().createElement(l.Switch,{size:"small",value:d,disabled:d}))),o().createElement("div",{style:{color:m.colorTextSecondary,fontSize:m.fontSizeSM}},c.Schema.compile(s,{t:p})))},q=function(){var e=(0,i.NT)(),t=(0,a.useToken)().token,n=(0,c.useField)(),r=(0,a.useAPIClient)(),s=(0,a.useRequest)(function(){return r.resource("aiTools").list().then(function(e){var t;return null==e||null==(t=e.data)?void 0:t.data})}),u=s.data,p=s.loading,m=function(e){var t=z(n.value||[]);t.some(function(t){return t.name===e})||t.push({name:e,autoCall:!1}),n.value=t},d=(null==u?void 0:u.map(function(e){var t,n,r={key:e.group.groupName},l={title:null!=(t=e.group.title)?t:"",description:null!=(n=e.group.description)?n:"",name:e.group.groupName,isRoot:!0};return e.tools?(r.label=o().createElement(K,l),r.children=e.tools.map(function(e){return{key:e.name,label:o().createElement(K,e),onClick:function(){return m(e.name)}}})):(r.label=o().createElement(K,l),r.onClick=function(){}),r}))||[];return o().createElement(o().Fragment,null,o().createElement("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-end",width:"100%",margin:"8px 0 16px 0"}},o().createElement(l.Dropdown,{menu:{items:d},placement:"bottomRight"},o().createElement(l.Button,{type:"primary",icon:o().createElement(D.PlusOutlined,null)},e("Add skill"),o().createElement(l.Tooltip,{title:e("Tools available for LLM function calling")},o().createElement(D.QuestionCircleOutlined,{style:{marginLeft:"4px"}}))))),!p&&o().createElement(l.List,{itemLayout:"vertical",bordered:!0,dataSource:n.value||[],renderItem:function(r){var a,i=(null!=(a=null==u?void 0:u.flatMap(function(e){return e.tools}))?a:[]).find(function(e){return e.name===r.name});return i?o().createElement(l.List.Item,{key:i.name,extra:o().createElement(l.Flex,{vertical:!0,justify:"end"},o().createElement(l.Space,null,o().createElement("div",{style:{fontSize:t.fontSizeSM}},e("Auto usage"),o().createElement(l.Switch,{style:{marginLeft:"4px",marginRight:"8px"},size:"small",checked:r.autoCall,onChange:function(e){var t=(n.value||[]).map(function(t){var n,o;return t.name===r.name?(n=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({},t),o=o={autoCall:e},Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(o)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(o)).forEach(function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(o,e))}),n):t});n.value=t}})),o().createElement(l.Popover,{content:o().createElement(L,i),placement:"bottom",arrow:!1,styles:{body:{padding:0,marginRight:"8px"}}},o().createElement(D.InfoCircleOutlined,null)),o().createElement(l.Button,{icon:o().createElement(D.DeleteOutlined,null),variant:"link",color:"default",onClick:function(){var e=z(n.value||[]),t=e.findIndex(function(e){return e.name===i.name});-1!==t&&(e.splice(t,1),n.value=e)}})))},o().createElement("div",null,c.Schema.compile(i.title,{t:e})),o().createElement("div",{style:{color:t.colorTextSecondary,fontSize:t.fontSizeSM}},c.Schema.compile(i.description,{t:e}))):null}}))},W=function(){var e=(0,i.NT)();return o().createElement(a.SchemaComponent,{components:{Skills:q},schema:{type:"void",properties:{skillSettings:{type:"object",properties:{skills:{type:"array","x-component":"Skills","x-decorator":"FormItem",description:e("Auto skill description")}}}}}})},$=n(8875),U=n(8563),_=n(3972);function G(e,t,n,r,o,l,a){try{var i=e[l](a),c=i.value}catch(e){n(e);return}i.done?t(c):Promise.resolve(c).then(r,o)}function H(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var l=e.apply(t,n);function a(e){G(l,r,o,a,i,"next",e)}function i(e){G(l,r,o,a,i,"throw",e)}a(void 0)})}}function Q(e,t){var n,r,o,l,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return l={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(l[Symbol.iterator]=function(){return this}),l;function i(l){return function(i){var c=[l,i];if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return a.label++,{value:c[1],done:!1};case 5:a.label++,r=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){a=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){a.label=c[1];break}if(6===c[0]&&a.label<o[1]){a.label=o[1],o=c;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(c);break}o[2]&&a.ops.pop(),a.trys.pop();continue}c=t.call(e,a)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}var X=function(){var e=(0,i.NT)();return{form:(0,r.useMemo)(function(){return(0,U.createForm)({initialValues:{username:"".concat((0,$.uid)()),enableKnowledgeBase:!1,knowledgeBase:{knowledgeBaseIds:[],topK:3,score:"0.6"},knowledgeBasePrompt:e("knowledge Base Prompt default")}})},[e])}},J=function(){var e=(0,a.useCollectionRecordData)();return{form:(0,r.useMemo)(function(){return(0,U.createForm)({initialValues:e})},[e])}},Y=function(){var e=(0,a.useActionContext)().setVisible,t=(0,c.useForm)();return{type:"default",onClick:function(){e(!1),t.reset()}}},Z=function(){var e=(0,a.useActionContext)().setVisible,t=l.App.useApp().message,n=(0,c.useForm)(),r=(0,a.useAPIClient)(),o=(0,a.useDataBlockRequest)().refresh,s=(0,_.S)().refresh,u=(0,i.NT)();return{type:"primary",onClick:function(){return H(function(){var l,a;return Q(this,function(i){switch(i.label){case 0:if(!(null==(l=n.values)?void 0:l.about))return t.warning(u("Please complete role setting before submitting")),[2];if(!(null==(a=null==l?void 0:l.modelSettings)?void 0:a.llmService)||!(null==a?void 0:a.model))return t.warning(u("Please complete model setting before submitting")),[2];return[4,n.submit()];case 1:return i.sent(),[4,r.resource("aiEmployees").create({values:l})];case 2:return i.sent(),o(),t.success(u("Saved successfully")),e(!1),n.reset(),s(),[2]}})})()}}},ee=function(){var e=(0,a.useActionContext)().setVisible,t=l.App.useApp().message,n=(0,c.useForm)(),r=(0,a.useDataBlockResource)(),o=(0,a.useDataBlockRequest)().refresh,s=(0,_.S)().refresh,u=(0,a.useCollection)().getFilterTargetKey(),p=(0,i.NT)();return{type:"primary",onClick:function(){return H(function(){var l,a;return Q(this,function(i){switch(i.label){case 0:if(!(null==(l=n.values)?void 0:l.about))return t.warning(p("Please complete persona before submitting")),[2];if(!(null==(a=null==l?void 0:l.modelSettings)?void 0:a.llmService)||!(null==a?void 0:a.model))return t.warning(p("Please complete model settings before submitting")),[2];return[4,n.submit()];case 1:return i.sent(),[4,r.update({values:l,filterByTk:l[u]})];case 2:return i.sent(),o(),t.success(p("Saved successfully")),e(!1),n.reset(),s(),[2]}})})()}}},et=function(){var e=(0,i.NT)(),t=(0,a.useCollectionRecordData)(),n=(0,a.useDestroyActionProps)().onClick,r=null==t?void 0:t.builtIn,o=l.App.useApp().message,c="root"===(0,a.useAPIClient)().auth.role;return{onClick:function(t,l){return H(function(){return Q(this,function(a){switch(a.label){case 0:if(r&&!c)return o.warning(e("Cannot delete built-in ai employees")),[2];return[4,n(t,l)];case 1:return a.sent(),[2]}})})()}}};function en(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var er=l.Card.Meta,eo=(0,r.createContext)(null),el=function(){var e=(0,r.useContext)(eo).aiEmployee;return{form:(0,r.useMemo)(function(){return(0,U.createForm)({initialValues:e})},[e])}},ea=function(e){var t=e.aiEmployee,n=(0,a.useToken)().token,r=(0,a.useActionContext)().setVisible;return o().createElement(l.Card,{variant:"borderless",hoverable:!0,onClick:function(){return r(!0)}},o().createElement(er,{avatar:t.avatar?o().createElement(l.Avatar,{size:40,src:(0,s.a)(t.avatar)}):null,title:t.nickname,description:o().createElement(o().Fragment,null,t.position&&o().createElement(l.Tag,{style:{marginBottom:n.marginXS}},t.position),o().createElement(l.Typography.Paragraph,{style:{height:n.fontSize*n.lineHeight*3},ellipsis:{rows:3},type:"secondary"},t.bio))}))},ei=function(){var e,t=(e=o().useState(!1),function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var l=[],a=!0,i=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(l.push(n.value),l.length!==t);a=!0);}catch(e){i=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(i)throw r}}return l}}(e,2)||function(e,t){if(e){if("string"==typeof e)return en(e,2);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return en(e,t)}}(e,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),n=t[0],r=t[1],i=(0,a.useAPIClient)(),c=(0,a.useRequest)(function(){return i.resource("aiEmployees").getTemplates().then(function(e){var t;return null==e||null==(t=e.data)?void 0:t.data})}),s=c.data;return c.loading?o().createElement(l.Spin,null):s&&s.length?o().createElement(l.Row,{gutter:[16,16]},s.map(function(e){return o().createElement(a.ActionContextProvider,{key:e.username,value:{visible:n,setVisible:r}},o().createElement(l.Col,{span:12},o().createElement(ea,{aiEmployee:e})),o().createElement(eo.Provider,{value:{aiEmployee:e}},o().createElement(a.SchemaComponent,{scope:{useCancelActionProps:Y,useCreateActionProps:Z,useTemplateFormProps:el},schema:{type:"void",name:(0,$.uid)(),"x-component":"Action.Drawer",title:'{{t("New AI employee")}}',"x-decorator":"FormV2","x-use-decorator-props":"useTemplateFormProps",properties:{form:{type:"void","x-component":"AIEmployeeForm"},footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{close:{title:"Cancel","x-component":"Action","x-component-props":{type:"default"},"x-use-component-props":"useCancelActionProps"},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary"},"x-use-component-props":"useCreateActionProps"}}}}}})))})):o().createElement(l.Empty,{image:l.Empty.PRESENTED_IMAGE_SIMPLE})},ec=function(){return(0,i.NT)(),o().createElement(a.SchemaComponent,{components:{Switch:P.Switch},schema:{type:"void",properties:{enableKnowledgeBase:{type:"boolean",title:'{{t("Enable Knowledge Base")}}',"x-decorator":"FormItem","x-component":"Switch"},knowledgeBasePrompt:{type:"string",title:'{{t("Knowledge Base Prompt")}}',required:!0,"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{autoSize:{minRows:5}},"x-reactions":[{dependencies:["enableKnowledgeBase"],fulfill:{state:{disabled:"{{$deps[0] === false}}"}}}]},knowledgeBase:{type:"object",properties:{knowledgeBaseIds:{type:"array",title:'{{t("Knowledge Base")}}',required:!0,"x-decorator":"FormItem","x-component":"RemoteSelect","x-component-props":{mode:"multiple",manual:!1,fieldNames:{label:"name",value:"id"},service:{resource:"aiKnowledgeBase",action:"list",params:{fields:["id","name"],filter:{enabled:!0}}}},"x-reactions":[{dependencies:["enableKnowledgeBase"],fulfill:{state:{disabled:"{{$deps[0] === false}}"}}}]},topK:{type:"number",title:'{{t("Top K")}}',required:!0,"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{min:1,max:100},"x-reactions":[{dependencies:["enableKnowledgeBase"],fulfill:{state:{disabled:"{{$deps[0] === false}}"}}}]},score:{type:"number",title:'{{t("Score")}}',required:!0,"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{min:0,max:1,step:.1},"x-reactions":[{dependencies:["enableKnowledgeBase"],fulfill:{state:{disabled:"{{$deps[0] === false}}"}}}]}}}}}})};function es(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function eu(e,t){if(e){if("string"==typeof e)return es(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return es(e,t)}}var ep=function(e){var t,n,c=e.edit,s=(0,i.NT)(),u=(0,a.useAPIClient)(),p=(t=(0,r.useState)(!1),function(e){if(Array.isArray(e))return e}(t)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var l=[],a=!0,i=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(l.push(n.value),l.length!==t);a=!0);}catch(e){i=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(i)throw r}}return l}}(t,2)||eu(t,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),m=p[0],f=p[1];return(0,r.useEffect)(function(){u.resource("aiSettings").isKnowledgeBaseEnabled().then(function(e){var t;f(null==e||null==(t=e.data)?void 0:t.data.enabled)}).catch(function(e){return console.error("api fail aiSettings.isKnowledgeBaseEnabled",e)})},[u]),o().createElement(l.Tabs,{items:[{key:"profile",label:s("Profile"),children:o().createElement(C,{edit:c}),forceRender:!0},{key:"roleSetting",label:s("Role setting"),children:o().createElement(N,null),forceRender:!0},{key:"modelSettings",label:s("Model settings"),children:o().createElement(d,null),forceRender:!0},{key:"skills",label:s("Skills"),children:o().createElement(W,null)}].concat(function(e){if(Array.isArray(e))return es(e)}(n=m?[{key:"knowledgeBase",label:s("KnowledgeBase"),children:o().createElement(ec,null)}]:[])||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(n)||eu(n)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())})},em=function(e){var t,n,r=(0,c.useField)();return r.value?o().createElement(l.Avatar,(t=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({shape:"square",size:"large"},e),n=n={src:(0,s.a)(r.value)},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}),t)):null},ed=function(e){var t=(0,c.useField)();return t.value?t.value&&o().createElement(D.CheckOutlined,{style:{color:"#52c41a"}}):null},ef=function(e){var t=(0,c.useField)();return t.value?o().createElement(l.Tag,null,t.value.model):null},ey=function(){var e=(0,i.NT)();return o().createElement(a.ExtendCollectionsProvider,{collections:[R]},o().createElement(a.SchemaComponent,{components:{AIEmployeeForm:ep,Avatar:em,Templates:ei,LLMModel:ef,Enabled:ed},scope:{t:e,useCreateFormProps:X,useEditFormProps:J,useCancelActionProps:Y,useCreateActionProps:Z,useEditActionProps:ee,useDeleteActionProps:et},schema:{type:"void",name:"ai-employees",properties:{block:{type:"void","x-component":"CardItem","x-component-props":{heightMode:"fullHeight"},"x-decorator":"TableBlockProvider","x-decorator-props":{collection:"aiEmployees",action:"list",rowKey:"username",dragSort:!0,dragSortBy:"sort"},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:20}},properties:{refresh:{title:"{{t('Refresh')}}","x-component":"Action","x-use-component-props":"useRefreshActionProps","x-component-props":{icon:"ReloadOutlined"}},add:{type:"void",title:"{{t('New AI employee')}}","x-align":"right","x-component":"Action","x-component-props":{type:"primary",icon:"PlusOutlined"},properties:{drawer:{type:"void","x-component":"Action.Drawer",title:'{{t("New AI employee")}}',"x-decorator":"FormV2","x-use-decorator-props":"useCreateFormProps",properties:{form:{type:"void","x-component":"AIEmployeeForm"},footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{close:{title:"Cancel","x-component":"Action","x-component-props":{type:"default"},"x-use-component-props":"useCancelActionProps"},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary"},"x-use-component-props":"useCreateActionProps"}}}}}}}}},table:{type:"array","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"username",rowSelection:{type:"checkbox"}},properties:{column0:{type:"void",title:e("Avatar"),"x-component":"TableV2.Column",properties:{avatar:{type:"string","x-component":"Avatar","x-component-props":{shape:"circle"}}}},column1:{type:"void",title:e("Username"),"x-component":"TableV2.Column",properties:{username:{type:"string","x-component":"Input","x-pattern":"readPretty"}}},column2:{type:"void",title:e("Nickname"),"x-component":"TableV2.Column",properties:{nickname:{type:"string","x-component":"Input","x-pattern":"readPretty"}}},column3:{type:"void",title:e("Position"),"x-component":"TableV2.Column",properties:{position:{type:"string","x-component":"Input","x-pattern":"readPretty"}}},column4:{type:"void",title:e("Model"),"x-component":"TableV2.Column",properties:{modelSettings:{type:"string","x-component":"LLMModel"}}},column5:{type:"void",title:e("Enabled"),"x-component":"TableV2.Column",properties:{enabled:{type:"string","x-component":"Enabled"}}},column6:{type:"void",title:'{{t("Actions")}}',"x-decorator":"TableV2.Column.ActionBar","x-component":"TableV2.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{edit:{type:"void",title:'{{t("Edit") }}',"x-action":"update","x-component":"Action.Link","x-component-props":{openMode:"drawer"},properties:{drawer:{type:"void",title:e("Edit AI employee"),"x-component":"Action.Drawer","x-decorator":"FormV2","x-use-decorator-props":"useEditFormProps",properties:{form:{type:"void","x-component":"AIEmployeeForm","x-component-props":{edit:!0}},footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{close:{title:e("Cancel"),"x-component":"Action","x-use-component-props":"useCancelActionProps"},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-use-component-props":"useEditActionProps"}}}}}}},destroy:{type:"void",title:'{{ t("Delete") }}',"x-action":"destroy","x-component":"Action.Link","x-use-component-props":"useDeleteActionProps","x-component-props":{confirm:{title:"{{t('Delete AI employee')}}",content:"{{t('Are you sure you want to delete this AI employee?')}}"}}}}}}}}}}}}}}))}}}]);
@@ -1,20 +0,0 @@
1
- import { BaseLLMOutputParser } from "@langchain/core/output_parsers";
2
- import { ChatGeneration } from "@langchain/core/outputs";
3
- import { InteropZodType } from "@langchain/core/utils/types";
4
- import { JsonOutputKeyToolsParserParamsInterop } from "@langchain/core/output_parsers/openai_tools";
5
- interface GoogleGenerativeAIToolsOutputParserParams<T extends Record<string, any>> extends JsonOutputKeyToolsParserParamsInterop<T> {
6
- }
7
- export declare class GoogleGenerativeAIToolsOutputParser<T extends Record<string, any> = Record<string, any>> extends BaseLLMOutputParser<T> {
8
- static lc_name(): string;
9
- lc_namespace: string[];
10
- returnId: boolean;
11
- /** The type of tool calls to return. */
12
- keyName: string;
13
- /** Whether to return only the first tool call. */
14
- returnSingle: boolean;
15
- zodSchema?: InteropZodType<T>;
16
- constructor(params: GoogleGenerativeAIToolsOutputParserParams<T>);
17
- protected _validateResult(result: unknown): Promise<T>;
18
- parseResult(generations: ChatGeneration[]): Promise<T>;
19
- }
20
- export {};
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,22 +0,0 @@
1
- import { EnhancedGenerateContentResponse, Content, Part, type FunctionDeclarationsTool as GoogleGenerativeAIFunctionDeclarationsTool, POSSIBLE_ROLES } from "@google/generative-ai";
2
- import { BaseMessage, UsageMetadata } from "@langchain/core/messages";
3
- import { ChatGenerationChunk, ChatResult } from "@langchain/core/outputs";
4
- import { GoogleGenerativeAIToolType } from "../types.js";
5
- export declare function getMessageAuthor(message: BaseMessage): string;
6
- /**
7
- * Maps a message type to a Google Generative AI chat author.
8
- * @param message The message to map.
9
- * @param model The model to use for mapping.
10
- * @returns The message type mapped to a Google Generative AI chat author.
11
- */
12
- export declare function convertAuthorToRole(author: string): (typeof POSSIBLE_ROLES)[number];
13
- export declare function convertMessageContentToParts(message: BaseMessage, isMultimodalModel: boolean, previousMessages: BaseMessage[]): Part[];
14
- export declare function convertBaseMessagesToContent(messages: BaseMessage[], isMultimodalModel: boolean, convertSystemMessageToHumanContent?: boolean): Content[];
15
- export declare function mapGenerateContentResultToChatResult(response: EnhancedGenerateContentResponse, extra?: {
16
- usageMetadata: UsageMetadata | undefined;
17
- }): ChatResult;
18
- export declare function convertResponseContentToChatGenerationChunk(response: EnhancedGenerateContentResponse, extra: {
19
- usageMetadata?: UsageMetadata | undefined;
20
- index: number;
21
- }): ChatGenerationChunk | null;
22
- export declare function convertToGenerativeAITools(tools: GoogleGenerativeAIToolType[]): GoogleGenerativeAIFunctionDeclarationsTool[];
@@ -1,10 +0,0 @@
1
- import { Tool as GenerativeAITool, ToolConfig } from "@google/generative-ai";
2
- import { ToolChoice } from "@langchain/core/language_models/chat_models";
3
- import { GoogleGenerativeAIToolType } from "../types.js";
4
- export declare function convertToolsToGenAI(tools: GoogleGenerativeAIToolType[], extra?: {
5
- toolChoice?: ToolChoice;
6
- allowedFunctionNames?: string[];
7
- }): {
8
- tools: GenerativeAITool[];
9
- toolConfig?: ToolConfig;
10
- };
@@ -1,14 +0,0 @@
1
- import { type FunctionDeclarationSchema as GenerativeAIFunctionDeclarationSchema, type SchemaType as FunctionDeclarationSchemaType } from "@google/generative-ai";
2
- import { InteropZodType } from "@langchain/core/utils/types";
3
- import { type JsonSchema7Type } from "@langchain/core/utils/json_schema";
4
- export interface GenerativeAIJsonSchema extends Record<string, unknown> {
5
- properties?: Record<string, GenerativeAIJsonSchema>;
6
- type: FunctionDeclarationSchemaType;
7
- }
8
- export interface GenerativeAIJsonSchemaDirty extends GenerativeAIJsonSchema {
9
- properties?: Record<string, GenerativeAIJsonSchemaDirty>;
10
- additionalProperties?: boolean;
11
- }
12
- export declare function removeAdditionalProperties(obj: Record<string, any>): GenerativeAIJsonSchema;
13
- export declare function schemaToGenerativeAIParameters<RunOutput extends Record<string, any> = Record<string, any>>(schema: InteropZodType<RunOutput> | JsonSchema7Type): GenerativeAIFunctionDeclarationSchema;
14
- export declare function jsonSchemaToGeminiParameters(schema: Record<string, any>): GenerativeAIFunctionDeclarationSchema;