@nocobase/plugin-ai 2.3.0-alpha.1 → 2.3.0-beta.10
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/ai-employees/block/ai-chat-box.md +133 -0
- package/dist/ai/docs/nocobase/ai-employees/knowledge-base/knowledge-base/documents.md +1 -1
- package/dist/ai/docs/nocobase/ai-employees/knowledge-base/knowledge-base/index.md +11 -7
- package/dist/ai/docs/nocobase/ai-employees/knowledge-base/knowledge-base/settings.md +12 -8
- package/dist/ai/docs/nocobase/ai-employees/knowledge-base/rag.md +43 -13
- package/dist/ai/docs/nocobase/ai-employees/knowledge-base/vector-database.md +3 -3
- package/dist/ai/docs/nocobase/ai-employees/workflow/nodes/knowledge/create-document.md +1 -1
- package/dist/ai/docs/nocobase/api/app/env.md +2 -0
- package/dist/ai/docs/nocobase/api/cli/api/resource/create.md +4 -3
- package/dist/ai/docs/nocobase/building-tips/ai-fill-js-block-form.md +1092 -0
- package/dist/ai/docs/nocobase/data-sources/calendar/calendar-collection.md +100 -3
- package/dist/ai/docs/nocobase/data-sources/collection-comment/index.md +92 -39
- package/dist/ai/docs/nocobase/data-sources/collection-sql/index.md +150 -29
- package/dist/ai/docs/nocobase/data-sources/collection-tree/index.md +93 -5
- package/dist/ai/docs/nocobase/data-sources/collection-view/index.md +226 -4
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/advanced/china-region.md +122 -5
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/advanced/collection-select.md +105 -4
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/advanced/json.md +102 -4
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/advanced/nano-id.md +104 -4
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/advanced/snowflake-id.md +108 -4
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/advanced/sort.md +3 -19
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/advanced/uuid.md +104 -4
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/associations/index.md +44 -8
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/basic/color.md +102 -4
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/basic/email.md +104 -4
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/basic/icon.md +102 -4
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/basic/input.md +112 -8
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/basic/integer.md +103 -4
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/basic/number.md +103 -4
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/basic/password.md +102 -4
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/basic/percent.md +104 -5
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/basic/phone.md +104 -4
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/basic/textarea.md +99 -8
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/basic/url.md +103 -4
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/choices/checkbox-group.md +105 -3
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/choices/checkbox.md +102 -4
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/choices/china-region.md +108 -5
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/choices/multiple-select.md +103 -5
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/choices/radio-group.md +106 -4
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/choices/select.md +103 -5
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/datetime/date.md +102 -4
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/datetime/datetime-without-tz.md +103 -5
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/datetime/datetime.md +103 -5
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/datetime/index.md +53 -47
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/datetime/time.md +102 -4
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/datetime/unix-timestamp.md +103 -5
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/geometric/circle.md +102 -4
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/geometric/line.md +103 -5
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/geometric/point.md +102 -4
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/geometric/polygon.md +102 -4
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/index.md +62 -16
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/media/markdown.md +104 -4
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/media/rich-text.md +105 -5
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/system-info/created-at.md +105 -5
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/system-info/created-by.md +103 -5
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/system-info/space.md +100 -6
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/system-info/table-oid.md +102 -4
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/system-info/updated-at.md +104 -5
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/system-info/updated-by.md +104 -6
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection-fields/validation.md +68 -58
- package/dist/ai/docs/nocobase/data-sources/data-modeling/collection.md +32 -13
- package/dist/ai/docs/nocobase/data-sources/data-modeling/index.md +41 -33
- package/dist/ai/docs/nocobase/data-sources/data-source-external-mariadb/index.md +114 -6
- package/dist/ai/docs/nocobase/data-sources/data-source-external-mssql/index.md +117 -6
- package/dist/ai/docs/nocobase/data-sources/data-source-external-mysql/index.md +103 -6
- package/dist/ai/docs/nocobase/data-sources/data-source-external-nocobase/index.md +75 -73
- package/dist/ai/docs/nocobase/data-sources/data-source-external-oracle/index.md +129 -11
- package/dist/ai/docs/nocobase/data-sources/data-source-external-postgres/index.md +110 -6
- package/dist/ai/docs/nocobase/data-sources/data-source-kingbase/index.md +75 -49
- package/dist/ai/docs/nocobase/data-sources/data-source-main/general-collection.md +116 -15
- package/dist/ai/docs/nocobase/data-sources/data-source-main/index.md +92 -62
- package/dist/ai/docs/nocobase/data-sources/data-source-main/inheritance-collection.md +97 -10
- package/dist/ai/docs/nocobase/data-sources/data-source-manager/external-database.md +97 -58
- package/dist/ai/docs/nocobase/data-sources/data-source-manager/index.md +32 -24
- package/dist/ai/docs/nocobase/data-sources/data-source-rest-api/index.md +115 -153
- package/dist/ai/docs/nocobase/data-sources/external/clickhouse.md +124 -0
- package/dist/ai/docs/nocobase/data-sources/external/doris.md +130 -0
- package/dist/ai/docs/nocobase/data-sources/external/index.md +140 -0
- package/dist/ai/docs/nocobase/data-sources/external/kingbase.md +129 -0
- package/dist/ai/docs/nocobase/data-sources/external/mariadb.md +126 -0
- package/dist/ai/docs/nocobase/data-sources/external/mssql.md +129 -0
- package/dist/ai/docs/nocobase/data-sources/external/mysql.md +115 -0
- package/dist/ai/docs/nocobase/data-sources/external/nocobase.md +159 -0
- package/dist/ai/docs/nocobase/data-sources/external/oceanbase.md +126 -0
- package/dist/ai/docs/nocobase/data-sources/external/oracle.md +158 -0
- package/dist/ai/docs/nocobase/data-sources/external/postgresql.md +122 -0
- package/dist/ai/docs/nocobase/data-sources/external/rest-api.md +245 -0
- package/dist/ai/docs/nocobase/data-sources/field-attachment-url/index.md +100 -12
- package/dist/ai/docs/nocobase/data-sources/field-encryption/index.md +48 -47
- package/dist/ai/docs/nocobase/data-sources/field-formula/index.md +99 -5
- package/dist/ai/docs/nocobase/data-sources/field-markdown-vditor/index.md +105 -5
- package/dist/ai/docs/nocobase/data-sources/field-sequence/index.md +102 -5
- package/dist/ai/docs/nocobase/data-sources/field-signature/index.md +18 -16
- package/dist/ai/docs/nocobase/data-sources/field-sort/index.md +76 -73
- package/dist/ai/docs/nocobase/data-sources/file-manager/field-attachment.md +101 -7
- package/dist/ai/docs/nocobase/data-sources/file-manager/file-collection.md +101 -14
- package/dist/ai/docs/nocobase/data-sources/index.md +49 -33
- package/dist/ai/docs/nocobase/data-sources/main/index.md +130 -0
- package/dist/ai/docs/nocobase/data-sources/main/kingbase.md +147 -0
- package/dist/ai/docs/nocobase/data-sources/main/mariadb.md +59 -0
- package/dist/ai/docs/nocobase/data-sources/main/mysql.md +59 -0
- package/dist/ai/docs/nocobase/data-sources/main/oceanbase.md +62 -0
- package/dist/ai/docs/nocobase/data-sources/main/postgresql.md +61 -0
- package/dist/ai/docs/nocobase/file-manager/file-preview/index.md +44 -3
- package/dist/ai/docs/nocobase/file-manager/stable-url.md +1 -1
- package/dist/ai/docs/nocobase/file-manager/storage/aliyun-oss.md +100 -3
- package/dist/ai/docs/nocobase/file-manager/storage/index.md +76 -26
- package/dist/ai/docs/nocobase/file-manager/storage/local.md +4 -2
- package/dist/ai/docs/nocobase/file-manager/storage/s3-pro.md +58 -7
- package/dist/ai/docs/nocobase/get-started/installation/docker-nginx.mdx +4 -1
- package/dist/ai/docs/nocobase/get-started/installation/docker.mdx +2 -0
- package/dist/ai/docs/nocobase/get-started/installation/env.md +13 -1
- package/dist/ai/docs/nocobase/nocobase-cli/production/reverse-proxy/caddy.md +28 -5
- package/dist/ai/docs/nocobase/nocobase-cli/production/reverse-proxy/nginx.md +25 -0
- package/dist/ai/docs/nocobase/ops-management/migration-manager/built-in-tables.md +1 -2
- 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/runjs/context/ai.md +194 -4
- package/dist/ai/docs/nocobase/security/guide.md +17 -2
- 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/ai/docs/nocobase/workflow/nodes/javascript.md +21 -1
- package/dist/ai/tools/executeFrontendTool.d.ts +10 -0
- package/dist/ai/tools/executeFrontendTool.js +86 -0
- package/dist/ai/tools/getSkill.js +1 -1
- package/dist/ai/tools/knowledge-base-retrieve.js +3 -1
- package/dist/ai/tools/loadFrontendTool.d.ts +10 -0
- package/dist/ai/tools/loadFrontendTool.js +99 -0
- package/dist/client/244.aeb24ce76c510b34.js +10 -0
- package/dist/client/{525.203778500aca5d05.js → 525.94dd4136c1361477.js} +1 -1
- package/dist/client/681.6ffbc9329b9ac242.js +10 -0
- package/dist/client/705.1d735e63c25f66a8.js +10 -0
- package/dist/client/index.d.ts +1 -3
- package/dist/client/index.js +8 -8
- package/dist/client-v2/244.ee9ec45eac0eb99f.js +10 -0
- package/dist/client-v2/420.a5b929a5e7f330be.js +10 -0
- package/dist/client-v2/681.6890caa389564ff7.js +10 -0
- package/dist/client-v2/705.00c101bef403fb44.js +10 -0
- package/dist/client-v2/ai-employees/AIEmployeeShortcut.d.ts +2 -0
- package/dist/client-v2/ai-employees/AddContextButton.d.ts +2 -0
- package/dist/client-v2/ai-employees/chatbox/components/AIEmployeeSwitcher.d.ts +1 -0
- package/dist/client-v2/ai-employees/chatbox/components/ChatBoxUnreadBadge.d.ts +17 -0
- package/dist/client-v2/ai-employees/chatbox/components/Conversations.d.ts +9 -1
- package/dist/client-v2/ai-employees/chatbox/components/MessageRenderers.d.ts +1 -1
- package/dist/client-v2/ai-employees/chatbox/components/Messages.d.ts +5 -1
- package/dist/client-v2/ai-employees/chatbox/components/ModelSwitcher.d.ts +4 -0
- package/dist/client-v2/ai-employees/chatbox/components/Sender.d.ts +33 -1
- package/dist/client-v2/ai-employees/chatbox/components/index.d.ts +1 -0
- package/dist/client-v2/ai-employees/chatbox/hooks/reasoning-stream.d.ts +10 -0
- package/dist/client-v2/ai-employees/chatbox/hooks/useChat.d.ts +8 -5
- package/dist/client-v2/ai-employees/chatbox/hooks/useChatBoxActions.d.ts +3 -2
- package/dist/client-v2/ai-employees/chatbox/hooks/useChatBoxEffect.d.ts +2 -1
- package/dist/client-v2/ai-employees/chatbox/hooks/useChatConversationActions.d.ts +3 -2
- package/dist/client-v2/ai-employees/chatbox/hooks/useChatMessageActions.d.ts +4 -2
- package/dist/client-v2/ai-employees/chatbox/hooks/useToolCallActions.d.ts +3 -1
- package/dist/client-v2/ai-employees/chatbox/hooks/useUploadFiles.d.ts +13 -3
- package/dist/client-v2/ai-employees/chatbox/hooks/useWorkflowTasks.d.ts +3 -2
- package/dist/client-v2/ai-employees/chatbox/index.d.ts +17 -0
- package/dist/client-v2/ai-employees/chatbox/roles.d.ts +2 -153
- package/dist/client-v2/ai-employees/chatbox/stores/chat-box.d.ts +46 -33
- package/dist/client-v2/ai-employees/chatbox/stores/chat-conversations.d.ts +7 -7
- package/dist/client-v2/ai-employees/chatbox/stores/chat-messages.d.ts +23 -18
- package/dist/client-v2/ai-employees/chatbox/stores/chat-sender.d.ts +43 -0
- package/dist/client-v2/ai-employees/chatbox/stores/chat-tool-call.d.ts +6 -5
- package/dist/client-v2/ai-employees/chatbox/stores/chat-tools.d.ts +11 -5
- package/dist/client-v2/ai-employees/chatbox/stores/mounted-chat-boxes.d.ts +20 -0
- package/dist/client-v2/ai-employees/chatbox/stores/runtime.d.ts +43 -0
- package/dist/client-v2/ai-employees/chatbox/stores/workflow-tasks.d.ts +22 -10
- package/dist/client-v2/ai-employees/chatbox/upload.d.ts +19 -0
- package/dist/client-v2/ai-employees/chatbox/utils.d.ts +28 -4
- package/dist/client-v2/ai-employees/frontend-tools.d.ts +11 -0
- package/dist/client-v2/ai-employees/tools/SuggestionsOptionsCard.d.ts +1 -1
- package/dist/client-v2/ai-employees/tools/WorkflowTaskOutputCard.d.ts +1 -1
- package/dist/client-v2/ai-employees/types.d.ts +30 -0
- package/dist/client-v2/block/ai-chat-box/AIChatBoxBlockModel.d.ts +21 -0
- package/dist/client-v2/block/ai-chat-box/AIChatBoxCoreModel.d.ts +13 -0
- package/dist/client-v2/{ai-employees/chatbox/components/DebugPanel.d.ts → block/ai-chat-box/components/AIChatBoxCoreView.d.ts} +1 -1
- package/dist/client-v2/block/ai-chat-box/components/AIChatBoxView.d.ts +12 -0
- package/dist/client-v2/block/ai-chat-box/index.d.ts +14 -0
- package/dist/client-v2/block/ai-chat-box/settings.d.ts +12 -0
- package/dist/client-v2/block/ai-chat-box/sub-models.d.ts +26 -0
- package/dist/client-v2/block/ai-chat-box/types.d.ts +38 -0
- package/dist/client-v2/block/ai-chat-box/utils.d.ts +26 -0
- package/dist/client-v2/index.d.ts +3 -5
- 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/llm-services/model-select.d.ts +33 -0
- package/dist/client-v2/llm-services/utils.d.ts +1 -0
- package/dist/client-v2/manager/ai-manager.d.ts +10 -3
- package/dist/client-v2/manager/frontend-tool-registry.d.ts +30 -0
- package/dist/client-v2/models/ai-employees/AIEmployeeActionModel.d.ts +4 -1
- package/dist/client-v2/models/ai-employees/AIEmployeeShortcutModel.d.ts +8 -0
- package/dist/client-v2/pages/EmployeesPage.d.ts +12 -0
- package/dist/client-v2/pages/LLMServicesPage.d.ts +9 -4
- package/dist/client-v2/repositories/AIConfigRepository.d.ts +2 -0
- package/dist/client-v2/runjs/registerAIEmployeeRunJSFacade.d.ts +1 -0
- package/dist/client-v2/workflow/types.d.ts +1 -0
- package/dist/collections/ai-employees.d.ts +1 -0
- package/dist/collections/ai-employees.js +1 -0
- package/dist/common/ai-employee-validation.d.ts +17 -0
- package/dist/common/ai-employee-validation.js +67 -0
- package/dist/common/error-codes.d.ts +14 -0
- package/dist/common/error-codes.js +51 -0
- package/dist/common/frontend-tools.d.ts +26 -0
- package/dist/common/frontend-tools.js +57 -0
- package/dist/common/llm-service-models.d.ts +16 -0
- package/dist/common/llm-service-models.js +84 -0
- package/dist/externalVersion.js +19 -17
- package/dist/locale/de-DE.json +2 -1
- package/dist/locale/en-US.json +87 -5
- package/dist/locale/es-ES.json +2 -1
- package/dist/locale/fr-FR.json +2 -1
- package/dist/locale/hu-HU.json +2 -1
- package/dist/locale/id-ID.json +2 -1
- package/dist/locale/it-IT.json +2 -1
- package/dist/locale/ja-JP.json +2 -1
- package/dist/locale/ko-KR.json +2 -1
- package/dist/locale/nl-NL.json +2 -1
- package/dist/locale/pt-BR.json +2 -1
- package/dist/locale/ru-RU.json +2 -1
- package/dist/locale/tr-TR.json +2 -1
- package/dist/locale/uk-UA.json +2 -1
- package/dist/locale/vi-VN.json +2 -1
- package/dist/locale/zh-CN.json +87 -5
- package/dist/locale/zh-TW.json +2 -1
- 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-conversations.d.ts +4 -1
- package/dist/server/ai-employees/ai-conversations.js +2 -0
- package/dist/server/ai-employees/ai-employee.d.ts +32 -2
- package/dist/server/ai-employees/ai-employee.js +367 -79
- package/dist/server/ai-employees/ai-knowledge-base.d.ts +21 -1
- package/dist/server/ai-employees/ai-knowledge-base.js +87 -12
- package/dist/server/ai-employees/middleware/conversation.js +28 -22
- package/dist/server/ai-employees/middleware/index.d.ts +1 -0
- package/dist/server/ai-employees/middleware/index.js +2 -0
- package/dist/server/ai-employees/middleware/tool-result-integrity.d.ts +22 -0
- package/dist/server/ai-employees/middleware/tool-result-integrity.js +211 -0
- 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/collections/ai-conversations.js +5 -0
- package/dist/server/document-loader/constants.js +1 -1
- package/dist/server/features/knowledge-base.d.ts +2 -0
- package/dist/server/frontend-tools.d.ts +25 -0
- package/dist/server/frontend-tools.js +171 -0
- package/dist/server/llm-providers/common/reasoning.js +18 -10
- package/dist/server/llm-providers/deepseek/index.d.ts +10 -0
- 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-feature-manager.js +1 -1
- package/dist/server/manager/ai-manager.d.ts +3 -0
- package/dist/server/manager/ai-manager.js +7 -2
- package/dist/server/manager/work-context-handler.js +10 -3
- package/dist/server/migrations/20260501000000-ai-employee-knowledge-base-retrieval-strategy.d.ts +14 -0
- package/dist/server/migrations/20260501000000-ai-employee-knowledge-base-retrieval-strategy.js +49 -0
- package/dist/server/plugin.d.ts +1 -0
- package/dist/server/plugin.js +31 -0
- package/dist/server/resource/aiConversations.d.ts +2 -0
- package/dist/server/resource/aiConversations.js +33 -3
- package/dist/server/resource/aiEmployees.d.ts +2 -0
- package/dist/server/resource/aiEmployees.js +96 -0
- package/dist/server/resource/aiWorkflowTasks.js +9 -1
- package/dist/server/resource/llmServices.d.ts +11 -0
- package/dist/server/resource/llmServices.js +85 -0
- package/dist/server/types/ai-message.type.d.ts +4 -0
- package/dist/server/types/knowledge-base.type.d.ts +8 -3
- package/dist/server/workflow/nodes/employee/files.d.ts +1 -1
- package/dist/server/workflow/nodes/employee/files.js +48 -1
- package/dist/server/workflow/nodes/employee/index.js +7 -2
- package/dist/server/workflow/nodes/employee/types.d.ts +1 -0
- package/dist/swagger/common.d.ts +143 -0
- package/dist/swagger/common.js +144 -0
- package/dist/swagger/employees.d.ts +301 -0
- package/dist/swagger/employees.js +131 -0
- package/dist/swagger/index.d.ts +1617 -0
- package/dist/swagger/index.js +62 -0
- package/dist/swagger/llm.d.ts +563 -0
- package/dist/swagger/llm.js +255 -0
- package/dist/swagger/schemas.d.ts +757 -0
- package/dist/swagger/schemas.js +392 -0
- package/package.json +2 -2
- package/dist/ai/docs/nocobase/ai-employees/knowledge-base/vector-store.md +0 -24
- package/dist/ai/docs/nocobase/data-sources/development/index.md +0 -6
- package/dist/client/372.40eb52905e3f3049.js +0 -10
- package/dist/client/681.399948c18d753667.js +0 -10
- package/dist/client/705.380279da896021fb.js +0 -10
- package/dist/client-v2/372.8cc3fde09c9bec77.js +0 -10
- package/dist/client-v2/406.341be51205c674e0.js +0 -10
- package/dist/client-v2/681.082f4f1c7b841983.js +0 -10
- package/dist/client-v2/705.1d10027ff8cfdf79.js +0 -10
- package/dist/client-v2/ai-employees/chatbox/stores/create-selectors.d.ts +0 -46
- package/dist/client-v2/ai-employees/chatbox/utils/normalizeTriggerTaskOptions.d.ts +0 -19
- 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
|
@@ -0,0 +1,171 @@
|
|
|
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 frontend_tools_exports = {};
|
|
28
|
+
__export(frontend_tools_exports, {
|
|
29
|
+
extractFrontendToolManifests: () => extractFrontendToolManifests,
|
|
30
|
+
findCurrentFrontendTool: () => findCurrentFrontendTool,
|
|
31
|
+
listCurrentFrontendTools: () => listCurrentFrontendTools,
|
|
32
|
+
prepareToolsForFrontendConversation: () => prepareToolsForFrontendConversation,
|
|
33
|
+
readFrontendToolResult: () => readFrontendToolResult,
|
|
34
|
+
shouldAutoExecuteFrontendTool: () => shouldAutoExecuteFrontendTool
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(frontend_tools_exports);
|
|
37
|
+
var import_zod = require("zod");
|
|
38
|
+
var import_frontend_tools = require("../common/frontend-tools");
|
|
39
|
+
const isRecord = (value) => !!value && typeof value === "object" && !Array.isArray(value);
|
|
40
|
+
const isMessageLike = (value) => !!value && typeof value === "object";
|
|
41
|
+
const normalizeFrontendToolManifests = (value) => {
|
|
42
|
+
if (!Array.isArray(value)) {
|
|
43
|
+
return [];
|
|
44
|
+
}
|
|
45
|
+
const manifests = /* @__PURE__ */ new Map();
|
|
46
|
+
for (const manifest of value) {
|
|
47
|
+
if ((0, import_frontend_tools.isFrontendToolManifest)(manifest) && manifest.id === `${manifest.blockUid}:${manifest.name}`) {
|
|
48
|
+
manifests.set(manifest.id, manifest);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return Array.from(manifests.values());
|
|
52
|
+
};
|
|
53
|
+
const extractFrontendToolManifests = (workContext) => {
|
|
54
|
+
const manifests = /* @__PURE__ */ new Map();
|
|
55
|
+
for (const item of workContext) {
|
|
56
|
+
const frontendTools = Array.isArray(item == null ? void 0 : item.frontendTools) ? item.frontendTools : [];
|
|
57
|
+
for (const frontendTool of frontendTools) {
|
|
58
|
+
if ((0, import_frontend_tools.isFrontendToolManifest)(frontendTool) && frontendTool.blockUid === item.uid && frontendTool.id === `${item.uid}:${frontendTool.name}`) {
|
|
59
|
+
manifests.set(frontendTool.id, frontendTool);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return Array.from(manifests.values());
|
|
64
|
+
};
|
|
65
|
+
const findRequestFrontendTools = (ctx) => {
|
|
66
|
+
var _a, _b;
|
|
67
|
+
const values = (_b = (_a = ctx.action) == null ? void 0 : _a.params) == null ? void 0 : _b.values;
|
|
68
|
+
const messages = Array.isArray(values == null ? void 0 : values.messages) ? values.messages.filter(isMessageLike) : [];
|
|
69
|
+
for (const message of messages) {
|
|
70
|
+
if (message.role !== "user") {
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
const frontendTools = extractFrontendToolManifests(Array.isArray(message.workContext) ? message.workContext : []);
|
|
74
|
+
if (frontendTools.length) {
|
|
75
|
+
return frontendTools;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return [];
|
|
79
|
+
};
|
|
80
|
+
const listCurrentFrontendTools = async (ctx, sessionId) => {
|
|
81
|
+
var _a, _b, _c;
|
|
82
|
+
const requestSessionId = (_c = (_b = (_a = ctx.action) == null ? void 0 : _a.params) == null ? void 0 : _b.values) == null ? void 0 : _c.sessionId;
|
|
83
|
+
const currentSessionId = sessionId ?? (typeof requestSessionId === "string" ? requestSessionId : "");
|
|
84
|
+
if (!currentSessionId) {
|
|
85
|
+
return findRequestFrontendTools(ctx);
|
|
86
|
+
}
|
|
87
|
+
const conversationRepository = ctx.db.getRepository("aiConversations");
|
|
88
|
+
const conversation = await conversationRepository.findOne({
|
|
89
|
+
filter: {
|
|
90
|
+
sessionId: currentSessionId
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
const options = conversation == null ? void 0 : conversation.options;
|
|
94
|
+
const boundTools = normalizeFrontendToolManifests(isRecord(options) ? options.frontendTools : void 0);
|
|
95
|
+
if (boundTools.length) {
|
|
96
|
+
return boundTools;
|
|
97
|
+
}
|
|
98
|
+
const frontendTools = findRequestFrontendTools(ctx);
|
|
99
|
+
if (!frontendTools.length || !conversation) {
|
|
100
|
+
return frontendTools;
|
|
101
|
+
}
|
|
102
|
+
await conversationRepository.update({
|
|
103
|
+
filter: {
|
|
104
|
+
sessionId: currentSessionId
|
|
105
|
+
},
|
|
106
|
+
values: {
|
|
107
|
+
options: {
|
|
108
|
+
...isRecord(options) ? options : {},
|
|
109
|
+
frontendTools
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
return frontendTools;
|
|
114
|
+
};
|
|
115
|
+
const findCurrentFrontendTool = async (ctx, toolId, sessionId) => {
|
|
116
|
+
const tools = await listCurrentFrontendTools(ctx, sessionId);
|
|
117
|
+
return tools.find((tool) => tool.id === toolId);
|
|
118
|
+
};
|
|
119
|
+
const shouldAutoExecuteFrontendTool = (tools, args) => {
|
|
120
|
+
var _a;
|
|
121
|
+
if (!isRecord(args) || typeof args.toolId !== "string") {
|
|
122
|
+
return false;
|
|
123
|
+
}
|
|
124
|
+
return ((_a = tools.find((tool) => tool.id === args.toolId)) == null ? void 0 : _a.permission) === "ALLOW";
|
|
125
|
+
};
|
|
126
|
+
const prepareToolsForFrontendConversation = (tools, frontendTools) => {
|
|
127
|
+
if (!frontendTools.length) {
|
|
128
|
+
return tools.filter(
|
|
129
|
+
(tool) => tool.definition.name !== import_frontend_tools.LOAD_FRONTEND_TOOL_NAME && tool.definition.name !== import_frontend_tools.EXECUTE_FRONTEND_TOOL_NAME
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
const catalog = frontendTools.map(({ id, name, title, description }) => ({ id, name, title, description }));
|
|
133
|
+
const toolIds = frontendTools.map((tool) => tool.id);
|
|
134
|
+
const toolIdSchema = import_zod.z.enum(toolIds).describe(`Use an exact tool id from this catalog: ${JSON.stringify(catalog)}`);
|
|
135
|
+
return tools.map((tool) => {
|
|
136
|
+
if (tool.definition.name !== import_frontend_tools.LOAD_FRONTEND_TOOL_NAME && tool.definition.name !== import_frontend_tools.EXECUTE_FRONTEND_TOOL_NAME) {
|
|
137
|
+
return tool;
|
|
138
|
+
}
|
|
139
|
+
const isLoader = tool.definition.name === import_frontend_tools.LOAD_FRONTEND_TOOL_NAME;
|
|
140
|
+
return {
|
|
141
|
+
...tool,
|
|
142
|
+
definition: {
|
|
143
|
+
...tool.definition,
|
|
144
|
+
description: `${tool.definition.description}
|
|
145
|
+
|
|
146
|
+
frontendToolCatalog: ${JSON.stringify(catalog)}`,
|
|
147
|
+
schema: isLoader ? import_zod.z.object({ toolId: toolIdSchema }) : import_zod.z.object({
|
|
148
|
+
toolId: toolIdSchema,
|
|
149
|
+
args: import_zod.z.record(import_zod.z.string(), import_zod.z.unknown()).default({})
|
|
150
|
+
})
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
});
|
|
154
|
+
};
|
|
155
|
+
const readFrontendToolResult = (ctx, toolCallId) => {
|
|
156
|
+
var _a, _b, _c;
|
|
157
|
+
const toolCallResults = (_c = (_b = (_a = ctx.action) == null ? void 0 : _a.params) == null ? void 0 : _b.values) == null ? void 0 : _c.toolCallResults;
|
|
158
|
+
const result = Array.isArray(toolCallResults) ? toolCallResults.find(
|
|
159
|
+
(item) => isRecord(item) && item.id === toolCallId && "result" in item
|
|
160
|
+
) : void 0;
|
|
161
|
+
return result ? { provided: true, value: result.result } : void 0;
|
|
162
|
+
};
|
|
163
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
164
|
+
0 && (module.exports = {
|
|
165
|
+
extractFrontendToolManifests,
|
|
166
|
+
findCurrentFrontendTool,
|
|
167
|
+
listCurrentFrontendTools,
|
|
168
|
+
prepareToolsForFrontendConversation,
|
|
169
|
+
readFrontendToolResult,
|
|
170
|
+
shouldAutoExecuteFrontendTool
|
|
171
|
+
});
|
|
@@ -55,19 +55,27 @@ const collectReasoningMap = (messages) => {
|
|
|
55
55
|
return reasoningMap;
|
|
56
56
|
};
|
|
57
57
|
const patchRequestMessagesReasoning = (request, reasoningMap) => {
|
|
58
|
+
var _a;
|
|
58
59
|
if (!(reasoningMap == null ? void 0 : reasoningMap.size) || !Array.isArray(request == null ? void 0 : request.messages)) {
|
|
59
60
|
return;
|
|
60
61
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
62
|
+
let lastUserMessageIndex = -1;
|
|
63
|
+
for (let i = request.messages.length - 1; i >= 0; i--) {
|
|
64
|
+
if (((_a = request.messages[i]) == null ? void 0 : _a.role) === "user") {
|
|
65
|
+
lastUserMessageIndex = i;
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
for (let i = lastUserMessageIndex + 1; i < request.messages.length; i++) {
|
|
70
|
+
const message = request.messages[i];
|
|
71
|
+
if ((message == null ? void 0 : message.role) !== "assistant" || !Array.isArray(message.tool_calls) || message.tool_calls.length === 0) {
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
if (typeof message.reasoning_content === "string" && message.reasoning_content.length > 0) {
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
const reasoningContent = reasoningMap.get(String(i));
|
|
78
|
+
if (typeof reasoningContent === "string" && reasoningContent.length > 0) {
|
|
71
79
|
message.reasoning_content = reasoningContent;
|
|
72
80
|
}
|
|
73
81
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
export * from './provider';
|
|
10
|
+
export * from './reasoning';
|
|
@@ -0,0 +1,32 @@
|
|
|
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 __copyProps = (to, from, except, desc) => {
|
|
15
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
+
for (let key of __getOwnPropNames(from))
|
|
17
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
18
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
23
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
|
+
var deepseek_exports = {};
|
|
25
|
+
module.exports = __toCommonJS(deepseek_exports);
|
|
26
|
+
__reExport(deepseek_exports, require("./provider"), module.exports);
|
|
27
|
+
__reExport(deepseek_exports, require("./reasoning"), module.exports);
|
|
28
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
29
|
+
0 && (module.exports = {
|
|
30
|
+
...require("./provider"),
|
|
31
|
+
...require("./reasoning")
|
|
32
|
+
});
|
|
@@ -0,0 +1,57 @@
|
|
|
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, type ChatDeepSeekInput } from '@langchain/deepseek';
|
|
10
|
+
import { AIMessage, AIMessageChunk, BaseMessage } from '@langchain/core/messages';
|
|
11
|
+
import { ChatOpenAI } from '@langchain/openai';
|
|
12
|
+
import type { CallbackManagerForLLMRun } from '@langchain/core/callbacks/manager';
|
|
13
|
+
import type OpenAI from 'openai';
|
|
14
|
+
import { Model } from '@nocobase/database';
|
|
15
|
+
import { LLMProvider, ReasoningOptions, ResolvedReasoningOptions } from '../provider';
|
|
16
|
+
import { LLMProviderMeta } from '../../manager/ai-manager';
|
|
17
|
+
import { DeepSeekReasoningConfig } from './reasoning';
|
|
18
|
+
import type { AIMessageInput } from '../../types';
|
|
19
|
+
declare class ReasoningDeepSeek extends ChatDeepSeek {
|
|
20
|
+
private readonly reasoningConfig;
|
|
21
|
+
constructor(fields: ChatDeepSeekInput, reasoningConfig: DeepSeekReasoningConfig);
|
|
22
|
+
_generate(messages: BaseMessage[], options: this['ParsedCallOptions'], runManager?: CallbackManagerForLLMRun): Promise<import("@langchain/core/dist/outputs").ChatResult>;
|
|
23
|
+
_streamResponseChunks(messages: BaseMessage[], options: this['ParsedCallOptions'], runManager?: CallbackManagerForLLMRun): AsyncGenerator<import("@langchain/core/dist/outputs").ChatGenerationChunk, void, unknown>;
|
|
24
|
+
completionWithRetry(request: OpenAI.Chat.ChatCompletionCreateParamsStreaming, requestOptions?: OpenAI.RequestOptions): Promise<AsyncIterable<OpenAI.Chat.Completions.ChatCompletionChunk>>;
|
|
25
|
+
completionWithRetry(request: OpenAI.Chat.ChatCompletionCreateParamsNonStreaming, requestOptions?: OpenAI.RequestOptions): Promise<OpenAI.Chat.Completions.ChatCompletion>;
|
|
26
|
+
}
|
|
27
|
+
export declare class DeepSeekProvider extends LLMProvider {
|
|
28
|
+
chatModel: ChatDeepSeek | ChatOpenAI;
|
|
29
|
+
get baseURL(): string;
|
|
30
|
+
createModel(): ChatOpenAI<import("@langchain/openai/dist/chat_models/index.cjs").ChatOpenAICallOptions> | ReasoningDeepSeek;
|
|
31
|
+
parseResponseChunk(chunk: unknown): string;
|
|
32
|
+
parseResponseMessage(message: Model): {
|
|
33
|
+
key: any;
|
|
34
|
+
createdAt: any;
|
|
35
|
+
content: any;
|
|
36
|
+
role: any;
|
|
37
|
+
};
|
|
38
|
+
parseReasoningContent(chunk: AIMessageChunk): {
|
|
39
|
+
status: string;
|
|
40
|
+
content: string;
|
|
41
|
+
} | null;
|
|
42
|
+
reshapeAIMessage({ aiMessage, values }: {
|
|
43
|
+
aiMessage: AIMessage;
|
|
44
|
+
values: AIMessageInput;
|
|
45
|
+
}): void;
|
|
46
|
+
prepareStoredAssistantAdditionalKwargs(additionalKwargs?: Record<string, unknown>): Record<string, unknown> | undefined;
|
|
47
|
+
protected builtInTools(): Record<string, unknown>[];
|
|
48
|
+
parseWebSearchAction(chunk: AIMessageChunk): {
|
|
49
|
+
type: string;
|
|
50
|
+
query: string;
|
|
51
|
+
}[];
|
|
52
|
+
protected resolveReasoningOptions(reasoning?: ReasoningOptions): ResolvedReasoningOptions;
|
|
53
|
+
isToolConflict(): boolean;
|
|
54
|
+
protected isApiSupportedAttachment(): boolean;
|
|
55
|
+
}
|
|
56
|
+
export declare const deepseekProviderOptions: LLMProviderMeta;
|
|
57
|
+
export {};
|
|
@@ -0,0 +1,320 @@
|
|
|
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 provider_exports = {};
|
|
28
|
+
__export(provider_exports, {
|
|
29
|
+
DeepSeekProvider: () => DeepSeekProvider,
|
|
30
|
+
deepseekProviderOptions: () => deepseekProviderOptions
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(provider_exports);
|
|
33
|
+
var import_deepseek = require("@langchain/deepseek");
|
|
34
|
+
var import_openai = require("@langchain/openai");
|
|
35
|
+
var import_provider = require("../provider");
|
|
36
|
+
var import_ai_manager = require("../../manager/ai-manager");
|
|
37
|
+
var import_reasoning = require("../common/reasoning");
|
|
38
|
+
var import_reasoning2 = require("./reasoning");
|
|
39
|
+
var import_utils = require("../../utils");
|
|
40
|
+
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
41
|
+
const collectReferences = (content, responseMetadata) => {
|
|
42
|
+
const references = [];
|
|
43
|
+
const addAnnotations = (annotations) => {
|
|
44
|
+
if (!Array.isArray(annotations)) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
for (const annotation of annotations) {
|
|
48
|
+
if (!isRecord(annotation)) {
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
const value = isRecord(annotation.value) ? annotation.value : annotation;
|
|
52
|
+
const url = typeof annotation.url === "string" ? annotation.url : value.url;
|
|
53
|
+
const title = typeof annotation.title === "string" ? annotation.title : value.title;
|
|
54
|
+
if (typeof url === "string") {
|
|
55
|
+
references.push({ title: typeof title === "string" ? title : "", url });
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
if (Array.isArray(content)) {
|
|
60
|
+
for (const block of content) {
|
|
61
|
+
if (isRecord(block) && block.type === "text") {
|
|
62
|
+
addAnnotations(block.annotations);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if (isRecord(responseMetadata) && Array.isArray(responseMetadata.output)) {
|
|
67
|
+
for (const item of responseMetadata.output) {
|
|
68
|
+
if (!isRecord(item) || item.type !== "message" || !Array.isArray(item.content)) {
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
for (const part of item.content) {
|
|
72
|
+
if (isRecord(part) && part.type === "output_text") {
|
|
73
|
+
addAnnotations(part.annotations);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return Array.from(new Map(references.map((reference) => [reference.url, reference])).values());
|
|
79
|
+
};
|
|
80
|
+
class ReasoningDeepSeek extends import_deepseek.ChatDeepSeek {
|
|
81
|
+
constructor(fields, reasoningConfig) {
|
|
82
|
+
super(fields);
|
|
83
|
+
this.reasoningConfig = reasoningConfig;
|
|
84
|
+
}
|
|
85
|
+
async _generate(messages, options, runManager) {
|
|
86
|
+
const reasoningMap = (0, import_reasoning.collectReasoningMap)(messages);
|
|
87
|
+
return super._generate(
|
|
88
|
+
messages,
|
|
89
|
+
{
|
|
90
|
+
...options || {},
|
|
91
|
+
[import_reasoning.REASONING_MAP_KEY]: reasoningMap
|
|
92
|
+
},
|
|
93
|
+
runManager
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
async *_streamResponseChunks(messages, options, runManager) {
|
|
97
|
+
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);
|
|
98
|
+
yield* super._streamResponseChunks(
|
|
99
|
+
messages,
|
|
100
|
+
{
|
|
101
|
+
...options || {},
|
|
102
|
+
[import_reasoning.REASONING_MAP_KEY]: reasoningMap
|
|
103
|
+
},
|
|
104
|
+
runManager
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
async completionWithRetry(request, requestOptions) {
|
|
108
|
+
const reasoningMap = requestOptions == null ? void 0 : requestOptions[import_reasoning.REASONING_MAP_KEY];
|
|
109
|
+
const modelKwargs = requestOptions == null ? void 0 : requestOptions[import_reasoning.MODEL_KWARGS_KEY];
|
|
110
|
+
(0, import_reasoning.patchRequestMessagesReasoning)(request, reasoningMap);
|
|
111
|
+
(0, import_reasoning.patchRequestModelKwargs)(request, modelKwargs);
|
|
112
|
+
(0, import_reasoning2.normalizeDeepSeekChatRequest)(request, this.reasoningConfig);
|
|
113
|
+
if (request.stream === true) {
|
|
114
|
+
return super.completionWithRetry(request, requestOptions);
|
|
115
|
+
}
|
|
116
|
+
return super.completionWithRetry(request, requestOptions);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
class DeepSeekChatOpenAIResponses extends import_openai.ChatOpenAIResponses {
|
|
120
|
+
constructor(fields, reasoningConfig) {
|
|
121
|
+
super(fields);
|
|
122
|
+
this.reasoningConfig = reasoningConfig;
|
|
123
|
+
}
|
|
124
|
+
async completionWithRetry(request, requestOptions) {
|
|
125
|
+
(0, import_reasoning2.normalizeDeepSeekResponsesRequest)(request, this.reasoningConfig);
|
|
126
|
+
if (request.stream === true) {
|
|
127
|
+
const stream = await super.completionWithRetry(
|
|
128
|
+
request,
|
|
129
|
+
requestOptions
|
|
130
|
+
);
|
|
131
|
+
return (0, import_reasoning2.adaptDeepSeekResponsesStream)(stream);
|
|
132
|
+
}
|
|
133
|
+
return super.completionWithRetry(request, requestOptions);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
class DeepSeekProvider extends import_provider.LLMProvider {
|
|
137
|
+
get baseURL() {
|
|
138
|
+
return "https://api.deepseek.com";
|
|
139
|
+
}
|
|
140
|
+
createModel() {
|
|
141
|
+
const { apiKey } = this.serviceOptions || {};
|
|
142
|
+
const { responseFormat, structuredOutput, ...modelOptions } = this.modelOptions || {};
|
|
143
|
+
const model = typeof modelOptions.model === "string" ? modelOptions.model : "";
|
|
144
|
+
const reasoningConfig = (0, import_reasoning2.resolveDeepSeekReasoningConfig)(model, this.modelReasoningOptions);
|
|
145
|
+
const reasoningParams = (0, import_reasoning2.getDeepSeekReasoningRequestParams)(reasoningConfig);
|
|
146
|
+
if (reasoningConfig.protocol === "responses") {
|
|
147
|
+
const { name, schema, strict } = structuredOutput || {};
|
|
148
|
+
let responseFormatOptions = {
|
|
149
|
+
type: responseFormat ?? "text"
|
|
150
|
+
};
|
|
151
|
+
if (responseFormat === "json_schema" && schema) {
|
|
152
|
+
responseFormatOptions = {
|
|
153
|
+
...responseFormatOptions,
|
|
154
|
+
schema,
|
|
155
|
+
name: name ?? "default",
|
|
156
|
+
strict: strict ?? false
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
const fields = {
|
|
160
|
+
apiKey,
|
|
161
|
+
...modelOptions,
|
|
162
|
+
modelKwargs: {
|
|
163
|
+
text: {
|
|
164
|
+
format: responseFormatOptions
|
|
165
|
+
},
|
|
166
|
+
...reasoningParams
|
|
167
|
+
},
|
|
168
|
+
configuration: {
|
|
169
|
+
baseURL: this.getResolvedBaseURL()
|
|
170
|
+
},
|
|
171
|
+
verbose: false
|
|
172
|
+
};
|
|
173
|
+
return new import_openai.ChatOpenAI({
|
|
174
|
+
...fields,
|
|
175
|
+
responses: new DeepSeekChatOpenAIResponses(fields, reasoningConfig),
|
|
176
|
+
useResponsesApi: true
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
const modelKwargs = {
|
|
180
|
+
...reasoningParams
|
|
181
|
+
};
|
|
182
|
+
if (responseFormat) {
|
|
183
|
+
modelKwargs.response_format = {
|
|
184
|
+
type: responseFormat
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
return new ReasoningDeepSeek(
|
|
188
|
+
{
|
|
189
|
+
apiKey,
|
|
190
|
+
...modelOptions,
|
|
191
|
+
modelKwargs,
|
|
192
|
+
configuration: {
|
|
193
|
+
baseURL: this.getResolvedBaseURL()
|
|
194
|
+
},
|
|
195
|
+
verbose: false
|
|
196
|
+
},
|
|
197
|
+
reasoningConfig
|
|
198
|
+
);
|
|
199
|
+
}
|
|
200
|
+
parseResponseChunk(chunk) {
|
|
201
|
+
if (Array.isArray(chunk)) {
|
|
202
|
+
const text = chunk.filter(isRecord).filter((block) => block.type === "text").map((block) => block.text).filter((value) => typeof value === "string").join("");
|
|
203
|
+
return text ? (0, import_utils.stripToolCallTags)(text) : null;
|
|
204
|
+
}
|
|
205
|
+
return typeof chunk === "string" ? (0, import_utils.stripToolCallTags)(chunk) : null;
|
|
206
|
+
}
|
|
207
|
+
parseResponseMessage(message) {
|
|
208
|
+
var _a, _b;
|
|
209
|
+
const result = super.parseResponseMessage(message);
|
|
210
|
+
if (["user", "tool"].includes(result == null ? void 0 : result.role)) {
|
|
211
|
+
return result;
|
|
212
|
+
}
|
|
213
|
+
const json = ((_a = message == null ? void 0 : message.toJSON) == null ? void 0 : _a.call(message)) ?? {};
|
|
214
|
+
const metadata = isRecord(json.metadata) ? json.metadata : {};
|
|
215
|
+
const additionalKwargs = isRecord(metadata.additional_kwargs) ? metadata.additional_kwargs : {};
|
|
216
|
+
const responseMetadata = isRecord(metadata.response_metadata) ? metadata.response_metadata : {};
|
|
217
|
+
const reasoningContent = (0, import_reasoning2.extractDeepSeekReasoningText)({
|
|
218
|
+
additional_kwargs: additionalKwargs,
|
|
219
|
+
response_metadata: responseMetadata
|
|
220
|
+
});
|
|
221
|
+
if (reasoningContent) {
|
|
222
|
+
result.content = {
|
|
223
|
+
...result.content ?? {},
|
|
224
|
+
reasoning: {
|
|
225
|
+
status: "stop",
|
|
226
|
+
content: reasoningContent
|
|
227
|
+
}
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
const references = collectReferences((_b = result == null ? void 0 : result.content) == null ? void 0 : _b.content, responseMetadata);
|
|
231
|
+
if (references.length) {
|
|
232
|
+
result.content.reference = references;
|
|
233
|
+
}
|
|
234
|
+
return result;
|
|
235
|
+
}
|
|
236
|
+
parseReasoningContent(chunk) {
|
|
237
|
+
const content = (0, import_reasoning2.extractDeepSeekReasoningText)({
|
|
238
|
+
content: chunk.content,
|
|
239
|
+
additional_kwargs: chunk.additional_kwargs
|
|
240
|
+
});
|
|
241
|
+
return content ? { status: "streaming", content } : null;
|
|
242
|
+
}
|
|
243
|
+
reshapeAIMessage({ aiMessage, values }) {
|
|
244
|
+
const reasoningItem = (0, import_reasoning2.getDeepSeekResponsesReasoningItem)(aiMessage);
|
|
245
|
+
const reasoningContent = (0, import_reasoning2.extractDeepSeekReasoningText)(aiMessage);
|
|
246
|
+
if (reasoningItem || reasoningContent) {
|
|
247
|
+
const additionalKwargs = {
|
|
248
|
+
...values.metadata.additional_kwargs ?? {},
|
|
249
|
+
...reasoningItem ? { reasoning: reasoningItem } : {},
|
|
250
|
+
...reasoningContent ? { reasoning_content: reasoningContent } : {}
|
|
251
|
+
};
|
|
252
|
+
values.metadata.additional_kwargs = additionalKwargs;
|
|
253
|
+
aiMessage.additional_kwargs = {
|
|
254
|
+
...aiMessage.additional_kwargs,
|
|
255
|
+
...reasoningItem ? { reasoning: reasoningItem } : {}
|
|
256
|
+
};
|
|
257
|
+
aiMessage.lc_kwargs.additional_kwargs = aiMessage.additional_kwargs;
|
|
258
|
+
}
|
|
259
|
+
const references = collectReferences(aiMessage.content, aiMessage.response_metadata);
|
|
260
|
+
if (references.length) {
|
|
261
|
+
values.content.reference = references;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
prepareStoredAssistantAdditionalKwargs(additionalKwargs) {
|
|
265
|
+
var _a, _b;
|
|
266
|
+
if (((_b = (0, import_reasoning2.getDeepSeekModelCapabilities)(String((_a = this.modelOptions) == null ? void 0 : _a.model))) == null ? void 0 : _b.protocol) !== "responses" || !additionalKwargs) {
|
|
267
|
+
return additionalKwargs;
|
|
268
|
+
}
|
|
269
|
+
const nextAdditionalKwargs = { ...additionalKwargs };
|
|
270
|
+
delete nextAdditionalKwargs.reasoning;
|
|
271
|
+
delete nextAdditionalKwargs.reasoning_content;
|
|
272
|
+
return Object.keys(nextAdditionalKwargs).length ? nextAdditionalKwargs : void 0;
|
|
273
|
+
}
|
|
274
|
+
builtInTools() {
|
|
275
|
+
var _a, _b, _c, _d;
|
|
276
|
+
if (((_b = (0, import_reasoning2.getDeepSeekModelCapabilities)(String((_a = this.modelOptions) == null ? void 0 : _a.model))) == null ? void 0 : _b.supportsWebSearch) === true && ((_d = (_c = this.modelOptions) == null ? void 0 : _c.builtIn) == null ? void 0 : _d.webSearch) === true) {
|
|
277
|
+
return [{ type: "web_search" }];
|
|
278
|
+
}
|
|
279
|
+
return [];
|
|
280
|
+
}
|
|
281
|
+
parseWebSearchAction(chunk) {
|
|
282
|
+
var _a;
|
|
283
|
+
const toolOutputs = (_a = chunk.additional_kwargs) == null ? void 0 : _a.tool_outputs;
|
|
284
|
+
if (!Array.isArray(toolOutputs)) {
|
|
285
|
+
return [];
|
|
286
|
+
}
|
|
287
|
+
return toolOutputs.filter(isRecord).filter((tool) => tool.type === "web_search_call" && isRecord(tool.action)).map((tool) => tool.action).filter((action) => typeof action.query === "string").map((action) => ({
|
|
288
|
+
type: typeof action.type === "string" ? action.type : "web_search",
|
|
289
|
+
query: action.query
|
|
290
|
+
}));
|
|
291
|
+
}
|
|
292
|
+
resolveReasoningOptions(reasoning) {
|
|
293
|
+
var _a;
|
|
294
|
+
const model = typeof ((_a = this.modelOptions) == null ? void 0 : _a.model) === "string" ? this.modelOptions.model : "";
|
|
295
|
+
const config = (0, import_reasoning2.resolveDeepSeekReasoningConfig)(model, reasoning);
|
|
296
|
+
const params = (0, import_reasoning2.getDeepSeekReasoningRequestParams)(config);
|
|
297
|
+
return Object.keys(params).length ? { modelKwargs: params } : {};
|
|
298
|
+
}
|
|
299
|
+
isToolConflict() {
|
|
300
|
+
return false;
|
|
301
|
+
}
|
|
302
|
+
isApiSupportedAttachment() {
|
|
303
|
+
return false;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
const deepseekProviderOptions = {
|
|
307
|
+
title: "DeepSeek",
|
|
308
|
+
supportedModel: [import_ai_manager.SupportedModel.LLM],
|
|
309
|
+
models: {
|
|
310
|
+
[import_ai_manager.SupportedModel.LLM]: ["deepseek-v4-pro", "deepseek-v4-flash", "deepseek-chat", "deepseek-reasoner"]
|
|
311
|
+
},
|
|
312
|
+
supportWebSearch: true,
|
|
313
|
+
webSearchModels: ["deepseek-v4-flash", "deepseek-v4-pro"],
|
|
314
|
+
provider: DeepSeekProvider
|
|
315
|
+
};
|
|
316
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
317
|
+
0 && (module.exports = {
|
|
318
|
+
DeepSeekProvider,
|
|
319
|
+
deepseekProviderOptions
|
|
320
|
+
});
|