@nocobase/plugin-ai 2.3.0-alpha.1 → 2.3.0-beta.2
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/storage/aliyun-oss.md +100 -3
- package/dist/ai/docs/nocobase/file-manager/storage/index.md +66 -26
- package/dist/ai/docs/nocobase/file-manager/storage/s3-pro.md +58 -7
- package/dist/ai/docs/nocobase/get-started/installation/env.md +1 -1
- 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/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.28ee769f796b7c2f.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-v2/705.1d10027ff8cfdf79.js → client/705.a4fe26945d175e8a.js} +1 -1
- package/dist/client/index.d.ts +1 -3
- package/dist/client/index.js +8 -8
- package/dist/client-v2/244.39348a95d627d9e3.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.f2e1b26a3f000075.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/collections/ai-employees.d.ts +1 -0
- package/dist/collections/ai-employees.js +1 -0
- package/dist/common/ai-employee-validation.d.ts +15 -0
- package/dist/common/ai-employee-validation.js +61 -0
- package/dist/common/error-codes.d.ts +13 -0
- package/dist/common/error-codes.js +48 -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 +85 -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 +85 -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 +4 -1
- package/dist/server/ai-employees/ai-employee.js +112 -47
- package/dist/server/ai-employees/ai-knowledge-base.d.ts +21 -1
- package/dist/server/ai-employees/ai-knowledge-base.js +76 -8
- package/dist/server/ai-employees/middleware/conversation.js +9 -2
- 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 +70 -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/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/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,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
|
+
});
|
|
@@ -0,0 +1,83 @@
|
|
|
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 type OpenAI from 'openai';
|
|
10
|
+
import type { ReasoningOptions } from '../provider';
|
|
11
|
+
export type DeepSeekApiProtocol = 'chat-completions' | 'responses';
|
|
12
|
+
export type DeepSeekThinkingMode = 'enabled' | 'disabled';
|
|
13
|
+
export type DeepSeekReasoningEffort = 'low' | 'high' | 'max';
|
|
14
|
+
type DeepSeekReasoningBehavior = 'switchable' | 'always-on' | 'always-off';
|
|
15
|
+
type DeepSeekModelCapabilities = {
|
|
16
|
+
protocol: DeepSeekApiProtocol;
|
|
17
|
+
reasoning: DeepSeekReasoningBehavior;
|
|
18
|
+
defaultThinking: DeepSeekThinkingMode;
|
|
19
|
+
efforts: ReadonlySet<DeepSeekReasoningEffort>;
|
|
20
|
+
supportsFunctionTools: boolean;
|
|
21
|
+
supportsStructuredOutput: boolean;
|
|
22
|
+
supportsWebSearch: boolean;
|
|
23
|
+
};
|
|
24
|
+
export type DeepSeekReasoningConfig = {
|
|
25
|
+
protocol: DeepSeekApiProtocol;
|
|
26
|
+
recognizedModel: boolean;
|
|
27
|
+
thinking?: DeepSeekThinkingMode;
|
|
28
|
+
effort?: DeepSeekReasoningEffort;
|
|
29
|
+
unsupportedRequestFields: ReadonlySet<string>;
|
|
30
|
+
};
|
|
31
|
+
type ReasoningSource = {
|
|
32
|
+
content?: unknown;
|
|
33
|
+
additional_kwargs?: Record<string, unknown>;
|
|
34
|
+
response_metadata?: Record<string, unknown>;
|
|
35
|
+
};
|
|
36
|
+
export declare const DEEPSEEK_MODEL_CAPABILITIES: {
|
|
37
|
+
readonly 'deepseek-v4-flash': {
|
|
38
|
+
readonly protocol: "responses";
|
|
39
|
+
readonly reasoning: "switchable";
|
|
40
|
+
readonly defaultThinking: "enabled";
|
|
41
|
+
readonly efforts: Set<DeepSeekReasoningEffort>;
|
|
42
|
+
readonly supportsFunctionTools: true;
|
|
43
|
+
readonly supportsStructuredOutput: true;
|
|
44
|
+
readonly supportsWebSearch: true;
|
|
45
|
+
};
|
|
46
|
+
readonly 'deepseek-v4-pro': {
|
|
47
|
+
readonly protocol: "responses";
|
|
48
|
+
readonly reasoning: "switchable";
|
|
49
|
+
readonly defaultThinking: "enabled";
|
|
50
|
+
readonly efforts: Set<DeepSeekReasoningEffort>;
|
|
51
|
+
readonly supportsFunctionTools: true;
|
|
52
|
+
readonly supportsStructuredOutput: true;
|
|
53
|
+
readonly supportsWebSearch: true;
|
|
54
|
+
};
|
|
55
|
+
readonly 'deepseek-chat': {
|
|
56
|
+
readonly protocol: "chat-completions";
|
|
57
|
+
readonly reasoning: "always-off";
|
|
58
|
+
readonly defaultThinking: "disabled";
|
|
59
|
+
readonly efforts: Set<DeepSeekReasoningEffort>;
|
|
60
|
+
readonly supportsFunctionTools: true;
|
|
61
|
+
readonly supportsStructuredOutput: true;
|
|
62
|
+
readonly supportsWebSearch: false;
|
|
63
|
+
};
|
|
64
|
+
readonly 'deepseek-reasoner': {
|
|
65
|
+
readonly protocol: "chat-completions";
|
|
66
|
+
readonly reasoning: "always-on";
|
|
67
|
+
readonly defaultThinking: "enabled";
|
|
68
|
+
readonly efforts: Set<DeepSeekReasoningEffort>;
|
|
69
|
+
readonly supportsFunctionTools: true;
|
|
70
|
+
readonly supportsStructuredOutput: true;
|
|
71
|
+
readonly supportsWebSearch: false;
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
export type OfficialDeepSeekModel = keyof typeof DEEPSEEK_MODEL_CAPABILITIES;
|
|
75
|
+
export declare const getDeepSeekModelCapabilities: (model: string) => DeepSeekModelCapabilities | null;
|
|
76
|
+
export declare const resolveDeepSeekReasoningConfig: (model: string, reasoning?: ReasoningOptions) => DeepSeekReasoningConfig;
|
|
77
|
+
export declare const getDeepSeekReasoningRequestParams: (config: DeepSeekReasoningConfig) => Record<string, unknown>;
|
|
78
|
+
export declare const normalizeDeepSeekChatRequest: <Request_1 extends OpenAI.Chat.Completions.ChatCompletionCreateParams>(request: Request_1, config: DeepSeekReasoningConfig) => Request_1;
|
|
79
|
+
export declare const normalizeDeepSeekResponsesRequest: <Request_1 extends OpenAI.Responses.ResponseCreateParams>(request: Request_1, config: DeepSeekReasoningConfig) => Request_1;
|
|
80
|
+
export declare const extractDeepSeekReasoningText: (source: Partial<ReasoningSource>) => string;
|
|
81
|
+
export declare const getDeepSeekResponsesReasoningItem: (source: Partial<ReasoningSource>) => Record<string, unknown> | null;
|
|
82
|
+
export declare function adaptDeepSeekResponsesStream(stream: AsyncIterable<OpenAI.Responses.ResponseStreamEvent>): AsyncGenerator<OpenAI.Responses.ResponseStreamEvent>;
|
|
83
|
+
export {};
|
|
@@ -0,0 +1,285 @@
|
|
|
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 reasoning_exports = {};
|
|
28
|
+
__export(reasoning_exports, {
|
|
29
|
+
DEEPSEEK_MODEL_CAPABILITIES: () => DEEPSEEK_MODEL_CAPABILITIES,
|
|
30
|
+
adaptDeepSeekResponsesStream: () => adaptDeepSeekResponsesStream,
|
|
31
|
+
extractDeepSeekReasoningText: () => extractDeepSeekReasoningText,
|
|
32
|
+
getDeepSeekModelCapabilities: () => getDeepSeekModelCapabilities,
|
|
33
|
+
getDeepSeekReasoningRequestParams: () => getDeepSeekReasoningRequestParams,
|
|
34
|
+
getDeepSeekResponsesReasoningItem: () => getDeepSeekResponsesReasoningItem,
|
|
35
|
+
normalizeDeepSeekChatRequest: () => normalizeDeepSeekChatRequest,
|
|
36
|
+
normalizeDeepSeekResponsesRequest: () => normalizeDeepSeekResponsesRequest,
|
|
37
|
+
resolveDeepSeekReasoningConfig: () => resolveDeepSeekReasoningConfig
|
|
38
|
+
});
|
|
39
|
+
module.exports = __toCommonJS(reasoning_exports);
|
|
40
|
+
const NO_EFFORTS = /* @__PURE__ */ new Set();
|
|
41
|
+
const V4_EFFORTS = /* @__PURE__ */ new Set(["low", "high", "max"]);
|
|
42
|
+
const THINKING_UNSUPPORTED_FIELDS = /* @__PURE__ */ new Set(["temperature", "top_p", "presence_penalty", "frequency_penalty"]);
|
|
43
|
+
const NO_UNSUPPORTED_FIELDS = /* @__PURE__ */ new Set();
|
|
44
|
+
const DEEPSEEK_MODEL_CAPABILITIES = {
|
|
45
|
+
"deepseek-v4-flash": {
|
|
46
|
+
protocol: "responses",
|
|
47
|
+
reasoning: "switchable",
|
|
48
|
+
defaultThinking: "enabled",
|
|
49
|
+
efforts: V4_EFFORTS,
|
|
50
|
+
supportsFunctionTools: true,
|
|
51
|
+
supportsStructuredOutput: true,
|
|
52
|
+
supportsWebSearch: true
|
|
53
|
+
},
|
|
54
|
+
"deepseek-v4-pro": {
|
|
55
|
+
protocol: "responses",
|
|
56
|
+
reasoning: "switchable",
|
|
57
|
+
defaultThinking: "enabled",
|
|
58
|
+
efforts: V4_EFFORTS,
|
|
59
|
+
supportsFunctionTools: true,
|
|
60
|
+
supportsStructuredOutput: true,
|
|
61
|
+
supportsWebSearch: true
|
|
62
|
+
},
|
|
63
|
+
"deepseek-chat": {
|
|
64
|
+
protocol: "chat-completions",
|
|
65
|
+
reasoning: "always-off",
|
|
66
|
+
defaultThinking: "disabled",
|
|
67
|
+
efforts: NO_EFFORTS,
|
|
68
|
+
supportsFunctionTools: true,
|
|
69
|
+
supportsStructuredOutput: true,
|
|
70
|
+
supportsWebSearch: false
|
|
71
|
+
},
|
|
72
|
+
"deepseek-reasoner": {
|
|
73
|
+
protocol: "chat-completions",
|
|
74
|
+
reasoning: "always-on",
|
|
75
|
+
defaultThinking: "enabled",
|
|
76
|
+
efforts: NO_EFFORTS,
|
|
77
|
+
supportsFunctionTools: true,
|
|
78
|
+
supportsStructuredOutput: true,
|
|
79
|
+
supportsWebSearch: false
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
83
|
+
const isOfficialDeepSeekModel = (model) => model in DEEPSEEK_MODEL_CAPABILITIES;
|
|
84
|
+
const getDeepSeekModelCapabilities = (model) => isOfficialDeepSeekModel(model) ? DEEPSEEK_MODEL_CAPABILITIES[model] : null;
|
|
85
|
+
const normalizeReasoningEffort = (mode) => {
|
|
86
|
+
if (mode === "minimal" || mode === "low") {
|
|
87
|
+
return "low";
|
|
88
|
+
}
|
|
89
|
+
if (mode === "xhigh") {
|
|
90
|
+
return "high";
|
|
91
|
+
}
|
|
92
|
+
return "high";
|
|
93
|
+
};
|
|
94
|
+
const resolveDeepSeekReasoningConfig = (model, reasoning) => {
|
|
95
|
+
const capabilities = getDeepSeekModelCapabilities(model);
|
|
96
|
+
if (!capabilities) {
|
|
97
|
+
return {
|
|
98
|
+
protocol: "chat-completions",
|
|
99
|
+
recognizedModel: false,
|
|
100
|
+
unsupportedRequestFields: NO_UNSUPPORTED_FIELDS
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
const mode = (reasoning == null ? void 0 : reasoning.mode) ?? "default";
|
|
104
|
+
if (mode === "default") {
|
|
105
|
+
return {
|
|
106
|
+
protocol: capabilities.protocol,
|
|
107
|
+
recognizedModel: true,
|
|
108
|
+
unsupportedRequestFields: capabilities.defaultThinking === "enabled" ? THINKING_UNSUPPORTED_FIELDS : NO_UNSUPPORTED_FIELDS
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
if (mode === "off") {
|
|
112
|
+
if (capabilities.reasoning === "always-on") {
|
|
113
|
+
throw new Error(`DeepSeek model "${model}" does not support disabling reasoning`);
|
|
114
|
+
}
|
|
115
|
+
return {
|
|
116
|
+
protocol: capabilities.protocol,
|
|
117
|
+
recognizedModel: true,
|
|
118
|
+
...capabilities.reasoning === "switchable" ? { thinking: "disabled" } : {},
|
|
119
|
+
unsupportedRequestFields: NO_UNSUPPORTED_FIELDS
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
if (capabilities.reasoning === "always-off") {
|
|
123
|
+
throw new Error(`DeepSeek model "${model}" does not support reasoning`);
|
|
124
|
+
}
|
|
125
|
+
const effort = normalizeReasoningEffort(mode);
|
|
126
|
+
return {
|
|
127
|
+
protocol: capabilities.protocol,
|
|
128
|
+
recognizedModel: true,
|
|
129
|
+
...capabilities.reasoning === "switchable" ? { thinking: "enabled" } : {},
|
|
130
|
+
...capabilities.efforts.has(effort) ? { effort } : {},
|
|
131
|
+
unsupportedRequestFields: THINKING_UNSUPPORTED_FIELDS
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
const getDeepSeekReasoningRequestParams = (config) => {
|
|
135
|
+
if (!config.recognizedModel) {
|
|
136
|
+
return {};
|
|
137
|
+
}
|
|
138
|
+
if (config.protocol === "responses") {
|
|
139
|
+
if (config.thinking === "disabled") {
|
|
140
|
+
return { reasoning: { effort: "none" } };
|
|
141
|
+
}
|
|
142
|
+
return config.effort ? { reasoning: { effort: config.effort } } : {};
|
|
143
|
+
}
|
|
144
|
+
return {
|
|
145
|
+
...config.thinking ? { thinking: { type: config.thinking } } : {},
|
|
146
|
+
...config.effort ? { reasoning_effort: config.effort } : {}
|
|
147
|
+
};
|
|
148
|
+
};
|
|
149
|
+
const removeUnsupportedRequestFields = (request, fields) => {
|
|
150
|
+
for (const field of fields) {
|
|
151
|
+
delete request[field];
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
const normalizeDeepSeekChatRequest = (request, config) => {
|
|
155
|
+
if (!config.recognizedModel) {
|
|
156
|
+
return request;
|
|
157
|
+
}
|
|
158
|
+
const mutableRequest = request;
|
|
159
|
+
delete mutableRequest.thinking;
|
|
160
|
+
delete mutableRequest.reasoning_effort;
|
|
161
|
+
Object.assign(mutableRequest, getDeepSeekReasoningRequestParams(config));
|
|
162
|
+
removeUnsupportedRequestFields(mutableRequest, config.unsupportedRequestFields);
|
|
163
|
+
return request;
|
|
164
|
+
};
|
|
165
|
+
const normalizeResponsesReasoningItems = (input) => {
|
|
166
|
+
if (!Array.isArray(input)) {
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
for (const item of input) {
|
|
170
|
+
if (!isRecord(item) || item.type !== "reasoning") {
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
const hasReasoningContent = Array.isArray(item.content) && item.content.some((part) => isRecord(part) && part.type === "reasoning_text" && typeof part.text === "string");
|
|
174
|
+
if (hasReasoningContent || !Array.isArray(item.summary)) {
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
177
|
+
const text = item.summary.filter(isRecord).map((part) => part.text).filter((part) => typeof part === "string" && part.length > 0).join("");
|
|
178
|
+
if (text) {
|
|
179
|
+
item.content = [{ type: "reasoning_text", text }];
|
|
180
|
+
item.summary = [];
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
const normalizeDeepSeekResponsesRequest = (request, config) => {
|
|
185
|
+
if (!config.recognizedModel) {
|
|
186
|
+
return request;
|
|
187
|
+
}
|
|
188
|
+
const mutableRequest = request;
|
|
189
|
+
delete mutableRequest.reasoning;
|
|
190
|
+
Object.assign(mutableRequest, getDeepSeekReasoningRequestParams(config));
|
|
191
|
+
removeUnsupportedRequestFields(mutableRequest, config.unsupportedRequestFields);
|
|
192
|
+
normalizeResponsesReasoningItems(request.input);
|
|
193
|
+
return request;
|
|
194
|
+
};
|
|
195
|
+
const getReasoningItemText = (value) => {
|
|
196
|
+
if (!isRecord(value)) {
|
|
197
|
+
return "";
|
|
198
|
+
}
|
|
199
|
+
if (Array.isArray(value.content)) {
|
|
200
|
+
const content = value.content.filter(isRecord).filter((part) => part.type === "reasoning_text").map((part) => part.text).filter((text) => typeof text === "string" && text.length > 0).join("");
|
|
201
|
+
if (content) {
|
|
202
|
+
return content;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
if (Array.isArray(value.summary)) {
|
|
206
|
+
return value.summary.filter(isRecord).map((part) => part.text).filter((text) => typeof text === "string" && text.length > 0).join("");
|
|
207
|
+
}
|
|
208
|
+
return "";
|
|
209
|
+
};
|
|
210
|
+
const extractDeepSeekReasoningText = (source) => {
|
|
211
|
+
var _a, _b, _c;
|
|
212
|
+
const reasoningContent = (_a = source.additional_kwargs) == null ? void 0 : _a.reasoning_content;
|
|
213
|
+
if (typeof reasoningContent === "string" && reasoningContent.length > 0) {
|
|
214
|
+
return reasoningContent;
|
|
215
|
+
}
|
|
216
|
+
if (Array.isArray(source.content)) {
|
|
217
|
+
const contentBlockText = source.content.filter(isRecord).filter((block) => block.type === "reasoning").map((block) => typeof block.reasoning === "string" ? block.reasoning : "").filter(Boolean).join("");
|
|
218
|
+
if (contentBlockText) {
|
|
219
|
+
return contentBlockText;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
const additionalReasoningText = getReasoningItemText((_b = source.additional_kwargs) == null ? void 0 : _b.reasoning);
|
|
223
|
+
if (additionalReasoningText) {
|
|
224
|
+
return additionalReasoningText;
|
|
225
|
+
}
|
|
226
|
+
const output = (_c = source.response_metadata) == null ? void 0 : _c.output;
|
|
227
|
+
if (Array.isArray(output)) {
|
|
228
|
+
const reasoningItem = output.find((item) => isRecord(item) && item.type === "reasoning");
|
|
229
|
+
return getReasoningItemText(reasoningItem);
|
|
230
|
+
}
|
|
231
|
+
return "";
|
|
232
|
+
};
|
|
233
|
+
const getDeepSeekResponsesReasoningItem = (source) => {
|
|
234
|
+
var _a, _b;
|
|
235
|
+
const output = (_a = source.response_metadata) == null ? void 0 : _a.output;
|
|
236
|
+
if (Array.isArray(output)) {
|
|
237
|
+
const reasoningItem = output.find((item) => isRecord(item) && item.type === "reasoning");
|
|
238
|
+
if (isRecord(reasoningItem)) {
|
|
239
|
+
return reasoningItem;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
return isRecord((_b = source.additional_kwargs) == null ? void 0 : _b.reasoning) ? source.additional_kwargs.reasoning : null;
|
|
243
|
+
};
|
|
244
|
+
async function* adaptDeepSeekResponsesStream(stream) {
|
|
245
|
+
const emittedWebSearchItems = /* @__PURE__ */ new Set();
|
|
246
|
+
for await (const event of stream) {
|
|
247
|
+
if (event.type === "response.reasoning_text.delta") {
|
|
248
|
+
yield {
|
|
249
|
+
type: "response.reasoning_summary_text.delta",
|
|
250
|
+
delta: event.delta,
|
|
251
|
+
item_id: event.item_id,
|
|
252
|
+
output_index: event.output_index,
|
|
253
|
+
sequence_number: event.sequence_number,
|
|
254
|
+
summary_index: event.content_index
|
|
255
|
+
};
|
|
256
|
+
continue;
|
|
257
|
+
}
|
|
258
|
+
if (event.type === "response.output_item.added" && event.item.type === "web_search_call" && isRecord(event.item.action) && typeof event.item.action.query === "string") {
|
|
259
|
+
emittedWebSearchItems.add(event.item.id);
|
|
260
|
+
yield {
|
|
261
|
+
type: "response.output_item.done",
|
|
262
|
+
item: event.item,
|
|
263
|
+
output_index: event.output_index,
|
|
264
|
+
sequence_number: event.sequence_number
|
|
265
|
+
};
|
|
266
|
+
continue;
|
|
267
|
+
}
|
|
268
|
+
if (event.type === "response.output_item.done" && event.item.type === "web_search_call" && emittedWebSearchItems.has(event.item.id)) {
|
|
269
|
+
continue;
|
|
270
|
+
}
|
|
271
|
+
yield event;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
275
|
+
0 && (module.exports = {
|
|
276
|
+
DEEPSEEK_MODEL_CAPABILITIES,
|
|
277
|
+
adaptDeepSeekResponsesStream,
|
|
278
|
+
extractDeepSeekReasoningText,
|
|
279
|
+
getDeepSeekModelCapabilities,
|
|
280
|
+
getDeepSeekReasoningRequestParams,
|
|
281
|
+
getDeepSeekResponsesReasoningItem,
|
|
282
|
+
normalizeDeepSeekChatRequest,
|
|
283
|
+
normalizeDeepSeekResponsesRequest,
|
|
284
|
+
resolveDeepSeekReasoningConfig
|
|
285
|
+
});
|