Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
refactor(web): remove legacy embedded API docs (#40929)
yyhb064a13aa44b
diff --git a/oxlint-suppressions.json b/oxlint-suppressions.jsonindex 56bc53e2680..447d378d032 100644--- a/oxlint-suppressions.json+++ b/oxlint-suppressions.json@@ -2495,21 +2495,6 @@"count": 1}},- "web/app/components/develop/code.tsx": {- "typescript/no-explicit-any": {- "count": 6- }- },- "web/app/components/develop/doc.tsx": {- "eslint-react/static-components": {- "count": 2- }- },- "web/app/components/develop/md.tsx": {- "typescript/no-explicit-any": {- "count": 2- }- },"web/app/components/explore/item-operation/__tests__/index.spec.tsx": {"jsx-a11y/click-events-have-key-events": {"count": 1diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex ca7a9a45680..7a4d68c116b 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -78,15 +78,6 @@ catalogs:'@lexical/utils':specifier: 0.47.0version: 0.47.0- '@mdx-js/loader':- specifier: 3.1.1- version: 3.1.1- '@mdx-js/react':- specifier: 3.1.1- version: 3.1.1- '@mdx-js/rollup':- specifier: 3.1.1- version: 3.1.1'@mediabunny/mp3-encoder':specifier: 1.53.1version: 1.53.1@@ -96,9 +87,6 @@ catalogs:'@napi-rs/keyring':specifier: 1.3.0version: 1.3.0- '@next/mdx':- specifier: 16.3.0- version: 16.3.0'@orpc/client':specifier: 1.15.0version: 1.15.0@@ -165,9 +153,6 @@ catalogs:'@tailwindcss/postcss':specifier: 4.3.3version: 4.3.3- '@tailwindcss/typography':- specifier: 0.5.20- version: 0.5.20'@tailwindcss/vite':specifier: 4.3.3version: 4.3.3@@ -1234,9 +1219,6 @@ importers:'@t3-oss/env-nextjs':specifier: 'catalog:'version: 0.13.11(@typescript/[email protected])([email protected](@typescript/[email protected]))([email protected])- '@tailwindcss/typography':- specifier: 'catalog:'- version: 0.5.20([email protected])'@tanstack/query-core':specifier: 'catalog:'version: 5.101.4@@ -1499,18 +1481,6 @@ importers:'@langgenius/dify-ui':specifier: workspace:*version: link:../packages/dify-ui- '@mdx-js/loader':- specifier: 'catalog:'- version: 3.1.1([email protected])- '@mdx-js/react':- specifier: 'catalog:'- version: 3.1.1(@types/[email protected])([email protected])- '@mdx-js/rollup':- specifier: 'catalog:'- version: 3.1.1([email protected])- '@next/mdx':- specifier: 'catalog:'- version: 16.3.0(@mdx-js/[email protected]([email protected]))(@mdx-js/[email protected](@types/[email protected])([email protected]))'@rgrove/parse-xml':specifier: 'catalog:'version: 4.2.3@@ -1630,7 +1600,7 @@ importers:version: 3.19.3vinext:specifier: 'catalog:'- version: 1.0.0-beta.5(@mdx-js/[email protected]([email protected]))(@vitejs/[email protected](@voidzero-dev/[email protected](@types/[email protected])(@typescript/[email protected])([email protected])([email protected])([email protected])([email protected])))(@vitejs/[email protected](@voidzero-dev/[email protected](@types/[email protected])(@typescript/[email protected])([email protected])([email protected])([email protected])([email protected]))([email protected]([email protected]))([email protected]([email protected]([email protected]))([email protected]))([email protected]))(@voidzero-dev/[email protected](@types/[email protected])(@typescript/[email protected])([email protected])([email protected])([email protected])([email protected]))([email protected](@babel/[email protected]([email protected]))(@playwright/[email protected])(@types/[email protected])([email protected]([email protected]))([email protected]))([email protected]([email protected]))([email protected]([email protected]([email protected]))([email protected]))([email protected])+ version: 1.0.0-beta.5(@vitejs/[email protected](@voidzero-dev/[email protected](@types/[email protected])(@typescript/[email protected])([email protected])([email protected])([email protected])([email protected])))(@vitejs/[email protected](@voidzero-dev/[email protected](@types/[email protected])(@typescript/[email protected])([email protected])([email protected])([email protected])([email protected]))([email protected]([email protected]))([email protected]([email protected]([email protected]))([email protected]))([email protected]))(@voidzero-dev/[email protected](@types/[email protected])(@typescript/[email protected])([email protected])([email protected])([email protected])([email protected]))([email protected](@babel/[email protected]([email protected]))(@playwright/[email protected])(@types/[email protected])([email protected]([email protected]))([email protected]))([email protected]([email protected]))([email protected]([email protected]([email protected]))([email protected]))([email protected])vite:specifier: npm:@voidzero-dev/[email protected]version: '@voidzero-dev/[email protected](@types/[email protected])(@typescript/[email protected])([email protected])([email protected])([email protected])([email protected])'@@ -2751,28 +2721,12 @@ packages:resolution: {integrity: sha512-9I2Zn6+NJLfaGoz9jN3lpwDgAYvfGeNYdbAIjJOqzs4Tpc+VU3Jqq4IofSUBKajiDS8k9fZIg18/z13mpk1bsA==}engines: {node: '>=8'}- '@mdx-js/[email protected]':- resolution: {integrity: sha512-0TTacJyZ9mDmY+VefuthVshaNIyCGZHJG2fMnGaDttCt8HmjUF7SizlHJpaCDoGnN635nK1wpzfpx/Xx5S4WnQ==}- peerDependencies:- webpack: '>=5'- peerDependenciesMeta:- webpack:- optional: true-- '@mdx-js/[email protected]':- resolution: {integrity: sha512-f6ZO2ifpwAQIpzGWaBQT2TXxPv6z3RBzQKpVftEWN78Vl/YweF1uwussDx8ECAXVtr3Rs89fKyG9YlzUs9DyGQ==}-'@mdx-js/[email protected]':resolution: {integrity: sha512-f++rKLQgUVYDAtECQ6fn/is15GkEH9+nZPM3MS0RcxVqoTfawHvDlSCH7JbMhAM6uJ32v3eXLvLmLvjGu7PTQw==}peerDependencies:'@types/react': '>=16'react: '>=16'- '@mdx-js/[email protected]':- resolution: {integrity: sha512-v8satFmBB+DqDzYohnm1u2JOvxx6Hl3pUvqzJvfs2Zk/ngZ1aRUhsWpXvwPkNeGN9c2NCm/38H29ZqXQUjf8dw==}- peerDependencies:- rollup: 4.62.4-'@mediabunny/[email protected]':resolution: {integrity: sha512-a4GceG4qSMWHzW0QOSBkoCPPHrnSkoKwLmJ/2g67lBuEM9cC1R25ibe8ha14WhzswAEFtzbzwoitUOFkhahWfg==}peerDependencies:@@ -2887,17 +2841,6 @@ packages:'@next/[email protected]':resolution: {integrity: sha512-o9r1S0BNiNreHP9Vs+Qnqd9kviDkJh8xIACY7UFZSmiGbbQRzPBBosvHzAU4TULHOIuOj/18RSsyz2qrREmIFw==}- '@next/[email protected]':- resolution: {integrity: sha512-Vpfuf928ACvx4AOdDXWx/cj13Ak6xlvMn3QCkjvfQMmLnQWCesQTeY01CPDbIyZvjY+NOwP7bvbvJ2ghkj/3GA==}- peerDependencies:- '@mdx-js/loader': '>=0.15.0'- '@mdx-js/react': '>=0.15.0'- peerDependenciesMeta:- '@mdx-js/loader':- optional: true- '@mdx-js/react':- optional: true-'@next/[email protected]':resolution: {integrity: sha512-55hpqq18bEVAlxedlTt3tFqZmKg2nUXT1kn1G/BGEy0R13h3LwtwHPVzzjG6P4LLeOHE32PFDQUVaJEWvBEZBw==}engines: {node: '>= 10'}@@ -4091,11 +4034,6 @@ packages:'@tailwindcss/[email protected]':resolution: {integrity: sha512-JTSZZGQi1AyKirbLN3azmjVzef92tcX7h+iSqPdaeStyFpGpDlKvvpxeOE8njhbUanbRwr3z8DyzhICWnMtQeg==}- '@tailwindcss/[email protected]':- resolution: {integrity: sha512-hwbzQuNUfcPvbegQFatVPl/MY/tcM9KLl963hQ5laJKPh81TEZ1+dNG9PirGvcaDBkp+BCshExAyKVPW91dozw==}- peerDependencies:- tailwindcss: '>=3.0.0 || >=4.0.0 || insiders'-'@tailwindcss/[email protected]':resolution: {integrity: sha512-yYU8cogLeSh/ms2jh8Fj7jaba/EWa7Ja6GoUqYZaraEuCI5YS6ms6ObZgjjedm+jm6XZjdNRWBpPP6Z86oOxcw==}peerDependencies:@@ -5237,9 +5175,6 @@ packages:resolution: {integrity: sha512-0bC0/4bTSrnwdhU3IsZDwEdojvuPrSg59OYZfKsLRtJZ0u8VBx9DebfqqG8bRdCC0I7vjgxmPi41P0lpkhJHtA==}- resolution: {integrity: sha512-LElXdjswlqjWrPpJFg1Fx4wpkOCxj1TDHlSV4PlaRxHGWko024xICaa97ZkMfs6DRKlCguiAI+rbXv5GWwXIkg==}-resolution: {integrity: sha512-htCUDlxyyCLMgaM3xXg0C0LW2xqfuQ6p05pCEIsXuyQ+a1koYKTuBMzRNwmybfLgvJDMd0r1LTn4+E0Ti6C2AA==}@@ -5480,9 +5415,6 @@ packages:resolution: {integrity: sha512-NQ8CWmMbFiZ+ck34Zxw4/awjIYcyutNPiVCdPe2hVXMD/NG2D+aWAz8NI2krOIagGnbny8j/YCyoiDsNRbnAbQ==}- resolution: {integrity: sha512-loKTxY1zCOuG4j9f6EPnuyyYkf58RnhhWTvRoZEokgB+WbdXehfjFviyOVYkqzEWz1Q5kRiZdBYS5SwxbQYwzw==}-resolution: {integrity: sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==}engines: {node: '>=7.0.0'}@@ -5596,10 +5528,6 @@ packages:resolution: {integrity: sha512-YUifsXXuknHlUsmlgyY0PKzgPOr7/FjCePfHNt0jxm83wHZi44VDMQ7/fGNkjY3/jV1MC+1CmZbaHzugyeRtpg==}- resolution: {integrity: sha512-/Tb/JcjK111nNScGob5MNtsntNM1aCNUDipB/TkwZFhyDrrE47SOx/18wF2bbjgc3ZzCSKW1T5nt5EbFoAz/Vg==}- engines: {node: '>=4'}-resolution: {integrity: sha512-6tun4LoZnj7VN6YeegOVb67KBX/7JJsqvj+pv3ZA7F878/eN33AbGa5b/S/wXxS/tcp8nc40xRUrsPlxIyNUPg==}@@ -5993,12 +5921,6 @@ packages:resolution: {integrity: sha512-OyZKhUVvEep9ITEiwHn8GKnMRQIVqoSIX7WnRbkWgJkllCujilqP2rD0u979tkl8wqyc8ICwlc1UBVv/Sl1G6w==}- resolution: {integrity: sha512-4CyanoAudUSBAn5K13H4JhsMH6L9ZP7XbLVe/dKybkxMO7eDyLsT8UHl9TRNrU2Gr9nz+FovfSIjuXWJ81uVwQ==}-- resolution: {integrity: sha512-8Ja+rNJ0Lt56Pcf3TAmpBZjmx8ZcK5Ts4cAzIOjsjevg9oSXJnl6SUQ2EevU8tv3h6ZLWmoKL5H4fgWvdvfETw==}-resolution: {integrity: sha512-HKVLS8dvII+xoKW9kmqxbRKrnWEXfJJr/FZhhJmiqIB0e053QNYFqOBouTMO/k5sID4MvCiUCvv8b9M4h32wIA==}engines: {node: '>=18'}@@ -6252,24 +6174,9 @@ packages:resolution: {integrity: sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==}engines: {node: '>=4.0'}- resolution: {integrity: sha512-cKUwm/HUcTDsYh/9FgnuFqpfquUbwIqwKM26BVCGDPVgvaCl/nDCCjUfiLlx6lsEZ3Z4RFxNbOQ60pkaEwFxGw==}-- resolution: {integrity: sha512-8U5eiL6BTrPxp/CHbs2yMgP8ftMhR5ww1eIKoWRMlqvltHF8fZn5LRDvTKuxD3DUn+shRbLGqXemcP51oFCsGQ==}-resolution: {integrity: sha512-hFtqIDZTIUZ9BXLb8y4pYGyk6+wekIivNVTcmvk8NoOh+VeRn5y6cEHzbURrWbfp1fIqdVipilzj+lfaadNZmg==}- resolution: {integrity: sha512-2CAASclonf+JFWBNJPndcOpA8EMJwa0Q8LUFJEKqXLW6+qBvbFZuF5gItbQOs/umBUkjviCSDCbBwU2cXbmrhQ==}-- resolution: {integrity: sha512-WDF+xj5rRWmD5tj6bIqRi6CkLIXbbNQUcxQHzGysQzvHmdYG2G7p/Tf0J0gpxGgkeMZNTIjT/AoSvC9Xehcgdg==}-- resolution: {integrity: sha512-m5KgiH85xAhhW8Wta0vShLcUvOsh3LLPI2YVwcbio1l7E09NTLL1EyMZFM1OyWowoH0skScNbhOPl4kcBgzTww==}-resolution: {integrity: sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==}@@ -6531,9 +6438,6 @@ packages:resolution: {integrity: sha512-3yTWghByc50aGS7JlGhk61SPenfE/p1oaFeNwkOOyrscaOkMGrcW9+Cy/QAIOBpZxP1yqDIzFMR0+Np0i0+usg==}- resolution: {integrity: sha512-48+B/rJWAp0jamNbAAf9M7Uf//UVqAoMmgXhBdxTDJLGKY+LRnZ99qcG+Qjl5HfMpYNzS5v4EAwVEF34LeAj7w==}-resolution: {integrity: sha512-OguPdidb+fbHQSU4Q4ZiLKnzWo8Wwsf5bZfbvu7//a9oTYoqD/fWpe96NuHkoS9h0ccGOTe0C4NGXdtS0iObOw==}@@ -7144,10 +7048,6 @@ packages:resolution: {integrity: sha512-hXdUTZYIVOt1Ex//jAQi+wTZZpUpwBj/0QsOzqegb3rGMMeJiSEu5xLHnYfBrRV4RH2+OCSOO95Is/7x1WJ4bw==}engines: {node: '>=10'}- resolution: {integrity: sha512-o5vL7aDWatOTX8LzaS1WMoaoxIiLRQJuIKKe2wAw6IeULDHaqbiqiggmx+pKvZDb1Sj+pE46Sn1T7lCqfFtg1Q==}- engines: {node: '>=16'}-resolution: {integrity: sha512-wiYz4+JrLyb/DqW2hkFJxP7Vd7JuTDm77fvbM8VfEQdmSMqcImWeeRbHwZjBjIFki/VaMK2BhFi7oUUZeM5bqw==}@@ -7199,9 +7099,6 @@ packages:resolution: {integrity: sha512-lj/z8v0r6ZtsN/cGNNtemmmfoLAFZnjMbNyLzBafjzikOM+glrjNHPlf6lQDOTccj9n5b0PPihEBbhneMyGs1Q==}- resolution: {integrity: sha512-JfbYLAW7XnYTTbUsmpu0kdBUVe+yKVJZBItEjwyYJiDJuZ9w4eeaqks4HQO+R7objWgS2ymV60GYpI14Ug554w==}-resolution: {integrity: sha512-EcmOpxsZ96CvlP03NghtH1EsLtr0n9Tm4lPUJUBccV9RwUOneqSycg19n5HGzCf+10LozMRSObtVr3ee1WoHtg==}@@ -7272,30 +7169,12 @@ packages:resolution: {integrity: sha512-lvEqd+fHjATVs+2v/8kg9i5Q0AP2k85H0WUOwpIVvUML8BapsMvh1XAogmQjOCsLpoKRCVQqEkQBB3NhVBcsOg==}- resolution: {integrity: sha512-dD/ADLJ1AeMvSAKBwO22zG22N4ybhe7kFIZ3LsDI0GlsNr2A3KYxb0LdC1u5rj4Nw+CHKY0RVdnHX8vj8ejm4Q==}-- resolution: {integrity: sha512-e5+q1DjMh62LZAJOnDraSSbDMvGJ8x3cbjygy2qFEi7HCeUT4BDKCvMozPozcD6WmOt6sVvYDNBKhFSz3kjOVQ==}-- resolution: {integrity: sha512-EpAiszsB3blw4Rpba7xTOUptcFeBFi+6PY8VnJ2hhimH+vCQDirWgsMpz7w1XcZE7LVrSAUGb9VJpG9ghlYvYQ==}-- resolution: {integrity: sha512-DJFl4ZqkErRpq/dAPyeWp15tGrcrrJho1hKK5uBS70BCtfrIFg81sqcTVu3Ta+KD1Tk5vAtBNElWxtAa+m8K9A==}-- resolution: {integrity: sha512-A873fJfhnJ2siZyUrJ31l34Uqwy4xIFmvPY1oj+Ean5PHcPBYzEsvqvWGaWcfEIr11O5Dlw3p2y0tZWpKHDejQ==}-resolution: {integrity: sha512-Xe6rDdJlkmbFRExpTOmRj9N3MaWmbAgdpSrBQvCFqhezUn4AHqJHbaEnfbVYYiexVSs//tqOdY/DxhjdCiJnIA==}resolution: {integrity: sha512-VFMekyQExqIW7xIChcXn4ok29YE3rnuyveW3wZQWWqF4Nv9Wk5rgJ99KzPvHjkmPXF93FXIbBp6YdW3t71/7Vg==}- resolution: {integrity: sha512-kQnEtA3vzucU2BkrIa8/VaSAsP+EJ3CKOvhMuJgOEGg9KDC6OAY6nSnNDVRiVNRqj7Y4SlSzcStaH/5jge8JdQ==}-resolution: {integrity: sha512-zRkxjtBxxLd2Sc0d+fbnEunsTj46SWXgXciZmHq0kDYGnck/ZSGj9/wULTV95uoeYiK5hRXP2mJ98Uo4cq/LQg==}@@ -7326,9 +7205,6 @@ packages:resolution: {integrity: sha512-c3cVx2y4KqUnwopcO9b/SCdo2O67LwJJ/UyqGfbigahfegL9myoEFoDYZgkT7f36T0bLrM9hZTAaAyH+PCAXjw==}- resolution: {integrity: sha512-jmsiEIiZ1n7X1Rr5k8wVExBQCg5jy4UXVADItHmNk1zkwEVhBuIUKRu3fqv+hs4nxLISi2DQGlqIOGiFxgbfHg==}-resolution: {integrity: sha512-2cNEiYDhCWKI+Gs9T0Tiysk136SnR13hhO8yW6BGNyhOC4qYFnwF1nKfD3HFAIXA5c45RrIG1ub11GiXeYd1xA==}@@ -7912,10 +7788,6 @@ packages:resolution: {integrity: sha512-rEwq/ZHlJIKw++XtLAO8PPuOQA/zaPJOZJ37BVuN97nLpMJeuDVLVGRwbFoBgLudgdTMP2hdRJP++H+8QOA3vg==}engines: {node: '>= 10.12'}- resolution: {integrity: sha512-bIoJLOmjCO1S9XdY/DcnR5hJxvrDir1PbGChrzXG3vw0/FOliy/fA3dmdhQ441kah4gKv+TwckGzex6wNS5cnQ==}- engines: {node: '>=4'}-resolution: {integrity: sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ==}@@ -8122,20 +7994,6 @@ packages:resolution: {integrity: sha512-dEWRjcINDu/F4l2dYx57ugBtD7HV9KXESyxhzw/MqWLeglJrsjJKqACPyUPg+6AF8mIgm+Zi0dZ3ACoIg+QtpA==}engines: {node: '>= 4'}- resolution: {integrity: sha512-8GtdyqaBcDfva+GUKDr3nev3VpKAhup1+RvkMvUxURHpW7QyIvk9F5wz7Vzo06CEMSilw6uArgRqhpiUcWp8ew==}-- resolution: {integrity: sha512-huSIy7VU2Z5OLv6oFLosQGGDqPqdO1iq6bWNAdhzMxSJP7RAso4fCZ1cKu8j9YHCZf3TPrq4dw3okhrylgcd7w==}- peerDependencies:- acorn: ^6.0.0 || ^7.0.0 || ^8.0.0-- resolution: {integrity: sha512-OYLsIGBB5Y5wjnSnQW6t3Xg7q3fQ7FWbw/vcXtORTnyaSFscOtABg+7Pnz6YZ6c27fG1/aN8CjfwoUEUIdwqWQ==}-- resolution: {integrity: sha512-cjwII1MdIIVloKvC9ErQ+OgAtwHBmcZ0Bg4ciz78FtbT8In39aAYbaA7zvxQ61xVMSPE8WxhLwLbhif4Js2C+g==}-resolution: {integrity: sha512-6tDA8g98We0zd0GvVeMT9arEOnTw9qM03L9cJXaCjrip1OO764RDBLBfrB4cwzNGDj5OA5ioymC9GkizgWJDUg==}engines: {node: '>=8'}@@ -8176,9 +8034,6 @@ packages:resolution: {integrity: sha512-/aE8hCfKlQeA8LmyeyQvQF3eBiLRGNlfBJEvWH7ivp9sBqs7TNqBL5X3v157rM4IFETqDnIOO+z5M/biZbo9Ww==}- resolution: {integrity: sha512-lqA4rGUf1JmacCNWWZx0Wv1dHqMwxzsDWYMTowuplHF3xH0N/MmrZ/G3BDZnzAkRmxDadujCjaKM2hqYdCBOGw==}-resolution: {integrity: sha512-CsnhKNsyI8Tub6L4sm5ZFsme4puGfc6pYylvXo1AeqaGbjOYyzNv3qZPwvs0oMJ39eryyeOdmxwUIo94IpEhqg==}@@ -8194,9 +8049,6 @@ packages:resolution: {integrity: sha512-MMqgnP74Igy+S3WwnhQ7kqGlEerTETXMvJhrUzDikVZ2/uogJCb+WHUg97hK9/jcfc0dkD73s3LN8zU49cTEtA==}- resolution: {integrity: sha512-Pjj2IYlUY3+D8x00UJsIOg5BEvfMyeI+2uLPn9VO9Wg4MEtN/VTIq2NEJQfde9PnX15KgtHyl9S0BcTnWrIuWg==}-resolution: {integrity: sha512-FCxlKLNGknS5ba/1lmpYijMUzX2esxW5xQqjWxw2eHFfS2MSdaHVINFmhjo+qN1WhZhNimq0dZATN9pH0IDrpA==}@@ -8380,10 +8232,6 @@ packages:resolution: {integrity: sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==}engines: {node: '>=0.10.0'}- resolution: {integrity: sha512-i5uvt8C3ikiWeNZSVZNWcfZPItFQOsYTUAOkcUPGd8DqDy1uOUikjt5dG+uRlwyvR108Fb9DOd4GvXfT0N2/uQ==}- engines: {node: '>= 12'}-resolution: {integrity: sha512-PEGlAwrG8yXGXRjW32fGbg66JAlOAwbObuqVoJpv/mRgoWDQfgH1wDPvtzWyUSNAXBGSk8h755YDbbcEy3SH2Q==}@@ -8787,9 +8635,6 @@ packages:resolution: {integrity: sha512-LsiILbtBETkDz8I9p1dQ0uyRUWuaQzd/cuEeS1hoRSyW5E5XGmTzlwY1OrNzzakGowI9Dr/I8HVaw4hTtnxy8g==}- resolution: {integrity: sha512-KaFVRjoqLyF6YXCbVLNad/eS4+OfPQQn2yOd7zF/h5T/CSL2v8NpN6a5TPvtbXthAGw5nG+PuTtq+DdIZr+cRQ==}-resolution: {integrity: sha512-fucsC7HjXvkB5R3kTCO7kUjRdrS0BJt3M/FPxmHMBOm8JQi2BsHAHFsy27E0EolP8rp0NzXsJ+jNPyDWvOJZPA==}@@ -10539,58 +10384,12 @@ snapshots:'@lukeed/[email protected]': {}- '@mdx-js/[email protected]([email protected])':- dependencies:- '@mdx-js/mdx': 3.1.1([email protected])- source-map: 0.7.6- transitivePeerDependencies:- - supports-color-- '@mdx-js/[email protected]([email protected])':- dependencies:- '@types/estree': 1.0.9- '@types/estree-jsx': 1.0.5- '@types/hast': 3.0.4- '@types/mdx': 2.0.14- acorn: 8.17.0- collapse-white-space: 2.1.0- devlop: 1.1.0- estree-util-is-identifier-name: 3.0.0- estree-util-scope: 1.0.0- estree-walker: 3.0.3- hast-util-to-jsx-runtime: 2.3.6([email protected])- markdown-extensions: 2.0.0- recma-build-jsx: 1.0.0- recma-jsx: 1.0.1([email protected])- recma-stringify: 1.0.0- rehype-recma: 1.0.0([email protected])- remark-mdx: 3.1.1([email protected])- remark-parse: 11.0.0([email protected])- remark-rehype: 11.1.2- source-map: 0.7.6- unified: 11.0.5- unist-util-position-from-estree: 2.0.0- unist-util-stringify-position: 4.0.0- unist-util-visit: 5.1.0- vfile: 6.0.3- transitivePeerDependencies:- - supports-color-dependencies:'@types/mdx': 2.0.14'@types/react': 19.2.18react: 19.2.8- '@mdx-js/[email protected]([email protected])':- dependencies:- '@mdx-js/mdx': 3.1.1([email protected])- '@rollup/pluginutils': 5.4.0- source-map: 0.7.6- vfile: 6.0.3- transitivePeerDependencies:- - supports-color-'@mediabunny/[email protected]([email protected])':dependencies:mediabunny: 1.53.1@@ -10680,13 +10479,6 @@ snapshots:'@next/[email protected]': {}- '@next/[email protected](@mdx-js/[email protected]([email protected]))(@mdx-js/[email protected](@types/[email protected])([email protected]))':- dependencies:- source-map: 0.7.6- optionalDependencies:- '@mdx-js/loader': 3.1.1([email protected])- '@mdx-js/react': 3.1.1(@types/[email protected])([email protected])-'@next/[email protected]':optional: true@@ -11561,11 +11353,6 @@ snapshots:postcss: 8.5.26tailwindcss: 4.3.3- '@tailwindcss/[email protected]([email protected])':- dependencies:- postcss-selector-parser: 6.1.4- tailwindcss: 4.3.3-'@tailwindcss/[email protected](@voidzero-dev/[email protected](@types/[email protected])(@typescript/[email protected])([email protected])([email protected])([email protected])([email protected]))':dependencies:'@tailwindcss/node': 4.3.3@@ -12782,8 +12569,6 @@ snapshots:estree-walker: 3.0.3js-tokens: 10.0.0- [email protected]: {}-@@ -13014,8 +12799,6 @@ snapshots:transitivePeerDependencies:- supports-color- [email protected]: {}-dependencies:color-name: 1.1.4@@ -13117,8 +12900,6 @@ snapshots:- [email protected]: {}-@@ -13523,20 +13304,6 @@ snapshots:- dependencies:- '@types/estree-jsx': 1.0.5- devlop: 1.1.0- estree-util-visit: 2.0.0- unist-util-position-from-estree: 2.0.0-- dependencies:- '@types/estree-jsx': 1.0.5- acorn: 8.17.0- esast-util-from-estree: 2.0.0- vfile-message: 4.0.3-optionalDependencies:'@esbuild/aix-ppc64': 0.28.2@@ -13976,35 +13743,8 @@ snapshots:- dependencies:- '@types/estree': 1.0.9-- dependencies:- '@types/estree-jsx': 1.0.5- devlop: 1.1.0- estree-util-is-identifier-name: 3.0.0- estree-walker: 3.0.3-- dependencies:- '@types/estree': 1.0.9- devlop: 1.1.0-- dependencies:- '@types/estree-jsx': 1.0.5- astring: 1.9.0- source-map: 0.7.6-- dependencies:- '@types/estree-jsx': 1.0.5- '@types/unist': 3.0.3-@@ -14273,27 +14013,6 @@ snapshots:'@ungap/structured-clone': 1.3.2unist-util-position: 5.0.0- dependencies:- '@types/estree': 1.0.9- '@types/estree-jsx': 1.0.5- '@types/hast': 3.0.4- comma-separated-tokens: 2.0.3- devlop: 1.1.0- estree-util-attach-comments: 3.0.0- estree-util-is-identifier-name: 3.0.0- hast-util-whitespace: 3.0.0- mdast-util-mdx-expression: 2.0.1([email protected])- mdast-util-mdx-jsx: 3.2.0([email protected])- mdast-util-mdxjs-esm: 2.0.1([email protected])- property-information: 7.2.0- space-separated-tokens: 2.0.2- style-to-js: 1.1.21- unist-util-position: 5.0.0- zwitch: 2.0.4- transitivePeerDependencies:- - supports-color-dependencies:'@types/hast': 3.0.4@@ -14828,8 +14547,6 @@ snapshots:dependencies:semver: 7.8.5- [email protected]: {}-@@ -14982,16 +14699,6 @@ snapshots:transitivePeerDependencies:- supports-color- dependencies:- mdast-util-from-markdown: 2.0.3([email protected])- mdast-util-mdx-expression: 2.0.1([email protected])- mdast-util-mdx-jsx: 3.2.0([email protected])- mdast-util-mdxjs-esm: 2.0.1([email protected])- mdast-util-to-markdown: 2.1.2- transitivePeerDependencies:- - supports-color-dependencies:'@types/estree-jsx': 1.0.5@@ -15182,57 +14889,6 @@ snapshots:micromark-util-symbol: 2.0.1micromark-util-types: 2.0.2- dependencies:- '@types/estree': 1.0.9- devlop: 1.1.0- micromark-factory-mdx-expression: 2.0.3- micromark-factory-space: 2.0.1- micromark-util-character: 2.1.1- micromark-util-events-to-acorn: 2.0.3- micromark-util-symbol: 2.0.1- micromark-util-types: 2.0.2-- dependencies:- '@types/estree': 1.0.9- devlop: 1.1.0- estree-util-is-identifier-name: 3.0.0- micromark-factory-mdx-expression: 2.0.3- micromark-factory-space: 2.0.1- micromark-util-character: 2.1.1- micromark-util-events-to-acorn: 2.0.3- micromark-util-symbol: 2.0.1- micromark-util-types: 2.0.2- vfile-message: 4.0.3-- dependencies:- micromark-util-types: 2.0.2-- dependencies:- '@types/estree': 1.0.9- devlop: 1.1.0- micromark-core-commonmark: 2.0.3- micromark-util-character: 2.1.1- micromark-util-events-to-acorn: 2.0.3- micromark-util-symbol: 2.0.1- micromark-util-types: 2.0.2- unist-util-position-from-estree: 2.0.0- vfile-message: 4.0.3-- dependencies:- acorn: 8.17.0- acorn-jsx: 5.3.2([email protected])- micromark-extension-mdx-expression: 3.0.1- micromark-extension-mdx-jsx: 3.0.2- micromark-extension-mdx-md: 2.0.0- micromark-extension-mdxjs-esm: 3.0.0- micromark-util-combine-extensions: 2.0.1- micromark-util-types: 2.0.2-dependencies:micromark-util-character: 2.1.1@@ -15246,18 +14902,6 @@ snapshots:micromark-util-symbol: 2.0.1micromark-util-types: 2.0.2- dependencies:- '@types/estree': 1.0.9- devlop: 1.1.0- micromark-factory-space: 2.0.1- micromark-util-character: 2.1.1- micromark-util-events-to-acorn: 2.0.3- micromark-util-symbol: 2.0.1- micromark-util-types: 2.0.2- unist-util-position-from-estree: 2.0.0- vfile-message: 4.0.3-dependencies:micromark-util-character: 2.1.1@@ -15310,16 +14954,6 @@ snapshots:- dependencies:- '@types/estree': 1.0.9- '@types/unist': 3.0.3- devlop: 1.1.0- estree-util-visit: 2.0.0- micromark-util-symbol: 2.0.1- micromark-util-types: 2.0.2- vfile-message: 4.0.3-@@ -15915,11 +15549,6 @@ snapshots:transitivePeerDependencies:- supports-color- dependencies:- cssesc: 3.0.0- util-deprecate: 1.0.2-@@ -16168,35 +15797,6 @@ snapshots:tiny-invariant: 1.3.3tslib: 2.8.1- dependencies:- '@types/estree': 1.0.9- estree-util-build-jsx: 3.0.1- vfile: 6.0.3-- dependencies:- acorn: 8.17.0- acorn-jsx: 5.3.2([email protected])- estree-util-to-js: 2.0.0- recma-parse: 1.0.0- recma-stringify: 1.0.0- unified: 11.0.5-- dependencies:- '@types/estree': 1.0.9- esast-util-from-js: 2.0.1- unified: 11.0.5- vfile: 6.0.3-- dependencies:- '@types/estree': 1.0.9- estree-util-to-js: 2.0.0- unified: 11.0.5- vfile: 6.0.3-dependencies:indent-string: 4.0.0@@ -16251,14 +15851,6 @@ snapshots:hast-util-raw: 9.1.0vfile: 6.0.3- dependencies:- '@types/estree': 1.0.9- '@types/hast': 3.0.4- hast-util-to-estree: 3.1.3([email protected])- transitivePeerDependencies:- - supports-color-dependencies:'@types/hast': 3.0.4@@ -16299,13 +15891,6 @@ snapshots:transitivePeerDependencies:- supports-color- dependencies:- mdast-util-mdx: 3.0.0([email protected])- micromark-extension-mdxjs: 3.0.0- transitivePeerDependencies:- - supports-color-dependencies:'@types/mdast': 4.0.4@@ -16527,8 +16112,6 @@ snapshots:- [email protected]: {}-@@ -16923,10 +16506,6 @@ snapshots:dependencies:'@types/unist': 3.0.3- dependencies:- '@types/unist': 3.0.3-dependencies:'@types/unist': 3.0.3@@ -17007,7 +16586,8 @@ snapshots:- [email protected]: {}+ optional: true@@ -17037,7 +16617,7 @@ snapshots:'@types/unist': 3.0.3vfile-message: 4.0.3- [email protected](@mdx-js/[email protected]([email protected]))(@vitejs/[email protected](@voidzero-dev/[email protected](@types/[email protected])(@typescript/[email protected])([email protected])([email protected])([email protected])([email protected])))(@vitejs/[email protected](@voidzero-dev/[email protected](@types/[email protected])(@typescript/[email protected])([email protected])([email protected])([email protected])([email protected]))([email protected]([email protected]))([email protected]([email protected]([email protected]))([email protected]))([email protected]))(@voidzero-dev/[email protected](@types/[email protected])(@typescript/[email protected])([email protected])([email protected])([email protected])([email protected]))([email protected](@babel/[email protected]([email protected]))(@playwright/[email protected])(@types/[email protected])([email protected]([email protected]))([email protected]))([email protected]([email protected]))([email protected]([email protected]([email protected]))([email protected]))([email protected]):+ [email protected](@vitejs/[email protected](@voidzero-dev/[email protected](@types/[email protected])(@typescript/[email protected])([email protected])([email protected])([email protected])([email protected])))(@vitejs/[email protected](@voidzero-dev/[email protected](@types/[email protected])(@typescript/[email protected])([email protected])([email protected])([email protected])([email protected]))([email protected]([email protected]))([email protected]([email protected]([email protected]))([email protected]))([email protected]))(@voidzero-dev/[email protected](@types/[email protected])(@typescript/[email protected])([email protected])([email protected])([email protected])([email protected]))([email protected](@babel/[email protected]([email protected]))(@playwright/[email protected])(@types/[email protected])([email protected]([email protected]))([email protected]))([email protected]([email protected]))([email protected]([email protected]([email protected]))([email protected]))([email protected]):dependencies:'@unpic/react': 1.0.2([email protected](@babel/[email protected]([email protected]))(@playwright/[email protected])(@types/[email protected])([email protected]([email protected]))([email protected]))([email protected]([email protected]))([email protected])'@vercel/og': 0.8.6@@ -17052,7 +16632,6 @@ snapshots:vite-plugin-commonjs: 0.10.4web-vitals: 4.2.4optionalDependencies:- '@mdx-js/rollup': 3.1.1([email protected])'@vitejs/plugin-rsc': 0.5.34(@voidzero-dev/[email protected](@types/[email protected])(@typescript/[email protected])([email protected])([email protected])([email protected])([email protected]))([email protected]([email protected]))([email protected]([email protected]([email protected]))([email protected]))([email protected])transitivePeerDependencies:@@ -17508,13 +17087,9 @@ time:'@lexical/[email protected]': '2026-07-09T21:14:16.798Z''@lexical/[email protected]': '2026-07-09T21:14:30.676Z''@lexical/[email protected]': '2026-07-09T21:14:36.426Z'- '@mdx-js/[email protected]': '2025-08-29T18:03:05.606Z'- '@mdx-js/[email protected]': '2025-08-29T18:02:56.462Z'- '@mdx-js/[email protected]': '2025-08-29T18:03:10.680Z''@mediabunny/[email protected]': '2026-08-12T14:19:33.332Z''@monaco-editor/[email protected]': '2025-02-13T16:13:41.390Z''@napi-rs/[email protected]': '2026-04-30T09:56:44.246Z'- '@next/[email protected]': '2026-08-03T20:29:50.185Z''@orpc/[email protected]': '2026-08-08T13:52:09.241Z''@orpc/[email protected]': '2026-08-08T13:52:15.717Z''@orpc/[email protected]': '2026-08-08T13:53:09.442Z'@@ -17537,7 +17112,6 @@ time:'@t3-oss/[email protected]': '2026-03-22T19:16:09.121Z''@t3-oss/[email protected]': '2026-03-22T19:16:09.026Z''@tailwindcss/[email protected]': '2026-07-16T12:03:56.054Z'- '@tailwindcss/[email protected]': '2026-06-08T10:34:41.124Z''@tailwindcss/[email protected]': '2026-07-16T12:04:06.316Z''@tanstack/[email protected]': '2026-07-21T13:03:59.996Z''@tanstack/[email protected]': '2026-08-11T12:45:38.255Z'diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yamlindex f3a54ff26eb..cfe7146c336 100644--- a/pnpm-workspace.yaml+++ b/pnpm-workspace.yaml@@ -87,13 +87,9 @@ catalog:'@lexical/selection': 0.47.0'@lexical/text': 0.47.0'@lexical/utils': 0.47.0- '@mdx-js/loader': 3.1.1- '@mdx-js/react': 3.1.1- '@mdx-js/rollup': 3.1.1'@mediabunny/mp3-encoder': 1.53.1'@monaco-editor/react': 4.7.0'@napi-rs/keyring': 1.3.0- '@next/mdx': 16.3.0'@orpc/client': 1.15.0'@orpc/contract': 1.15.0'@orpc/openapi-client': 1.15.0@@ -116,7 +112,6 @@ catalog:'@t3-oss/env-core': 0.13.11'@t3-oss/env-nextjs': 0.13.11'@tailwindcss/postcss': 4.3.3- '@tailwindcss/typography': 0.5.20'@tailwindcss/vite': 4.3.3'@tanstack/eslint-plugin-query': 5.101.4'@tanstack/form-core': 1.33.5diff --git a/web/app/(commonLayout)/@detailSidebar/app/[appId]/develop/page.tsx b/web/app/(commonLayout)/@detailSidebar/app/[appId]/develop/page.tsxdeleted file mode 100644index 7a5e2af4267..00000000000--- a/web/app/(commonLayout)/@detailSidebar/app/[appId]/develop/page.tsx+++ /dev/null@@ -1,5 +0,0 @@-import { AppDetailSidebarSlot } from '../sidebar-page'--export default function AppDevelopDetailSidebarSlot() {- return <AppDetailSidebarSlot />-}diff --git a/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/__tests__/layout-main.spec.tsx b/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/__tests__/layout-main.spec.tsxindex 35b2dd427cd..1fc6114bca5 100644--- a/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/__tests__/layout-main.spec.tsx+++ b/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/__tests__/layout-main.spec.tsx@@ -87,7 +87,6 @@ describe('AppDetailLayout', () => {['/app/app-1/workflow', 'common.appMenus.promptEng', AppModeEnum.WORKFLOW],['/app/app-1/configuration', 'common.appMenus.promptEng', AppModeEnum.CHAT],['/app/app-1/access-point', 'common.appMenus.accessPoint', AppModeEnum.WORKFLOW],- ['/app/app-1/develop', 'common.appMenus.apiAccess', AppModeEnum.WORKFLOW],['/app/app-1/deploy', 'common.appMenus.deploy', AppModeEnum.WORKFLOW],['/app/app-1/logs', 'common.appMenus.logs', AppModeEnum.WORKFLOW],['/app/app-1/annotations', 'common.appMenus.annotations', AppModeEnum.CHAT],diff --git a/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/develop/page.tsx b/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/develop/page.tsxdeleted file mode 100644index a48279ac2cf..00000000000--- a/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/develop/page.tsx+++ /dev/null@@ -1,17 +0,0 @@-import type { Locale } from '@/i18n-config'-import * as React from 'react'-import DevelopMain from '@/app/components/develop'--export type IDevelopProps = {- params: Promise<{ locale: Locale; appId: string }>-}--const Develop = async (props: IDevelopProps) => {- const params = await props.params-- const { appId } = params-- return <DevelopMain appId={appId} />-}--export default Developdiff --git a/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/layout-main.tsx b/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/layout-main.tsxindex 35dbab80ddd..24a254fe57e 100644--- a/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/layout-main.tsx+++ b/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/layout-main.tsx@@ -37,7 +37,6 @@ const appDetailPageTitle = (pathname: string, t: ReturnType<typeof useTranslatioreturn t(($) => $['appMenus.promptEng'], { ns: 'common' })if (pathname.endsWith('/access-point'))return t(($) => $['appMenus.accessPoint'], { ns: 'common' })- if (pathname.endsWith('/develop')) return t(($) => $['appMenus.apiAccess'], { ns: 'common' })if (pathname.endsWith('/deploy')) return t(($) => $['appMenus.deploy'], { ns: 'common' })if (pathname.endsWith('/logs')) return t(($) => $['appMenus.logs'], { ns: 'common' })if (pathname.endsWith('/annotations'))diff --git a/web/app/components/develop/secret-key/__tests__/secret-key-modal.spec.tsx b/web/app/components/api-key/__tests__/api-key-modal.spec.tsxsimilarity index 86%rename from web/app/components/develop/secret-key/__tests__/secret-key-modal.spec.tsxrename to web/app/components/api-key/__tests__/api-key-modal.spec.tsxindex 6ed06786344..de2f6adf729 100644--- a/web/app/components/develop/secret-key/__tests__/secret-key-modal.spec.tsx+++ b/web/app/components/api-key/__tests__/api-key-modal.spec.tsx@@ -1,14 +1,14 @@import type { ApiKeyList as AppApiKeyList } from '@dify/contracts/api/console/apps/types.gen'import type { ApiKeyList as DatasetApiKeyList } from '@dify/contracts/api/console/datasets/types.gen'import type { EnvironmentApiKey } from '@dify/contracts/enterprise-app-deploy/types.gen'-import type { SecretKeyScope } from '../secret-key-modal'-import { QueryClientProvider } from '@tanstack/react-query'+import type { ComponentProps } from 'react'+import { QueryClientProvider, skipToken } from '@tanstack/react-query'import { act, screen, waitFor } from '@testing-library/react'import userEvent from '@testing-library/user-event'import { afterEach } from 'vite-plus/test'import { render } from '@/test/console/render'import { createTestQueryClient } from '@/test/query-client'-import SecretKeyModal from '../secret-key-modal'+import { ApiKeyModal } from '../api-key-modal'const apiMocks = vi.hoisted(() => ({appKeys: [] as AppApiKeyList['data'],@@ -33,10 +33,13 @@ vi.mock('@/service/client', () => ({get: {queryOptions: ({ input }: { input: unknown }) => ({queryKey: ['apps', 'api-keys', input],- queryFn: () => {- apiMocks.listApp(input)- return Promise.resolve({ data: apiMocks.appKeys })- },+ queryFn:+ input === skipToken+ ? skipToken+ : () => {+ apiMocks.listApp(input)+ return Promise.resolve({ data: apiMocks.appKeys })+ },}),},post: {@@ -83,13 +86,15 @@ vi.mock('@/service/client', () => ({appDeploy: {accessService: {listEnvironmentApiKeys: {- queryOptions: ({ input, enabled }: { input: unknown; enabled?: boolean }) => ({+ queryOptions: ({ input }: { input: unknown }) => ({queryKey: ['environment', 'api-keys', input],- queryFn: () => {- apiMocks.listEnvironment(input)- return Promise.resolve({ data: apiMocks.environmentKeys })- },- enabled,+ queryFn:+ input === skipToken+ ? skipToken+ : () => {+ apiMocks.listEnvironment(input)+ return Promise.resolve({ data: apiMocks.environmentKeys })+ },}),},createEnvironmentApiKey: {@@ -136,23 +141,26 @@ const environmentScope = {environmentId: 'staging',} as const-async function renderModal(scope: SecretKeyScope, overrides: { canManage?: boolean } = {}) {+async function renderModal(+ scope: ComponentProps<typeof ApiKeyModal>['scope'],+ overrides: { canManage?: boolean } = {},+) {const queryClient = createTestQueryClient()- const onClose = vi.fn()+ const onOpenChange = vi.fn()const result = render(<QueryClientProvider client={queryClient}>- <SecretKeyModal- isShow+ <ApiKeyModal+ opencanManage={overrides.canManage ?? true}scope={scope}- onClose={onClose}+ onOpenChange={onOpenChange}/></QueryClientProvider>,)await act(async () => {vi.runAllTimers()})- return { ...result, onClose }+ return { ...result, onOpenChange }}async function confirmKeyDeletion(accessibleName: string) {@@ -165,7 +173,7 @@ async function confirmKeyDeletion(accessibleName: string) {await user.click(await screen.findByText('common.operation.confirm'))}-describe('SecretKeyModal', () => {+describe('ApiKeyModal', () => {beforeEach(() => {vi.clearAllMocks()vi.useFakeTimers({ shouldAdvanceTime: true })@@ -236,7 +244,9 @@ describe('SecretKeyModal', () => {params: { resource_id: 'app-123' },})})- expect(await screen.findByText('new-app-token-123')).toBeInTheDocument()+ expect(+ await screen.findByRole('textbox', { name: 'appApi.apiKeyModal.secretKey' }),+ ).toHaveValue('new-app-token-123')})it('creates a dataset API key through the generated mutation', async () => {@@ -248,7 +258,9 @@ describe('SecretKeyModal', () => {await waitFor(() => {expect(apiMocks.createDataset).toHaveBeenCalledWith()})- expect(await screen.findByText('new-dataset-token-123')).toBeInTheDocument()+ expect(+ await screen.findByRole('textbox', { name: 'appApi.apiKeyModal.secretKey' }),+ ).toHaveValue('new-dataset-token-123')})it('deletes an app API key through the generated mutation input', async () => {@@ -342,8 +354,8 @@ describe('SecretKeyModal', () => {})})expect(- await screen.findByText('env-created-secret-key-abcdefghijklmnopqrst'),- ).toBeInTheDocument()+ await screen.findByRole('textbox', { name: 'appApi.apiKeyModal.secretKey' }),+ ).toHaveValue('env-created-secret-key-abcdefghijklmnopqrst')})it('deletes an environment-scoped API key', async () => {@@ -382,11 +394,11 @@ describe('SecretKeyModal', () => {})it('exposes an accessible close button', async () => {- const { onClose } = await renderModal(datasetScope)+ const { onOpenChange } = await renderModal(datasetScope)const user = userEvent.setup({ advanceTimers: vi.advanceTimersByTime })await user.click(screen.getByRole('button', { name: 'common.operation.close' }))- expect(onClose).toHaveBeenCalled()+ expect(onOpenChange).toHaveBeenCalledWith(false)})})diff --git a/web/app/components/api-key/api-key-modal.tsx b/web/app/components/api-key/api-key-modal.tsxnew file mode 100644index 00000000000..5ee47bddb95--- /dev/null+++ b/web/app/components/api-key/api-key-modal.tsx@@ -0,0 +1,231 @@+'use client'++import type { ApiKeyItem } from '@dify/contracts/api/console/apps/types.gen'+import {+ AlertDialog,+ AlertDialogActions,+ AlertDialogCancelButton,+ AlertDialogConfirmButton,+ AlertDialogContent,+ AlertDialogDescription,+ AlertDialogTitle,+} from '@langgenius/dify-ui/alert-dialog'+import { Button } from '@langgenius/dify-ui/button'+import {+ Dialog,+ DialogCloseButton,+ DialogContent,+ DialogDescription,+ DialogTitle,+} from '@langgenius/dify-ui/dialog'+import { skipToken, useMutation, useQuery } from '@tanstack/react-query'+import { useAtomValue } from 'jotai'+import { useState } from 'react'+import { useTranslation } from 'react-i18next'+import Loading from '@/app/components/base/loading'+import { currentWorkspaceAtom } from '@/context/workspace-state'+import { consoleQuery } from '@/service/client'+import { ApiKeyTable } from './api-key-table'+import { CreatedApiKeyDialog } from './created-api-key-dialog'++type CreatedApiKey = Pick<ApiKeyItem, 'token'>+type ApiKeyScope =+ | { type: 'app'; appId: string }+ | { type: 'dataset' }+ | { type: 'environment'; appId: string; environmentId: string }++type ApiKeyModalProps = {+ open: boolean+ canManage: boolean+ scope: ApiKeyScope+ onOpenChange: (open: boolean) => void+}++export function ApiKeyModal({ open, canManage, scope, onOpenChange }: ApiKeyModalProps) {+ const { t } = useTranslation()+ const currentWorkspace = useAtomValue(currentWorkspaceAtom)+ const [deleteKeyId, setDeleteKeyId] = useState<string>()+ const [createdApiKey, setCreatedApiKey] = useState<CreatedApiKey>()++ const appApiKeysQuery = useQuery(+ consoleQuery.apps.byResourceId.apiKeys.get.queryOptions({+ input: open && scope.type === 'app' ? { params: { resource_id: scope.appId } } : skipToken,+ }),+ )+ const datasetApiKeysQuery = useQuery({+ ...consoleQuery.datasets.apiKeys.get.queryOptions(),+ enabled: open && scope.type === 'dataset',+ })+ const environmentApiKeysQuery = useQuery(+ consoleQuery.enterprise.appDeploy.accessService.listEnvironmentApiKeys.queryOptions({+ input:+ open && scope.type === 'environment'+ ? { params: { app_id: scope.appId, environment_id: scope.environmentId } }+ : skipToken,+ }),+ )++ const createAppApiKey = useMutation(consoleQuery.apps.byResourceId.apiKeys.post.mutationOptions())+ const deleteAppApiKey = useMutation(+ consoleQuery.apps.byResourceId.apiKeys.byApiKeyId.delete.mutationOptions(),+ )+ const createDatasetApiKey = useMutation(consoleQuery.datasets.apiKeys.post.mutationOptions())+ const deleteDatasetApiKey = useMutation(+ consoleQuery.datasets.apiKeys.byApiKeyId.delete.mutationOptions(),+ )+ const createEnvironmentApiKey = useMutation(+ consoleQuery.enterprise.appDeploy.accessService.createEnvironmentApiKey.mutationOptions(),+ )+ const deleteEnvironmentApiKey = useMutation(+ consoleQuery.enterprise.appDeploy.accessService.deleteEnvironmentApiKey.mutationOptions(),+ )++ const apiKeys =+ scope.type === 'app'+ ? appApiKeysQuery.data?.data+ : scope.type === 'dataset'+ ? datasetApiKeysQuery.data?.data+ : environmentApiKeysQuery.data?.data+ const isLoading =+ scope.type === 'app'+ ? appApiKeysQuery.isLoading+ : scope.type === 'dataset'+ ? datasetApiKeysQuery.isLoading+ : environmentApiKeysQuery.isLoading+ const isCreating =+ scope.type === 'app'+ ? createAppApiKey.isPending+ : scope.type === 'dataset'+ ? createDatasetApiKey.isPending+ : createEnvironmentApiKey.isPending+ const isDeleting =+ scope.type === 'app'+ ? deleteAppApiKey.isPending+ : scope.type === 'dataset'+ ? deleteDatasetApiKey.isPending+ : deleteEnvironmentApiKey.isPending+ const createDisabled = !currentWorkspace.id || !canManage++ const handleOpenChange = (nextOpen: boolean) => {+ if (!nextOpen) {+ setDeleteKeyId(undefined)+ setCreatedApiKey(undefined)+ }+ onOpenChange(nextOpen)+ }++ const handleCreate = () => {+ if (createDisabled || isCreating) return++ switch (scope.type) {+ case 'app':+ createAppApiKey.mutate(+ { params: { resource_id: scope.appId } },+ { onSuccess: setCreatedApiKey },+ )+ break+ case 'dataset':+ createDatasetApiKey.mutate(undefined, { onSuccess: setCreatedApiKey })+ break+ case 'environment':+ createEnvironmentApiKey.mutate(+ { params: { app_id: scope.appId, environment_id: scope.environmentId } },+ { onSuccess: setCreatedApiKey },+ )+ break+ }+ }++ const handleDelete = () => {+ if (!deleteKeyId || isDeleting) return++ const onSuccess = () => setDeleteKeyId(undefined)+ switch (scope.type) {+ case 'app':+ deleteAppApiKey.mutate(+ { params: { resource_id: scope.appId, api_key_id: deleteKeyId } },+ { onSuccess },+ )+ break+ case 'dataset':+ deleteDatasetApiKey.mutate({ params: { api_key_id: deleteKeyId } }, { onSuccess })+ break+ case 'environment':+ deleteEnvironmentApiKey.mutate(+ {+ params: {+ app_id: scope.appId,+ environment_id: scope.environmentId,+ api_key_id: deleteKeyId,+ },+ },+ { onSuccess },+ )+ break+ }+ }++ return (+ <>+ <Dialog open={open} onOpenChange={handleOpenChange}>+ <DialogContent className="flex w-200 flex-col overflow-hidden p-0">+ <div className="flex shrink-0 flex-col gap-1 px-6 pt-6 pr-14 pb-4">+ <DialogTitle className="title-2xl-semi-bold text-text-primary">+ {t(($) => $['apiKeyModal.apiSecretKey'], { ns: 'appApi' })}+ </DialogTitle>+ <DialogDescription className="system-sm-regular text-text-tertiary">+ {t(($) => $['apiKeyModal.apiSecretKeyTips'], { ns: 'appApi' })}+ </DialogDescription>+ </div>+ <DialogCloseButton aria-label={t(($) => $['operation.close'], { ns: 'common' })} />+ {isLoading && (+ <div className="flex min-h-24 items-center border-y border-divider-subtle px-6">+ <Loading />+ </div>+ )}+ {!!apiKeys?.length && (+ <ApiKeyTable apiKeys={apiKeys} canManage={canManage} onDeleteRequest={setDeleteKeyId} />+ )}+ <div className="flex shrink-0 px-6 py-4">+ <Button disabled={createDisabled} loading={isCreating} onClick={handleCreate}>+ <span aria-hidden className="i-ri-add-line size-4 shrink-0" />+ {t(($) => $['apiKeyModal.createNewSecretKey'], { ns: 'appApi' })}+ </Button>+ </div>+ </DialogContent>+ </Dialog>+ <AlertDialog+ open={deleteKeyId !== undefined}+ onOpenChange={(open) => {+ if (!open && !isDeleting) setDeleteKeyId(undefined)+ }}+ >+ <AlertDialogContent>+ <div className="flex flex-col gap-2 px-6 pt-6 pb-4">+ <AlertDialogTitle className="w-full truncate title-2xl-semi-bold text-text-primary">+ {t(($) => $['actionMsg.deleteConfirmTitle'], { ns: 'appApi' })}+ </AlertDialogTitle>+ <AlertDialogDescription className="w-full system-md-regular wrap-break-word whitespace-pre-wrap text-text-tertiary">+ {t(($) => $['actionMsg.deleteConfirmTips'], { ns: 'appApi' })}+ </AlertDialogDescription>+ </div>+ <AlertDialogActions>+ <AlertDialogCancelButton disabled={isDeleting}>+ {t(($) => $['operation.cancel'], { ns: 'common' })}+ </AlertDialogCancelButton>+ <AlertDialogConfirmButton loading={isDeleting} onClick={handleDelete}>+ {t(($) => $['operation.confirm'], { ns: 'common' })}+ </AlertDialogConfirmButton>+ </AlertDialogActions>+ </AlertDialogContent>+ </AlertDialog>+ <CreatedApiKeyDialog+ open={open && createdApiKey !== undefined}+ onOpenChange={(nextOpen) => {+ if (!nextOpen) setCreatedApiKey(undefined)+ }}+ value={createdApiKey?.token ?? ''}+ />+ </>+ )+}diff --git a/web/app/components/api-key/api-key-table.tsx b/web/app/components/api-key/api-key-table.tsxnew file mode 100644index 00000000000..69788c080ea--- /dev/null+++ b/web/app/components/api-key/api-key-table.tsx@@ -0,0 +1,75 @@+import type { ApiKeyItem } from '@dify/contracts/api/console/apps/types.gen'+import type { EnvironmentApiKey } from '@dify/contracts/enterprise-app-deploy/types.gen'+import { IconButton } from '@langgenius/dify-ui/icon-button'+import { useTranslation } from 'react-i18next'+import { CopyFeedback } from '@/app/components/base/copy-feedback'+import useTimestamp from '@/hooks/use-timestamp'++type ApiKeyTableProps = {+ apiKeys: Array<ApiKeyItem | EnvironmentApiKey>+ canManage: boolean+ onDeleteRequest: (apiKeyId: string) => void+}++export function ApiKeyTable({ apiKeys, canManage, onDeleteRequest }: ApiKeyTableProps) {+ const { t } = useTranslation()+ const { formatTime } = useTimestamp()+ const maskToken = (token: string) => `${token.slice(0, 3)}...${token.slice(-20)}`++ return (+ <div className="min-h-0 overflow-auto border-y border-divider-subtle">+ <table className="w-full table-fixed text-left system-sm-regular text-text-secondary">+ <thead className="sticky top-0 bg-components-panel-bg system-xs-semibold-uppercase text-text-tertiary">+ <tr className="border-b border-divider-regular">+ <th className="w-64 px-6 py-2" scope="col">+ {t(($) => $['apiKeyModal.secretKey'], { ns: 'appApi' })}+ </th>+ <th className="w-48 px-3 py-2" scope="col">+ {t(($) => $['apiKeyModal.created'], { ns: 'appApi' })}+ </th>+ <th className="w-48 px-3 py-2" scope="col">+ {t(($) => $['apiKeyModal.lastUsed'], { ns: 'appApi' })}+ </th>+ <th className="w-24 px-6 py-2" scope="col">+ <span className="sr-only">{t(($) => $['operation.settings'], { ns: 'common' })}</span>+ </th>+ </tr>+ </thead>+ <tbody>+ {apiKeys.map((apiKey) => (+ <tr className="border-b border-divider-regular last:border-b-0" key={apiKey.id}>+ <td className="truncate px-6 py-2 font-mono">{maskToken(apiKey.token)}</td>+ <td className="truncate px-3 py-2">+ {formatTime(+ Number(apiKey.created_at),+ t(($) => $.dateTimeFormat, { ns: 'appLog' }) as string,+ )}+ </td>+ <td className="truncate px-3 py-2">+ {apiKey.last_used_at+ ? formatTime(+ Number(apiKey.last_used_at),+ t(($) => $.dateTimeFormat, { ns: 'appLog' }) as string,+ )+ : t(($) => $.never, { ns: 'appApi' })}+ </td>+ <td className="px-6 py-1">+ <div className="flex justify-end gap-1">+ <CopyFeedback content={apiKey.token} />+ {canManage && (+ <IconButton+ aria-label={`${t(($) => $['operation.delete'], { ns: 'common' })} ${maskToken(apiKey.token)}`}+ onClick={() => onDeleteRequest(apiKey.id)}+ >+ <span aria-hidden className="i-ri-delete-bin-line size-4" />+ </IconButton>+ )}+ </div>+ </td>+ </tr>+ ))}+ </tbody>+ </table>+ </div>+ )+}diff --git a/web/app/components/api-key/created-api-key-dialog.tsx b/web/app/components/api-key/created-api-key-dialog.tsxnew file mode 100644index 00000000000..47aaaabbe5b--- /dev/null+++ b/web/app/components/api-key/created-api-key-dialog.tsx@@ -0,0 +1,59 @@+'use client'++import { Button } from '@langgenius/dify-ui/button'+import {+ Dialog,+ DialogCloseButton,+ DialogContent,+ DialogDescription,+ DialogTitle,+} from '@langgenius/dify-ui/dialog'+import { InputGroup, InputGroupAddon, InputGroupInput } from '@langgenius/dify-ui/input-group'+import { useTranslation } from 'react-i18next'+import { CopyFeedback } from '@/app/components/base/copy-feedback'++type CreatedApiKeyDialogProps = {+ open: boolean+ onOpenChange: (open: boolean) => void+ value: string+}++export function CreatedApiKeyDialog({ open, onOpenChange, value }: CreatedApiKeyDialogProps) {+ const { t } = useTranslation()++ return (+ <Dialog open={open} onOpenChange={onOpenChange}>+ <DialogContent className="overflow-hidden p-0">+ <div className="flex flex-col gap-1 px-6 pt-6 pr-14 pb-4">+ <DialogTitle className="title-2xl-semi-bold text-text-primary">+ {t(($) => $['apiKeyModal.apiSecretKey'], { ns: 'appApi' })}+ </DialogTitle>+ <DialogDescription className="system-sm-regular text-text-tertiary">+ {t(($) => $['apiKeyModal.generateTips'], { ns: 'appApi' })}+ </DialogDescription>+ </div>+ <DialogCloseButton aria-label={t(($) => $['operation.close'], { ns: 'common' })} />+ <div className="px-6 pb-4">+ <InputGroup>+ <InputGroupInput+ aria-label={t(($) => $['apiKeyModal.secretKey'], { ns: 'appApi' })}+ autoComplete="off"+ className="font-mono"+ readOnly+ spellCheck={false}+ value={value}+ />+ <InputGroupAddon align="inline-end" className="pe-1">+ <CopyFeedback content={value} />+ </InputGroupAddon>+ </InputGroup>+ </div>+ <div className="flex justify-end px-6 pb-6">+ <Button variant="primary" onClick={() => onOpenChange(false)}>+ {t(($) => $['actionMsg.ok'], { ns: 'appApi' })}+ </Button>+ </div>+ </DialogContent>+ </Dialog>+ )+}diff --git a/web/app/components/app/access-point/__tests__/api-secret-key-button.spec.tsx b/web/app/components/app/access-point/__tests__/api-secret-key-button.spec.tsxindex c312b107a33..ced723970f3 100644--- a/web/app/components/app/access-point/__tests__/api-secret-key-button.spec.tsx+++ b/web/app/components/app/access-point/__tests__/api-secret-key-button.spec.tsx@@ -1,6 +1,5 @@import type { ApiKeyList } from '@dify/contracts/api/console/apps/types.gen'import type { ReactElement } from 'react'-import type { SecretKeyScope } from '@/app/components/develop/secret-key/secret-key-modal'import { screen } from '@testing-library/react'import userEvent from '@testing-library/user-event'import { consoleQuery } from '@/service/client'@@ -25,17 +24,20 @@ const render = (ui: ReactElement) => {return renderWithConsoleQuery(ui, { queryClient })}-vi.mock('@/app/components/develop/secret-key/secret-key-modal', () => ({- default: ({+vi.mock('@/app/components/api-key/api-key-modal', () => ({+ ApiKeyModal: ({canManage,- isShow,+ open,scope,}: {canManage: boolean- isShow: boolean- scope: SecretKeyScope+ open: boolean+ scope:+ | { type: 'app'; appId: string }+ | { type: 'dataset' }+ | { type: 'environment'; appId: string; environmentId: string }}) =>- isShow ? (+ open ? (<div role="dialog" aria-label="API key management">{scope.type === 'dataset' ? '' : scope.appId}:{scope.type === 'environment' ? scope.environmentId : ''}:{String(canManage)}diff --git a/web/app/components/app/access-point/shared/access-point-url.tsx b/web/app/components/app/access-point/shared/access-point-url.tsxindex 06bd7dbdcce..7b267dcf915 100644--- a/web/app/components/app/access-point/shared/access-point-url.tsx+++ b/web/app/components/app/access-point/shared/access-point-url.tsx@@ -3,7 +3,7 @@import { Button, buttonVariants } from '@langgenius/dify-ui/button'import { IconButton } from '@langgenius/dify-ui/icon-button'import { useTranslation } from 'react-i18next'-import CopyFeedback from '@/app/components/base/copy-feedback'+import { CopyFeedback } from '@/app/components/base/copy-feedback'import ShareQRCode from '@/app/components/base/qrcode'import { AccessPointEndpoint } from './access-point-card'@@ -81,7 +81,7 @@ export function AccessPointUrl({<span aria-hidden className="i-ri-file-copy-line size-4 text-text-disabled" /></div>) : (- <CopyFeedback content={value} className="size-6!" />+ <CopyFeedback content={value} className="size-6" />)}{showQrCode &&(copyDisabled ? (diff --git a/web/app/components/app/access-point/shared/api-secret-key-button.tsx b/web/app/components/app/access-point/shared/api-secret-key-button.tsxindex 99bdf4fc94d..c640e5ca51d 100644--- a/web/app/components/app/access-point/shared/api-secret-key-button.tsx+++ b/web/app/components/app/access-point/shared/api-secret-key-button.tsx@@ -5,7 +5,7 @@ import { cn } from '@langgenius/dify-ui/cn'import { skipToken, useQuery } from '@tanstack/react-query'import { useState } from 'react'import { useTranslation } from 'react-i18next'-import SecretKeyModal from '@/app/components/develop/secret-key/secret-key-modal'+import { ApiKeyModal } from '@/app/components/api-key/api-key-modal'import { consoleQuery } from '@/service/client'type ApiSecretKeyButtonProps = {@@ -44,7 +44,7 @@ export function ApiSecretKeyButton({<Buttonvariant="secondary"size="medium"- className="gap-1.5 px-3"+ className="px-3"disabled={buttonDisabled}onClick={() => setModalOpen(true)}>@@ -60,13 +60,13 @@ export function ApiSecretKeyButton({</span></Button>- <SecretKeyModal+ <ApiKeyModalcanManage={canManage}- isShow={modalOpen}+ open={modalOpen}scope={environmentId ? { type: 'environment', appId, environmentId } : { type: 'app', appId }}- onClose={() => setModalOpen(false)}+ onOpenChange={setModalOpen}/></>)diff --git a/web/app/components/base/audio-btn/__tests__/audio.player.manager.spec.ts b/web/app/components/base/audio-btn/__tests__/audio.player.manager.spec.tsindex 60023038339..5441aece298 100644--- a/web/app/components/base/audio-btn/__tests__/audio.player.manager.spec.ts+++ b/web/app/components/base/audio-btn/__tests__/audio.player.manager.spec.ts@@ -36,7 +36,7 @@ const MockAudioPlayer = vi.hoisted(() => {})vi.mock('@/app/components/base/audio-btn/audio', () => ({- default: MockAudioPlayer,+ AudioPlayer: MockAudioPlayer,}))describe('AudioPlayerManager', () => {diff --git a/web/app/components/base/audio-btn/__tests__/audio.spec.ts b/web/app/components/base/audio-btn/__tests__/audio.spec.tsindex 263ab832bd9..1f40d4555ba 100644--- a/web/app/components/base/audio-btn/__tests__/audio.spec.ts+++ b/web/app/components/base/audio-btn/__tests__/audio.spec.ts@@ -1,7 +1,7 @@import { Buffer } from 'node:buffer'import { waitFor } from '@testing-library/react'import { AppSourceType } from '@/service/share'-import AudioPlayer from '../audio'+import { AudioPlayer } from '../audio'const mockTextToAudioStream = vi.hoisted(() => vi.fn())diff --git a/web/app/components/base/audio-btn/__tests__/index.spec.tsx b/web/app/components/base/audio-btn/__tests__/index.spec.tsxindex fa0868446d7..07a1350f0d6 100644--- a/web/app/components/base/audio-btn/__tests__/index.spec.tsx+++ b/web/app/components/base/audio-btn/__tests__/index.spec.tsx@@ -2,7 +2,7 @@ import { act, render, screen, waitFor } from '@testing-library/react'import userEvent from '@testing-library/user-event'import i18next from 'i18next'import { useParams, usePathname } from '@/next/navigation'-import AudioBtn from '../index'+import { AudioBtn } from '../index'const mockPlayAudio = vi.fn()const mockPauseAudio = vi.fn()diff --git a/web/app/components/base/audio-btn/audio.player.manager.ts b/web/app/components/base/audio-btn/audio.player.manager.tsindex fefeac7ca82..c2b84ba3db4 100644--- a/web/app/components/base/audio-btn/audio.player.manager.ts+++ b/web/app/components/base/audio-btn/audio.player.manager.ts@@ -1,4 +1,4 @@-import AudioPlayer from '@/app/components/base/audio-btn/audio'+import { AudioPlayer } from '@/app/components/base/audio-btn/audio'declare global {// oxlint-disable-next-line typescript/consistent-type-definitionsdiff --git a/web/app/components/base/audio-btn/audio.ts b/web/app/components/base/audio-btn/audio.tsindex 026e43ec3e9..06168ae5440 100644--- a/web/app/components/base/audio-btn/audio.ts+++ b/web/app/components/base/audio-btn/audio.ts@@ -8,7 +8,7 @@ declare global {ManagedMediaSource?: typeof MediaSource}}-export default class AudioPlayer {+export class AudioPlayer {mediaSource: MediaSource | nullaudio: HTMLAudioElementaudioContext: AudioContextdiff --git a/web/app/components/base/audio-btn/index.stories.tsx b/web/app/components/base/audio-btn/index.stories.tsxindex 617b704716a..be6471534e0 100644--- a/web/app/components/base/audio-btn/index.stories.tsx+++ b/web/app/components/base/audio-btn/index.stories.tsx@@ -1,7 +1,7 @@import type { Meta, StoryObj } from '@storybook/nextjs-vite'import type { ComponentProps } from 'react'import { useEffect } from 'react'-import AudioBtn from '.'+import { AudioBtn } from '.'import { ensureMockAudioManager } from '../../../../.storybook/utils/audio-player-manager.mock'ensureMockAudioManager()diff --git a/web/app/components/base/audio-btn/index.tsx b/web/app/components/base/audio-btn/index.tsxindex 42df07142c3..295d1c45bfd 100644--- a/web/app/components/base/audio-btn/index.tsx+++ b/web/app/components/base/audio-btn/index.tsx@@ -1,4 +1,5 @@'use client'+import { cn } from '@langgenius/dify-ui/cn'import { Tooltip, TooltipContent, TooltipTrigger } from '@langgenius/dify-ui/tooltip'import { t } from 'i18next'import { useState } from 'react'@@ -6,7 +7,6 @@ import { AudioPlayerManager } from '@/app/components/base/audio-btn/audio.playerimport Loading from '@/app/components/base/loading'import { isInstalledAppPath } from '@/app/components/explore/installed-app/routes'import { useParams, usePathname } from '@/next/navigation'-import s from './style.module.css'type AudioBtnProps = {id?: string@@ -14,17 +14,16 @@ type AudioBtnProps = {value?: stringclassName?: stringisAudition?: boolean- noCache?: boolean}type AudioState = 'initial' | 'loading' | 'playing' | 'paused' | 'ended'-const AudioBtn = ({ id, voice, value, className, isAudition }: AudioBtnProps) => {+export function AudioBtn({ id, voice, value, className, isAudition }: AudioBtnProps) {const [audioState, setAudioState] = useState<AudioState>('initial')const params = useParams()const pathname = usePathname()- const audio_finished_call = (event: string): void => {+ const handleAudioEvent = (event: string): void => {switch (event) {case 'ended':setAudioState('ended')@@ -53,16 +52,16 @@ const AudioBtn = ({ id, voice, value, className, isAudition }: AudioBtnProps) =>if (isInstalledAppPath(pathname)) url = `/installed-apps/${params.appId}/text-to-audio`else url = `/apps/${params.appId}/text-to-audio`}- const handleToggle = async () => {+ const handleToggle = () => {if (audioState === 'playing' || audioState === 'loading') {setTimeout(() => setAudioState('paused'), 1)AudioPlayerManager.getInstance()- .getAudioPlayer(url, isPublic, id, value, voice, audio_finished_call)+ .getAudioPlayer(url, isPublic, id, value, voice, handleAudioEvent).pauseAudio()} else {setTimeout(() => setAudioState('loading'), 1)AudioPlayerManager.getInstance()- .getAudioPlayer(url, isPublic, id, value, voice, audio_finished_call)+ .getAudioPlayer(url, isPublic, id, value, voice, handleAudioEvent).playAudio()}}@@ -77,7 +76,10 @@ const AudioBtn = ({ id, voice, value, className, isAudition }: AudioBtnProps) =>return (<div- className={`inline-flex items-center justify-center ${audioState === 'loading' || audioState === 'playing' ? 'mr-1' : className}`}+ className={cn(+ 'inline-flex items-center justify-center',+ audioState === 'loading' || audioState === 'playing' ? 'mr-1' : className,+ )}><Tooltip><TooltipTrigger@@ -87,7 +89,10 @@ const AudioBtn = ({ id, voice, value, className, isAudition }: AudioBtnProps) =>type="button"aria-label={tooltipContent}disabled={audioState === 'loading'}- className={`box-border flex size-6 cursor-pointer items-center justify-center border-none bg-transparent ${isAudition ? 'p-0.5' : 'rounded-md bg-white p-0'}`}+ className={cn(+ 'box-border flex size-6 cursor-pointer items-center justify-center border-none bg-transparent',+ isAudition ? 'p-0.5' : 'rounded-md bg-white p-0',+ )}onClick={handleToggle}>{audioState === 'loading' ? (@@ -96,9 +101,15 @@ const AudioBtn = ({ id, voice, value, className, isAudition }: AudioBtnProps) =></div>) : (<div className="flex size-full items-center justify-center rounded-md hover:bg-gray-50">- <div- className={`size-4 ${audioState === 'playing' ? s.pauseIcon : s.playIcon}`}- ></div>+ <span+ aria-hidden="true"+ className={cn(+ 'size-4',+ audioState === 'playing'+ ? 'i-ri-pause-circle-fill'+ : 'i-ri-play-large-fill',+ )}+ /></div>)}</button>@@ -110,5 +121,3 @@ const AudioBtn = ({ id, voice, value, className, isAudition }: AudioBtnProps) =></div>)}--export default AudioBtndiff --git a/web/app/components/base/audio-btn/style.module.css b/web/app/components/base/audio-btn/style.module.cssdeleted file mode 100644index 7e3175aa139..00000000000--- a/web/app/components/base/audio-btn/style.module.css+++ /dev/null@@ -1,10 +0,0 @@-.playIcon {- background-image: url(~@/app/components/develop/secret-key/assets/play.svg);- background-position: center;- background-repeat: no-repeat;-}-.pauseIcon {- background-image: url(~@/app/components/develop/secret-key/assets/pause.svg);- background-position: center;- background-repeat: no-repeat;-}diff --git a/web/app/components/base/chat/chat/__tests__/index.spec.tsx b/web/app/components/base/chat/chat/__tests__/index.spec.tsxindex 72185a62cdd..ef5657aba8b 100644--- a/web/app/components/base/chat/chat/__tests__/index.spec.tsx+++ b/web/app/components/base/chat/chat/__tests__/index.spec.tsx@@ -14,7 +14,7 @@ import Chat from '../index'// Question – pulls Markdown, copy-to-clipboard, react-textarea-autosize.// ChatInputArea – pulls browser audio APIs unavailable in the test DOM runtime// and the VoiceInput / FileContextProvider chains.-// PromptLogModal– pulls CopyFeedbackNew and deep modal dep chain.+// PromptLogModal– pulls CopyFeedback and deep modal dep chain.// AgentLogModal – pulls @remixicon/react (causes lint push error), useClickAway// from ahooks, and AgentLogDetail (workflow graph renderer).// es-toolkit/compat – debounce must return a fn with .cancel() or the cleanupdiff --git a/web/app/components/base/chat/chat/hooks.ts b/web/app/components/base/chat/chat/hooks.tsindex 36748b2b0e1..b360e3fbb7c 100644--- a/web/app/components/base/chat/chat/hooks.ts+++ b/web/app/components/base/chat/chat/hooks.ts@@ -1,6 +1,6 @@import type { ChatConfig, ChatItem, ChatItemInTree, Inputs } from '../types'import type { InputForm, ThoughtItem } from './type'-import type AudioPlayer from '@/app/components/base/audio-btn/audio'+import type { AudioPlayer } from '@/app/components/base/audio-btn/audio'import type { FileEntity } from '@/app/components/base/file-uploader/types'import type { Annotation } from '@/models/log'import type { IOnDataMoreInfo, IOtherOptions } from '@/service/base'diff --git a/web/app/components/base/copy-feedback/__tests__/index.spec.tsx b/web/app/components/base/copy-feedback/__tests__/index.spec.tsxindex ce2565fc766..f465ec9ebb6 100644--- a/web/app/components/base/copy-feedback/__tests__/index.spec.tsx+++ b/web/app/components/base/copy-feedback/__tests__/index.spec.tsx@@ -1,14 +1,13 @@-import { fireEvent, render, screen } from '@testing-library/react'-import CopyFeedback, { CopyFeedbackNew } from '..'+import { render, screen } from '@testing-library/react'+import userEvent from '@testing-library/user-event'+import { CopyFeedback } from '..'const mockCopy = vi.fn()-const mockReset = vi.fn()let mockCopied = falsevi.mock('foxact/use-clipboard', () => ({useClipboard: () => ({copy: mockCopy,- reset: mockReset,copied: mockCopied,}),}))@@ -19,70 +18,24 @@ describe('CopyFeedback', () => {vi.clearAllMocks()})- describe('Rendering', () => {- it('renders the action button with copy icon', () => {- render(<CopyFeedback content="test content" />)- expect(screen.getByRole('button')).toBeInTheDocument()- })+ it('copies the supplied content from the accessible action', async () => {+ const user = userEvent.setup()+ render(<CopyFeedback content="test content" />)- it('renders the copied icon when copied is true', () => {- mockCopied = true- render(<CopyFeedback content="test content" />)- expect(screen.getByRole('button')).toBeInTheDocument()- })- })-- describe('User Interactions', () => {- it('calls copy with content when clicked', () => {- render(<CopyFeedback content="test content" />)- const button = screen.getByRole('button', {- name: 'appOverview.overview.appInfo.embedded.copy',- })- fireEvent.click(button)- expect(mockCopy).toHaveBeenCalledWith('test content')- })+ await user.click(+ screen.getByRole('button', { name: 'appOverview.overview.appInfo.embedded.copy' }),+ )- it('does not reset on mouse leave (relies on hook timeout)', () => {- render(<CopyFeedback content="test content" />)- const button = screen.getByRole('button', {- name: 'appOverview.overview.appInfo.embedded.copy',- })- fireEvent.mouseLeave(button)- expect(mockReset).not.toHaveBeenCalled()- })+ expect(mockCopy).toHaveBeenCalledWith('test content')})-})-describe('CopyFeedbackNew', () => {- beforeEach(() => {- mockCopied = false- vi.clearAllMocks()- })-- describe('Rendering', () => {- it('renders the component', () => {- render(<CopyFeedbackNew content="test content" />)- expect(- screen.getByRole('button', { name: 'appOverview.overview.appInfo.embedded.copy' }),- ).toBeInTheDocument()- })- })+ it('announces the copied state through the action name', () => {+ mockCopied = true- describe('User Interactions', () => {- it('calls copy with content when clicked', () => {- render(<CopyFeedbackNew content="test content" />)- fireEvent.click(- screen.getByRole('button', { name: 'appOverview.overview.appInfo.embedded.copy' }),- )- expect(mockCopy).toHaveBeenCalledWith('test content')- })+ render(<CopyFeedback content="test content" />)- it('does not reset on mouse leave (relies on hook timeout)', () => {- render(<CopyFeedbackNew content="test content" />)- fireEvent.mouseLeave(- screen.getByRole('button', { name: 'appOverview.overview.appInfo.embedded.copy' }),- )- expect(mockReset).not.toHaveBeenCalled()- })+ expect(+ screen.getByRole('button', { name: 'appOverview.overview.appInfo.embedded.copied' }),+ ).toBeInTheDocument()})})diff --git a/web/app/components/base/copy-feedback/index.stories.tsx b/web/app/components/base/copy-feedback/index.stories.tsxindex c105a0cdb4c..dd542b1fd83 100644--- a/web/app/components/base/copy-feedback/index.stories.tsx+++ b/web/app/components/base/copy-feedback/index.stories.tsx@@ -1,6 +1,5 @@import type { Meta, StoryObj } from '@storybook/nextjs-vite'-import { useState } from 'react'-import CopyFeedback, { CopyFeedbackNew } from '.'+import { CopyFeedback } from '.'const meta = {title: 'Base/Feedback/CopyFeedback',@@ -22,19 +21,14 @@ export default metatype Story = StoryObj<typeof meta>const CopyDemo = ({ content }: { content: string }) => {- const [value] = useState(content)return (<div className="flex flex-col gap-4"><div className="flex items-center gap-2 text-sm text-text-secondary"><span>Client ID:</span><span className="rounded-sm bg-background-default-subtle px-2 py-1 font-mono text-xs text-text-primary">- {value}+ {content}</span>- <CopyFeedback content={value} />- </div>- <div className="flex items-center gap-2 text-sm text-text-secondary">- <span>Use the new ghost variant:</span>- <CopyFeedbackNew content={value} />+ <CopyFeedback content={content} /></div></div>)@@ -48,7 +42,6 @@ export const Playground: Story = {language: 'tsx',code: `<CopyFeedback content="acc-3f92fa" />-<CopyFeedbackNew content="acc-3f92fa" />`.trim(),},},diff --git a/web/app/components/base/copy-feedback/index.tsx b/web/app/components/base/copy-feedback/index.tsxindex adaad74b815..8cbda5df6a4 100644--- a/web/app/components/base/copy-feedback/index.tsx+++ b/web/app/components/base/copy-feedback/index.tsx@@ -1,20 +1,19 @@'use client'+import { cn } from '@langgenius/dify-ui/cn'import { IconButton } from '@langgenius/dify-ui/icon-button'import { Tooltip, TooltipContent, TooltipTrigger } from '@langgenius/dify-ui/tooltip'-import { RiClipboardFill, RiClipboardLine } from '@remixicon/react'import { useClipboard } from 'foxact/use-clipboard'import { useCallback } from 'react'import { useTranslation } from 'react-i18next'-import copyStyle from './style.module.css'-type Props = Readonly<{+type CopyFeedbackProps = Readonly<{content: stringclassName?: string}>const prefixEmbedded = 'overview.appInfo.embedded'-const CopyFeedback = ({ content }: Props) => {+export function CopyFeedback({ content, className }: CopyFeedbackProps) {const { t } = useTranslation()// Rely on useClipboard's own timer to flip `copied` back to false so the// "Copied" tooltip stays visible long enough to be read, matching the@@ -35,12 +34,11 @@ const CopyFeedback = ({ content }: Props) => {<Tooltip><TooltipTriggerrender={- <IconButton aria-label={safeText} onClick={handleCopy}>- {copied ? (- <RiClipboardFill className="size-4" aria-hidden="true" />- ) : (- <RiClipboardLine className="size-4" aria-hidden="true" />- )}+ <IconButton aria-label={safeText} className={className} onClick={handleCopy}>+ <span+ aria-hidden="true"+ className={cn('size-4', copied ? 'i-ri-clipboard-fill' : 'i-ri-clipboard-line')}+ /></IconButton>}/>@@ -48,40 +46,3 @@ const CopyFeedback = ({ content }: Props) => {</Tooltip>)}--export default CopyFeedback--export const CopyFeedbackNew = ({ content, className }: Pick<Props, 'className' | 'content'>) => {- const { t } = useTranslation()- const { copied, copy } = useClipboard({ timeout: 2000 })-- const tooltipText = copied- ? t(($) => $[`${prefixEmbedded}.copied`], { ns: 'appOverview' })- : t(($) => $[`${prefixEmbedded}.copy`], { ns: 'appOverview' })- /* v8 ignore next -- i18n test mock always returns a non-empty string; runtime fallback is defensive. -- @preserve */- const safeText = tooltipText || ''-- const handleCopy = useCallback(() => {- copy(content)- }, [copy, content])-- return (- <Tooltip>- <TooltipTrigger- render={- <button- type="button"- aria-label={safeText}- className={`size-8 cursor-pointer rounded-lg border-none bg-transparent p-0 hover:bg-components-button-ghost-bg-hover focus-visible:ring-1 focus-visible:ring-components-input-border-active focus-visible:outline-hidden ${className ?? ''}`}- onClick={handleCopy}- >- <div- className={`size-full ${copyStyle.copyIcon} ${copied ? copyStyle.copied : ''}`}- ></div>- </button>- }- />- <TooltipContent>{safeText}</TooltipContent>- </Tooltip>- )-}diff --git a/web/app/components/base/copy-feedback/style.module.css b/web/app/components/base/copy-feedback/style.module.cssdeleted file mode 100644index 83625d61891..00000000000--- a/web/app/components/base/copy-feedback/style.module.css+++ /dev/null@@ -1,15 +0,0 @@-.copyIcon {- background-image: url(~@/app/components/develop/secret-key/assets/copy.svg);- background-position: center;- background-repeat: no-repeat;-}--.copyIcon:hover {- background-image: url(~@/app/components/develop/secret-key/assets/copy-hover.svg);- background-position: center;- background-repeat: no-repeat;-}--.copyIcon.copied {- background-image: url(~@/app/components/develop/secret-key/assets/copied.svg);-}diff --git a/web/app/components/base/features/new-feature-panel/text-to-speech/param-config-content.tsx b/web/app/components/base/features/new-feature-panel/text-to-speech/param-config-content.tsxindex 8e3bc4c6457..0b6fb662f60 100644--- a/web/app/components/base/features/new-feature-panel/text-to-speech/param-config-content.tsx+++ b/web/app/components/base/features/new-feature-panel/text-to-speech/param-config-content.tsx@@ -14,7 +14,7 @@ import { skipToken, useQuery } from '@tanstack/react-query'import { produce } from 'immer'import { useTranslation } from 'react-i18next'import { replace } from 'string-ts'-import AudioBtn from '@/app/components/base/audio-btn'+import { AudioBtn } from '@/app/components/base/audio-btn'import { useFeatures, useFeaturesStore } from '@/app/components/base/features/hooks'import { Infotip } from '@/app/components/base/infotip'import { languages } from '@/i18n-config/language'@@ -173,12 +173,7 @@ const VoiceParamConfig = ({ onClose, onChange }: VoiceParamConfigProps) => {role="group"aria-label={t(($) => $.play, { ns: 'appApi', defaultValue: 'Play' })}>- <AudioBtn- value={languageItem?.example}- isAudition- voice={text2speech?.voice}- noCache- />+ <AudioBtn value={languageItem?.example} isAudition voice={text2speech?.voice} /></div>)}</div>diff --git a/web/app/components/base/input/index.tsx b/web/app/components/base/input/index.tsxindex 37c3358aa90..2db9fdee345 100644--- a/web/app/components/base/input/index.tsx+++ b/web/app/components/base/input/index.tsx@@ -5,7 +5,7 @@ import { cva } from 'class-variance-authority'import { noop } from 'es-toolkit/function'import * as React from 'react'import { useTranslation } from 'react-i18next'-import { CopyFeedbackNew } from '../copy-feedback'+import { CopyFeedback } from '../copy-feedback'const inputVariants = cva('', {variants: {@@ -150,10 +150,7 @@ const Input = React.forwardRef<HTMLInputElement, InputProps>()}{showCopyIcon && (<div className={cn('group absolute top-1/2 right-0 -translate-y-1/2 cursor-pointer')}>- <CopyFeedbackNew- content={String(value ?? '')}- className="size-7! hover:bg-transparent"- />+ <CopyFeedback content={String(value ?? '')} className="size-7! hover:bg-transparent" /></div>)}{unit && (diff --git a/web/app/components/base/markdown-blocks/__tests__/code-block.spec.tsx b/web/app/components/base/markdown-blocks/__tests__/code-block.spec.tsxindex b7aacb1cbe2..dc9b72f53d1 100644--- a/web/app/components/base/markdown-blocks/__tests__/code-block.spec.tsx+++ b/web/app/components/base/markdown-blocks/__tests__/code-block.spec.tsx@@ -2,7 +2,7 @@ import { act, render, screen, waitFor } from '@testing-library/react'import userEvent from '@testing-library/user-event'import * as echarts from 'echarts'import { Theme } from '@/types/app'-import CodeBlock from '../code-block'+import { CodeBlock } from '../code-block'const { mockHighlightCode } = vi.hoisted(() => ({mockHighlightCode: vi.fn(),diff --git a/web/app/components/base/markdown-blocks/code-block.stories.tsx b/web/app/components/base/markdown-blocks/code-block.stories.tsxindex 50d27bce65c..bcc763220e7 100644--- a/web/app/components/base/markdown-blocks/code-block.stories.tsx+++ b/web/app/components/base/markdown-blocks/code-block.stories.tsx@@ -1,5 +1,5 @@import type { Meta, StoryObj } from '@storybook/nextjs-vite'-import CodeBlock from './code-block'+import { CodeBlock } from './code-block'const SAMPLE_CODE = `const greet = (name: string) => {return \`Hello, \${name}\`diff --git a/web/app/components/base/markdown-blocks/code-block.tsx b/web/app/components/base/markdown-blocks/code-block.tsxindex 671d6f276fb..5339b557abf 100644--- a/web/app/components/base/markdown-blocks/code-block.tsx+++ b/web/app/components/base/markdown-blocks/code-block.tsx@@ -1,11 +1,12 @@import type { JSX } from 'react'import type { BundledLanguage, BundledTheme } from 'shiki/bundle/web'+import { IconButton } from '@langgenius/dify-ui/icon-button'+import { Toggle } from '@langgenius/dify-ui/toggle'import ReactEcharts from 'echarts-for-react'import { memo, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react'import CopyIcon from '@/app/components/base/copy-icon'import MarkdownMusic from '@/app/components/base/markdown-blocks/music'import ErrorBoundary from '@/app/components/base/markdown/error-boundary'-import SVGBtn from '@/app/components/base/svg'import useTheme from '@/hooks/use-theme'import dynamic from '@/next/dynamic'import { Theme } from '@/types/app'@@ -137,7 +138,7 @@ type EChartsEventParams = {[key: string]: any}-const CodeBlock: any = memo(({ inline, className, children = '', ...props }: any) => {+export const CodeBlock: any = memo(({ inline, className, children = '', ...props }: any) => {const { theme } = useTheme()const [isSVG, setIsSVG] = useState(true)const [chartState, setChartState] = useState<'loading' | 'success' | 'error'>('loading')@@ -543,7 +544,20 @@ const CodeBlock: any = memo(({ inline, className, children = '', ...props }: any<div className="flex h-8 items-center justify-between rounded-t-[10px] border-b border-divider-subtle bg-components-input-bg-normal p-1 pl-3"><div className="system-xs-semibold-uppercase text-text-secondary">{languageShowName}</div><div className="flex items-center gap-1">- {language === 'svg' && <SVGBtn isSVG={isSVG} setIsSVG={setIsSVG} />}+ {language === 'svg' && (+ <Toggle+ pressed={isSVG}+ onPressedChange={setIsSVG}+ render={+ <IconButton aria-label="SVG">+ <span+ aria-hidden+ className={isSVG ? 'i-ri-file-code-fill size-4' : 'i-ri-file-code-line size-4'}+ />+ </IconButton>+ }+ />+ )}<CopyIcon content={String(children).replace(/\n$/, '')} /></div></div>@@ -552,5 +566,3 @@ const CodeBlock: any = memo(({ inline, className, children = '', ...props }: any)})CodeBlock.displayName = 'CodeBlock'--export default CodeBlockdiff --git a/web/app/components/base/markdown/__tests__/streamdown-wrapper.spec.tsx b/web/app/components/base/markdown/__tests__/streamdown-wrapper.spec.tsxindex fd2e85d3092..ca0ba503187 100644--- a/web/app/components/base/markdown/__tests__/streamdown-wrapper.spec.tsx+++ b/web/app/components/base/markdown/__tests__/streamdown-wrapper.spec.tsx@@ -23,7 +23,7 @@ vi.mock('@/app/components/base/markdown-blocks', () => ({}))vi.mock('@/app/components/base/markdown-blocks/code-block', () => ({- default: ({ children }: PropsWithChildren) => <code>{children}</code>,+ CodeBlock: ({ children }: PropsWithChildren) => <code>{children}</code>,}))describe('StreamdownWrapper', () => {diff --git a/web/app/components/base/markdown/streamdown-wrapper.tsx b/web/app/components/base/markdown/streamdown-wrapper.tsxindex a01a7423abe..36b2c2334f8 100644--- a/web/app/components/base/markdown/streamdown-wrapper.tsx+++ b/web/app/components/base/markdown/streamdown-wrapper.tsx@@ -37,9 +37,11 @@ type SanitizeSchema = {const MARKDOWN_FORM_TAG_RE = /<form(?:\s|>)/i-const CodeBlock = dynamic(() => import('@/app/components/base/markdown-blocks/code-block'), {- ssr: false,-})+const CodeBlock = dynamic(+ () =>+ import('@/app/components/base/markdown-blocks/code-block').then((module) => module.CodeBlock),+ { ssr: false },+)const mathPlugin = createMathPlugin({singleDollarTextMath: ENABLE_SINGLE_DOLLAR_LATEX,diff --git a/web/app/components/base/prompt-log-modal/card.tsx b/web/app/components/base/prompt-log-modal/card.tsxindex 42032744b76..4ee4984a1fb 100644--- a/web/app/components/base/prompt-log-modal/card.tsx+++ b/web/app/components/base/prompt-log-modal/card.tsx@@ -1,5 +1,5 @@import type { FC } from 'react'-import { CopyFeedbackNew } from '@/app/components/base/copy-feedback'+import { CopyFeedback } from '@/app/components/base/copy-feedback'type CardProps = {log: { role: string; text: string }[]@@ -21,7 +21,7 @@ const Card: FC<CardProps> = ({ log }) => {><div className="flex h-8 items-center justify-between"><div className="font-semibold text-indigo-800">{item.role.toUpperCase()}</div>- <CopyFeedbackNew+ <CopyFeedbackclassName="hidden size-6 group-hover/card:block"content={item.text}/>diff --git a/web/app/components/base/prompt-log-modal/index.tsx b/web/app/components/base/prompt-log-modal/index.tsxindex 6c8e83a749a..9ec9ae954b3 100644--- a/web/app/components/base/prompt-log-modal/index.tsx+++ b/web/app/components/base/prompt-log-modal/index.tsx@@ -3,7 +3,7 @@ import type { IChatItem } from '@/app/components/base/chat/chat/type'import { useClickAway } from 'ahooks'import { useEffect, useRef, useState } from 'react'import { useTranslation } from 'react-i18next'-import { CopyFeedbackNew } from '@/app/components/base/copy-feedback'+import { CopyFeedback } from '@/app/components/base/copy-feedback'import Card from './card'type PromptLogModalProps = {@@ -43,7 +43,7 @@ const PromptLogModal: FC<PromptLogModalProps> = ({ currentLogItem, width, onCanc<div className="flex items-center">{currentLogItem.log?.length === 1 && (<>- <CopyFeedbackNew className="size-6" content={currentLogItem.log[0]!.text} />+ <CopyFeedback className="size-6" content={currentLogItem.log[0]!.text} /><div className="mx-2.5 h-3.5 w-px bg-divider-regular" /></>)}diff --git a/web/app/components/base/svg/__tests__/index.spec.tsx b/web/app/components/base/svg/__tests__/index.spec.tsxdeleted file mode 100644index 1eca0acff91..00000000000--- a/web/app/components/base/svg/__tests__/index.spec.tsx+++ /dev/null@@ -1,20 +0,0 @@-import { render, screen } from '@testing-library/react'-import userEvent from '@testing-library/user-event'-import SVGBtn from '..'--describe('SVGBtn', () => {- it('exposes and toggles the SVG preview state', async () => {- const user = userEvent.setup()- const setIsSVG = vi.fn()- const { rerender } = render(<SVGBtn isSVG={false} setIsSVG={setIsSVG} />)-- await user.click(screen.getByRole('button', { name: 'SVG', pressed: false }))-- expect(setIsSVG).toHaveBeenCalledOnce()- expect(setIsSVG.mock.calls[0]![0]).toBe(true)-- rerender(<SVGBtn isSVG setIsSVG={setIsSVG} />)-- expect(screen.getByRole('button', { name: 'SVG', pressed: true })).toBeInTheDocument()- })-})diff --git a/web/app/components/base/svg/index.stories.tsx b/web/app/components/base/svg/index.stories.tsxdeleted file mode 100644index 3b89cf40e12..00000000000--- a/web/app/components/base/svg/index.stories.tsx+++ /dev/null@@ -1,39 +0,0 @@-import type { Meta, StoryObj } from '@storybook/nextjs-vite'-import { useState } from 'react'-import SVGBtn from '.'--const SvgToggleDemo = () => {- const [isSVG, setIsSVG] = useState(false)-- return (- <div className="flex w-full max-w-xs flex-col items-center gap-4 rounded-2xl border border-divider-subtle bg-components-panel-bg p-6">- <p className="text-xs tracking-[0.18em] text-text-tertiary uppercase">SVG toggle</p>- <SVGBtn isSVG={isSVG} setIsSVG={setIsSVG} />- <span className="text-xs text-text-secondary">- Mode:{' '}- <code className="rounded-sm bg-background-default px-2 py-1 text-[11px]">- {isSVG ? 'SVG' : 'PNG'}- </code>- </span>- </div>- )-}--const meta = {- title: 'Base/General/SVGBtn',- component: SvgToggleDemo,- parameters: {- layout: 'centered',- docs: {- description: {- component: 'Small toggle used in icon pickers to switch between SVG and bitmap assets.',- },- },- },- tags: ['autodocs'],-} satisfies Meta<typeof SvgToggleDemo>--export default meta-type Story = StoryObj<typeof meta>--export const Playground: Story = {}diff --git a/web/app/components/base/svg/index.tsx b/web/app/components/base/svg/index.tsxdeleted file mode 100644index 1cf7574067f..00000000000--- a/web/app/components/base/svg/index.tsx+++ /dev/null@@ -1,29 +0,0 @@-import { cn } from '@langgenius/dify-ui/cn'-import { IconButton } from '@langgenius/dify-ui/icon-button'-import { Toggle } from '@langgenius/dify-ui/toggle'-import * as React from 'react'-import s from './style.module.css'--type ISVGBtnProps = {- isSVG: boolean- setIsSVG: React.Dispatch<React.SetStateAction<boolean>>-}--const SVGBtn = ({ isSVG, setIsSVG }: ISVGBtnProps) => {- return (- <Toggle- pressed={isSVG}- onPressedChange={setIsSVG}- render={- <IconButton aria-label="SVG">- <span- aria-hidden="true"- className={cn('block size-4', isSVG ? s.svgIconed : s.svgIcon)}- />- </IconButton>- }- />- )-}--export default SVGBtndiff --git a/web/app/components/base/svg/style.module.css b/web/app/components/base/svg/style.module.cssdeleted file mode 100644index 9258fe8ed3f..00000000000--- a/web/app/components/base/svg/style.module.css+++ /dev/null@@ -1,11 +0,0 @@-.svgIcon {- background-image: url(~@/app/components/develop/secret-key/assets/svg.svg);- background-position: center;- background-repeat: no-repeat;-}--.svgIconed {- background-image: url(~@/app/components/develop/secret-key/assets/svged.svg);- background-position: center;- background-repeat: no-repeat;-}diff --git a/web/app/components/datasets/extra-info/service-api/__tests__/card.spec.tsx b/web/app/components/datasets/extra-info/service-api/__tests__/card.spec.tsxindex a609c25c80c..f5a2b02daf5 100644--- a/web/app/components/datasets/extra-info/service-api/__tests__/card.spec.tsx+++ b/web/app/components/datasets/extra-info/service-api/__tests__/card.spec.tsx@@ -1,25 +1,25 @@import { Popover } from '@langgenius/dify-ui/popover'import { render, screen } from '@testing-library/react'import userEvent from '@testing-library/user-event'-import Card from '../card'+import { ServiceApiCard } from '../card'vi.mock('@/hooks/use-api-access-url', () => ({useDatasetApiAccessUrl: () => 'https://docs.dify.ai/api-reference/datasets',}))describe('Service API card', () => {- const renderCard = (props: React.ComponentProps<typeof Card>) =>+ const renderCard = (props: React.ComponentProps<typeof ServiceApiCard>) =>render(<Popover>- <Card {...props} />+ <ServiceApiCard {...props} /></Popover>,)it('shows the service endpoint and API reference', () => {renderCard({apiBaseUrl: 'https://api.example.com',- canManageSecretKey: true,- onOpenSecretKeyModal: vi.fn(),+ canManageApiKey: true,+ onOpenApiKeyModal: vi.fn(),})expect(screen.getByText('https://api.example.com')).toBeInTheDocument()@@ -30,20 +30,24 @@ describe('Service API card', () => {it('opens secret-key management when allowed', async () => {const user = userEvent.setup()- const onOpenSecretKeyModal = vi.fn()+ const onOpenApiKeyModal = vi.fn()renderCard({apiBaseUrl: 'https://api.example.com',- canManageSecretKey: true,- onOpenSecretKeyModal,+ canManageApiKey: true,+ onOpenApiKeyModal,})await user.click(screen.getByRole('button', { name: 'dataset.serviceApi.card.apiKey' }))- expect(onOpenSecretKeyModal).toHaveBeenCalledOnce()+ expect(onOpenApiKeyModal).toHaveBeenCalledOnce()})it('disables secret-key management when it is not allowed', () => {- renderCard({ apiBaseUrl: 'https://api.example.com', onOpenSecretKeyModal: vi.fn() })+ renderCard({+ apiBaseUrl: 'https://api.example.com',+ canManageApiKey: false,+ onOpenApiKeyModal: vi.fn(),+ })expect(screen.getByRole('button', { name: 'dataset.serviceApi.card.apiKey' })).toBeDisabled()})diff --git a/web/app/components/datasets/extra-info/service-api/__tests__/index.spec.tsx b/web/app/components/datasets/extra-info/service-api/__tests__/index.spec.tsxindex f52a87be28c..876ed181f51 100644--- a/web/app/components/datasets/extra-info/service-api/__tests__/index.spec.tsx+++ b/web/app/components/datasets/extra-info/service-api/__tests__/index.spec.tsx@@ -1,7 +1,7 @@import { screen } from '@testing-library/react'import userEvent from '@testing-library/user-event'import { render } from '@/test/console/render'-import ServiceApi from '../index'+import { ServiceApi } from '../index'let mockPermissionKeys = ['dataset.api_key.manage']@@ -13,8 +13,8 @@ vi.mock('@/context/permission-state', async () => {}))})-vi.mock('@/app/components/develop/secret-key/secret-key-modal', () => ({- default: ({ isShow }: { isShow: boolean }) => (isShow ? <div>secret key modal</div> : null),+vi.mock('@/app/components/api-key/api-key-modal', () => ({+ ApiKeyModal: ({ open }: { open: boolean }) => (open ? <div>API key modal</div> : null),}))vi.mock('@/hooks/use-api-access-url', () => ({@@ -32,15 +32,13 @@ describe('ServiceApi', () => {const trigger = screen.getByRole('button', { name: 'dataset.serviceApi.title' })expect(trigger).not.toHaveAttribute('data-popup-open')- expect(trigger.firstElementChild).toHaveClass('hover:bg-state-base-hover')await user.click(trigger)expect(trigger).toHaveAttribute('data-popup-open', '')- expect(trigger.firstElementChild).toHaveClass('bg-state-base-hover')await user.click(screen.getByRole('button', { name: 'dataset.serviceApi.card.apiKey' }))- expect(screen.getByText('secret key modal')).toBeInTheDocument()+ expect(screen.getByText('API key modal')).toBeInTheDocument()})it('prevents secret-key management without workspace permission', async () => {@@ -51,6 +49,6 @@ describe('ServiceApi', () => {await user.click(screen.getByRole('button', { name: 'dataset.serviceApi.title' }))expect(screen.getByRole('button', { name: 'dataset.serviceApi.card.apiKey' })).toBeDisabled()- expect(screen.queryByText('secret key modal')).not.toBeInTheDocument()+ expect(screen.queryByText('API key modal')).not.toBeInTheDocument()})})diff --git a/web/app/components/datasets/extra-info/service-api/card.tsx b/web/app/components/datasets/extra-info/service-api/card.tsxindex a2739bd1538..1705475d6d6 100644--- a/web/app/components/datasets/extra-info/service-api/card.tsx+++ b/web/app/components/datasets/extra-info/service-api/card.tsx@@ -1,19 +1,18 @@import { Button } from '@langgenius/dify-ui/button'import { PopoverClose } from '@langgenius/dify-ui/popover'import { StatusDot } from '@langgenius/dify-ui/status-dot'-import * as React from 'react'import { useTranslation } from 'react-i18next'-import CopyFeedback from '@/app/components/base/copy-feedback'+import { CopyFeedback } from '@/app/components/base/copy-feedback'import { useDatasetApiAccessUrl } from '@/hooks/use-api-access-url'import Link from '@/next/link'type CardProps = {apiBaseUrl: string- onOpenSecretKeyModal: () => void- canManageSecretKey?: boolean+ canManageApiKey: boolean+ onOpenApiKeyModal: () => void}-const Card = ({ apiBaseUrl, onOpenSecretKeyModal, canManageSecretKey = false }: CardProps) => {+export function ServiceApiCard({ apiBaseUrl, canManageApiKey, onOpenApiKeyModal }: CardProps) {const { t } = useTranslation()const apiReferenceUrl = useDatasetApiAccessUrl()@@ -24,7 +23,10 @@ const Card = ({ apiBaseUrl, onOpenSecretKeyModal, canManageSecretKey = false }:<div className="flex items-center gap-x-3"><div className="flex grow items-center gap-x-2"><div className="flex size-6 shrink-0 items-center justify-center rounded-lg border-[0.5px] border-divider-subtle bg-util-colors-blue-brand-blue-brand-500 shadow-md shadow-shadow-shadow-5">- <span className="i-custom-vender-knowledge-api-aggregate size-4 text-text-primary-on-surface" />+ <span+ aria-hidden+ className="i-custom-vender-knowledge-api-aggregate size-4 text-text-primary-on-surface"+ /></div><div className="grow truncate system-sm-semibold text-text-secondary">{t(($) => $['serviceApi.card.title'], { ns: 'dataset' })}@@ -49,7 +51,6 @@ const Card = ({ apiBaseUrl, onOpenSecretKeyModal, canManageSecretKey = false }:</div></div></div>- {/* Actions */}<div className="flex gap-x-1 border-t-[0.5px] border-divider-subtle p-4"><PopoverCloserender={@@ -57,27 +58,28 @@ const Card = ({ apiBaseUrl, onOpenSecretKeyModal, canManageSecretKey = false }:variant="ghost"size="small"className="text-text-tertiary"- disabled={!canManageSecretKey}- onClick={onOpenSecretKeyModal}+ disabled={!canManageApiKey}+ onClick={onOpenApiKeyModal}>- <span className="i-ri-key-2-line size-3.5 shrink-0" />+ <span aria-hidden className="i-ri-key-2-line size-3.5 shrink-0" /><span className="system-xs-medium">{t(($) => $['serviceApi.card.apiKey'], { ns: 'dataset' })}</span></Button>}/>- <Link href={apiReferenceUrl} target="_blank" rel="noopener noreferrer">- <Button variant="ghost" size="small" className="text-text-tertiary">- <span className="i-ri-book-open-line size-3.5 shrink-0" />- <span className="system-xs-medium">- {t(($) => $['serviceApi.card.apiReference'], { ns: 'dataset' })}- </span>- </Button>- </Link>+ <Button+ variant="ghost"+ size="small"+ className="text-text-tertiary"+ render={<Link href={apiReferenceUrl} target="_blank" rel="noopener noreferrer" />}+ >+ <span aria-hidden className="i-ri-book-open-line size-3.5 shrink-0" />+ <span className="system-xs-medium">+ {t(($) => $['serviceApi.card.apiReference'], { ns: 'dataset' })}+ </span>+ </Button></div></div>)}--export default React.memo(Card)diff --git a/web/app/components/datasets/extra-info/service-api/index.tsx b/web/app/components/datasets/extra-info/service-api/index.tsxindex 7dd1271949e..73ceda8675c 100644--- a/web/app/components/datasets/extra-info/service-api/index.tsx+++ b/web/app/components/datasets/extra-info/service-api/index.tsx@@ -2,53 +2,40 @@ import { cn } from '@langgenius/dify-ui/cn'import { Popover, PopoverContent, PopoverTrigger } from '@langgenius/dify-ui/popover'import { StatusDot } from '@langgenius/dify-ui/status-dot'import { useAtomValue } from 'jotai'-import * as React from 'react'-import { useCallback, useState } from 'react'+import { useState } from 'react'import { useTranslation } from 'react-i18next'-import SecretKeyModal from '@/app/components/develop/secret-key/secret-key-modal'+import { ApiKeyModal } from '@/app/components/api-key/api-key-modal'import { workspacePermissionKeysAtom } from '@/context/permission-state'import { hasPermission } from '@/utils/permission'-import Card from './card'+import { ServiceApiCard } from './card'type ServiceApiProps = {apiBaseUrl: string}-const ServiceApi = ({ apiBaseUrl }: ServiceApiProps) => {+export function ServiceApi({ apiBaseUrl }: ServiceApiProps) {const { t } = useTranslation()- const [open, setOpen] = useState(false)- const [isSecretKeyModalVisible, setIsSecretKeyModalVisible] = useState(false)+ const [popoverOpen, setPopoverOpen] = useState(false)+ const [apiKeyModalOpen, setApiKeyModalOpen] = useState(false)const workspacePermissionKeys = useAtomValue(workspacePermissionKeysAtom)- const canManageSecretKey = hasPermission(workspacePermissionKeys, 'dataset.api_key.manage')-- const handleOpenSecretKeyModal = useCallback(() => {- setIsSecretKeyModalVisible(true)- }, [])-- const handleCloseSecretKeyModal = useCallback(() => {- setIsSecretKeyModalVisible(false)- }, [])+ const canManageApiKey = hasPermission(workspacePermissionKeys, 'dataset.api_key.manage')return (<div className="flex items-center">- <Popover open={open} onOpenChange={setOpen}>+ <Popover open={popoverOpen} onOpenChange={setPopoverOpen}><PopoverTrigger- render={(props, state) => (+ render={(props) => (<button{...props}type="button"- className={cn('w-full border-none bg-transparent p-0 text-left', props.className)}+ className={cn(+ 'relative flex h-6 w-full cursor-pointer items-center justify-center gap-1 overflow-hidden rounded-md border-none bg-transparent px-1.5 py-1 text-left text-text-tertiary hover:bg-state-base-hover data-popup-open:bg-state-base-hover',+ props.className,+ )}>- <div- className={cn(- 'relative flex h-6 cursor-pointer items-center justify-center gap-1 overflow-hidden rounded-md px-1.5 py-1 text-text-tertiary',- state.open ? 'bg-state-base-hover' : 'hover:bg-state-base-hover',- )}- >- <StatusDot className={cn('shrink-0')} status={apiBaseUrl ? 'success' : 'warning'} />- <div className="px-0.5 system-xs-medium">- {t(($) => $['serviceApi.title'], { ns: 'dataset' })}- </div>+ <StatusDot className="shrink-0" status={apiBaseUrl ? 'success' : 'warning'} />+ <div className="px-0.5 system-xs-medium">+ {t(($) => $['serviceApi.title'], { ns: 'dataset' })}</div></button>)}@@ -59,21 +46,19 @@ const ServiceApi = ({ apiBaseUrl }: ServiceApiProps) => {alignOffset={-4}popupClassName="border-none bg-transparent shadow-none">- <Card+ <ServiceApiCardapiBaseUrl={apiBaseUrl}- onOpenSecretKeyModal={handleOpenSecretKeyModal}- canManageSecretKey={canManageSecretKey}+ canManageApiKey={canManageApiKey}+ onOpenApiKeyModal={() => setApiKeyModalOpen(true)}/></PopoverContent></Popover>- <SecretKeyModal- isShow={isSecretKeyModalVisible}- onClose={handleCloseSecretKeyModal}- canManage={canManageSecretKey}+ <ApiKeyModal+ open={apiKeyModalOpen}+ onOpenChange={setApiKeyModalOpen}+ canManage={canManageApiKey}scope={{ type: 'dataset' }}/></div>)}--export default React.memo(ServiceApi)diff --git a/web/app/components/datasets/list/__tests__/header.spec.tsx b/web/app/components/datasets/list/__tests__/header.spec.tsxindex f95ad7441d8..e11ea858f3f 100644--- a/web/app/components/datasets/list/__tests__/header.spec.tsx+++ b/web/app/components/datasets/list/__tests__/header.spec.tsx@@ -12,7 +12,7 @@ vi.mock('@/app/components/datasets/create/website/base/checkbox-with-label', ()}))vi.mock('../../extra-info/service-api', () => ({- default: () => <button type="button">service api</button>,+ ServiceApi: () => <button type="button">service api</button>,}))const defaultProps = {diff --git a/web/app/components/datasets/list/__tests__/index.spec.tsx b/web/app/components/datasets/list/__tests__/index.spec.tsxindex 6d57050d5b1..9ad61c02c00 100644--- a/web/app/components/datasets/list/__tests__/index.spec.tsx+++ b/web/app/components/datasets/list/__tests__/index.spec.tsx@@ -188,12 +188,11 @@ vi.mock('../../external-api/external-api-panel', () => ({),}))-// Mock SecretKeyModal — it depends on user profile context and service APIs-// not configured in this test. ServiceApi always mounts the modal (controlled-// by `isShow`) so we provide a lightweight stub.-vi.mock('@/app/components/develop/secret-key/secret-key-modal', () => ({- default: ({ isShow }: { isShow: boolean }) =>- isShow ? <div data-testid="secret-key-modal" /> : null,+// Mock ApiKeyModal — it depends on user profile context and service APIs+// not configured in this test. ServiceApi always mounts the controlled modal,+// so we provide a lightweight stub.+vi.mock('@/app/components/api-key/api-key-modal', () => ({+ ApiKeyModal: ({ open }: { open: boolean }) => (open ? <div data-testid="api-key-modal" /> : null),}))// Mock TagManagementModaldiff --git a/web/app/components/datasets/list/header.tsx b/web/app/components/datasets/list/header.tsxindex 6c16d8c3261..fef282a8c87 100644--- a/web/app/components/datasets/list/header.tsx+++ b/web/app/components/datasets/list/header.tsx@@ -18,7 +18,7 @@ import {} from '@/app/components/step-by-step-tour/dropdown-menu'import { KnowledgeViewSwitcher } from '@/features/new-rag/components/knowledge-view-switcher'import { TagFilter } from '@/features/tag-management/components/tag-filter'-import ServiceApi from '../extra-info/service-api'+import { ServiceApi } from '../extra-info/service-api'type Props = {apiBaseUrl: stringdiff --git a/web/app/components/develop/ApiServer.tsx b/web/app/components/develop/ApiServer.tsxdeleted file mode 100644index 52b38232eca..00000000000--- a/web/app/components/develop/ApiServer.tsx+++ /dev/null@@ -1,36 +0,0 @@-'use client'--import type { FC } from 'react'-import { useTranslation } from 'react-i18next'-import CopyFeedback from '@/app/components/base/copy-feedback'-import SecretKeyButton from '@/app/components/develop/secret-key/secret-key-button'--type ApiServerProps = {- apiBaseUrl: string- appId?: string- canManageApiKey?: boolean-}-const ApiServer: FC<ApiServerProps> = ({ apiBaseUrl, appId, canManageApiKey = false }) => {- const { t } = useTranslation()-- return (- <div className="flex flex-wrap items-center gap-y-2">- <div className="mr-2 flex h-8 items-center rounded-lg border-[0.5px] border-components-input-border-active bg-components-input-bg-normal pr-1 pl-1.5 leading-5">- <div className="mr-0.5 h-5 shrink-0 rounded-md border border-divider-subtle px-1.5 text-[11px] text-text-tertiary">- {t(($) => $.apiServer, { ns: 'appApi' })}- </div>- <div className="w-fit truncate px-1 text-[13px] font-medium text-text-secondary sm:w-62">- {apiBaseUrl}- </div>- <div className="mx-1 h-3.5 w-px bg-divider-regular"></div>- <CopyFeedback content={apiBaseUrl} />- </div>- <div className="mr-2 flex h-8 items-center rounded-lg border-[0.5px] border-[#D1FADF] bg-[#ECFDF3] px-3 text-xs font-semibold text-[#039855]">- {t(($) => $.ok, { ns: 'appApi' })}- </div>- <SecretKeyButton className="h-8! shrink-0" appId={appId} canManage={canManageApiKey} />- </div>- )-}--export default ApiServerdiff --git a/web/app/components/develop/__tests__/ApiServer.spec.tsx b/web/app/components/develop/__tests__/ApiServer.spec.tsxdeleted file mode 100644index 63e7a37bd7b..00000000000--- a/web/app/components/develop/__tests__/ApiServer.spec.tsx+++ /dev/null@@ -1,34 +0,0 @@-import { render, screen } from '@testing-library/react'-import userEvent from '@testing-library/user-event'-import ApiServer from '../ApiServer'--vi.mock('@/app/components/develop/secret-key/secret-key-modal', () => ({- default: ({ isShow, onClose }: { isShow: boolean; onClose: () => void }) =>- isShow ? (- <div role="dialog" aria-label="Secret key">- <button type="button" onClick={onClose}>- Close Modal- </button>- </div>- ) : null,-}))--describe('ApiServer', () => {- it('shows the configured API endpoint', () => {- render(<ApiServer apiBaseUrl="https://api.example.com/v1" />)-- expect(screen.getByText('https://api.example.com/v1')).toBeInTheDocument()- expect(screen.getByRole('button', { name: /apiKey/i })).toBeDisabled()- })-- it('opens and closes API key management for authorized users', async () => {- const user = userEvent.setup()- render(<ApiServer apiBaseUrl="https://api.example.com" appId="app-123" canManageApiKey />)-- await user.click(screen.getByRole('button', { name: /apiKey/i }))- expect(screen.getByRole('dialog', { name: 'Secret key' })).toBeInTheDocument()-- await user.click(screen.getByRole('button', { name: 'Close Modal' }))- expect(screen.queryByRole('dialog', { name: 'Secret key' })).not.toBeInTheDocument()- })-})diff --git a/web/app/components/develop/__tests__/code.spec.tsx b/web/app/components/develop/__tests__/code.spec.tsxdeleted file mode 100644index 12e317c52b8..00000000000--- a/web/app/components/develop/__tests__/code.spec.tsx+++ /dev/null@@ -1,54 +0,0 @@-import { render, screen } from '@testing-library/react'-import userEvent from '@testing-library/user-event'-import { writeTextToClipboard } from '@/utils/clipboard'-import { CodeGroup } from '../code'--vi.mock('@/utils/clipboard', () => ({- writeTextToClipboard: vi.fn().mockResolvedValue(undefined),-}))--describe('CodeGroup', () => {- beforeEach(() => {- window.scrollBy = vi.fn()- })-- it('switches between named code examples', async () => {- const user = userEvent.setup()- render(- <CodeGroup- targetCode={[- { title: 'JavaScript', code: 'console.log("js")' },- { title: 'Python', code: 'print("py")' },- ]}- />,- )-- expect(screen.getByText('console.log("js")')).toBeInTheDocument()- await user.click(screen.getByRole('tab', { name: 'Python' }))-- expect(screen.getByText('print("py")')).toBeInTheDocument()- expect(screen.getByRole('tab', { name: 'Python' })).toHaveAttribute('aria-selected', 'true')- })-- it('copies the displayed code', async () => {- const user = userEvent.setup()- render(<CodeGroup targetCode="code to copy" />)-- await user.click(screen.getByRole('button', { name: 'Copy' }))-- expect(writeTextToClipboard).toHaveBeenCalledWith('code to copy')- expect(await screen.findByRole('button', { name: 'Copied!' })).toBeInTheDocument()- })-- it('renders authored code content when targetCode is omitted', () => {- render(- <CodeGroup>- <pre>- <code>child code content</code>- </pre>- </CodeGroup>,- )-- expect(screen.getByText('child code content')).toBeInTheDocument()- })-})diff --git a/web/app/components/develop/__tests__/doc.spec.tsx b/web/app/components/develop/__tests__/doc.spec.tsxdeleted file mode 100644index c4cc62851bb..00000000000--- a/web/app/components/develop/__tests__/doc.spec.tsx+++ /dev/null@@ -1,82 +0,0 @@-import { render, screen } from '@testing-library/react'-import userEvent from '@testing-library/user-event'-import { AppModeEnum } from '@/types/app'-import Doc from '../doc'--vi.mock('../template/template.en.mdx', () => ({ default: () => <div>completion-en</div> }))-vi.mock('../template/template.zh.mdx', () => ({ default: () => <div>completion-zh</div> }))-vi.mock('../template/template.ja.mdx', () => ({ default: () => <div>completion-ja</div> }))-vi.mock('../template/template_chat.en.mdx', () => ({ default: () => <div>chat-en</div> }))-vi.mock('../template/template_chat.zh.mdx', () => ({ default: () => <div>chat-zh</div> }))-vi.mock('../template/template_chat.ja.mdx', () => ({ default: () => <div>chat-ja</div> }))-vi.mock('../template/template_advanced_chat.en.mdx', () => ({- default: () => <div>advanced-chat-en</div>,-}))-vi.mock('../template/template_advanced_chat.zh.mdx', () => ({- default: () => <div>advanced-chat-zh</div>,-}))-vi.mock('../template/template_advanced_chat.ja.mdx', () => ({- default: () => <div>advanced-chat-ja</div>,-}))-vi.mock('../template/template_workflow.en.mdx', () => ({ default: () => <div>workflow-en</div> }))-vi.mock('../template/template_workflow.zh.mdx', () => ({ default: () => <div>workflow-zh</div> }))-vi.mock('../template/template_workflow.ja.mdx', () => ({ default: () => <div>workflow-ja</div> }))--const mockLocale = vi.fn(() => 'en-US')--vi.mock('@/context/i18n', () => ({- useLocale: () => mockLocale(),-}))--vi.mock('@/i18n-config/language', () => ({- LanguagesSupported: ['en-US', 'zh-Hans', 'ja-JP'],- getDocLanguage: (locale: string) =>- locale === 'zh-Hans' ? 'zh' : locale === 'ja-JP' ? 'ja' : 'en',-}))--const makeAppDetail = (mode: AppModeEnum) =>- ({- mode,- model_config: { configs: { prompt_variables: [] } },- }) as unknown as Parameters<typeof Doc>[0]['appDetail']--describe('Doc', () => {- beforeEach(() => {- mockLocale.mockReturnValue('en-US')- Object.defineProperty(window, 'matchMedia', {- writable: true,- value: vi.fn().mockReturnValue({ matches: false }),- })- })-- it.each([- [AppModeEnum.CHAT, 'chat-en'],- [AppModeEnum.AGENT_CHAT, 'chat-en'],- [AppModeEnum.ADVANCED_CHAT, 'advanced-chat-en'],- [AppModeEnum.WORKFLOW, 'workflow-en'],- [AppModeEnum.COMPLETION, 'completion-en'],- ])('selects the documentation for %s apps', (mode, template) => {- render(<Doc appDetail={makeAppDetail(mode)} />)-- expect(screen.getByText(template)).toBeInTheDocument()- })-- it.each([- ['zh-Hans', 'chat-zh'],- ['ja-JP', 'chat-ja'],- ])('selects the %s documentation', (locale, template) => {- mockLocale.mockReturnValue(locale)- render(<Doc appDetail={makeAppDetail(AppModeEnum.CHAT)} />)-- expect(screen.getByText(template)).toBeInTheDocument()- })-- it('expands the table of contents', async () => {- const user = userEvent.setup()- render(<Doc appDetail={makeAppDetail(AppModeEnum.CHAT)} />)-- await user.click(screen.getByRole('button', { name: 'Open table of contents' }))-- expect(screen.getByRole('navigation')).toBeInTheDocument()- })-})diff --git a/web/app/components/develop/__tests__/index.spec.tsx b/web/app/components/develop/__tests__/index.spec.tsxdeleted file mode 100644index 3a72471e0b4..00000000000--- a/web/app/components/develop/__tests__/index.spec.tsx+++ /dev/null@@ -1,363 +0,0 @@-import { screen } from '@testing-library/react'-import { renderWithAccountProfile as render } from '@/test/console/account-profile'-import { AppACLPermission } from '@/utils/permission'-import DevelopMain from '../index'--const mockAppDetailValue: { current: unknown } = { current: undefined }-vi.mock('@/context/workspace-state', async () => {- const { createWorkspaceStateModuleMock } = await import('@/test/console/state-fixture')- return createWorkspaceStateModuleMock(() => ({- currentWorkspace: { id: 'workspace-1' },- }))-})--vi.mock('@/app/components/app/store', () => ({- useStore: (selector: (state: unknown) => unknown) => {- const state = { appDetail: mockAppDetailValue.current }- return selector(state)- },-}))--vi.mock('@/app/components/develop/doc', () => ({- default: ({ appDetail }: { appDetail: { name?: string } | null }) => (- <div data-testid="doc-component">Doc Component -{appDetail?.name}</div>- ),-}))--vi.mock('@/app/components/develop/ApiServer', () => ({- default: ({- apiBaseUrl,- appId,- canManageApiKey,- }: {- apiBaseUrl: string- appId: string- canManageApiKey: boolean- }) => (- <div data-testid="api-server" data-can-manage-api-key={canManageApiKey}>- API Server -{apiBaseUrl} -{appId}- </div>- ),-}))--vi.mock('@/context/permission-state', async () => {- const { createPermissionStateModuleMock } = await import('@/test/console/state-fixture')-- return createPermissionStateModuleMock(() => ({- workspacePermissionKeys: [],- }))-})--describe('DevelopMain', () => {- beforeEach(() => {- vi.clearAllMocks()- mockAppDetailValue.current = undefined- })-- describe('loading state', () => {- it('should show loading when appDetail is undefined', () => {- mockAppDetailValue.current = undefined- render(<DevelopMain appId="app-123" />)-- expect(screen.getByRole('status')).toBeInTheDocument()- })-- it('should show loading when appDetail is null', () => {- mockAppDetailValue.current = null- render(<DevelopMain appId="app-123" />)-- expect(screen.getByRole('status')).toBeInTheDocument()- })-- it('should have centered loading container', () => {- mockAppDetailValue.current = undefined- const { container } = render(<DevelopMain appId="app-123" />)-- const loadingContainer = container.querySelector('.flex.h-full.items-center.justify-center')- expect(loadingContainer).toBeInTheDocument()- })-- it('should have correct background on loading state', () => {- mockAppDetailValue.current = undefined- const { container } = render(<DevelopMain appId="app-123" />)-- const loadingContainer = container.querySelector('.bg-background-default')- expect(loadingContainer).toBeInTheDocument()- })- })-- describe('with appDetail loaded', () => {- const mockAppDetail = {- id: 'app-123',- name: 'Test Application',- api_base_url: 'https://api.example.com/v1',- mode: 'chat',- }-- beforeEach(() => {- mockAppDetailValue.current = mockAppDetail- })-- it('should render ApiServer component', () => {- render(<DevelopMain appId="app-123" />)- expect(screen.getByTestId('api-server')).toBeInTheDocument()- })-- it('should pass api_base_url to ApiServer', () => {- render(<DevelopMain appId="app-123" />)- expect(screen.getByTestId('api-server')).toHaveTextContent('https://api.example.com/v1')- })-- it('should pass appId to ApiServer', () => {- render(<DevelopMain appId="app-123" />)- expect(screen.getByTestId('api-server')).toHaveTextContent('app-123')- })-- it.each([- [[AppACLPermission.ReleaseAndVersion], 'true'],- [[AppACLPermission.Edit], 'false'],- ])('should gate API key management by release permission', (permissionKeys, canManage) => {- mockAppDetailValue.current = { ...mockAppDetail, permission_keys: permissionKeys }- render(<DevelopMain appId="app-123" />)-- expect(screen.getByTestId('api-server')).toHaveAttribute('data-can-manage-api-key', canManage)- })-- it('should render Doc component', () => {- render(<DevelopMain appId="app-123" />)- expect(screen.getByTestId('doc-component')).toBeInTheDocument()- })-- it('should pass appDetail to Doc component', () => {- render(<DevelopMain appId="app-123" />)- expect(screen.getByTestId('doc-component')).toHaveTextContent('Test Application')- })-- it('should not show loading when appDetail exists', () => {- render(<DevelopMain appId="app-123" />)- expect(screen.queryByRole('status')).not.toBeInTheDocument()- })- })-- describe('layout structure', () => {- const mockAppDetail = {- id: 'app-123',- name: 'Test Application',- api_base_url: 'https://api.example.com',- mode: 'chat',- }-- beforeEach(() => {- mockAppDetailValue.current = mockAppDetail- })-- it('should have flex column layout', () => {- render(<DevelopMain appId="app-123" />)- const mainContainer = screen.getByTestId('develop-main')- expect(mainContainer.className).toContain('flex')- expect(mainContainer.className).toContain('flex-col')- })-- it('should have relative positioning', () => {- render(<DevelopMain appId="app-123" />)- const mainContainer = screen.getByTestId('develop-main')- expect(mainContainer.className).toContain('relative')- })-- it('should have full height', () => {- render(<DevelopMain appId="app-123" />)- const mainContainer = screen.getByTestId('develop-main')- expect(mainContainer.className).toContain('h-full')- })-- it('should have overflow-hidden', () => {- render(<DevelopMain appId="app-123" />)- const mainContainer = screen.getByTestId('develop-main')- expect(mainContainer.className).toContain('overflow-hidden')- })- })-- describe('header section', () => {- const mockAppDetail = {- id: 'app-123',- name: 'Test Application',- api_base_url: 'https://api.example.com',- mode: 'chat',- }-- beforeEach(() => {- mockAppDetailValue.current = mockAppDetail- })-- it('should have header with border', () => {- const { container } = render(<DevelopMain appId="app-123" />)- const header = container.querySelector('.border-b')- expect(header).toBeInTheDocument()- })-- it('should have shrink-0 on header to prevent shrinking', () => {- const { container } = render(<DevelopMain appId="app-123" />)- const header = container.querySelector('.shrink-0')- expect(header).toBeInTheDocument()- })-- it('should have horizontal padding on header', () => {- const { container } = render(<DevelopMain appId="app-123" />)- const header = container.querySelector('.px-6')- expect(header).toBeInTheDocument()- })-- it('should have vertical padding on header', () => {- const { container } = render(<DevelopMain appId="app-123" />)- const header = container.querySelector('.py-2')- expect(header).toBeInTheDocument()- })-- it('should have items centered in header', () => {- const { container } = render(<DevelopMain appId="app-123" />)- const header = container.querySelector('.items-center')- expect(header).toBeInTheDocument()- })-- it('should have justify-between in header', () => {- const { container } = render(<DevelopMain appId="app-123" />)- const header = container.querySelector('.justify-between')- expect(header).toBeInTheDocument()- })- })-- describe('content section', () => {- const mockAppDetail = {- id: 'app-123',- name: 'Test Application',- api_base_url: 'https://api.example.com',- mode: 'chat',- }-- beforeEach(() => {- mockAppDetailValue.current = mockAppDetail- })-- it('should have grow class for content area', () => {- const { container } = render(<DevelopMain appId="app-123" />)- const content = container.querySelector('.grow')- expect(content).toBeInTheDocument()- })-- it('should have overflow-auto for content scrolling', () => {- const { container } = render(<DevelopMain appId="app-123" />)- const content = container.querySelector('.overflow-auto')- expect(content).toBeInTheDocument()- })-- it('should have horizontal padding on content', () => {- const { container } = render(<DevelopMain appId="app-123" />)- const content = container.querySelector('.p-4')- expect(content).toBeInTheDocument()- })-- it('should have vertical padding on content', () => {- const { container } = render(<DevelopMain appId="app-123" />)- const content = container.querySelector('.p-4')- expect(content).toBeInTheDocument()- })-- it('should have responsive padding', () => {- const { container } = render(<DevelopMain appId="app-123" />)- const content = container.querySelector('[class*="sm:px-10"]')- expect(content).toBeInTheDocument()- })- })-- describe('with different appIds', () => {- const mockAppDetail = {- id: 'app-456',- name: 'Another App',- api_base_url: 'https://another-api.com',- mode: 'completion',- }-- beforeEach(() => {- mockAppDetailValue.current = mockAppDetail- })-- it('should pass different appId to ApiServer', () => {- render(<DevelopMain appId="app-456" />)- expect(screen.getByTestId('api-server')).toHaveTextContent('app-456')- })-- it('should handle app with different api_base_url', () => {- render(<DevelopMain appId="app-456" />)- expect(screen.getByTestId('api-server')).toHaveTextContent('https://another-api.com')- })- })-- describe('empty state handling', () => {- it('should handle appDetail with minimal properties', () => {- mockAppDetailValue.current = {- api_base_url: 'https://api.test.com',- }- render(<DevelopMain appId="app-minimal" />)- expect(screen.getByTestId('api-server')).toBeInTheDocument()- })-- it('should handle appDetail with empty api_base_url', () => {- mockAppDetailValue.current = {- api_base_url: '',- name: 'Empty URL App',- }- render(<DevelopMain appId="app-empty-url" />)- expect(screen.getByTestId('api-server')).toBeInTheDocument()- })- })-- describe('title element', () => {- const mockAppDetail = {- id: 'app-123',- name: 'Test Application',- api_base_url: 'https://api.example.com',- mode: 'chat',- }-- beforeEach(() => {- mockAppDetailValue.current = mockAppDetail- })-- it('should have title div with correct styling', () => {- const { container } = render(<DevelopMain appId="app-123" />)- const title = container.querySelector('.text-lg.font-medium.text-text-primary')- expect(title).toBeInTheDocument()- })-- it('should render empty title div', () => {- const { container } = render(<DevelopMain appId="app-123" />)- const title = container.querySelector('.text-lg.font-medium.text-text-primary')- expect(title?.textContent).toBe('')- })- })-- describe('border styling', () => {- const mockAppDetail = {- id: 'app-123',- name: 'Test Application',- api_base_url: 'https://api.example.com',- mode: 'chat',- }-- beforeEach(() => {- mockAppDetailValue.current = mockAppDetail- })-- it('should have solid border style', () => {- const { container } = render(<DevelopMain appId="app-123" />)- const header = container.querySelector('.border-solid')- expect(header).toBeInTheDocument()- })-- it('should have divider regular color on border', () => {- const { container } = render(<DevelopMain appId="app-123" />)- const header = container.querySelector('.border-b-divider-regular')- expect(header).toBeInTheDocument()- })- })-})diff --git a/web/app/components/develop/__tests__/toc-panel.spec.tsx b/web/app/components/develop/__tests__/toc-panel.spec.tsxdeleted file mode 100644index 301a09a1edc..00000000000--- a/web/app/components/develop/__tests__/toc-panel.spec.tsx+++ /dev/null@@ -1,55 +0,0 @@-import type { TocItem } from '../hooks/use-doc-toc'-import { render, screen } from '@testing-library/react'-import userEvent from '@testing-library/user-event'-import TocPanel from '../toc-panel'--const toc: TocItem[] = [- { href: '#introduction', text: 'Introduction' },- { href: '#authentication', text: 'Authentication' },-]--const defaultProps = {- toc,- activeSection: '',- isTocExpanded: false,- onToggle: vi.fn(),- onItemClick: vi.fn(),-}--describe('TocPanel', () => {- it('opens and closes the table of contents', async () => {- const user = userEvent.setup()- const onToggle = vi.fn()- const { rerender } = render(<TocPanel {...defaultProps} onToggle={onToggle} />)-- await user.click(screen.getByRole('button', { name: 'Open table of contents' }))- expect(onToggle).toHaveBeenCalledWith(true)-- rerender(<TocPanel {...defaultProps} isTocExpanded onToggle={onToggle} />)- await user.click(screen.getByRole('button', { name: 'Close' }))- expect(onToggle).toHaveBeenLastCalledWith(false)- })-- it('renders navigable document sections', () => {- render(<TocPanel {...defaultProps} isTocExpanded />)-- expect(screen.getByRole('link', { name: 'Introduction' })).toHaveAttribute(- 'href',- '#introduction',- )- expect(screen.getByRole('link', { name: 'Authentication' })).toHaveAttribute(- 'href',- '#authentication',- )- })-- it('reports the selected section', async () => {- const user = userEvent.setup()- const onItemClick = vi.fn()- render(<TocPanel {...defaultProps} isTocExpanded onItemClick={onItemClick} />)-- await user.click(screen.getByRole('link', { name: 'Authentication' }))-- expect(onItemClick).toHaveBeenCalledWith(expect.any(Object), toc[1])- })-})diff --git a/web/app/components/develop/__tests__/use-doc-toc.spec.ts b/web/app/components/develop/__tests__/use-doc-toc.spec.tsdeleted file mode 100644index fc25e5f564b..00000000000--- a/web/app/components/develop/__tests__/use-doc-toc.spec.ts+++ /dev/null@@ -1,425 +0,0 @@-import { act, renderHook } from '@testing-library/react'-import { beforeEach, describe, expect, it, vi } from 'vite-plus/test'-import { useDocToc } from '../hooks/use-doc-toc'--/**- * Unit tests for the useDocToc custom hook.- * Covers TOC extraction, viewport-based expansion, scroll tracking, and click handling.- */-describe('useDocToc', () => {- const defaultOptions = { appDetail: { mode: 'chat' }, locale: 'en-US' }-- beforeEach(() => {- vi.clearAllMocks()- vi.useRealTimers()-- Object.defineProperty(window, 'matchMedia', {- writable: true,- value: vi.fn().mockReturnValue({ matches: false }),- })- })-- // Covers initial state values based on viewport width- describe('initial state', () => {- it('should set isTocExpanded to false on narrow viewport', () => {- const { result } = renderHook(() => useDocToc(defaultOptions))-- expect(result.current.isTocExpanded).toBe(false)- expect(result.current.toc).toEqual([])- expect(result.current.activeSection).toBe('')- })-- it('should set isTocExpanded to true on wide viewport', () => {- Object.defineProperty(window, 'matchMedia', {- writable: true,- value: vi.fn().mockReturnValue({ matches: true }),- })-- const { result } = renderHook(() => useDocToc(defaultOptions))-- expect(result.current.isTocExpanded).toBe(true)- })- })-- // Covers TOC extraction from DOM article headings- describe('TOC extraction', () => {- it('should extract toc items from article h2 anchors', async () => {- vi.useFakeTimers()- const article = document.createElement('article')- const h2 = document.createElement('h2')- const anchor = document.createElement('a')- anchor.href = '#section-1'- anchor.textContent = 'Section 1'- h2.appendChild(anchor)- article.appendChild(h2)- document.body.appendChild(article)-- const { result } = renderHook(() => useDocToc(defaultOptions))-- await act(async () => {- vi.runAllTimers()- })-- expect(result.current.toc).toEqual([{ href: '#section-1', text: 'Section 1' }])- expect(result.current.activeSection).toBe('section-1')-- document.body.removeChild(article)- vi.useRealTimers()- })-- it('should return empty toc when no article exists', async () => {- vi.useFakeTimers()- const { result } = renderHook(() => useDocToc(defaultOptions))-- await act(async () => {- vi.runAllTimers()- })-- expect(result.current.toc).toEqual([])- expect(result.current.activeSection).toBe('')- vi.useRealTimers()- })-- it('should skip h2 headings without anchors', async () => {- vi.useFakeTimers()- const article = document.createElement('article')- const h2NoAnchor = document.createElement('h2')- h2NoAnchor.textContent = 'No Anchor'- article.appendChild(h2NoAnchor)-- const h2WithAnchor = document.createElement('h2')- const anchor = document.createElement('a')- anchor.href = '#valid'- anchor.textContent = 'Valid'- h2WithAnchor.appendChild(anchor)- article.appendChild(h2WithAnchor)-- document.body.appendChild(article)-- const { result } = renderHook(() => useDocToc(defaultOptions))-- await act(async () => {- vi.runAllTimers()- })-- expect(result.current.toc).toHaveLength(1)- expect(result.current.toc[0]).toEqual({ href: '#valid', text: 'Valid' })-- document.body.removeChild(article)- vi.useRealTimers()- })-- it('should re-extract toc when appDetail changes', async () => {- vi.useFakeTimers()- const article = document.createElement('article')- document.body.appendChild(article)-- const { result, rerender } = renderHook((props) => useDocToc(props), {- initialProps: defaultOptions,- })-- await act(async () => {- vi.runAllTimers()- })-- expect(result.current.toc).toEqual([])-- // Add a heading, then change appDetail to trigger re-extraction- const h2 = document.createElement('h2')- const anchor = document.createElement('a')- anchor.href = '#new-section'- anchor.textContent = 'New Section'- h2.appendChild(anchor)- article.appendChild(h2)-- rerender({ appDetail: { mode: 'workflow' }, locale: 'en-US' })-- await act(async () => {- vi.runAllTimers()- })-- expect(result.current.toc).toHaveLength(1)-- document.body.removeChild(article)- vi.useRealTimers()- })-- it('should re-extract toc when locale changes', async () => {- vi.useFakeTimers()- const article = document.createElement('article')- const h2 = document.createElement('h2')- const anchor = document.createElement('a')- anchor.href = '#sec'- anchor.textContent = 'Sec'- h2.appendChild(anchor)- article.appendChild(h2)- document.body.appendChild(article)-- const { result, rerender } = renderHook((props) => useDocToc(props), {- initialProps: defaultOptions,- })-- await act(async () => {- vi.runAllTimers()- })-- expect(result.current.toc).toHaveLength(1)-- rerender({ appDetail: defaultOptions.appDetail, locale: 'zh-Hans' })-- await act(async () => {- vi.runAllTimers()- })-- // Should still have the toc item after re-extraction- expect(result.current.toc).toHaveLength(1)-- document.body.removeChild(article)- vi.useRealTimers()- })- })-- // Covers manual toggle via setIsTocExpanded- describe('setIsTocExpanded', () => {- it('should toggle isTocExpanded state', () => {- const { result } = renderHook(() => useDocToc(defaultOptions))-- expect(result.current.isTocExpanded).toBe(false)-- act(() => {- result.current.setIsTocExpanded(true)- })-- expect(result.current.isTocExpanded).toBe(true)-- act(() => {- result.current.setIsTocExpanded(false)- })-- expect(result.current.isTocExpanded).toBe(false)- })- })-- // Covers smooth-scroll click handler- describe('handleTocClick', () => {- it('should prevent default and scroll to target element', () => {- const scrollContainer = document.createElement('div')- scrollContainer.className = 'overflow-auto'- scrollContainer.scrollTo = vi.fn()- document.body.appendChild(scrollContainer)-- const target = document.createElement('div')- target.id = 'target-section'- Object.defineProperty(target, 'offsetTop', { value: 500 })- scrollContainer.appendChild(target)-- const { result } = renderHook(() => useDocToc(defaultOptions))-- const mockEvent = {- preventDefault: vi.fn(),- } as unknown as React.MouseEvent<HTMLAnchorElement>- act(() => {- result.current.handleTocClick(mockEvent, { href: '#target-section', text: 'Target' })- })-- expect(mockEvent.preventDefault).toHaveBeenCalled()- expect(scrollContainer.scrollTo).toHaveBeenCalledWith({- top: 420, // 500 - 80 (HEADER_OFFSET)- behavior: 'smooth',- })-- document.body.removeChild(scrollContainer)- })-- it('should do nothing when target element does not exist', () => {- const { result } = renderHook(() => useDocToc(defaultOptions))-- const mockEvent = {- preventDefault: vi.fn(),- } as unknown as React.MouseEvent<HTMLAnchorElement>- act(() => {- result.current.handleTocClick(mockEvent, { href: '#nonexistent', text: 'Missing' })- })-- expect(mockEvent.preventDefault).toHaveBeenCalled()- })- })-- // Covers scroll-based active section tracking- describe('scroll tracking', () => {- // Helper: set up DOM with scroll container, article headings, and matching target elements- const setupScrollDOM = (sections: Array<{ id: string; text: string; top: number }>) => {- const scrollContainer = document.createElement('div')- scrollContainer.className = 'overflow-auto'- document.body.appendChild(scrollContainer)-- const article = document.createElement('article')- sections.forEach(({ id, text, top }) => {- // Heading with anchor for TOC extraction- const h2 = document.createElement('h2')- const anchor = document.createElement('a')- anchor.href = `#${id}`- anchor.textContent = text- h2.appendChild(anchor)- article.appendChild(h2)-- // Target element for scroll tracking- const target = document.createElement('div')- target.id = id- target.getBoundingClientRect = vi.fn().mockReturnValue({ top })- scrollContainer.appendChild(target)- })- document.body.appendChild(article)-- return {- scrollContainer,- article,- cleanup: () => {- document.body.removeChild(scrollContainer)- document.body.removeChild(article)- },- }- }-- it('should register scroll listener when toc has items', async () => {- vi.useFakeTimers()- const { scrollContainer, cleanup } = setupScrollDOM([- { id: 'sec-a', text: 'Section A', top: 0 },- ])- const addSpy = vi.spyOn(scrollContainer, 'addEventListener')- const removeSpy = vi.spyOn(scrollContainer, 'removeEventListener')-- const { unmount } = renderHook(() => useDocToc(defaultOptions))-- await act(async () => {- vi.runAllTimers()- })-- expect(addSpy).toHaveBeenCalledWith('scroll', expect.any(Function))-- unmount()-- expect(removeSpy).toHaveBeenCalledWith('scroll', expect.any(Function))-- cleanup()- vi.useRealTimers()- })-- it('should update activeSection when scrolling past a section', async () => {- vi.useFakeTimers()- // innerHeight/2 = 384 with the default test viewport height (768), so top <= 384 means "scrolled past"- const { scrollContainer, cleanup } = setupScrollDOM([- { id: 'intro', text: 'Intro', top: 100 },- { id: 'details', text: 'Details', top: 600 },- ])-- const { result } = renderHook(() => useDocToc(defaultOptions))-- // Extract TOC items- await act(async () => {- vi.runAllTimers()- })-- expect(result.current.toc).toHaveLength(2)- expect(result.current.activeSection).toBe('intro')-- // Fire scroll — 'intro' (top=100) is above midpoint, 'details' (top=600) is below- await act(async () => {- scrollContainer.dispatchEvent(new Event('scroll'))- })-- expect(result.current.activeSection).toBe('intro')-- cleanup()- vi.useRealTimers()- })-- it('should track the last section above the viewport midpoint', async () => {- vi.useFakeTimers()- const { scrollContainer, cleanup } = setupScrollDOM([- { id: 'sec-1', text: 'Section 1', top: 50 },- { id: 'sec-2', text: 'Section 2', top: 200 },- { id: 'sec-3', text: 'Section 3', top: 800 },- ])-- const { result } = renderHook(() => useDocToc(defaultOptions))-- await act(async () => {- vi.runAllTimers()- })-- // Fire scroll — sec-1 (top=50) and sec-2 (top=200) are above midpoint (384),- // sec-3 (top=800) is below. The last one above midpoint wins.- await act(async () => {- scrollContainer.dispatchEvent(new Event('scroll'))- })-- expect(result.current.activeSection).toBe('sec-2')-- cleanup()- vi.useRealTimers()- })-- it('should not update activeSection when no section is above midpoint', async () => {- vi.useFakeTimers()- const { scrollContainer, cleanup } = setupScrollDOM([- { id: 'far-away', text: 'Far Away', top: 1000 },- ])-- const { result } = renderHook(() => useDocToc(defaultOptions))-- await act(async () => {- vi.runAllTimers()- })-- // Initial activeSection is set by extraction- const initialSection = result.current.activeSection-- await act(async () => {- scrollContainer.dispatchEvent(new Event('scroll'))- })-- // Should not change since the element is below midpoint- expect(result.current.activeSection).toBe(initialSection)-- cleanup()- vi.useRealTimers()- })-- it('should handle elements not found in DOM during scroll', async () => {- vi.useFakeTimers()- const scrollContainer = document.createElement('div')- scrollContainer.className = 'overflow-auto'- document.body.appendChild(scrollContainer)-- // Article with heading but NO matching target element by id- const article = document.createElement('article')- const h2 = document.createElement('h2')- const anchor = document.createElement('a')- anchor.href = '#missing-target'- anchor.textContent = 'Missing'- h2.appendChild(anchor)- article.appendChild(h2)- document.body.appendChild(article)-- const { result } = renderHook(() => useDocToc(defaultOptions))-- await act(async () => {- vi.runAllTimers()- })-- const initialSection = result.current.activeSection-- // Scroll fires but getElementById returns null — no crash, no change- await act(async () => {- scrollContainer.dispatchEvent(new Event('scroll'))- })-- expect(result.current.activeSection).toBe(initialSection)-- document.body.removeChild(scrollContainer)- document.body.removeChild(article)- vi.useRealTimers()- })- })-})diff --git a/web/app/components/develop/__tests__/workflow-version-api-upgrade-notice.spec.tsx b/web/app/components/develop/__tests__/workflow-version-api-upgrade-notice.spec.tsxdeleted file mode 100644index 517deb775a3..00000000000--- a/web/app/components/develop/__tests__/workflow-version-api-upgrade-notice.spec.tsx+++ /dev/null@@ -1,179 +0,0 @@-import type { CloudPlan } from '@dify/contracts/api/console/features/types.gen'-import { fireEvent, render, screen, within } from '@testing-library/react'-import {- WorkflowVersionApiContent,- WorkflowVersionApiUpgradeNotice,-} from '../workflow-version-api-upgrade-notice'--let mockPlanType: CloudPlan = 'professional'-let mockEnableBilling = true-let mockIsFetchedPlan = true--vi.mock('@/context/provider-context', () => ({- useProviderContext: () => ({- plan: { type: mockPlanType },- enableBilling: mockEnableBilling,- isFetchedPlan: mockIsFetchedPlan,- }),-}))--vi.mock('@/app/components/billing/plan-upgrade-modal', () => ({- PlanUpgradeModal: ({- show,- title,- description,- onClose,- }: {- show: boolean- title: string- description: string- onClose: () => void- }) =>- show ? (- <div data-testid="plan-upgrade-modal">- <div>{title}</div>- <div>{description}</div>- <button type="button" onClick={onClose}>- close upgrade modal- </button>- </div>- ) : null,-}))--vi.mock('@/app/components/billing/upgrade-btn', () => ({- default: ({- onClick,- isShort,- size,- loc,- className,- }: {- onClick: () => void- isShort: boolean- size: string- loc: string- className: string- }) => (- <button- type="button"- data-is-short={isShort}- data-size={size}- data-loc={loc}- className={className}- onClick={onClick}- >- billing.upgradeBtn.encourageShort- </button>- ),-}))--describe('WorkflowVersionApiUpgradeNotice', () => {- beforeEach(() => {- mockPlanType = 'professional'- mockEnableBilling = true- mockIsFetchedPlan = true- })-- it('should not render before the plan is fetched', () => {- mockPlanType = 'sandbox'- mockIsFetchedPlan = false-- render(<WorkflowVersionApiUpgradeNotice />)-- expect(- screen.queryByRole('button', { name: 'billing.upgradeBtn.encourageShort' }),- ).not.toBeInTheDocument()- })-- it('should not render when billing is disabled', () => {- mockPlanType = 'sandbox'- mockEnableBilling = false-- render(<WorkflowVersionApiUpgradeNotice />)-- expect(- screen.queryByRole('button', { name: 'billing.upgradeBtn.encourageShort' }),- ).not.toBeInTheDocument()- })-- it('should not render for paid plans', () => {- render(<WorkflowVersionApiUpgradeNotice />)-- expect(- screen.queryByRole('button', { name: 'billing.upgradeBtn.encourageShort' }),- ).not.toBeInTheDocument()- })-- it('should show a small upgrade button and open the plan upgrade modal for sandbox plans', () => {- mockPlanType = 'sandbox'-- render(<WorkflowVersionApiUpgradeNotice />)-- expect(screen.queryByText('billing.upgrade.workflowVersionRun.title')).not.toBeInTheDocument()- expect(- screen.queryByText('billing.upgrade.workflowVersionRun.description'),- ).not.toBeInTheDocument()-- const upgradeButton = screen.getByRole('button', { name: 'billing.upgradeBtn.encourageShort' })- expect(upgradeButton).toHaveAttribute('data-is-short', 'true')- expect(upgradeButton).toHaveAttribute('data-size', 'custom')- expect(upgradeButton).toHaveAttribute('data-loc', 'workflow-version-api-docs')- expect(upgradeButton).toHaveClass('h-5!', 'rounded-md!', 'px-1!')-- fireEvent.click(upgradeButton)-- const modal = screen.getByTestId('plan-upgrade-modal')- expect(modal).toBeInTheDocument()- expect(within(modal).getByText('billing.upgrade.workflowVersionRun.title')).toBeInTheDocument()- expect(- within(modal).getByText('billing.upgrade.workflowVersionRun.description'),- ).toBeInTheDocument()- })-})--describe('WorkflowVersionApiContent', () => {- beforeEach(() => {- mockPlanType = 'professional'- mockEnableBilling = true- mockIsFetchedPlan = true- })-- it('should hide content while the billing plan is loading', () => {- mockIsFetchedPlan = false-- render(<WorkflowVersionApiContent>paid API details</WorkflowVersionApiContent>)-- expect(screen.queryByText('paid API details')).not.toBeInTheDocument()- })-- it('should hide content for sandbox plans', () => {- mockPlanType = 'sandbox'-- const { container } = render(- <>- <h2>paid API</h2>- <WorkflowVersionApiContent>paid API details</WorkflowVersionApiContent>- <hr />- </>,- )-- expect(screen.queryByText('paid API details')).not.toBeInTheDocument()- expect(container.querySelector('h2 + [aria-hidden="true"] + hr')).toBeInTheDocument()- })-- it('should show content for paid plans', () => {- render(<WorkflowVersionApiContent>paid API details</WorkflowVersionApiContent>)-- expect(screen.getByText('paid API details')).toBeInTheDocument()- })-- it('should show content when billing is disabled', () => {- mockPlanType = 'sandbox'- mockEnableBilling = false- mockIsFetchedPlan = false-- render(<WorkflowVersionApiContent>paid API details</WorkflowVersionApiContent>)-- expect(screen.getByText('paid API details')).toBeInTheDocument()- })-})diff --git a/web/app/components/develop/code.tsx b/web/app/components/develop/code.tsxdeleted file mode 100644index 74de97fe35c..00000000000--- a/web/app/components/develop/code.tsx+++ /dev/null@@ -1,293 +0,0 @@-'use client'-import type { PropsWithChildren, ReactElement } from 'react'-import { cn } from '@langgenius/dify-ui/cn'-import { Tabs, TabsList, TabsPanel, TabsTab } from '@langgenius/dify-ui/tabs'-import { Children, useEffect, useRef, useState } from 'react'-import { writeTextToClipboard } from '@/utils/clipboard'-import { Tag } from './tag'--type IChildrenProps = {- children: React.ReactNode- [key: string]: any-}--function ClipboardIcon(props: any) {- return (- <svg viewBox="0 0 20 20" aria-hidden="true" {...props}>- <path- strokeWidth="0"- d="M5.5 13.5v-5a2 2 0 0 1 2-2l.447-.894A2 2 0 0 1 9.737 4.5h.527a2 2 0 0 1 1.789 1.106l.447.894a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-5a2 2 0 0 1-2-2Z"- />- <path- fill="none"- strokeLinejoin="round"- d="M12.5 6.5a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-5a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2m5 0-.447-.894a2 2 0 0 0-1.79-1.106h-.527a2 2 0 0 0-1.789 1.106L7.5 6.5m5 0-1 1h-3l-1-1"- />- </svg>- )-}--function CopyButton({ code }: { code: string }) {- const [copyCount, setCopyCount] = useState(0)- const copied = copyCount > 0-- useEffect(() => {- if (copyCount > 0) {- const timeout = setTimeout(() => setCopyCount(0), 1000)- return () => {- clearTimeout(timeout)- }- }- }, [copyCount])-- return (- <button- type="button"- className={cn(- 'group/button absolute top-1.5 right-4 overflow-hidden rounded-full py-1 pr-3 pl-2 text-2xs font-medium opacity-0 backdrop-blur-sm transition group-hover:opacity-100 focus:opacity-100',- copied- ? 'bg-emerald-400/10 inset-ring-1 inset-ring-emerald-400/20'- : 'bg-white/5 hover:bg-white/7.5 dark:bg-white/2.5 dark:hover:bg-white/5',- )}- onClick={() => {- writeTextToClipboard(code).then(() => {- setCopyCount((count) => count + 1)- })- }}- >- <span- aria-hidden={copied}- className={cn(- 'pointer-events-none flex items-center gap-0.5 text-zinc-400 transition duration-300',- copied && '-translate-y-1.5 opacity-0',- )}- >- <ClipboardIcon className="size-5 fill-zinc-500/20 stroke-zinc-500 transition-colors group-hover/button:stroke-zinc-400" />- Copy- </span>- <span- aria-hidden={!copied}- className={cn(- 'pointer-events-none absolute inset-0 flex items-center justify-center text-emerald-400 transition duration-300',- !copied && 'translate-y-1.5 opacity-0',- )}- >- Copied!- </span>- </button>- )-}--function CodePanelHeader({ tag, label }: { tag?: string; label?: string }) {- if (!tag && !label) return null-- return (- <div className="flex h-9 items-center gap-2 border-y border-t-transparent border-b-white/7.5 bg-white/2.5 bg-zinc-900 px-4 dark:border-b-white/5 dark:bg-white/1">- {tag && (- <div className="dark flex">- <Tag variant="small">{tag}</Tag>- </div>- )}- {tag && label && <span className="size-0.5 rounded-full bg-zinc-500" />}- {label && <span className="font-mono text-xs text-zinc-400">{label}</span>}- </div>- )-}--type CodeExample = {- title?: string- tag?: string- code: string-}--type CodeTab = {- title: string- value: string-}--type ICodePanelProps = {- children?: React.ReactNode- tag?: string- label?: string- code?: string- title?: string- targetCode?: CodeExample-}--function CodePanel({ tag, label, children, targetCode }: ICodePanelProps) {- const child = Children.toArray(children)[0] as ReactElement<any>-- return (- <div className="group dark:bg-white/2.5">- <CodePanelHeader tag={tag} label={label} />- <div className="relative">- {/* <pre className="p-4 overflow-x-auto text-xs text-white">{children}</pre> */}- {/* <CopyButton code={child.props.code ?? code} /> */}- {/* <CopyButton code={child.props.children.props.children} /> */}- <pre className="overflow-x-auto p-4 text-xs text-white">- {targetCode?.code ? <code>{targetCode?.code}</code> : child}- </pre>- <CopyButton code={targetCode?.code ?? child.props.children.props.children} />- </div>- </div>- )-}--type CodeGroupHeaderProps = {- title?: string- tabs?: CodeTab[]-}--function CodeGroupHeader({ title, tabs }: CodeGroupHeaderProps) {- const hasTabs = (tabs?.length ?? 0) > 1-- return (- <div className="flex min-h-[calc(--spacing(12)+1px)] flex-wrap items-start gap-x-4 border-b border-zinc-700 bg-zinc-800 px-4 dark:border-zinc-800 dark:bg-transparent">- {title && <h3 className="mr-auto pt-3 text-xs font-semibold text-white">{title}</h3>}- {hasTabs && (- <TabsList className="-mb-px flex gap-4 rounded-none bg-transparent p-0 text-xs font-medium">- {tabs!.map((tab) => (- <TabsTab- key={tab.value}- value={tab.value}- className="h-auto rounded-none border-0 border-b border-transparent bg-transparent px-0 py-3 text-xs font-medium text-zinc-400 shadow-none transition hover:bg-transparent hover:text-zinc-300 focus:not-focus-visible:outline-hidden focus-visible:ring-0 data-active:border-emerald-500 data-active:bg-transparent data-active:text-emerald-400 data-active:shadow-none"- >- {tab.title}- </TabsTab>- ))}- </TabsList>- )}- </div>- )-}--type ICodeGroupPanelsProps = PropsWithChildren<{- targetCode?: CodeExample[]- tabs?: CodeTab[]- [key: string]: any-}>--function CodeGroupPanels({ children, targetCode, tabs, ...props }: ICodeGroupPanelsProps) {- if ((targetCode?.length ?? 0) > 1 && tabs) {- return (- <>- {targetCode!.map((code, index) => {- const tab = tabs[index]-- return (- <TabsPanel key={code.title || code.tag || index} value={tab?.value ?? String(index)}>- <CodePanel {...props} targetCode={code} />- </TabsPanel>- )- })}- </>- )- }-- return (- <CodePanel {...props} targetCode={targetCode?.[0]}>- {children}- </CodePanel>- )-}--function usePreventLayoutShift() {- const positionRef = useRef<any>(null)- const rafRef = useRef<any>(null)-- useEffect(() => {- return () => {- if (rafRef.current) window.cancelAnimationFrame(rafRef.current)- }- }, [])-- return {- positionRef,- preventLayoutShift(callback: () => void) {- if (!positionRef.current) {- callback()- return- }-- const initialTop = positionRef.current.getBoundingClientRect().top-- callback()-- rafRef.current = window.requestAnimationFrame(() => {- if (!positionRef.current) return-- const newTop = positionRef.current.getBoundingClientRect().top- window.scrollBy(0, newTop - initialTop)- })- },- }-}--function useTabGroupProps(tabValues: string[]) {- const [selectedValue, setSelectedValue] = useState(tabValues[0] ?? '')- const { positionRef, preventLayoutShift } = usePreventLayoutShift()- const value = tabValues.includes(selectedValue) ? selectedValue : (tabValues[0] ?? '')-- return {- ref: positionRef,- value,- onValueChange: (newValue: string | number | null) => {- if (newValue == null) return-- const nextValue = String(newValue)- if (!tabValues.includes(nextValue)) return-- preventLayoutShift(() => {- setSelectedValue(nextValue)- })- },- }-}--type CodeGroupProps = PropsWithChildren<{- /** Code example(s) to display */- targetCode?: string | CodeExample[]- /** Example block title */- title?: string- /** HTTP method tag, e.g. GET, POST */- tag?: string- /** API path */- label?: string-}>--export function CodeGroup({ children, title, targetCode, ...props }: CodeGroupProps) {- const examples =- typeof targetCode === 'string' ? ([{ code: targetCode }] as CodeExample[]) : targetCode- const tabs =- examples?.map(({ title }, index) => ({- title: title || 'Code',- value: String(index),- })) || []- const tabGroupProps = useTabGroupProps(tabs.map((tab) => tab.value))- const hasTabs = tabs.length > 1- const content = (- <>- <CodeGroupHeader title={title} tabs={hasTabs ? tabs : undefined} />- <CodeGroupPanels {...props} targetCode={examples} tabs={hasTabs ? tabs : undefined}>- {children}- </CodeGroupPanels>- </>- )-- return hasTabs ? (- <Tabs- {...tabGroupProps}- className="not-prose my-6 overflow-hidden rounded-2xl bg-zinc-900 shadow-md dark:ring-1 dark:ring-white/10"- >- {content}- </Tabs>- ) : (- <div className="not-prose my-6 overflow-hidden rounded-2xl bg-zinc-900 shadow-md dark:ring-1 dark:ring-white/10">- {content}- </div>- )-}--export function Embed({ value, ...props }: IChildrenProps) {- return <span {...props}>{value}</span>-}diff --git a/web/app/components/develop/doc.tsx b/web/app/components/develop/doc.tsxdeleted file mode 100644index d6554611c9e..00000000000--- a/web/app/components/develop/doc.tsx+++ /dev/null@@ -1,116 +0,0 @@-'use client'-import type { ComponentType } from 'react'-import type { App, AppSSO } from '@/types/app'-import { cn } from '@langgenius/dify-ui/cn'-import { useMemo } from 'react'-import { useLocale } from '@/context/i18n'-import useTheme from '@/hooks/use-theme'-import { getDocLanguage } from '@/i18n-config/language'-import { AppModeEnum, Theme } from '@/types/app'-import { useDocToc } from './hooks/use-doc-toc'-import TemplateEn from './template/template.en.mdx'-import TemplateJa from './template/template.ja.mdx'-import TemplateZh from './template/template.zh.mdx'-import TemplateAdvancedChatEn from './template/template_advanced_chat.en.mdx'-import TemplateAdvancedChatJa from './template/template_advanced_chat.ja.mdx'-import TemplateAdvancedChatZh from './template/template_advanced_chat.zh.mdx'-import TemplateChatEn from './template/template_chat.en.mdx'-import TemplateChatJa from './template/template_chat.ja.mdx'-import TemplateChatZh from './template/template_chat.zh.mdx'-import TemplateWorkflowEn from './template/template_workflow.en.mdx'-import TemplateWorkflowJa from './template/template_workflow.ja.mdx'-import TemplateWorkflowZh from './template/template_workflow.zh.mdx'-import TocPanel from './toc-panel'--type AppDetail = App & Partial<AppSSO>-type PromptVariable = { key: string; name: string }--type IDocProps = {- appDetail: AppDetail-}--// Shared props shape for all MDX template components-type TemplateProps = {- appDetail: AppDetail- variables: PromptVariable[]- inputs: Record<string, string>-}--// Lookup table: [appMode][docLanguage] → template component-// MDX components accept arbitrary props at runtime but expose a narrow static type,-// so we assert the map type to allow passing TemplateProps when rendering.-const TEMPLATE_MAP = {- [AppModeEnum.CHAT]: { zh: TemplateChatZh, ja: TemplateChatJa, en: TemplateChatEn },- [AppModeEnum.AGENT_CHAT]: { zh: TemplateChatZh, ja: TemplateChatJa, en: TemplateChatEn },- [AppModeEnum.ADVANCED_CHAT]: {- zh: TemplateAdvancedChatZh,- ja: TemplateAdvancedChatJa,- en: TemplateAdvancedChatEn,- },- [AppModeEnum.WORKFLOW]: {- zh: TemplateWorkflowZh,- ja: TemplateWorkflowJa,- en: TemplateWorkflowEn,- },- [AppModeEnum.COMPLETION]: { zh: TemplateZh, ja: TemplateJa, en: TemplateEn },-} as Record<string, Record<string, ComponentType<TemplateProps>>>--const resolveTemplate = (- mode: string | undefined,- locale: string,-): ComponentType<TemplateProps> | null => {- if (!mode) return null- const langTemplates = TEMPLATE_MAP[mode]- if (!langTemplates) return null- const docLang = getDocLanguage(locale)- return langTemplates[docLang] ?? langTemplates.en ?? null-}--const Doc = ({ appDetail }: IDocProps) => {- const locale = useLocale()- const { theme } = useTheme()- const { toc, isTocExpanded, setIsTocExpanded, activeSection, handleTocClick } = useDocToc({- appDetail,- locale,- })-- // model_config.configs.prompt_variables exists in the raw API response but is not modeled in ModelConfig type- const variables: PromptVariable[] =- (- appDetail?.model_config as unknown as- | Record<string, Record<string, PromptVariable[]>>- | undefined- )?.configs?.prompt_variables ?? []- const inputs = variables.reduce<Record<string, string>>((res, variable) => {- res[variable.key] = variable.name || ''- return res- }, {})-- const TemplateComponent = useMemo(- () => resolveTemplate(appDetail?.mode, locale),- [appDetail?.mode, locale],- )-- return (- <div className="flex">- <div- className={`fixed top-32 right-20 z-10 transition-all duration-150 ease-out ${isTocExpanded ? 'w-70' : 'w-11'}`}- >- <TocPanel- toc={toc}- activeSection={activeSection}- isTocExpanded={isTocExpanded}- onToggle={setIsTocExpanded}- onItemClick={handleTocClick}- />- </div>- <article className={cn('prose-xl prose', theme === Theme.dark && 'prose-invert')}>- {TemplateComponent && (- <TemplateComponent appDetail={appDetail} variables={variables} inputs={inputs} />- )}- </article>- </div>- )-}--export default Docdiff --git a/web/app/components/develop/hooks/__tests__/use-doc-toc.spec.tsx b/web/app/components/develop/hooks/__tests__/use-doc-toc.spec.tsxdeleted file mode 100644index aff8bad3bc8..00000000000--- a/web/app/components/develop/hooks/__tests__/use-doc-toc.spec.tsx+++ /dev/null@@ -1,134 +0,0 @@-import type { TocItem } from '../use-doc-toc'-import { act, renderHook } from '@testing-library/react'-import { useDocToc } from '../use-doc-toc'--const mockMatchMedia = (matches: boolean) => {- vi.stubGlobal(- 'matchMedia',- vi.fn().mockImplementation((query: string) => ({- matches,- media: query,- onchange: null,- addEventListener: vi.fn(),- removeEventListener: vi.fn(),- addListener: vi.fn(),- removeListener: vi.fn(),- dispatchEvent: vi.fn(),- })),- )-}--const setupDocument = () => {- document.body.innerHTML = `- <div class="overflow-auto"></div>- <article>- <h2 id="intro"><a href="#intro">Intro</a></h2>- <h2 id="details"><a href="#details">Details</a></h2>- </article>- `-- const scrollContainer = document.querySelector('.overflow-auto') as HTMLDivElement- scrollContainer.scrollTo = vi.fn()-- const intro = document.getElementById('intro') as HTMLElement- const details = document.getElementById('details') as HTMLElement-- Object.defineProperty(intro, 'offsetTop', { configurable: true, value: 140 })- Object.defineProperty(details, 'offsetTop', { configurable: true, value: 320 })-- return {- scrollContainer,- intro,- details,- }-}--describe('useDocToc', () => {- beforeEach(() => {- vi.clearAllMocks()- vi.useFakeTimers()- document.body.innerHTML = ''- mockMatchMedia(false)- })-- afterEach(() => {- vi.useRealTimers()- vi.unstubAllGlobals()- })-- it('should extract headings and expand the TOC on wide screens', async () => {- setupDocument()- mockMatchMedia(true)-- const { result } = renderHook(() =>- useDocToc({- appDetail: { id: 'app-1' },- locale: 'en',- }),- )-- act(() => {- vi.runAllTimers()- })-- expect(result.current.toc).toEqual<TocItem[]>([- { href: '#intro', text: 'Intro' },- { href: '#details', text: 'Details' },- ])- expect(result.current.activeSection).toBe('intro')- expect(result.current.isTocExpanded).toBe(true)- })-- it('should update the active section when the scroll container scrolls', async () => {- const { scrollContainer, intro, details } = setupDocument()- Object.defineProperty(window, 'innerHeight', { configurable: true, value: 800 })-- intro.getBoundingClientRect = vi.fn(() => ({ top: 500 }) as DOMRect)- details.getBoundingClientRect = vi.fn(() => ({ top: 300 }) as DOMRect)-- const { result } = renderHook(() =>- useDocToc({- appDetail: { id: 'app-1' },- locale: 'en',- }),- )-- act(() => {- vi.runAllTimers()- })-- act(() => {- scrollContainer.dispatchEvent(new Event('scroll'))- })-- expect(result.current.activeSection).toBe('details')- })-- it('should scroll the container to the clicked heading offset', async () => {- const { scrollContainer } = setupDocument()- const { result } = renderHook(() =>- useDocToc({- appDetail: { id: 'app-1' },- locale: 'en',- }),- )-- act(() => {- vi.runAllTimers()- })-- const preventDefault = vi.fn()- act(() => {- result.current.handleTocClick(- { preventDefault } as unknown as React.MouseEvent<HTMLAnchorElement>,- { href: '#details', text: 'Details' },- )- })-- expect(preventDefault).toHaveBeenCalledTimes(1)- expect(scrollContainer.scrollTo).toHaveBeenCalledWith({- top: 240,- behavior: 'smooth',- })- })-})diff --git a/web/app/components/develop/hooks/use-doc-toc.ts b/web/app/components/develop/hooks/use-doc-toc.tsdeleted file mode 100644index 38c6b19b020..00000000000--- a/web/app/components/develop/hooks/use-doc-toc.ts+++ /dev/null@@ -1,107 +0,0 @@-import { useCallback, useEffect, useState } from 'react'--export type TocItem = {- href: string- text: string-}--type UseDocTocOptions = {- appDetail: Record<string, unknown> | null- locale: string-}--const HEADER_OFFSET = 80-const SCROLL_CONTAINER_SELECTOR = '.overflow-auto'--const getTargetId = (href: string) => href.replace('#', '')--/**- * Extract heading anchors from the rendered <article> as TOC items.- */-const extractTocFromArticle = (): TocItem[] => {- const article = document.querySelector('article')- if (!article) return []-- return Array.from(article.querySelectorAll('h2'))- .map((heading) => {- const anchor = heading.querySelector('a')- if (!anchor) return null- return {- href: anchor.getAttribute('href') || '',- text: anchor.textContent || '',- }- })- .filter((item): item is TocItem => item !== null)-}--/**- * Custom hook that manages table-of-contents state:- * - Extracts TOC items from rendered headings- * - Tracks the active section on scroll- * - Auto-expands the panel on wide viewports- */-export const useDocToc = ({ appDetail, locale }: UseDocTocOptions) => {- const [toc, setToc] = useState<TocItem[]>([])- const [isTocExpanded, setIsTocExpanded] = useState(() => {- if (typeof window === 'undefined') return false- return window.matchMedia('(min-width: 1280px)').matches- })- const [activeSection, setActiveSection] = useState<string>('')-- // Re-extract TOC items whenever the doc content changes- useEffect(() => {- const timer = setTimeout(() => {- const tocItems = extractTocFromArticle()- setToc(tocItems)- if (tocItems.length > 0) setActiveSection(getTargetId(tocItems[0]!.href))- }, 0)- return () => clearTimeout(timer)- }, [appDetail, locale])-- // Track active section based on scroll position- useEffect(() => {- const scrollContainer = document.querySelector(SCROLL_CONTAINER_SELECTOR)- if (!scrollContainer || toc.length === 0) return-- const handleScroll = () => {- let currentSection = ''- for (const item of toc) {- const targetId = getTargetId(item.href)- const element = document.getElementById(targetId)- if (element) {- const rect = element.getBoundingClientRect()- if (rect.top <= window.innerHeight / 2) currentSection = targetId- }- }-- if (currentSection && currentSection !== activeSection) setActiveSection(currentSection)- }-- scrollContainer.addEventListener('scroll', handleScroll)- return () => scrollContainer.removeEventListener('scroll', handleScroll)- }, [toc, activeSection])-- // Smooth-scroll to a TOC target on click- const handleTocClick = useCallback((e: React.MouseEvent<HTMLAnchorElement>, item: TocItem) => {- e.preventDefault()- const targetId = getTargetId(item.href)- const element = document.getElementById(targetId)- if (!element) return-- const scrollContainer = document.querySelector(SCROLL_CONTAINER_SELECTOR)- if (scrollContainer) {- scrollContainer.scrollTo({- top: element.offsetTop - HEADER_OFFSET,- behavior: 'smooth',- })- }- }, [])-- return {- toc,- isTocExpanded,- setIsTocExpanded,- activeSection,- handleTocClick,- }-}diff --git a/web/app/components/develop/index.tsx b/web/app/components/develop/index.tsxdeleted file mode 100644index f282c00a685..00000000000--- a/web/app/components/develop/index.tsx+++ /dev/null@@ -1,55 +0,0 @@-'use client'--import { useSuspenseQuery } from '@tanstack/react-query'-import { useAtomValue } from 'jotai'-import { useStore as useAppStore } from '@/app/components/app/store'-import Loading from '@/app/components/base/loading'-import ApiServer from '@/app/components/develop/ApiServer'-import Doc from '@/app/components/develop/doc'-import { workspacePermissionKeysAtom } from '@/context/permission-state'-import { userProfileQueryOptions } from '@/features/account-profile/client'-import { getAppACLCapabilities } from '@/utils/permission'--type IDevelopMainProps = {- appId: string-}--const DevelopMain = ({ appId }: IDevelopMainProps) => {- const appDetail = useAppStore((state) => state.appDetail)- const { data: currentUserId } = useSuspenseQuery({- ...userProfileQueryOptions(),- select: (data) => data.profile.id,- })- const workspacePermissionKeys = useAtomValue(workspacePermissionKeysAtom)- const appACLCapabilities = getAppACLCapabilities(appDetail?.permission_keys, {- currentUserId,- resourceMaintainer: appDetail?.maintainer,- workspacePermissionKeys,- })-- if (!appDetail) {- return (- <div className="flex h-full items-center justify-center bg-background-default">- <Loading />- </div>- )- }-- return (- <div data-testid="develop-main" className="relative flex h-full flex-col overflow-hidden">- <div className="flex shrink-0 items-center justify-between border-b border-solid border-b-divider-regular px-6 py-2">- <div className="text-lg font-medium text-text-primary"></div>- <ApiServer- apiBaseUrl={appDetail.api_base_url}- appId={appId}- canManageApiKey={appACLCapabilities.canReleaseAndVersion}- />- </div>- <div className="grow overflow-auto p-4 sm:px-10">- <Doc appDetail={appDetail} />- </div>- </div>- )-}--export default DevelopMaindiff --git a/web/app/components/develop/md.tsx b/web/app/components/develop/md.tsxdeleted file mode 100644index e870cb98780..00000000000--- a/web/app/components/develop/md.tsx+++ /dev/null@@ -1,137 +0,0 @@-'use client'-import { cn } from '@langgenius/dify-ui/cn'--type IChildrenProps = {- children: React.ReactNode- id?: string- tag?: any- label?: any- anchor: boolean-}--type IHeaderingProps = {- url: string- method: 'PUT' | 'DELETE' | 'GET' | 'POST' | 'PATCH'- title: string- name: string- titleAction?: React.ReactNode-}--export const Heading = function H2({ url, method, title, name, titleAction }: IHeaderingProps) {- let style = ''- switch (method) {- case 'PUT':- style =- 'ring-amber-300 bg-amber-400/10 text-amber-500 dark:ring-amber-400/30 dark:bg-amber-400/10 dark:text-amber-400'- break- case 'DELETE':- style =- 'ring-rose-200 bg-rose-50 text-red-500 dark:ring-rose-500/20 dark:bg-rose-400/10 dark:text-rose-400'- break- case 'POST':- style =- 'ring-sky-300 bg-sky-400/10 text-sky-500 dark:ring-sky-400/30 dark:bg-sky-400/10 dark:text-sky-400'- break- case 'PATCH':- style =- 'ring-violet-300 bg-violet-400/10 text-violet-500 dark:ring-violet-400/30 dark:bg-violet-400/10 dark:text-violet-400'- break- default:- style =- 'ring-emerald-300 dark:ring-emerald-400/30 bg-emerald-400/10 text-emerald-500 dark:text-emerald-400'- break- }- return (- <>- <span id={name?.replace(/^#/, '')} className="relative -top-28" />- <div className="flex items-center gap-x-3">- <span- className={`rounded-lg px-1.5 font-mono text-2xs/6 font-semibold ring-1 ring-inset ${style}`}- >- {method}- </span>- {/* <span className="h-0.5 w-0.5 rounded-full bg-zinc-300 dark:bg-zinc-600"></span> */}- <span className="font-mono text-xs text-zinc-400">{url}</span>- </div>- <h2 className={cn('mt-2 scroll-mt-32', titleAction && 'flex items-center gap-x-2')}>- <a href={name} className="group text-inherit no-underline hover:text-inherit">- {title}- </a>- {titleAction}- </h2>- </>- )-}--export function Row({ children }: IChildrenProps) {- return (- <div className="grid grid-cols-1 items-start gap-x-16 gap-y-10 xl:max-w-none! xl:grid-cols-2">- {children}- </div>- )-}--type IColProps = IChildrenProps & {- sticky: boolean-}-export function Col({ children, sticky = false }: IColProps) {- return (- <div className={cn('*:first:mt-0 *:last:mb-0', sticky && 'xl:sticky xl:top-24')}>- {children}- </div>- )-}--export function Properties({ children }: IChildrenProps) {- return (- <div className="my-6">- <ul className="m-0 max-w-[calc(var(--container-lg)-(--spacing(8)))] list-none divide-y divide-zinc-900/5 p-0 dark:divide-white/5">- {children}- </ul>- </div>- )-}--type IProperty = IChildrenProps & {- name: string- type: string- nameAction?: React.ReactNode-}-export function Property({ name, type, nameAction, children }: IProperty) {- return (- <li className="m-0 px-0 py-4 first:pt-0 last:pb-0">- <dl className="m-0 flex flex-wrap items-center gap-x-3 gap-y-2">- <dt className="sr-only">Name</dt>- <dd>- <code>{name}</code>- {nameAction ? <span className="ml-2 inline-flex align-middle">{nameAction}</span> : null}- </dd>- <dt className="sr-only">Type</dt>- <dd className="font-mono text-xs text-zinc-400 dark:text-zinc-500">{type}</dd>- <dt className="sr-only">Description</dt>- <dd className="w-full flex-none *:first:mt-0 *:last:mb-0">{children}</dd>- </dl>- </li>- )-}--type ISubProperty = IChildrenProps & {- name: string- type: string-}-export function SubProperty({ name, type, children }: ISubProperty) {- return (- <li className="m-0 px-0 py-1 last:pb-0">- <dl className="m-0 flex flex-wrap items-center gap-x-3">- <dt className="sr-only">Name</dt>- <dd>- <code>{name}</code>- </dd>- <dt className="sr-only">Type</dt>- <dd className="font-mono text-xs text-zinc-400 dark:text-zinc-500">{type}</dd>- <dt className="sr-only">Description</dt>- <dd className="w-full flex-none *:first:mt-0 *:last:mb-0">{children}</dd>- </dl>- </li>- )-}diff --git a/web/app/components/develop/secret-key/__tests__/input-copy.spec.tsx b/web/app/components/develop/secret-key/__tests__/input-copy.spec.tsxdeleted file mode 100644index 44bc7ebc774..00000000000--- a/web/app/components/develop/secret-key/__tests__/input-copy.spec.tsx+++ /dev/null@@ -1,297 +0,0 @@-import { act, render, screen } from '@testing-library/react'-import userEvent from '@testing-library/user-event'-import InputCopy from '../input-copy'--async function renderAndFlush(ui: React.ReactElement) {- const result = render(ui)- await act(async () => {- vi.runAllTimers()- })- return result-}--const execCommandMock = vi.fn().mockReturnValue(true)--describe('InputCopy', () => {- beforeEach(() => {- vi.clearAllMocks()- vi.spyOn(console, 'error').mockImplementation(() => {})- vi.useFakeTimers({ shouldAdvanceTime: true })- execCommandMock.mockReturnValue(true)- document.execCommand = execCommandMock- })-- afterEach(() => {- vi.runOnlyPendingTimers()- vi.useRealTimers()- vi.restoreAllMocks()- })-- describe('rendering', () => {- it('should render the value', async () => {- await renderAndFlush(<InputCopy value="test-api-key-12345" />)- expect(screen.getByText('test-api-key-12345')).toBeInTheDocument()- })-- it('should render with empty value by default', async () => {- await renderAndFlush(<InputCopy />)- expect(screen.getAllByRole('button').length).toBeGreaterThan(0)- })-- it('should render children when provided', async () => {- await renderAndFlush(- <InputCopy value="key">- <span data-testid="custom-child">Custom Content</span>- </InputCopy>,- )- expect(screen.getByTestId('custom-child')).toBeInTheDocument()- })-- it('should render CopyFeedback component', async () => {- await renderAndFlush(<InputCopy value="test" />)- const buttons = screen.getAllByRole('button')- expect(buttons.length).toBeGreaterThan(0)- })- })-- describe('styling', () => {- it('should have flex layout', async () => {- const { container } = await renderAndFlush(<InputCopy value="test" />)- const wrapper = container.firstChild as HTMLElement- expect(wrapper.className).toContain('flex')- })-- it('should have items-center alignment', async () => {- const { container } = await renderAndFlush(<InputCopy value="test" />)- const wrapper = container.firstChild as HTMLElement- expect(wrapper.className).toContain('items-center')- })-- it('should have hover state', async () => {- const { container } = await renderAndFlush(<InputCopy value="test" />)- const wrapper = container.firstChild as HTMLElement- expect(wrapper.className).toContain('hover:bg-state-base-hover')- })-- it('should have py-2 padding', async () => {- const { container } = await renderAndFlush(<InputCopy value="test" />)- const wrapper = container.firstChild as HTMLElement- expect(wrapper.className).toContain('py-2')- })- })-- describe('copy functionality', () => {- it('should copy value when clicked', async () => {- const user = userEvent.setup({ advanceTimers: vi.advanceTimersByTime })- await renderAndFlush(<InputCopy value="copy-this-value" />)-- const copyableArea = screen.getByText('copy-this-value')- await act(async () => {- await user.click(copyableArea)- })-- expect(execCommandMock).toHaveBeenCalledWith('copy')- })-- it('should update copied state after clicking', async () => {- const user = userEvent.setup({ advanceTimers: vi.advanceTimersByTime })- await renderAndFlush(<InputCopy value="test-value" />)-- const copyableArea = screen.getByText('test-value')- await act(async () => {- await user.click(copyableArea)- })-- expect(execCommandMock).toHaveBeenCalledWith('copy')- })-- it('should reset copied state after timeout', async () => {- const user = userEvent.setup({ advanceTimers: vi.advanceTimersByTime })- await renderAndFlush(<InputCopy value="test-value" />)-- const copyableArea = screen.getByText('test-value')- await act(async () => {- await user.click(copyableArea)- })-- expect(execCommandMock).toHaveBeenCalledWith('copy')-- await act(async () => {- vi.advanceTimersByTime(1500)- })-- expect(screen.getByText('test-value')).toBeInTheDocument()- })-- it('should render tooltip on value', async () => {- await renderAndFlush(<InputCopy value="test-value" />)- const valueText = screen.getByText('test-value')- expect(valueText).toBeInTheDocument()- })- })-- describe('tooltip', () => {- it('should render tooltip wrapper', async () => {- await renderAndFlush(<InputCopy value="test" />)- const valueText = screen.getByText('test')- expect(valueText).toBeInTheDocument()- })-- it('should have cursor-pointer on clickable area', async () => {- await renderAndFlush(<InputCopy value="test" />)- const valueText = screen.getByText('test')- const clickableArea = valueText.closest('button')- expect(clickableArea).toBeInTheDocument()- expect(clickableArea?.className).toContain('cursor-pointer')- })- })-- describe('divider', () => {- it('should render vertical divider', async () => {- const { container } = await renderAndFlush(<InputCopy value="test" />)- const divider = container.querySelector('.bg-divider-regular')- expect(divider).toBeInTheDocument()- })-- it('should have correct divider dimensions', async () => {- const { container } = await renderAndFlush(<InputCopy value="test" />)- const divider = container.querySelector('.bg-divider-regular')- expect(divider?.className).toContain('h-4')- expect(divider?.className).toContain('w-px')- })-- it('should have shrink-0 on divider', async () => {- const { container } = await renderAndFlush(<InputCopy value="test" />)- const divider = container.querySelector('.bg-divider-regular')- expect(divider?.className).toContain('shrink-0')- })- })-- describe('value display', () => {- it('should have truncate class for long values', async () => {- await renderAndFlush(<InputCopy value="very-long-api-key-value-that-might-overflow" />)- const valueText = screen.getByText('very-long-api-key-value-that-might-overflow')- const container = valueText.closest('button')- expect(container).toBeInTheDocument()- })-- it('should have text-secondary color on value', async () => {- await renderAndFlush(<InputCopy value="test-value" />)- const valueText = screen.getByText('test-value')- expect(valueText.className).toContain('text-text-secondary')- })-- it('should have absolute positioning for overlay', async () => {- await renderAndFlush(<InputCopy value="test" />)- const valueText = screen.getByText('test')- const container = valueText.closest('button')- expect(container).toBeInTheDocument()- expect(container?.className).toContain('absolute')- })- })-- describe('inner container', () => {- it('should have grow class on inner container', async () => {- const { container } = await renderAndFlush(<InputCopy value="test" />)- const innerContainer = container.querySelector('.grow')- expect(innerContainer).toBeInTheDocument()- })-- it('should have h-5 height on inner container', async () => {- const { container } = await renderAndFlush(<InputCopy value="test" />)- const innerContainer = container.querySelector('.h-5')- expect(innerContainer).toBeInTheDocument()- })- })-- describe('with children', () => {- it('should render children before value', async () => {- const { container } = await renderAndFlush(- <InputCopy value="key">- <span data-testid="prefix">Prefix:</span>- </InputCopy>,- )- const children = container.querySelector('[data-testid="prefix"]')- expect(children).toBeInTheDocument()- })-- it('should render both children and value', async () => {- await renderAndFlush(- <InputCopy value="api-key">- <span>Label:</span>- </InputCopy>,- )- expect(screen.getByText('Label:')).toBeInTheDocument()- expect(screen.getByText('api-key')).toBeInTheDocument()- })- })-- describe('CopyFeedback section', () => {- it('should have margin on CopyFeedback container', async () => {- const { container } = await renderAndFlush(<InputCopy value="test" />)- const copyFeedbackContainer = container.querySelector('.mx-1')- expect(copyFeedbackContainer).toBeInTheDocument()- })- })-- describe('relative container', () => {- it('should have relative positioning on value container', async () => {- const { container } = await renderAndFlush(<InputCopy value="test" />)- const relativeContainer = container.querySelector('.relative')- expect(relativeContainer).toBeInTheDocument()- })-- it('should have grow on value container', async () => {- const { container } = await renderAndFlush(<InputCopy value="test" />)- const valueContainer = container.querySelector('.relative.grow')- expect(valueContainer).toBeInTheDocument()- })-- it('should have full height on value container', async () => {- const { container } = await renderAndFlush(<InputCopy value="test" />)- const valueContainer = container.querySelector('.relative.h-full')- expect(valueContainer).toBeInTheDocument()- })- })-- describe('edge cases', () => {- it('should handle undefined value', async () => {- await renderAndFlush(<InputCopy value={undefined} />)- expect(screen.getAllByRole('button').length).toBeGreaterThan(0)- })-- it('should handle empty string value', async () => {- await renderAndFlush(<InputCopy value="" />)- expect(screen.getAllByRole('button').length).toBeGreaterThan(0)- })-- it('should handle very long values', async () => {- const longValue = 'a'.repeat(500)- await renderAndFlush(<InputCopy value={longValue} />)- expect(screen.getByText(longValue)).toBeInTheDocument()- })-- it('should handle special characters in value', async () => {- const specialValue = 'key-with-special-chars!@#$%^&*()'- await renderAndFlush(<InputCopy value={specialValue} />)- expect(screen.getByText(specialValue)).toBeInTheDocument()- })- })-- describe('multiple clicks', () => {- it('should handle multiple rapid clicks', async () => {- const user = userEvent.setup({ advanceTimers: vi.advanceTimersByTime })- await renderAndFlush(<InputCopy value="test" />)-- const copyableArea = screen.getByText('test')-- await act(async () => {- await user.click(copyableArea)- await user.click(copyableArea)- await user.click(copyableArea)- })-- expect(execCommandMock).toHaveBeenCalledTimes(3)- })- })-})diff --git a/web/app/components/develop/secret-key/__tests__/secret-key-button.spec.tsx b/web/app/components/develop/secret-key/__tests__/secret-key-button.spec.tsxdeleted file mode 100644index 9b6772351ed..00000000000--- a/web/app/components/develop/secret-key/__tests__/secret-key-button.spec.tsx+++ /dev/null@@ -1,260 +0,0 @@-import type { SecretKeyScope } from '../secret-key-modal'-import { act, render, screen } from '@testing-library/react'-import userEvent from '@testing-library/user-event'-import SecretKeyButton from '../secret-key-button'--vi.mock('@/app/components/develop/secret-key/secret-key-modal', () => ({- default: ({- isShow,- onClose,- canManage,- scope,- }: {- isShow: boolean- onClose: () => void- canManage: boolean- scope: SecretKeyScope- }) =>- isShow ? (- <div data-testid="secret-key-modal">- <span>{`Modal for ${scope.type === 'dataset' ? 'no-app' : scope.appId}`}</span>- <span data-testid="modal-can-manage">{String(canManage)}</span>- <button onClick={onClose} data-testid="close-modal">- Close- </button>- </div>- ) : null,-}))--describe('SecretKeyButton', () => {- describe('rendering', () => {- it('should render the button', () => {- render(<SecretKeyButton />)- expect(screen.getByRole('button'))!.toBeInTheDocument()- })-- it('should render the API key text', () => {- render(<SecretKeyButton />)- expect(screen.getByText('appApi.apiKey'))!.toBeInTheDocument()- })-- it('should render the key icon', () => {- const { container } = render(<SecretKeyButton />)- const icon = container.querySelector('.i-ri-key-2-line')- expect(icon)!.toBeInTheDocument()- })-- it('should not show modal initially', () => {- render(<SecretKeyButton />)- expect(screen.queryByTestId('secret-key-modal')).not.toBeInTheDocument()- })- })-- describe('button interaction', () => {- it('should open modal when button is clicked', async () => {- const user = userEvent.setup()- render(<SecretKeyButton canManage />)-- const button = screen.getByRole('button')- await act(async () => {- await user.click(button)- })-- expect(screen.getByTestId('secret-key-modal'))!.toBeInTheDocument()- })-- it('should close modal when onClose is called', async () => {- const user = userEvent.setup()- render(<SecretKeyButton canManage />)-- const button = screen.getByRole('button')- await act(async () => {- await user.click(button)- })-- expect(screen.getByTestId('secret-key-modal'))!.toBeInTheDocument()-- const closeButton = screen.getByTestId('close-modal')- await act(async () => {- await user.click(closeButton)- })-- expect(screen.queryByTestId('secret-key-modal')).not.toBeInTheDocument()- })-- it('should toggle modal visibility', async () => {- const user = userEvent.setup()- render(<SecretKeyButton canManage />)-- const button = screen.getByRole('button')-- await act(async () => {- await user.click(button)- })- expect(screen.getByTestId('secret-key-modal'))!.toBeInTheDocument()-- const closeButton = screen.getByTestId('close-modal')- await act(async () => {- await user.click(closeButton)- })- expect(screen.queryByTestId('secret-key-modal')).not.toBeInTheDocument()-- await act(async () => {- await user.click(button)- })- expect(screen.getByTestId('secret-key-modal'))!.toBeInTheDocument()- })- })-- describe('props', () => {- it('should pass appId to modal', async () => {- const user = userEvent.setup()- render(<SecretKeyButton appId="app-123" canManage />)-- const button = screen.getByRole('button')- await act(async () => {- await user.click(button)- })-- expect(screen.getByText('Modal for app-123'))!.toBeInTheDocument()- })-- it('should handle undefined appId', async () => {- const user = userEvent.setup()- render(<SecretKeyButton canManage />)-- const button = screen.getByRole('button')- await act(async () => {- await user.click(button)- })-- expect(screen.getByText('Modal for no-app'))!.toBeInTheDocument()- })-- it('should pass canManage to modal', async () => {- const user = userEvent.setup()- render(<SecretKeyButton appId="app-123" canManage />)-- const button = screen.getByRole('button')- await act(async () => {- await user.click(button)- })-- expect(screen.getByTestId('modal-can-manage')).toHaveTextContent('true')- })-- it('should disable the button and keep modal closed when canManage is false', async () => {- const user = userEvent.setup()- render(<SecretKeyButton appId="app-123" canManage={false} />)-- const button = screen.getByRole('button')- expect(button).toBeDisabled()-- await act(async () => {- await user.click(button)- })-- expect(screen.queryByTestId('secret-key-modal')).not.toBeInTheDocument()- })-- it('should disable the button by default when canManage is omitted', () => {- render(<SecretKeyButton appId="app-123" />)-- expect(screen.getByRole('button')).toBeDisabled()- })-- it('should apply custom textCls', () => {- render(<SecretKeyButton textCls="custom-text-class" />)- const text = screen.getByText('appApi.apiKey')- expect(text.className).toContain('custom-text-class')- })- })-- describe('modal props', () => {- it('should pass isShow prop to modal', async () => {- const user = userEvent.setup()- render(<SecretKeyButton canManage />)-- expect(screen.queryByTestId('secret-key-modal')).not.toBeInTheDocument()-- const button = screen.getByRole('button')- await act(async () => {- await user.click(button)- })-- expect(screen.getByTestId('secret-key-modal'))!.toBeInTheDocument()- })-- it('should pass onClose callback to modal', async () => {- const user = userEvent.setup()- render(<SecretKeyButton canManage />)-- const button = screen.getByRole('button')- await act(async () => {- await user.click(button)- })-- const closeButton = screen.getByTestId('close-modal')- await act(async () => {- await user.click(closeButton)- })-- expect(screen.queryByTestId('secret-key-modal')).not.toBeInTheDocument()- })- })-- describe('accessibility', () => {- it('should have accessible button', () => {- render(<SecretKeyButton />)- const button = screen.getByRole('button')- expect(button)!.toBeInTheDocument()- })-- it('should be keyboard accessible', async () => {- const user = userEvent.setup()- render(<SecretKeyButton canManage />)-- const button = screen.getByRole('button')- button.focus()- expect(document.activeElement).toBe(button)-- await act(async () => {- await user.keyboard('{Enter}')- })-- expect(screen.getByTestId('secret-key-modal'))!.toBeInTheDocument()- })- })-- describe('multiple instances', () => {- it('should work independently when multiple instances exist', async () => {- const user = userEvent.setup()- render(- <>- <SecretKeyButton appId="app-1" canManage />- <SecretKeyButton appId="app-2" canManage />- </>,- )-- const buttons = screen.getAllByRole('button')- expect(buttons).toHaveLength(2)-- await act(async () => {- await user.click(buttons[0]!)- })-- expect(screen.getByText('Modal for app-1'))!.toBeInTheDocument()-- const closeButton = screen.getByTestId('close-modal')- await act(async () => {- await user.click(closeButton)- })-- await act(async () => {- await user.click(buttons[1]!)- })-- expect(screen.getByText('Modal for app-2'))!.toBeInTheDocument()- })- })-})diff --git a/web/app/components/develop/secret-key/__tests__/secret-key-generate.spec.tsx b/web/app/components/develop/secret-key/__tests__/secret-key-generate.spec.tsxdeleted file mode 100644index b332defdbbe..00000000000--- a/web/app/components/develop/secret-key/__tests__/secret-key-generate.spec.tsx+++ /dev/null@@ -1,235 +0,0 @@-import type { ApiKeyItem } from '@dify/contracts/api/console/apps/types.gen'-import { act, render, screen } from '@testing-library/react'-import userEvent from '@testing-library/user-event'-import SecretKeyGenerateModal from '../secret-key-generate'--const createMockApiKey = (token: string): Pick<ApiKeyItem, 'token'> => ({- token,-})--async function renderModal(ui: React.ReactElement) {- const result = render(ui)- await act(async () => {- vi.runAllTimers()- })- return result-}--describe('SecretKeyGenerateModal', () => {- const defaultProps = {- isShow: true,- onClose: vi.fn(),- }-- beforeEach(() => {- vi.clearAllMocks()- vi.useFakeTimers({ shouldAdvanceTime: true })- })-- afterEach(() => {- vi.runOnlyPendingTimers()- vi.useRealTimers()- })-- describe('rendering when shown', () => {- it('should render the modal when isShow is true', async () => {- await renderModal(<SecretKeyGenerateModal {...defaultProps} />)- expect(screen.getByText('appApi.apiKeyModal.apiSecretKey')).toBeInTheDocument()- })-- it('should render the generate tips text', async () => {- await renderModal(<SecretKeyGenerateModal {...defaultProps} />)- expect(screen.getByText('appApi.apiKeyModal.generateTips')).toBeInTheDocument()- })-- it('should render the OK button', async () => {- await renderModal(<SecretKeyGenerateModal {...defaultProps} />)- expect(screen.getByText('appApi.actionMsg.ok')).toBeInTheDocument()- })-- it('should render the close icon', async () => {- await renderModal(<SecretKeyGenerateModal {...defaultProps} />)- expect(screen.getByRole('button', { name: 'common.operation.close' })).toBeInTheDocument()- })-- it('should render InputCopy component', async () => {- await renderModal(- <SecretKeyGenerateModal {...defaultProps} newKey={createMockApiKey('test-token-123')} />,- )- expect(screen.getByText('test-token-123')).toBeInTheDocument()- })- })-- describe('rendering when hidden', () => {- it('should not render content when isShow is false', async () => {- await renderModal(<SecretKeyGenerateModal {...defaultProps} isShow={false} />)- expect(screen.queryByText('appApi.apiKeyModal.apiSecretKey')).not.toBeInTheDocument()- })- })-- describe('newKey prop', () => {- it('should display the token when newKey is provided', async () => {- await renderModal(- <SecretKeyGenerateModal {...defaultProps} newKey={createMockApiKey('sk-abc123xyz')} />,- )- expect(screen.getByText('sk-abc123xyz')).toBeInTheDocument()- })-- it('should handle undefined newKey', async () => {- await renderModal(<SecretKeyGenerateModal {...defaultProps} newKey={undefined} />)- expect(screen.getByText('appApi.apiKeyModal.apiSecretKey')).toBeInTheDocument()- })-- it('should handle newKey with empty token', async () => {- await renderModal(<SecretKeyGenerateModal {...defaultProps} newKey={createMockApiKey('')} />)- expect(screen.getByText('appApi.apiKeyModal.apiSecretKey')).toBeInTheDocument()- })-- it('should display long tokens correctly', async () => {- const longToken = `sk-${'a'.repeat(100)}`- await renderModal(- <SecretKeyGenerateModal {...defaultProps} newKey={createMockApiKey(longToken)} />,- )- expect(screen.getByText(longToken)).toBeInTheDocument()- })- })-- describe('close functionality', () => {- it('should call onClose when X icon is clicked', async () => {- const user = userEvent.setup({ advanceTimers: vi.advanceTimersByTime })- const onClose = vi.fn()- await renderModal(<SecretKeyGenerateModal {...defaultProps} onClose={onClose} />)-- await user.click(screen.getByRole('button', { name: 'common.operation.close' }))-- expect(onClose).toHaveBeenCalled()- })-- it('should call onClose when OK button is clicked', async () => {- const user = userEvent.setup({ advanceTimers: vi.advanceTimersByTime })- const onClose = vi.fn()- await renderModal(<SecretKeyGenerateModal {...defaultProps} onClose={onClose} />)-- const okButton = screen.getByRole('button', { name: /ok/i })- await act(async () => {- await user.click(okButton)- })-- expect(onClose).toHaveBeenCalled()- })- })-- describe('modal styling', () => {- it('should have px-8 padding', async () => {- await renderModal(<SecretKeyGenerateModal {...defaultProps} />)- const modal = document.body.querySelector('.px-8')- expect(modal).toBeInTheDocument()- })- })-- describe('tips text styling', () => {- it('should have mt-1 margin on tips', async () => {- await renderModal(<SecretKeyGenerateModal {...defaultProps} />)- const tips = screen.getByText('appApi.apiKeyModal.generateTips')- expect(tips.className).toContain('mt-1')- })-- it('should have correct font size', async () => {- await renderModal(<SecretKeyGenerateModal {...defaultProps} />)- const tips = screen.getByText('appApi.apiKeyModal.generateTips')- expect(tips.className).toContain('text-[13px]')- })-- it('should have normal font weight', async () => {- await renderModal(<SecretKeyGenerateModal {...defaultProps} />)- const tips = screen.getByText('appApi.apiKeyModal.generateTips')- expect(tips.className).toContain('font-normal')- })-- it('should have leading-5 line height', async () => {- await renderModal(<SecretKeyGenerateModal {...defaultProps} />)- const tips = screen.getByText('appApi.apiKeyModal.generateTips')- expect(tips.className).toContain('leading-5')- })-- it('should have tertiary text color', async () => {- await renderModal(<SecretKeyGenerateModal {...defaultProps} />)- const tips = screen.getByText('appApi.apiKeyModal.generateTips')- expect(tips.className).toContain('text-text-tertiary')- })- })-- describe('InputCopy section', () => {- it('should render InputCopy with token value', async () => {- await renderModal(- <SecretKeyGenerateModal {...defaultProps} newKey={createMockApiKey('test-token')} />,- )- expect(screen.getByText('test-token')).toBeInTheDocument()- })-- it('should have w-full class on InputCopy', async () => {- await renderModal(- <SecretKeyGenerateModal {...defaultProps} newKey={createMockApiKey('test')} />,- )- const inputText = screen.getByText('test')- const inputContainer = inputText.closest('.w-full')- expect(inputContainer).toBeInTheDocument()- })- })-- describe('OK button section', () => {- it('should render OK button', async () => {- await renderModal(<SecretKeyGenerateModal {...defaultProps} />)- const button = screen.getByRole('button', { name: /ok/i })- expect(button).toBeInTheDocument()- })-- it('should have button container with flex layout', async () => {- await renderModal(<SecretKeyGenerateModal {...defaultProps} />)- const button = screen.getByRole('button', { name: /ok/i })- const container = button.parentElement- expect(container).toBeInTheDocument()- expect(container?.className).toContain('flex')- })-- it('should have shrink-0 on button', async () => {- await renderModal(<SecretKeyGenerateModal {...defaultProps} />)- const button = screen.getByRole('button', { name: /ok/i })- expect(button.className).toContain('shrink-0')- })- })-- describe('button text styling', () => {- it('should have text-xs font size on button text', async () => {- await renderModal(<SecretKeyGenerateModal {...defaultProps} />)- const buttonText = screen.getByText('appApi.actionMsg.ok')- expect(buttonText.className).toContain('text-xs')- })-- it('should have font-medium on button text', async () => {- await renderModal(<SecretKeyGenerateModal {...defaultProps} />)- const buttonText = screen.getByText('appApi.actionMsg.ok')- expect(buttonText.className).toContain('font-medium')- })-- it('should have secondary text color on button text', async () => {- await renderModal(<SecretKeyGenerateModal {...defaultProps} />)- const buttonText = screen.getByText('appApi.actionMsg.ok')- expect(buttonText.className).toContain('text-text-secondary')- })- })-- describe('default prop values', () => {- it('should default isShow to false', async () => {- await renderModal(<SecretKeyGenerateModal isShow={false} onClose={vi.fn()} />)- expect(screen.queryByText('appApi.apiKeyModal.apiSecretKey')).not.toBeInTheDocument()- })- })-- describe('modal title', () => {- it('should display the correct title', async () => {- await renderModal(<SecretKeyGenerateModal {...defaultProps} />)- expect(screen.getByText('appApi.apiKeyModal.apiSecretKey')).toBeInTheDocument()- })- })-})diff --git a/web/app/components/develop/secret-key/assets/copied.svg b/web/app/components/develop/secret-key/assets/copied.svgdeleted file mode 100644index de5f86cc197..00000000000--- a/web/app/components/develop/secret-key/assets/copied.svg+++ /dev/null@@ -1,3 +0,0 @@-<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">- <path d="M10.6665 2.66683C11.2865 2.66683 11.5965 2.66683 11.8508 2.73498C12.541 2.91991 13.0801 3.45901 13.265 4.14919C13.3332 4.40352 13.3332 4.71352 13.3332 5.3335V11.4668C13.3332 12.5869 13.3332 13.147 13.1152 13.5748C12.9234 13.9511 12.6175 14.2571 12.2412 14.4488C11.8133 14.6668 11.2533 14.6668 10.1332 14.6668H5.8665C4.7464 14.6668 4.18635 14.6668 3.75852 14.4488C3.3822 14.2571 3.07624 13.9511 2.88449 13.5748C2.6665 13.147 2.6665 12.5869 2.6665 11.4668V5.3335C2.6665 4.71352 2.6665 4.40352 2.73465 4.14919C2.91959 3.45901 3.45868 2.91991 4.14887 2.73498C4.4032 2.66683 4.71319 2.66683 5.33317 2.66683M5.99984 10.0002L7.33317 11.3335L10.3332 8.3335M6.39984 4.00016H9.59984C9.9732 4.00016 10.1599 4.00016 10.3025 3.9275C10.4279 3.86359 10.5299 3.7616 10.5938 3.63616C10.6665 3.49355 10.6665 3.30686 10.6665 2.9335V2.40016C10.6665 2.02679 10.6665 1.84011 10.5938 1.6975C10.5299 1.57206 10.4279 1.47007 10.3025 1.40616C10.1599 1.3335 9.97321 1.3335 9.59984 1.3335H6.39984C6.02647 1.3335 5.83978 1.3335 5.69718 1.40616C5.57174 1.47007 5.46975 1.57206 5.40583 1.6975C5.33317 1.84011 5.33317 2.02679 5.33317 2.40016V2.9335C5.33317 3.30686 5.33317 3.49355 5.40583 3.63616C5.46975 3.7616 5.57174 3.86359 5.69718 3.9275C5.83978 4.00016 6.02647 4.00016 6.39984 4.00016Z" stroke="#1D2939" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>-</svg>diff --git a/web/app/components/develop/secret-key/assets/copy-hover.svg b/web/app/components/develop/secret-key/assets/copy-hover.svgdeleted file mode 100644index ca8334aed24..00000000000--- a/web/app/components/develop/secret-key/assets/copy-hover.svg+++ /dev/null@@ -1,3 +0,0 @@-<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">- <path d="M10.6665 2.66634H11.9998C12.3535 2.66634 12.6926 2.80682 12.9426 3.05687C13.1927 3.30691 13.3332 3.64605 13.3332 3.99967V13.333C13.3332 13.6866 13.1927 14.0258 12.9426 14.2758C12.6926 14.5259 12.3535 14.6663 11.9998 14.6663H3.99984C3.64622 14.6663 3.30708 14.5259 3.05703 14.2758C2.80698 14.0258 2.6665 13.6866 2.6665 13.333V3.99967C2.6665 3.64605 2.80698 3.30691 3.05703 3.05687C3.30708 2.80682 3.64622 2.66634 3.99984 2.66634H5.33317M5.99984 1.33301H9.99984C10.368 1.33301 10.6665 1.63148 10.6665 1.99967V3.33301C10.6665 3.7012 10.368 3.99967 9.99984 3.99967H5.99984C5.63165 3.99967 5.33317 3.7012 5.33317 3.33301V1.99967C5.33317 1.63148 5.63165 1.33301 5.99984 1.33301Z" stroke="#1D2939" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>-</svg>diff --git a/web/app/components/develop/secret-key/assets/copy.svg b/web/app/components/develop/secret-key/assets/copy.svgdeleted file mode 100644index 18d2b4e7fcd..00000000000--- a/web/app/components/develop/secret-key/assets/copy.svg+++ /dev/null@@ -1,3 +0,0 @@-<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">- <path d="M10.6665 2.66634H11.9998C12.3535 2.66634 12.6926 2.80682 12.9426 3.05687C13.1927 3.30691 13.3332 3.64605 13.3332 3.99967V13.333C13.3332 13.6866 13.1927 14.0258 12.9426 14.2758C12.6926 14.5259 12.3535 14.6663 11.9998 14.6663H3.99984C3.64622 14.6663 3.30708 14.5259 3.05703 14.2758C2.80698 14.0258 2.6665 13.6866 2.6665 13.333V3.99967C2.6665 3.64605 2.80698 3.30691 3.05703 3.05687C3.30708 2.80682 3.64622 2.66634 3.99984 2.66634H5.33317M5.99984 1.33301H9.99984C10.368 1.33301 10.6665 1.63148 10.6665 1.99967V3.33301C10.6665 3.7012 10.368 3.99967 9.99984 3.99967H5.99984C5.63165 3.99967 5.33317 3.7012 5.33317 3.33301V1.99967C5.33317 1.63148 5.63165 1.33301 5.99984 1.33301Z" stroke="#667085" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>-</svg>diff --git a/web/app/components/develop/secret-key/assets/pause.svg b/web/app/components/develop/secret-key/assets/pause.svgdeleted file mode 100644index a204b179d2f..00000000000--- a/web/app/components/develop/secret-key/assets/pause.svg+++ /dev/null@@ -1,10 +0,0 @@-<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">-<g clip-path="url(#clip0_129_2189)">-<path d="M10.6666 14V10M13.3333 14V10M18.6666 12C18.6666 15.6819 15.6819 18.6667 12 18.6667C8.31808 18.6667 5.33331 15.6819 5.33331 12C5.33331 8.3181 8.31808 5.33333 12 5.33333C15.6819 5.33333 18.6666 8.3181 18.6666 12Z" stroke="#155EEF" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>-</g>-<defs>-<clipPath id="clip0_129_2189">-<rect width="16" height="16" fill="white" transform="translate(4 4)"/>-</clipPath>-</defs>-</svg>diff --git a/web/app/components/develop/secret-key/assets/play.svg b/web/app/components/develop/secret-key/assets/play.svgdeleted file mode 100644index b423e98ce24..00000000000--- a/web/app/components/develop/secret-key/assets/play.svg+++ /dev/null@@ -1,11 +0,0 @@-<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">-<g clip-path="url(#clip0_129_107)">-<path d="M7.99998 14.6666C11.6819 14.6666 14.6666 11.6819 14.6666 7.99998C14.6666 4.31808 11.6819 1.33331 7.99998 1.33331C4.31808 1.33331 1.33331 4.31808 1.33331 7.99998C1.33331 11.6819 4.31808 14.6666 7.99998 14.6666Z" stroke="#667085" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>-<path d="M6.66665 5.33331L10.6666 7.99998L6.66665 10.6666V5.33331Z" stroke="#667085" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>-</g>-<defs>-<clipPath id="clip0_129_107">-<rect width="16" height="16" fill="white"/>-</clipPath>-</defs>-</svg>diff --git a/web/app/components/develop/secret-key/assets/qrcode-hover.svg b/web/app/components/develop/secret-key/assets/qrcode-hover.svgdeleted file mode 100644index 84e3ee70d08..00000000000--- a/web/app/components/develop/secret-key/assets/qrcode-hover.svg+++ /dev/null@@ -1,4 +0,0 @@-<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">- <path d="M4.33333 4.33333H4.34M11.6667 4.33333H11.6733M4.33333 11.6667H4.34M8.66667 8.66667H8.67333M11.6667 11.6667H11.6733M11.3333 14H14V11.3333M9.33333 11V14M14 9.33333H11M10.4 6.66667H12.9333C13.3067 6.66667 13.4934 6.66667 13.636 6.594C13.7614 6.53009 13.8634 6.4281 13.9273 6.30266C14 6.16005 14 5.97337 14 5.6V3.06667C14 2.6933 14 2.50661 13.9273 2.36401C13.8634 2.23856 13.7614 2.13658 13.636 2.07266C13.4934 2 13.3067 2 12.9333 2H10.4C10.0266 2 9.83995 2 9.69734 2.07266C9.5719 2.13658 9.46991 2.23856 9.406 2.36401C9.33333 2.50661 9.33333 2.6933 9.33333 3.06667V5.6C9.33333 5.97337 9.33333 6.16005 9.406 6.30266C9.46991 6.4281 9.5719 6.53009 9.69734 6.594C9.83995 6.66667 10.0266 6.66667 10.4 6.66667ZM3.06667 6.66667H5.6C5.97337 6.66667 6.16005 6.66667 6.30266 6.594C6.4281 6.53009 6.53009 6.4281 6.594 6.30266C6.66667 6.16005 6.66667 5.97337 6.66667 5.6V3.06667C6.66667 2.6933 6.66667 2.50661 6.594 2.36401C6.53009 2.23856 6.4281 2.13658 6.30266 2.07266C6.16005 2 5.97337 2 5.6 2H3.06667C2.6933 2 2.50661 2 2.36401 2.07266C2.23856 2.13658 2.13658 2.23856 2.07266 2.36401C2 2.50661 2 2.6933 2 3.06667V5.6C2 5.97337 2 6.16005 2.07266 6.30266C2.13658 6.4281 2.23856 6.53009 2.36401 6.594C2.50661 6.66667 2.6933 6.66667 3.06667 6.66667ZM3.06667 14H5.6C5.97337 14 6.16005 14 6.30266 13.9273C6.4281 13.8634 6.53009 13.7614 6.594 13.636C6.66667 13.4934 6.66667 13.3067 6.66667 12.9333V10.4C6.66667 10.0266 6.66667 9.83995 6.594 9.69734C6.53009 9.5719 6.4281 9.46991 6.30266 9.406C6.16005 9.33333 5.97337 9.33333 5.6 9.33333H3.06667C2.6933 9.33333 2.50661 9.33333 2.36401 9.406C2.23856 9.46991 2.13658 9.5719 2.07266 9.69734C2 9.83995 2 10.0266 2 10.4V12.9333C2 13.3067 2 13.4934 2.07266 13.636C2.13658 13.7614 2.23856 13.8634 2.36401 13.9273C2.50661 14 2.6933 14 3.06667 14Z" stroke="#1D2939" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>- </svg>-\ No newline at end of filediff --git a/web/app/components/develop/secret-key/assets/qrcode.svg b/web/app/components/develop/secret-key/assets/qrcode.svgdeleted file mode 100644index 57878d5fc4a..00000000000--- a/web/app/components/develop/secret-key/assets/qrcode.svg+++ /dev/null@@ -1,4 +0,0 @@-<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">- <path d="M4.33333 4.33333H4.34M11.6667 4.33333H11.6733M4.33333 11.6667H4.34M8.66667 8.66667H8.67333M11.6667 11.6667H11.6733M11.3333 14H14V11.3333M9.33333 11V14M14 9.33333H11M10.4 6.66667H12.9333C13.3067 6.66667 13.4934 6.66667 13.636 6.594C13.7614 6.53009 13.8634 6.4281 13.9273 6.30266C14 6.16005 14 5.97337 14 5.6V3.06667C14 2.6933 14 2.50661 13.9273 2.36401C13.8634 2.23856 13.7614 2.13658 13.636 2.07266C13.4934 2 13.3067 2 12.9333 2H10.4C10.0266 2 9.83995 2 9.69734 2.07266C9.5719 2.13658 9.46991 2.23856 9.406 2.36401C9.33333 2.50661 9.33333 2.6933 9.33333 3.06667V5.6C9.33333 5.97337 9.33333 6.16005 9.406 6.30266C9.46991 6.4281 9.5719 6.53009 9.69734 6.594C9.83995 6.66667 10.0266 6.66667 10.4 6.66667ZM3.06667 6.66667H5.6C5.97337 6.66667 6.16005 6.66667 6.30266 6.594C6.4281 6.53009 6.53009 6.4281 6.594 6.30266C6.66667 6.16005 6.66667 5.97337 6.66667 5.6V3.06667C6.66667 2.6933 6.66667 2.50661 6.594 2.36401C6.53009 2.23856 6.4281 2.13658 6.30266 2.07266C6.16005 2 5.97337 2 5.6 2H3.06667C2.6933 2 2.50661 2 2.36401 2.07266C2.23856 2.13658 2.13658 2.23856 2.07266 2.36401C2 2.50661 2 2.6933 2 3.06667V5.6C2 5.97337 2 6.16005 2.07266 6.30266C2.13658 6.4281 2.23856 6.53009 2.36401 6.594C2.50661 6.66667 2.6933 6.66667 3.06667 6.66667ZM3.06667 14H5.6C5.97337 14 6.16005 14 6.30266 13.9273C6.4281 13.8634 6.53009 13.7614 6.594 13.636C6.66667 13.4934 6.66667 13.3067 6.66667 12.9333V10.4C6.66667 10.0266 6.66667 9.83995 6.594 9.69734C6.53009 9.5719 6.4281 9.46991 6.30266 9.406C6.16005 9.33333 5.97337 9.33333 5.6 9.33333H3.06667C2.6933 9.33333 2.50661 9.33333 2.36401 9.406C2.23856 9.46991 2.13658 9.5719 2.07266 9.69734C2 9.83995 2 10.0266 2 10.4V12.9333C2 13.3067 2 13.4934 2.07266 13.636C2.13658 13.7614 2.23856 13.8634 2.36401 13.9273C2.50661 14 2.6933 14 3.06667 14Z" stroke="#667085" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>- </svg>-\ No newline at end of filediff --git a/web/app/components/develop/secret-key/assets/svg.svg b/web/app/components/develop/secret-key/assets/svg.svgdeleted file mode 100644index bf401e060ac..00000000000--- a/web/app/components/develop/secret-key/assets/svg.svg+++ /dev/null@@ -1 +0,0 @@-<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1694177685288" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4415" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16"><path d="M192 384h640a42.666667 42.666667 0 0 1 42.666667 42.666667v362.666666a42.666667 42.666667 0 0 1-42.666667 42.666667H192v106.666667a21.333333 21.333333 0 0 0 21.333333 21.333333h725.333334a21.333333 21.333333 0 0 0 21.333333-21.333333V308.821333L949.909333 298.666667h-126.528A98.048 98.048 0 0 1 725.333333 200.618667V72.661333L716.714667 64H213.333333a21.333333 21.333333 0 0 0-21.333333 21.333333v298.666667zM128 832H42.666667a42.666667 42.666667 0 0 1-42.666667-42.666667V426.666667a42.666667 42.666667 0 0 1 42.666667-42.666667h85.333333V85.333333a85.333333 85.333333 0 0 1 85.333333-85.333333h530.026667L1024 282.453333V938.666667a85.333333 85.333333 0 0 1-85.333333 85.333333H213.333333a85.333333 85.333333 0 0 1-85.333333-85.333333v-106.666667z m61.376-364.885333c-27.434667 0-49.898667 6.528-67.712 19.968-19.221333 13.824-28.501333 33.024-28.501333 57.216s9.621333 42.624 29.226666 55.296c7.466667 4.608 27.093333 12.288 58.432 23.04 28.138667 9.216 44.522667 15.36 49.514667 18.048 15.68 8.448 23.872 19.968 23.872 34.56 0 11.52-5.696 20.352-16.384 27.264-10.688 6.528-25.664 9.984-44.181333 9.984-21.013333 0-36.352-4.224-46.314667-11.904-11.050667-8.832-17.813333-23.808-20.672-44.544H85.333333c1.792 34.944 13.546667 60.288 34.922667 76.416 17.450667 13.056 42.026667 19.584 73.386667 19.584 32.426667 0 57.706667-7.296 75.52-21.12 17.813333-14.208 26.730667-33.792 26.730666-58.368 0-25.344-11.050667-44.928-33.130666-59.136-9.984-6.144-32.064-15.36-66.624-26.88-23.509333-8.064-38.122667-13.824-43.477334-16.896-12.096-6.912-17.813333-16.512-17.813333-28.032 0-13.056 4.992-22.656 15.68-28.416 8.554667-4.992 20.672-7.296 36.693333-7.296 18.538667 0 32.789333 3.456 42.048 11.136 9.258667 7.296 16.021333 19.584 19.584 36.48h41.344c-2.496-29.952-12.821333-52.224-30.656-66.432-16.725333-13.44-40.256-19.968-70.186666-19.968z m118.976 5.376L398.848 746.666667h50.24l90.496-274.176h-45.226667l-69.845333 223.488h-1.066667l-69.845333-223.488h-45.226667z m368.405333-5.376c-37.76 0-67.690667 13.824-89.792 42.24-21.013333 26.496-31.36 60.288-31.36 101.376 0 40.704 10.346667 74.112 31.36 99.84 22.442667 27.648 53.802667 41.472 94.421334 41.472 22.805333 0 43.093333-3.072 61.632-9.216A143.829333 143.829333 0 0 0 789.333333 716.714667V600.746667h-109.013333v38.4h67.328v56.448c-8.533333 5.376-17.450667 9.6-27.434667 12.672a123.285333 123.285333 0 0 1-34.197333 4.608c-30.997333 0-53.802667-9.216-68.416-27.648-13.525333-17.28-20.309333-42.24-20.309333-74.496 0-33.792 7.488-59.52 22.826666-77.952 13.866667-17.664 32.768-26.112 56.64-26.112 19.221333 0 34.901333 4.224 46.656 13.056 11.413333 8.832 19.242667 21.888 22.826667 39.552h42.026667c-4.629333-30.72-16.042667-53.376-34.197334-68.736-18.88-15.744-44.544-23.424-77.312-23.424z" fill="#8a8a8a" p-id="4416"></path></svg>\ No newline at end of filediff --git a/web/app/components/develop/secret-key/assets/svged.svg b/web/app/components/develop/secret-key/assets/svged.svgdeleted file mode 100644index bca6210b95d..00000000000--- a/web/app/components/develop/secret-key/assets/svged.svg+++ /dev/null@@ -1 +0,0 @@-<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1694177378730" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4206" width="16" height="16" xmlns:xlink="http://www.w3.org/1999/xlink"><path d="M192 384h640a42.666667 42.666667 0 0 1 42.666667 42.666667v362.666666a42.666667 42.666667 0 0 1-42.666667 42.666667H192v106.666667a21.333333 21.333333 0 0 0 21.333333 21.333333h725.333334a21.333333 21.333333 0 0 0 21.333333-21.333333V308.821333L949.909333 298.666667h-126.528A98.048 98.048 0 0 1 725.333333 200.618667V72.661333L716.714667 64H213.333333a21.333333 21.333333 0 0 0-21.333333 21.333333v298.666667zM128 832H42.666667a42.666667 42.666667 0 0 1-42.666667-42.666667V426.666667a42.666667 42.666667 0 0 1 42.666667-42.666667h85.333333V85.333333a85.333333 85.333333 0 0 1 85.333333-85.333333h530.026667L1024 282.453333V938.666667a85.333333 85.333333 0 0 1-85.333333 85.333333H213.333333a85.333333 85.333333 0 0 1-85.333333-85.333333v-106.666667z m61.376-364.885333c-27.434667 0-49.898667 6.528-67.712 19.968-19.221333 13.824-28.501333 33.024-28.501333 57.216s9.621333 42.624 29.226666 55.296c7.466667 4.608 27.093333 12.288 58.432 23.04 28.138667 9.216 44.522667 15.36 49.514667 18.048 15.68 8.448 23.872 19.968 23.872 34.56 0 11.52-5.696 20.352-16.384 27.264-10.688 6.528-25.664 9.984-44.181333 9.984-21.013333 0-36.352-4.224-46.314667-11.904-11.050667-8.832-17.813333-23.808-20.672-44.544H85.333333c1.792 34.944 13.546667 60.288 34.922667 76.416 17.450667 13.056 42.026667 19.584 73.386667 19.584 32.426667 0 57.706667-7.296 75.52-21.12 17.813333-14.208 26.730667-33.792 26.730666-58.368 0-25.344-11.050667-44.928-33.130666-59.136-9.984-6.144-32.064-15.36-66.624-26.88-23.509333-8.064-38.122667-13.824-43.477334-16.896-12.096-6.912-17.813333-16.512-17.813333-28.032 0-13.056 4.992-22.656 15.68-28.416 8.554667-4.992 20.672-7.296 36.693333-7.296 18.538667 0 32.789333 3.456 42.048 11.136 9.258667 7.296 16.021333 19.584 19.584 36.48h41.344c-2.496-29.952-12.821333-52.224-30.656-66.432-16.725333-13.44-40.256-19.968-70.186666-19.968z m118.976 5.376L398.848 746.666667h50.24l90.496-274.176h-45.226667l-69.845333 223.488h-1.066667l-69.845333-223.488h-45.226667z m368.405333-5.376c-37.76 0-67.690667 13.824-89.792 42.24-21.013333 26.496-31.36 60.288-31.36 101.376 0 40.704 10.346667 74.112 31.36 99.84 22.442667 27.648 53.802667 41.472 94.421334 41.472 22.805333 0 43.093333-3.072 61.632-9.216A143.829333 143.829333 0 0 0 789.333333 716.714667V600.746667h-109.013333v38.4h67.328v56.448c-8.533333 5.376-17.450667 9.6-27.434667 12.672a123.285333 123.285333 0 0 1-34.197333 4.608c-30.997333 0-53.802667-9.216-68.416-27.648-13.525333-17.28-20.309333-42.24-20.309333-74.496 0-33.792 7.488-59.52 22.826666-77.952 13.866667-17.664 32.768-26.112 56.64-26.112 19.221333 0 34.901333 4.224 46.656 13.056 11.413333 8.832 19.242667 21.888 22.826667 39.552h42.026667c-4.629333-30.72-16.042667-53.376-34.197334-68.736-18.88-15.744-44.544-23.424-77.312-23.424z" fill="#1A8EF7" p-id="4207"></path></svg>\ No newline at end of filediff --git a/web/app/components/develop/secret-key/assets/trash-gray.svg b/web/app/components/develop/secret-key/assets/trash-gray.svgdeleted file mode 100644index ef65c30e909..00000000000--- a/web/app/components/develop/secret-key/assets/trash-gray.svg+++ /dev/null@@ -1,3 +0,0 @@-<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">- <path d="M6 2H10M2 4H14M12.6667 4L12.1991 11.0129C12.129 12.065 12.0939 12.5911 11.8667 12.99C11.6666 13.3412 11.3648 13.6235 11.0011 13.7998C10.588 14 10.0607 14 9.00623 14H6.99377C5.93927 14 5.41202 14 4.99889 13.7998C4.63517 13.6235 4.33339 13.3412 4.13332 12.99C3.90607 12.5911 3.871 12.065 3.80086 11.0129L3.33333 4M6.66667 7V10.3333M9.33333 7V10.3333" stroke="#667085" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>-</svg>diff --git a/web/app/components/develop/secret-key/assets/trash-red.svg b/web/app/components/develop/secret-key/assets/trash-red.svgdeleted file mode 100644index 4266dde6edb..00000000000--- a/web/app/components/develop/secret-key/assets/trash-red.svg+++ /dev/null@@ -1,3 +0,0 @@-<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">- <path d="M6 2H10M2 4H14M12.6667 4L12.1991 11.0129C12.129 12.065 12.0939 12.5911 11.8667 12.99C11.6666 13.3412 11.3648 13.6235 11.0011 13.7998C10.588 14 10.0607 14 9.00623 14H6.99377C5.93927 14 5.41202 14 4.99889 13.7998C4.63517 13.6235 4.33339 13.3412 4.13332 12.99C3.90607 12.5911 3.871 12.065 3.80086 11.0129L3.33333 4M6.66667 7V10.3333M9.33333 7V10.3333" stroke="#D92D20" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>-</svg>diff --git a/web/app/components/develop/secret-key/input-copy.tsx b/web/app/components/develop/secret-key/input-copy.tsxdeleted file mode 100644index 83788f01286..00000000000--- a/web/app/components/develop/secret-key/input-copy.tsx+++ /dev/null@@ -1,66 +0,0 @@-'use client'-import { Tooltip, TooltipContent, TooltipTrigger } from '@langgenius/dify-ui/tooltip'-import { t } from 'i18next'-import * as React from 'react'-import { useEffect, useState } from 'react'-import CopyFeedback from '@/app/components/base/copy-feedback'-import { writeTextToClipboard } from '@/utils/clipboard'--type IInputCopyProps = {- value?: string- className?: string- children?: React.ReactNode-}--const InputCopy = ({ value = '', className, children }: IInputCopyProps) => {- const [isCopied, setIsCopied] = useState(false)- const copyLabel = isCopied- ? `${t(($) => $.copied, { ns: 'appApi' })}`- : `${t(($) => $.copy, { ns: 'appApi' })}`- const handleCopy = () => {- writeTextToClipboard(value).then(() => {- setIsCopied(true)- })- }-- useEffect(() => {- if (isCopied) {- const timeout = setTimeout(() => {- setIsCopied(false)- }, 1000)-- return () => {- clearTimeout(timeout)- }- }- }, [isCopied])-- return (- <div- className={`flex items-center rounded-lg bg-components-input-bg-normal py-2 hover:bg-state-base-hover ${className}`}- >- <div className="flex h-5 grow items-center">- {children}- <div className="relative h-full grow text-[13px]">- <button- type="button"- className="r-0 absolute top-0 left-0 w-full cursor-pointer truncate border-none bg-transparent px-2 py-0 text-left"- aria-label={copyLabel}- onClick={handleCopy}- >- <Tooltip>- <TooltipTrigger render={<span className="text-text-secondary">{value}</span>} />- <TooltipContent placement="bottom">{copyLabel}</TooltipContent>- </Tooltip>- </button>- </div>- <div className="h-4 w-px shrink-0 bg-divider-regular" />- <div className="mx-1">- <CopyFeedback content={value} />- </div>- </div>- </div>- )-}--export default InputCopydiff --git a/web/app/components/develop/secret-key/secret-key-button.tsx b/web/app/components/develop/secret-key/secret-key-button.tsxdeleted file mode 100644index 47e1e987827..00000000000--- a/web/app/components/develop/secret-key/secret-key-button.tsx+++ /dev/null@@ -1,49 +0,0 @@-'use client'-import { Button } from '@langgenius/dify-ui/button'-import { useState } from 'react'-import { useTranslation } from 'react-i18next'-import SecretKeyModal from '@/app/components/develop/secret-key/secret-key-modal'--type ISecretKeyButtonProps = {- className?: string- appId?: string- textCls?: string- canManage?: boolean-}--const SecretKeyButton = ({- className,- appId,- textCls,- canManage = false,-}: ISecretKeyButtonProps) => {- const [isVisible, setIsVisible] = useState(false)- const { t } = useTranslation()-- return (- <>- <Button- className={`px-3 ${className}`}- onClick={() => setIsVisible(true)}- size="small"- variant="ghost"- disabled={!canManage}- >- <div className="flex size-3.5 items-center justify-center">- <span className="i-ri-key-2-line size-3.5 text-text-tertiary" />- </div>- <div className={`system-xs-medium text-text-tertiary ${textCls}`}>- {t(($) => $.apiKey, { ns: 'appApi' })}- </div>- </Button>- <SecretKeyModal- isShow={isVisible}- onClose={() => setIsVisible(false)}- canManage={canManage}- scope={appId ? { type: 'app', appId } : { type: 'dataset' }}- />- </>- )-}--export default SecretKeyButtondiff --git a/web/app/components/develop/secret-key/secret-key-generate.tsx b/web/app/components/develop/secret-key/secret-key-generate.tsxdeleted file mode 100644index 885824a1cd7..00000000000--- a/web/app/components/develop/secret-key/secret-key-generate.tsx+++ /dev/null@@ -1,69 +0,0 @@-'use client'-import type { ApiKeyItem } from '@dify/contracts/api/console/apps/types.gen'-import { Button } from '@langgenius/dify-ui/button'-import { cn } from '@langgenius/dify-ui/cn'-import { Dialog, DialogContent, DialogTitle } from '@langgenius/dify-ui/dialog'-import { useTranslation } from 'react-i18next'-import InputCopy from './input-copy'-import s from './style.module.css'--type ISecretKeyGenerateModalProps = {- isShow: boolean- onClose: () => void- newKey?: Pick<ApiKeyItem, 'token'>- className?: string-}--const SecretKeyGenerateModal = ({- isShow = false,- onClose,- newKey,- className,-}: ISecretKeyGenerateModalProps) => {- const { t } = useTranslation()- return (- <Dialog- open={isShow}- onOpenChange={(open) => {- if (!open) onClose()- }}- >- <DialogContent- className={cn(- 'w-full max-w-120 overflow-hidden! border-none px-8 text-left align-middle',- className,- )}- >- <DialogTitle className="title-2xl-semi-bold text-text-primary">- {`${t(($) => $['apiKeyModal.apiSecretKey'], { ns: 'appApi' })}`}- </DialogTitle>-- <div className="-mt-6 -mr-2 mb-4 flex justify-end">- <button- type="button"- aria-label={t(($) => $['operation.close'], { ns: 'common' })}- className="cursor-pointer border-none bg-transparent text-text-tertiary"- onClick={onClose}- >- <span aria-hidden className="i-heroicons-x-mark-20-solid size-6" />- </button>- </div>- <p className="mt-1 text-[13px] leading-5 font-normal text-text-tertiary">- {t(($) => $['apiKeyModal.generateTips'], { ns: 'appApi' })}- </p>- <div className="my-4">- <InputCopy className="w-full" value={newKey?.token} />- </div>- <div className="my-4 flex justify-end">- <Button className={`shrink-0 ${s.w64}`} onClick={onClose}>- <span className="text-xs font-medium text-text-secondary">- {t(($) => $['actionMsg.ok'], { ns: 'appApi' })}- </span>- </Button>- </div>- </DialogContent>- </Dialog>- )-}--export default SecretKeyGenerateModaldiff --git a/web/app/components/develop/secret-key/secret-key-modal/index.tsx b/web/app/components/develop/secret-key/secret-key-modal/index.tsxdeleted file mode 100644index be70f0e99ea..00000000000--- a/web/app/components/develop/secret-key/secret-key-modal/index.tsx+++ /dev/null@@ -1,154 +0,0 @@-'use client'--import { skipToken, useMutation, useQuery } from '@tanstack/react-query'-import { useAtomValue } from 'jotai'-import { currentWorkspaceAtom } from '@/context/workspace-state'-import { consoleQuery } from '@/service/client'-import { SecretKeyModalView } from './view'--export type SecretKeyScope =- | { type: 'app'; appId: string }- | { type: 'dataset' }- | { type: 'environment'; appId: string; environmentId: string }--export type SecretKeyModalProps = {- isShow: boolean- canManage: boolean- scope: SecretKeyScope- onClose: () => void-}--type SecretKeyControllerProps = Omit<SecretKeyModalProps, 'scope'> & {- createDisabled: boolean-}--export default function SecretKeyModal({- isShow = false,- canManage,- scope,- onClose,-}: SecretKeyModalProps) {- const currentWorkspace = useAtomValue(currentWorkspaceAtom)- const controllerProps = {- canManage,- createDisabled: !currentWorkspace.id || !canManage,- isShow,- onClose,- }-- switch (scope.type) {- case 'app':- return <AppSecretKeyController {...controllerProps} appId={scope.appId} />- case 'dataset':- return <DatasetSecretKeyController {...controllerProps} />- case 'environment':- return (- <EnvironmentSecretKeyController- {...controllerProps}- appId={scope.appId}- environmentId={scope.environmentId}- />- )- }-}--function AppSecretKeyController({- appId,- ...viewProps-}: SecretKeyControllerProps & { appId: string }) {- const apiKeysQuery = useQuery(- consoleQuery.apps.byResourceId.apiKeys.get.queryOptions({- input: viewProps.isShow ? { params: { resource_id: appId } } : skipToken,- }),- )- const createMutation = useMutation(consoleQuery.apps.byResourceId.apiKeys.post.mutationOptions())- const deleteMutation = useMutation(- consoleQuery.apps.byResourceId.apiKeys.byApiKeyId.delete.mutationOptions(),- )-- return (- <SecretKeyModalView- {...viewProps}- apiKeys={apiKeysQuery.data?.data}- isCreating={createMutation.isPending}- isDeleting={deleteMutation.isPending}- isLoading={apiKeysQuery.isLoading}- onCreate={(onSuccess) =>- createMutation.mutate({ params: { resource_id: appId } }, { onSuccess })- }- onDelete={(keyId, onSuccess) =>- deleteMutation.mutate({ params: { resource_id: appId, api_key_id: keyId } }, { onSuccess })- }- />- )-}--function DatasetSecretKeyController(viewProps: SecretKeyControllerProps) {- const apiKeysQuery = useQuery({- ...consoleQuery.datasets.apiKeys.get.queryOptions(),- enabled: viewProps.isShow,- })- const createMutation = useMutation(consoleQuery.datasets.apiKeys.post.mutationOptions())- const deleteMutation = useMutation(- consoleQuery.datasets.apiKeys.byApiKeyId.delete.mutationOptions(),- )-- return (- <SecretKeyModalView- {...viewProps}- apiKeys={apiKeysQuery.data?.data}- isCreating={createMutation.isPending}- isDeleting={deleteMutation.isPending}- isLoading={apiKeysQuery.isLoading}- onCreate={(onSuccess) => createMutation.mutate(undefined, { onSuccess })}- onDelete={(keyId, onSuccess) =>- deleteMutation.mutate({ params: { api_key_id: keyId } }, { onSuccess })- }- />- )-}--function EnvironmentSecretKeyController({- appId,- environmentId,- ...viewProps-}: SecretKeyControllerProps & { appId: string; environmentId: string }) {- const params = {- app_id: appId,- environment_id: environmentId,- }- const apiKeysQuery = useQuery(- consoleQuery.enterprise.appDeploy.accessService.listEnvironmentApiKeys.queryOptions({- input: { params },- enabled: viewProps.isShow,- }),- )- const createMutation = useMutation(- consoleQuery.enterprise.appDeploy.accessService.createEnvironmentApiKey.mutationOptions(),- )- const deleteMutation = useMutation(- consoleQuery.enterprise.appDeploy.accessService.deleteEnvironmentApiKey.mutationOptions(),- )-- return (- <SecretKeyModalView- {...viewProps}- apiKeys={apiKeysQuery.data?.data}- isCreating={createMutation.isPending}- isDeleting={deleteMutation.isPending}- isLoading={apiKeysQuery.isLoading}- onCreate={(onSuccess) => createMutation.mutate({ params }, { onSuccess })}- onDelete={(keyId, onSuccess) =>- deleteMutation.mutate(- {- params: {- ...params,- api_key_id: keyId,- },- },- { onSuccess },- )- }- />- )-}diff --git a/web/app/components/develop/secret-key/secret-key-modal/view.tsx b/web/app/components/develop/secret-key/secret-key-modal/view.tsxdeleted file mode 100644index 5d2edd4a0f0..00000000000--- a/web/app/components/develop/secret-key/secret-key-modal/view.tsx+++ /dev/null@@ -1,219 +0,0 @@-'use client'--import type { ApiKeyItem } from '@dify/contracts/api/console/apps/types.gen'-import type { EnvironmentApiKey } from '@dify/contracts/enterprise-app-deploy/types.gen'-import {- AlertDialog,- AlertDialogActions,- AlertDialogCancelButton,- AlertDialogConfirmButton,- AlertDialogContent,- AlertDialogDescription,- AlertDialogTitle,-} from '@langgenius/dify-ui/alert-dialog'-import { Button } from '@langgenius/dify-ui/button'-import { cn } from '@langgenius/dify-ui/cn'-import { Dialog, DialogContent, DialogTitle } from '@langgenius/dify-ui/dialog'-import { IconButton } from '@langgenius/dify-ui/icon-button'-import { useState } from 'react'-import { useTranslation } from 'react-i18next'-import CopyFeedback from '@/app/components/base/copy-feedback'-import Loading from '@/app/components/base/loading'-import useTimestamp from '@/hooks/use-timestamp'-import SecretKeyGenerateModal from '../secret-key-generate'-import s from '../style.module.css'--type SecretKeyItem = ApiKeyItem | EnvironmentApiKey-type CreatedSecretKey = Pick<ApiKeyItem, 'token'>--export type SecretKeyModalViewProps = {- apiKeys?: SecretKeyItem[]- canManage: boolean- createDisabled: boolean- isCreating: boolean- isDeleting: boolean- isLoading: boolean- isShow: boolean- onClose: () => void- onCreate: (onSuccess: (createdKey: CreatedSecretKey) => void) => void- onDelete: (keyId: string, onSuccess: () => void) => void-}--export function SecretKeyModalView({- apiKeys,- canManage,- createDisabled,- isCreating,- isDeleting,- isLoading,- isShow,- onClose,- onCreate,- onDelete,-}: SecretKeyModalViewProps) {- const { t } = useTranslation()- const { formatTime } = useTimestamp()- const [deleteKeyId, setDeleteKeyId] = useState<string>()- const [newKey, setNewKey] = useState<CreatedSecretKey>()-- const handleClose = () => {- setDeleteKeyId(undefined)- setNewKey(undefined)- onClose()- }-- const handleCreate = () => {- if (createDisabled || isCreating) return- onCreate(setNewKey)- }-- const handleDelete = () => {- if (!deleteKeyId || isDeleting) return- onDelete(deleteKeyId, () => setDeleteKeyId(undefined))- }-- const generateToken = (token: string) => {- return `${token.slice(0, 3)}...${token.slice(-20)}`- }-- return (- <>- <Dialog- open={isShow}- onOpenChange={(open) => {- if (!open) handleClose()- }}- >- <DialogContent- className={cn(- 'max-h-[calc(100vh-80px)]! w-full max-w-200! overflow-hidden! border-none text-left align-middle',- `${s.customModal} flex flex-col px-8`,- )}- >- <DialogTitle className="title-2xl-semi-bold text-text-primary">- {t(($) => $['apiKeyModal.apiSecretKey'], { ns: 'appApi' })}- </DialogTitle>-- <div className="-mt-6 -mr-2 mb-4 flex justify-end">- <button- type="button"- aria-label={t(($) => $['operation.close'], { ns: 'common' })}- className="flex size-6 cursor-pointer items-center justify-center text-text-tertiary"- onClick={handleClose}- >- <span- className="i-heroicons-x-mark-20-solid size-6 cursor-pointer"- aria-hidden="true"- />- </button>- </div>- <p className="mt-1 shrink-0 text-[13px] leading-5 font-normal text-text-tertiary">- {t(($) => $['apiKeyModal.apiSecretKeyTips'], { ns: 'appApi' })}- </p>- {isLoading && (- <div className="mt-4">- <Loading />- </div>- )}- {!!apiKeys?.length && (- <div className="mt-4 flex grow flex-col overflow-hidden">- <div className="flex h-9 shrink-0 items-center border-b border-divider-regular text-xs font-semibold text-text-tertiary">- <div className="w-64 shrink-0 px-3">- {t(($) => $['apiKeyModal.secretKey'], { ns: 'appApi' })}- </div>- <div className="w-50 shrink-0 px-3">- {t(($) => $['apiKeyModal.created'], { ns: 'appApi' })}- </div>- <div className="w-50 shrink-0 px-3">- {t(($) => $['apiKeyModal.lastUsed'], { ns: 'appApi' })}- </div>- <div className="grow px-3" />- </div>- <div className="grow overflow-auto">- {apiKeys.map((api) => (- <div- className="flex h-9 items-center border-b border-divider-regular text-sm font-normal text-text-secondary"- key={api.id}- >- <div className="w-64 shrink-0 truncate px-3 font-mono">- {generateToken(api.token)}- </div>- <div className="w-50 shrink-0 truncate px-3">- {formatTime(- Number(api.created_at),- t(($) => $.dateTimeFormat, { ns: 'appLog' }) as string,- )}- </div>- <div className="w-50 shrink-0 truncate px-3">- {api.last_used_at- ? formatTime(- Number(api.last_used_at),- t(($) => $.dateTimeFormat, { ns: 'appLog' }) as string,- )- : t(($) => $.never, { ns: 'appApi' })}- </div>- <div className="flex grow space-x-2 px-3">- <CopyFeedback content={api.token} />- {canManage && (- <IconButton- aria-label={`${t(($) => $['operation.delete'], { ns: 'common' })} ${generateToken(api.token)}`}- onClick={() => setDeleteKeyId(api.id)}- >- <span aria-hidden className="i-ri-delete-bin-line size-4" />- </IconButton>- )}- </div>- </div>- ))}- </div>- </div>- )}- <div className="flex">- <Button- className={`mt-4 flex shrink-0 ${s.autoWidth}`}- onClick={handleCreate}- disabled={createDisabled || isCreating}- loading={isCreating}- >- <span className="i-heroicons-plus-20-solid flex size-4 shrink-0" />- <div className="text-xs font-medium text-text-secondary">- {t(($) => $['apiKeyModal.createNewSecretKey'], { ns: 'appApi' })}- </div>- </Button>- </div>- <AlertDialog- open={deleteKeyId !== undefined}- onOpenChange={(open) => {- if (!open && !isDeleting) setDeleteKeyId(undefined)- }}- >- <AlertDialogContent>- <div className="flex flex-col gap-2 px-6 pt-6 pb-4">- <AlertDialogTitle className="w-full truncate title-2xl-semi-bold text-text-primary">- {t(($) => $['actionMsg.deleteConfirmTitle'], { ns: 'appApi' })}- </AlertDialogTitle>- <AlertDialogDescription className="w-full system-md-regular wrap-break-word whitespace-pre-wrap text-text-tertiary">- {t(($) => $['actionMsg.deleteConfirmTips'], { ns: 'appApi' })}- </AlertDialogDescription>- </div>- <AlertDialogActions>- <AlertDialogCancelButton disabled={isDeleting}>- {t(($) => $['operation.cancel'], { ns: 'common' })}- </AlertDialogCancelButton>- <AlertDialogConfirmButton loading={isDeleting} onClick={handleDelete}>- {t(($) => $['operation.confirm'], { ns: 'common' })}- </AlertDialogConfirmButton>- </AlertDialogActions>- </AlertDialogContent>- </AlertDialog>- </DialogContent>- </Dialog>- <SecretKeyGenerateModal- className="shrink-0"- isShow={isShow && newKey !== undefined}- onClose={() => setNewKey(undefined)}- newKey={newKey}- />- </>- )-}diff --git a/web/app/components/develop/secret-key/style.module.css b/web/app/components/develop/secret-key/style.module.cssdeleted file mode 100644index 3a16187d8df..00000000000--- a/web/app/components/develop/secret-key/style.module.css+++ /dev/null@@ -1,57 +0,0 @@-.customModal {- max-width: 800px !important;- max-height: calc(100vh - 80px);-}--.close {- top: 1.5rem;- right: 1.5rem;-}--.trash {- color: transparent;-}--.w64 {- width: 4rem;-}--.customApi {- font-size: 11px;-}--.autoWidth {- width: auto;-}--.trashIcon {- background-color: transparent;- background-image: url(./assets/trash-gray.svg);- background-position: center;- background-repeat: no-repeat;- background-size: 16px 16px;-}--.trashIcon:hover {- background-color: rgba(254, 228, 226, 1);- background-image: url(./assets/trash-red.svg);- background-position: center;- background-repeat: no-repeat;- background-size: 16px 16px;-}--.copyIcon {- background-image: url(./assets/copy.svg);- background-position: center;- background-repeat: no-repeat;-}--.copyIcon:hover {- background-image: url(./assets/copy-hover.svg);- background-position: center;- background-repeat: no-repeat;-}--.copyIcon.copied {- background-image: url(./assets/copied.svg);-}diff --git a/web/app/components/develop/tag.tsx b/web/app/components/develop/tag.tsxdeleted file mode 100644index e3b5112ba38..00000000000--- a/web/app/components/develop/tag.tsx+++ /dev/null@@ -1,65 +0,0 @@-'use client'-import { cn } from '@langgenius/dify-ui/cn'--const variantStyles = {- medium: 'rounded-lg px-1.5 ring-1 ring-inset',-} as { [key: string]: string }--const colorStyles = {- emerald: {- small: 'text-emerald-500 dark:text-emerald-400',- medium:- 'ring-emerald-300 dark:ring-emerald-400/30 bg-emerald-400/10 text-emerald-500 dark:text-emerald-400',- },- sky: {- small: 'text-sky-500',- medium:- 'ring-sky-300 bg-sky-400/10 text-sky-500 dark:ring-sky-400/30 dark:bg-sky-400/10 dark:text-sky-400',- },- amber: {- small: 'text-amber-500',- medium:- 'ring-amber-300 bg-amber-400/10 text-amber-500 dark:ring-amber-400/30 dark:bg-amber-400/10 dark:text-amber-400',- },- rose: {- small: 'text-red-500 dark:text-rose-500',- medium:- 'ring-rose-200 bg-rose-50 text-red-500 dark:ring-rose-500/20 dark:bg-rose-400/10 dark:text-rose-400',- },- zinc: {- small: 'text-zinc-400 dark:text-zinc-500',- medium:- 'ring-zinc-200 bg-zinc-50 text-zinc-500 dark:ring-zinc-500/20 dark:bg-zinc-400/10 dark:text-zinc-400',- },-} as { [key: string]: { [key: string]: string } }--const valueColorMap = {- get: 'emerald',- post: 'sky',- put: 'amber',- delete: 'rose',-} as { [key: string]: string }--type ITagProps = {- children: string- color?: string- variant?: string-}--export function Tag({- children,- variant = 'medium',- color = valueColorMap[children.toLowerCase()] ?? 'emerald',-}: ITagProps) {- return (- <span- className={cn(- 'font-mono text-2xs/6 font-semibold',- variantStyles[variant],- colorStyles[color]![variant],- )}- >- {children}- </span>- )-}diff --git a/web/app/components/develop/template/__tests__/template_advanced_chat.spec.ts b/web/app/components/develop/template/__tests__/template_advanced_chat.spec.tsdeleted file mode 100644index e68eb0518b9..00000000000--- a/web/app/components/develop/template/__tests__/template_advanced_chat.spec.ts+++ /dev/null@@ -1,35 +0,0 @@-import { readFileSync } from 'node:fs'-import { resolve } from 'node:path'--const templates = [- ['English', 'template_advanced_chat.en.mdx'],- ['Japanese', 'template_advanced_chat.ja.mdx'],- ['Chinese', 'template_advanced_chat.zh.mdx'],-] as const--describe.each(templates)('%s advanced chat API template', (_language, templateFile) => {- it('should show the workflow version upgrade action next to workflow_id', () => {- const source = readFileSync(- resolve(process.cwd(), 'app/components/develop/template', templateFile),- 'utf8',- )-- expect(source).toContain(- "import { WorkflowVersionApiUpgradeNotice } from '../workflow-version-api-upgrade-notice.tsx'",- )- expect(source).toContain(- "<Property name='workflow_id' type='string' key='workflow_id' nameAction={<WorkflowVersionApiUpgradeNotice />}>",- )- expect(source).not.toContain('titleAction={<WorkflowVersionApiUpgradeNotice />}')- })-- it('should document the workflow version plan error', () => {- const source = readFileSync(- resolve(process.cwd(), 'app/components/develop/template', templateFile),- 'utf8',- )-- expect(source).toContain('403')- expect(source).toContain('workflow_version_execution_not_allowed')- })-})diff --git a/web/app/components/develop/template/__tests__/template_workflow.spec.ts b/web/app/components/develop/template/__tests__/template_workflow.spec.tsdeleted file mode 100644index 10151e5af43..00000000000--- a/web/app/components/develop/template/__tests__/template_workflow.spec.ts+++ /dev/null@@ -1,26 +0,0 @@-import { readFileSync } from 'node:fs'-import { resolve } from 'node:path'--const templates = [- ['English', 'template_workflow.en.mdx'],- ['Japanese', 'template_workflow.ja.mdx'],- ['Chinese', 'template_workflow.zh.mdx'],-] as const--describe.each(templates)('%s workflow API template', (_language, templateFile) => {- it('should hide only the paid API details behind the plan gate', () => {- const source = readFileSync(- resolve(process.cwd(), 'app/components/develop/template', templateFile),- 'utf8',- )- const paidApiStart = source.indexOf("name='#Execute-Specific-Workflow'")- const nextApiStart = source.indexOf("url='/workflows/run/:workflow_run_id'", paidApiStart)- const paidApi = source.slice(paidApiStart, nextApiStart)-- expect(paidApiStart).toBeGreaterThanOrEqual(0)- expect(nextApiStart).toBeGreaterThan(paidApiStart)- expect(paidApi).toContain('titleAction={<WorkflowVersionApiUpgradeNotice />}')- expect(paidApi).toContain('<WorkflowVersionApiContent>\n<Row>')- expect(paidApi).toContain('</Row>\n</WorkflowVersionApiContent>')- })-})diff --git a/web/app/components/develop/template/template.en.mdx b/web/app/components/develop/template/template.en.mdxdeleted file mode 100755index ab8d3cb9482..00000000000--- a/web/app/components/develop/template/template.en.mdx+++ /dev/null@@ -1,869 +0,0 @@-import { CodeGroup } from '../code.tsx'-import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx'--# Completion App API--The text generation application offers non-session support and is ideal for translation, article writing, summarization AI, and more.--<div>- ### Base URL- <CodeGroup title="Code" targetCode={props.appDetail.api_base_url} />-- ### Authentication-- The Service API uses `API-Key` authentication.- <i>**Strongly recommend storing your API Key on the server-side, not shared or stored on the client-side, to avoid possible API-Key leakage that can lead to serious consequences.**</i>-- For all API requests, include your API Key in the `Authorization` HTTP Header, as shown below:-- <CodeGroup title="Code" targetCode='Authorization: Bearer {API_KEY}' />-</div>-------<Heading- url='/completion-messages'- method='POST'- title='Create Completion Message'- name='#Create-Completion-Message'-/>-<Row>- <Col>- Send a request to the text generation application.-- ### Request Body-- <Properties>-- <Property name='inputs' type='object' key='inputs'>- Allows the entry of various variable values defined by the App.- The `inputs` parameter contains multiple key/value pairs, with each key corresponding to a specific variable and each value being the specific value for that variable.- The text generation application requires at least one key/value pair to be inputted.- - `query` (string) Required- The input text, the content to be processed.- </Property>- <Property name='response_mode' type='string' key='response_mode'>- The mode of response return, supporting:- - `streaming` Streaming mode (recommended), implements a typewriter-like output through SSE ([Server-Sent Events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events)).- - `blocking` Blocking mode, returns result after execution is complete. (Requests may be interrupted if the process is long)- <i>Due to Cloudflare restrictions, the request will be interrupted without a return after 100 seconds.</i>- </Property>- <Property name='user' type='string' key='user'>- User identifier, used to define the identity of the end-user, convenient for retrieval and statistics.- The rules are defined by the developer and need to ensure that the user identifier is unique within the application. The Service API does not share conversations created by the WebApp.- </Property>- <Property name='files' type='array[object]' key='files'>- File list, suitable for inputting files combined with text understanding and answering questions, available only when the model supports Vision/Video capability.- - `type` (string) Supported type:- - `document` Supported types include: 'TXT', 'MD', 'MARKDOWN', 'MDX', 'PDF', 'HTML', 'XLSX', 'XLS', 'VTT', 'PROPERTIES', 'DOC', 'DOCX', 'CSV', 'EML', 'MSG', 'PPTX', 'PPT', 'XML', 'EPUB'- - `image` Supported types include: 'JPG', 'JPEG', 'PNG', 'GIF', 'WEBP', 'SVG'- - `audio` Supported types include: 'MP3', 'M4A', 'WAV', 'WEBM', 'MPGA'- - `video` Supported types include: 'MP4', 'MOV', 'MPEG', 'WEBM'- - `custom` Supported types include: other file types- - `transfer_method` (string) Transfer method:- - `remote_url`: File URL.- - `local_file`: Upload file.- - `url` File URL. (Only when transfer method is `remote_url`).- - `upload_file_id` Upload file ID. (Only when transfer method is `local_file`).- </Property>- <Property name='trace_session_id' type='string' key='trace_session_id'>- (Optional) Trace session ID for observability grouping. Tracing providers that support session grouping can use this value as the exported session identifier. It does not change conversation_id, workflow_run_id, trace_id, or span relationships. Supports the following three ways to pass, in order of priority:<br/>- - Header: via HTTP Header <code>X-Trace-Session-Id</code>, highest priority.<br/>- - Query parameter: via URL query parameter <code>trace_session_id</code>.<br/>- - Request Body: via request body field <code>trace_session_id</code> (i.e., this field).<br/>- </Property>- </Properties>-- ### Response- When `response_mode` is `blocking`, return a CompletionResponse object.- When `response_mode` is `streaming`, return a ChunkCompletionResponse stream.-- ### ChatCompletionResponse- Returns the complete App result, `Content-Type` is `application/json`.- - `message_id` (string) Unique message ID- - `mode` (string) App mode, fixed as `chat`- - `answer` (string) Complete response content- - `metadata` (object) Metadata- - `usage` (Usage) Model usage information- - `retriever_resources` (array[RetrieverResource]) Citation and Attribution List- - `created_at` (int) Message creation timestamp, e.g., 1705395332-- ### ChunkChatCompletionResponse- Returns the stream chunks outputted by the App, `Content-Type` is `text/event-stream`.- Each streaming chunk starts with `data:`, separated by two newline characters `\n\n`, as shown below:- <CodeGroup>- ```streaming {{ title: 'Response' }}- data: {"event": "message", "task_id": "900bbd43-dc0b-4383-a372-aa6e6c414227", "id": "663c5084-a254-4040-8ad3-51f2a3c1a77c", "answer": "Hi", "created_at": 1705398420}\n\n- ```- </CodeGroup>- The structure of the streaming chunks varies depending on the `event`:- - `event: message` LLM returns text chunk event, i.e., the complete text is output in a chunked fashion.- - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API- - `message_id` (string) Unique message ID- - `answer` (string) LLM returned text chunk content- - `created_at` (int) Creation timestamp, e.g., 1705395332- - `event: message_end` Message end event, receiving this event means streaming has ended.- - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API- - `message_id` (string) Unique message ID- - `metadata` (object) Metadata- - `usage` (Usage) Model usage information- - `retriever_resources` (array[RetrieverResource]) Citation and Attribution List- - `event: tts_message` TTS audio stream event, that is, speech synthesis output. The content is an audio block in Mp3 format, encoded as a base64 string. When playing, simply decode the base64 and feed it into the player. (This message is available only when auto-play is enabled)- - `task_id` (string) Task ID, used for request tracking and the stop response interface below- - `message_id` (string) Unique message ID- - `audio` (string) The audio after speech synthesis, encoded in base64 text content, when playing, simply decode the base64 and feed it into the player- - `created_at` (int) Creation timestamp, e.g.: 1705395332- - `event: tts_message_end` TTS audio stream end event, receiving this event indicates the end of the audio stream.- - `task_id` (string) Task ID, used for request tracking and the stop response interface below- - `message_id` (string) Unique message ID- - `audio` (string) The end event has no audio, so this is an empty string- - `created_at` (int) Creation timestamp, e.g.: 1705395332- - `event: message_replace` Message content replacement event.- When output content moderation is enabled, if the content is flagged, then the message content will be replaced with a preset reply through this event.- - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API- - `message_id` (string) Unique message ID- - `answer` (string) Replacement content (directly replaces all LLM reply text)- - `created_at` (int) Creation timestamp, e.g., 1705395332- - `event: error`- Exceptions that occur during the streaming process will be output in the form of stream events, and reception of an error event will end the stream.- - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API- - `message_id` (string) Unique message ID- - `status` (int) HTTP status code- - `code` (string) Error code- - `message` (string) Error message- - `event: ping` Ping event every 10 seconds to keep the connection alive.-- ### Errors- - 404, Conversation does not exists- - 400, `invalid_param`, abnormal parameter input- - 400, `app_unavailable`, App configuration unavailable- - 400, `provider_not_initialize`, no available model credential configuration- - 400, `provider_quota_exceeded`, model invocation quota insufficient- - 400, `model_currently_not_support`, current model unavailable- - 400, `completion_request_error`, text generation failed- - 500, internal server error-- </Col>- <Col sticky>-- <CodeGroup- title="Request"- tag="POST"- label="/completion-messages"- targetCode={`curl -X POST '${props.appDetail.api_base_url}/completion-messages' \\---header 'Authorization: Bearer {api_key}' \\---header 'Content-Type: application/json' \\---data-raw '{- "inputs": {"query": "Hello, world!"},- "response_mode": "streaming",- "user": "abc-123"-}'`}- />- ### Blocking Mode- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "event": "message",- "message_id": "9da23599-e713-473b-982c-4328d4f5c78a",- "mode": "completion",- "answer": "Hello World!...",- "metadata": {- "usage": {- "prompt_tokens": 1033,- "prompt_unit_price": "0.001",- "prompt_price_unit": "0.001",- "prompt_price": "0.0010330",- "completion_tokens": 128,- "completion_unit_price": "0.002",- "completion_price_unit": "0.001",- "completion_price": "0.0002560",- "total_tokens": 1161,- "total_price": "0.0012890",- "currency": "USD",- "latency": 0.7682376249867957- }- },- "created_at": 1705407629- }- ```- </CodeGroup>- ### Streaming Mode- <CodeGroup title="Response">- ```streaming {{ title: 'Response' }}- data: {"event": "message", "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "answer": " I", "created_at": 1679586595}- data: {"event": "message", "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "answer": "'m", "created_at": 1679586595}- data: {"event": "message", "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "answer": " glad", "created_at": 1679586595}- data: {"event": "message", "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "answer": " to", "created_at": 1679586595}- data: {"event": "message", "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "answer": " meet", "created_at": 1679586595}- data: {"event": "message", "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "answer": " you", "created_at": 1679586595}- data: {"event": "message_end", "id": "5e52ce04-874b-4d27-9045-b3bc80def685", "metadata": {"usage": {"prompt_tokens": 1033, "prompt_unit_price": "0.001", "prompt_price_unit": "0.001", "prompt_price": "0.0010330", "completion_tokens": 135, "completion_unit_price": "0.002", "completion_price_unit": "0.001", "completion_price": "0.0002700", "total_tokens": 1168, "total_price": "0.0013030", "currency": "USD", "latency": 1.381760165997548}}}- data: {"event": "tts_message", "conversation_id": "23dd85f3-1a41-4ea0-b7a9-062734ccfaf9", "message_id": "a8bdc41c-13b2-4c18-bfd9-054b9803038c", "created_at": 1721205487, "task_id": "3bf8a0bb-e73b-4690-9e66-4e429bad8ee7", "audio": "qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq"}- data: {"event": "tts_message_end", "conversation_id": "23dd85f3-1a41-4ea0-b7a9-062734ccfaf9", "message_id": "a8bdc41c-13b2-4c18-bfd9-054b9803038c", "created_at": 1721205487, "task_id": "3bf8a0bb-e73b-4690-9e66-4e429bad8ee7", "audio": ""}- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/files/upload'- method='POST'- title='File Upload'- name='#file-upload'-/>-<Row>- <Col>- Upload a file (currently only images are supported) for use when sending messages, enabling multimodal understanding of images and text.- Supports png, jpg, jpeg, webp, gif formats.- <i>Uploaded files are for use by the current end-user only.</i>-- ### Request Body- This interface requires a `multipart/form-data` request.- - `file` (File) Required- The file to be uploaded.- - `user` (string) Required- User identifier, defined by the developer's rules, must be unique within the application. The Service API does not share conversations created by the WebApp.-- ### Response- After a successful upload, the server will return the file's ID and related information.- - `id` (uuid) ID- - `name` (string) File name- - `size` (int) File size (bytes)- - `extension` (string) File extension- - `mime_type` (string) File mime-type- - `created_by` (uuid) End-user ID- - `created_at` (timestamp) Creation timestamp, e.g., 1705395332-- ### Errors- - 400, `no_file_uploaded`, a file must be provided- - 400, `too_many_files`, currently only one file is accepted- - 400, `unsupported_preview`, the file does not support preview- - 400, `unsupported_estimate`, the file does not support estimation- - 413, `file_too_large`, the file is too large- - 415, `unsupported_file_type`, unsupported extension, currently only document files are accepted- - 503, `s3_connection_failed`, unable to connect to S3 service- - 503, `s3_permission_denied`, no permission to upload files to S3- - 503, `s3_file_too_large`, file exceeds S3 size limit- - 500, internal server error--- </Col>- <Col sticky>- ### Request Example- <CodeGroup- title="Request"- tag="POST"- label="/files/upload"- targetCode={`curl -X POST '${props.appDetail.api_base_url}/files/upload' \\---header 'Authorization: Bearer {api_key}' \\---form 'file=@localfile;type=image/[png|jpeg|jpg|webp|gif]' \\---form 'user=abc-123'`}- />--- ### Response Example- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "id": "72fa9618-8f89-4a37-9b33-7e1178a24a67",- "name": "example.png",- "size": 1024,- "extension": "png",- "mime_type": "image/png",- "created_by": "6ad1ab0a-73ff-4ac1-b9e4-cdb312f71f13",- "created_at": 1577836800,- }- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/end-users/:end_user_id'- method='GET'- title='Get End User'- name='#end-user'-/>-<Row>- <Col>- Retrieve an end user by ID.-- This is useful when other APIs return an end-user ID (e.g. `created_by` from File Upload).-- ### Path Parameters- - `end_user_id` (uuid) Required- End user ID.-- ### Response- Returns an EndUser object.- - `id` (uuid) ID- - `tenant_id` (uuid) Tenant ID- - `app_id` (uuid) App ID- - `type` (string) End user type- - `external_user_id` (string) External user ID- - `name` (string) Name- - `is_anonymous` (boolean) Whether anonymous- - `session_id` (string) Session ID- - `created_at` (string) ISO 8601 datetime- - `updated_at` (string) ISO 8601 datetime-- ### Errors- - 404, `end_user_not_found`, end user not found- - 500, internal server error-- </Col>- <Col sticky>- ### Request Example- <CodeGroup- title="Request"- tag="GET"- label="/end-users/:end_user_id"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/end-users/6ad1ab0a-73ff-4ac1-b9e4-cdb312f71f13' \\---header 'Authorization: Bearer {api_key}'`}- />-- ### Response Example- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "id": "6ad1ab0a-73ff-4ac1-b9e4-cdb312f71f13",- "tenant_id": "8c0f3f3a-66b0-4b55-a0bf-8b8e0d6aee7d",- "app_id": "6c8c3f41-2c6f-4e1b-8f4f-7f11c8f2ad2a",- "type": "service_api",- "external_user_id": "abc-123",- "name": "Alice",- "is_anonymous": false,- "session_id": "abc-123",- "created_at": "2024-01-01T00:00:00Z",- "updated_at": "2024-01-01T00:00:00Z"- }- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/files/:file_id/preview'- method='GET'- title='File Preview'- name='#file-preview'-/>-<Row>- <Col>- Preview or download uploaded files. This endpoint allows you to access files that have been previously uploaded via the File Upload API.-- <i>Files can only be accessed if they belong to messages within the requesting application.</i>-- ### Path Parameters- - `file_id` (string) Required- The unique identifier of the file to preview, obtained from the File Upload API response.-- ### Query Parameters- - `as_attachment` (boolean) Optional- Whether to force download the file as an attachment. Default is `false` (preview in browser).-- ### Response- Returns the file content with appropriate headers for browser display or download.- - `Content-Type` Set based on file mime type- - `Content-Length` File size in bytes (if available)- - `Content-Disposition` Set to "attachment" if `as_attachment=true`- - `Cache-Control` Caching headers for performance- - `Accept-Ranges` Set to "bytes" for audio/video files-- ### Errors- - 400, `invalid_param`, abnormal parameter input- - 403, `file_access_denied`, file access denied or file does not belong to current application- - 404, `file_not_found`, file not found or has been deleted- - 500, internal server error-- </Col>- <Col sticky>- ### Request Example- <CodeGroup- title="Request"- tag="GET"- label="/files/:file_id/preview"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/files/72fa9618-8f89-4a37-9b33-7e1178a24a67/preview' \\---header 'Authorization: Bearer {api_key}'`}- />-- ### Download as Attachment- <CodeGroup- title="Download- Request"- tag="GET"- label="/files/:file_id/preview?as_attachment=true"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/files/72fa9618-8f89-4a37-9b33-7e1178a24a67/preview?as_attachment=true' \\---header 'Authorization: Bearer {api_key}' \\---output downloaded_file.png`}- />-- ### Response Headers Example- <CodeGroup title="Response Headers">- ```http {{ title: 'Headers - Image Preview' }}- Content-Type: image/png- Content-Length: 1024- Cache-Control: public, max-age=3600- ```- </CodeGroup>-- ### Download Response Headers- <CodeGroup title="Download Response Headers">- ```http {{ title: 'Headers - File Download' }}- Content-Type: image/png- Content-Length: 1024- Content-Disposition: attachment; filename*=UTF-8''example.png- Cache-Control: public, max-age=3600- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/completion-messages/:task_id/stop'- method='POST'- title='Stop Generate'- name='#stop-generatebacks'-/>-<Row>- <Col>- Only supported in streaming mode.- ### Path- - `task_id` (string) Task ID, can be obtained from the streaming chunk return- Request Body- - `user` (string) Required- User identifier, used to define the identity of the end-user, must be consistent with the user passed in the send message interface. The Service API does not share conversations created by the WebApp.- ### Response- - `result` (string) Always returns "success"- </Col>- <Col sticky>- ### Request Example- <CodeGroup- title="Request"- tag="POST"- label="/completion-messages/:task_id/stop"- targetCode={`curl -X POST '${props.appDetail.api_base_url}/completion-messages/:task_id/stop' \\--H 'Authorization: Bearer {api_key}' \\--H 'Content-Type: application/json' \\---data-raw '{ "user": "abc-123"}'`}- />-- ### Response Example- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "result": "success"- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/messages/:message_id/feedbacks'- method='POST'- title='Message Feedback'- name='#feedbacks'-/>-<Row>- <Col>- End-users can provide feedback messages, facilitating application developers to optimize expected outputs.-- ### Path- <Properties>- <Property name='message_id' type='string' key='message_id'>- Message ID- </Property>- </Properties>-- ### Request Body-- <Properties>- <Property name='rating' type='string' key='rating'>- Upvote as `like`, downvote as `dislike`, revoke upvote as `null`- </Property>- <Property name='user' type='string' key='user'>- User identifier, defined by the developer's rules, must be unique within the application.- </Property>- <Property name='content' type='string' key='content'>- The specific content of message feedback.- </Property>- </Properties>-- ### Response- - `result` (string) Always returns "success"- </Col>- <Col sticky>-- <CodeGroup- title="Request"- tag="POST"- label="/messages/:message_id/feedbacks"- targetCode={`curl -X POST '${props.appDetail.api_base_url}/messages/:message_id/feedbacks \\---header 'Authorization: Bearer {api_key}' \\---header 'Content-Type: application/json' \\---data-raw '{- "rating": "like",- "user": "abc-123",- "content": "message feedback information"-}'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "result": "success"- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/app/feedbacks'- method='GET'- title='Get feedbacks of application'- name='#app-feedbacks'-/>-<Row>- <Col>- Get application's feedbacks.-- ### Query- <Properties>- <Property name='page' type='string' key='page'>- (optional)pagination,default:1- </Property>- </Properties>-- <Properties>- <Property name='limit' type='string' key='limit'>- (optional) records per page default:20- </Property>- </Properties>-- ### Response- - `data` (List) return apps feedback list.- </Col>- <Col sticky>-- <CodeGroup- title="Request"- tag="GET"- label="/app/feedbacks"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/app/feedbacks?page=1&limit=20'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "data": [- {- "id": "8c0fbed8-e2f9-49ff-9f0e-15a35bdd0e25",- "app_id": "f252d396-fe48-450e-94ec-e184218e7346",- "conversation_id": "2397604b-9deb-430e-b285-4726e51fd62d",- "message_id": "709c0b0f-0a96-4a4e-91a4-ec0889937b11",- "rating": "like",- "content": "message feedback information-3",- "from_source": "user",- "from_end_user_id": "74286412-9a1a-42c1-929c-01edb1d381d5",- "from_account_id": null,- "created_at": "2025-04-24T09:24:38",- "updated_at": "2025-04-24T09:24:38"- }- ]- }- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/text-to-audio'- method='POST'- title='Text to Audio'- name='#audio'-/>-<Row>- <Col>- Text to speech.-- ### Request Body-- <Properties>- <Property name='message_id' type='str' key='message_id'>- For text messages generated by Dify, simply pass the generated message-id directly. The backend will use the message-id to look up the corresponding content and synthesize the voice information directly. If both message_id and text are provided simultaneously, the message_id is given priority.- </Property>- <Property name='text' type='str' key='text'>- Speech generated content.- </Property>- <Property name='user' type='string' key='user'>- The user identifier, defined by the developer, must ensure uniqueness within the app.- </Property>- </Properties>- </Col>- <Col sticky>-- <CodeGroup- title="Request"- tag="POST"- label="/text-to-audio"- targetCode={`curl -o text-to-audio.mp3 -X POST '${props.appDetail.api_base_url}/text-to-audio' \\---header 'Authorization: Bearer {api_key}' \\---header 'Content-Type: application/json' \\---data-raw '{- "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290",- "text": "Hello Dify",- "user": "abc-123"-}'`}- />-- <CodeGroup title="headers">- ```json {{ title: 'headers' }}- {- "Content-Type": "audio/wav"- }- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/info'- method='GET'- title='Get Application Basic Information'- name='#info'-/>-<Row>- <Col>- Used to get basic information about this application-- ### Response- - `name` (string) application name- - `description` (string) application description- - `tags` (array[string]) application tags- - `mode` (string) application mode- - `author_name` (string) author name- </Col>- <Col>- <CodeGroup- title="Request"- tag="GET"- label="/info"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/info' \\--H 'Authorization: Bearer {api_key}'`}- />- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "name": "My App",- "description": "This is my app.",- "tags": [- "tag1",- "tag2"- ],- "mode": "chat",- "author_name": "Dify"- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/parameters'- method='GET'- title='Get Application Parameters Information'- name='#parameters'-/>-<Row>- <Col>- Used at the start of entering the page to obtain information such as features, input parameter names, types, and default values.-- ### Response- - `opening_statement` (string) Opening statement- - `suggested_questions` (array[string]) List of suggested questions for the opening- - `suggested_questions_after_answer` (object) Suggest questions after enabling the answer.- - `enabled` (bool) Whether it is enabled- - `speech_to_text` (object) Speech to text- - `enabled` (bool) Whether it is enabled- - `retriever_resource` (object) Citation and Attribution- - `enabled` (bool) Whether it is enabled- - `annotation_reply` (object) Annotation reply- - `enabled` (bool) Whether it is enabled- - `user_input_form` (array[object]) User input form configuration- - `text-input` (object) Text input control- - `label` (string) Variable display label name- - `variable` (string) Variable ID- - `required` (bool) Whether it is required- - `default` (string) Default value- - `paragraph` (object) Paragraph text input control- - `label` (string) Variable display label name- - `variable` (string) Variable ID- - `required` (bool) Whether it is required- - `default` (string) Default value- - `select` (object) Dropdown control- - `label` (string) Variable display label name- - `variable` (string) Variable ID- - `required` (bool) Whether it is required- - `default` (string) Default value- - `options` (array[string]) Option values- - `file_upload` (object) File upload configuration- - `document` (object) Document settings- Currently only supports document types: `txt`, `md`, `markdown`, `pdf`, `html`, `xlsx`, `xls`, `docx`, `csv`, `eml`, `msg`, `pptx`, `ppt`, `xml`, `epub`.- - `enabled` (bool) Whether it is enabled- - `number_limits` (int) Document number limit, default is 3- - `transfer_methods` (array[string]) List of transfer methods: `remote_url`, `local_file`. Must choose one.- - `image` (object) Image settings- Currently only supports image types: `png`, `jpg`, `jpeg`, `webp`, `gif`.- - `enabled` (bool) Whether it is enabled- - `number_limits` (int) Image number limit, default is 3- - `transfer_methods` (array[string]) List of transfer methods: `remote_url`, `local_file`. Must choose one.- - `audio` (object) Audio settings- Currently only supports audio types: `mp3`, `m4a`, `wav`, `webm`, `amr`.- - `enabled` (bool) Whether it is enabled- - `number_limits` (int) Audio number limit, default is 3- - `transfer_methods` (array[string]) List of transfer methods: `remote_url`, `local_file`. Must choose one.- - `video` (object) Video settings- Currently only supports video types: `mp4`, `mov`, `mpeg`, `mpga`.- - `enabled` (bool) Whether it is enabled- - `number_limits` (int) Video number limit, default is 3- - `transfer_methods` (array[string]) List of transfer methods: `remote_url`, `local_file`. Must choose one.- - `custom` (object) Custom settings- - `enabled` (bool) Whether it is enabled- - `number_limits` (int) Custom number limit, default is 3- - `transfer_methods` (array[string]) List of transfer methods: `remote_url`, `local_file`. Must choose one.- - `system_parameters` (object) System parameters- - `file_size_limit` (int) Document upload size limit (MB)- - `image_file_size_limit` (int) Image file upload size limit (MB)- - `audio_file_size_limit` (int) Audio file upload size limit (MB)- - `video_file_size_limit` (int) Video file upload size limit (MB)-- </Col>- <Col sticky>-- <CodeGroup- title="Request"- tag="GET"- label="/parameters"- targetCode={` curl -X GET '${props.appDetail.api_base_url}/parameters'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "opening_statement": "Hello!",- "suggested_questions_after_answer": {- "enabled": true- },- "speech_to_text": {- "enabled": true- },- "retriever_resource": {- "enabled": true- },- "annotation_reply": {- "enabled": true- },- "user_input_form": [- {- "paragraph": {- "label": "Query",- "variable": "query",- "required": true,- "default": ""- }- }- ],- "file_upload": {- "image": {- "enabled": false,- "number_limits": 3,- "detail": "high",- "transfer_methods": [- "remote_url",- "local_file"- ]- }- },- "system_parameters": {- "file_size_limit": 15,- "image_file_size_limit": 10,- "audio_file_size_limit": 50,- "video_file_size_limit": 100- }- }- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/site'- method='GET'- title='Get Application WebApp Settings'- name='#site'-/>-<Row>- <Col>- Used to get the WebApp settings of the application.- ### Response- - `title` (string) WebApp name- - `chat_color_theme` (string) Chat color theme, in hex format- - `chat_color_theme_inverted` (bool) Whether the chat color theme is inverted- - `icon_type` (string) Icon type, `emoji` - emoji, `image` - picture- - `icon` (string) Icon. If it's `emoji` type, it's an emoji symbol; if it's `image` type, it's an image URL.- - `icon_background` (string) Background color in hex format- - `icon_url` (string) Icon URL- - `description` (string) Description- - `copyright` (string) Copyright information- - `privacy_policy` (string) Privacy policy link- - `custom_disclaimer` (string) Custom disclaimer- - `default_language` (string) Default language- - `show_workflow_steps` (bool) Whether to show workflow details- - `use_icon_as_answer_icon` (bool) Whether to replace 🤖 in chat with the WebApp icon- </Col>- <Col>- <CodeGroup- title="Request"- tag="GET"- label="/site"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/site' \\--H 'Authorization: Bearer {api_key}'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "title": "My App",- "chat_color_theme": "#ff4a4a",- "chat_color_theme_inverted": false,- "icon_type": "emoji",- "icon": "😄",- "icon_background": "#FFEAD5",- "icon_url": null,- "description": "This is my app.",- "copyright": "all rights reserved",- "privacy_policy": "",- "custom_disclaimer": "All generated by AI",- "default_language": "en-US",- "show_workflow_steps": false,- "use_icon_as_answer_icon": false,- }- ```- </CodeGroup>- </Col>-</Row>-___diff --git a/web/app/components/develop/template/template.ja.mdx b/web/app/components/develop/template/template.ja.mdxdeleted file mode 100755index 2dd311112e9..00000000000--- a/web/app/components/develop/template/template.ja.mdx+++ /dev/null@@ -1,866 +0,0 @@-import { CodeGroup } from '../code.tsx'-import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx'--# Completion アプリ API--テキスト生成アプリケーションはセッションレスをサポートし、翻訳、記事作成、要約 AI 等に最適です。--<div>- ### ベース URL- <CodeGroup title="コード" targetCode={props.appDetail.api_base_url} />-- ### 認証-- サービス API は `API-Key` 認証を使用します。- <i>**API キーの漏洩による重大な結果を避けるため、API キーはサーバーサイドに保存し、クライアントサイドでは共有や保存しないことを強く推奨します。**</i>-- すべての API リクエストで、以下のように `Authorization` HTTP ヘッダーに API キーを含めてください:-- <CodeGroup title="コード" targetCode='Authorization: Bearer {API_KEY}' />-</div>-------<Heading- url='/completion-messages'- method='POST'- title='完了メッセージの作成'- name='#Create-Completion-Message'-/>-<Row>- <Col>- テキスト生成アプリケーションにリクエストを送信します。-- ### リクエストボディ-- <Properties>-- <Property name='inputs' type='object' key='inputs'>- アプリで定義された各種変数値を入力できます。- `inputs`パラメータには複数のキー/値ペアが含まれ、各キーは特定の変数に対応し、各値はその変数の具体的な値となります。- テキスト生成アプリケーションでは、少なくとも1つのキー/値ペアの入力が必要です。- - `query` (string) 必須- 入力テキスト、処理される内容。- </Property>- <Property name='response_mode' type='string' key='response_mode'>- レスポンス返却モード、以下をサポート:- - `streaming` ストリーミングモード(推奨)、SSE([Server-Sent Events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events))によるタイプライター風の出力を実装。- - `blocking` ブロッキングモード、実行完了後に結果を返却。(処理が長い場合はリクエストが中断される可能性があります)- <i>Cloudflareの制限により、100秒後に返却なしで中断されます。</i>- </Property>- <Property name='user' type='string' key='user'>- ユーザー識別子、エンドユーザーの身元を定義し、取得や統計に使用します。- アプリケーション内で開発者が一意に定義する必要があります。- </Property>- <Property name='files' type='array[object]' key='files'>- ファイルリスト、モデルが Vision/Video 機能をサポートしている場合に限り、ファイルをテキスト理解および質問応答に組み合わせて入力するのに適しています。- - `type` (string) サポートされるタイプ:- - `document` サポートされるタイプには以下が含まれます:'TXT', 'MD', 'MARKDOWN', 'MDX', 'PDF', 'HTML', 'XLSX', 'XLS', 'VTT', 'PROPERTIES', 'DOC', 'DOCX', 'CSV', 'EML', 'MSG', 'PPTX', 'PPT', 'XML', 'EPUB'- - `image` サポートされるタイプには以下が含まれます:'JPG', 'JPEG', 'PNG', 'GIF', 'WEBP', 'SVG'- - `audio` サポートされるタイプには以下が含まれます:'MP3', 'M4A', 'WAV', 'WEBM', 'MPGA'- - `video` サポートされるタイプには以下が含まれます:'MP4', 'MOV', 'MPEG', 'WEBM'- - `custom` サポートされるタイプには以下が含まれます:その他のファイルタイプ- - `transfer_method` (string) 転送方法:- - `remote_url`: ファイルのURL。- - `local_file`: ファイルをアップロード。- - `url` ファイルのURL。(転送方法が `remote_url` の場合のみ)。- - `upload_file_id` アップロードされたファイルID。(転送方法が `local_file` の場合のみ)。- </Property>- <Property name='trace_session_id' type='string' key='trace_session_id'>- (オプション)可観測性のグルーピングに使用するトレースセッションID。セッションのグルーピングに対応するトレースプロバイダーは、この値をエクスポートされるセッション識別子として使用できます。conversation_id、workflow_run_id、trace_id、または span の関係は変更しません。以下の3つの方法で渡すことができ、優先順位は次のとおりです:<br/>- - Header:HTTPヘッダー <code>X-Trace-Session-Id</code> で渡す(最優先)。<br/>- - クエリパラメータ:URLクエリパラメータ <code>trace_session_id</code> で渡す。<br/>- - リクエストボディ:リクエストボディの <code>trace_session_id</code> フィールドで渡す(本フィールド)。<br/>- </Property>- </Properties>-- ### レスポンス- `response_mode`が`blocking`の場合、CompletionResponseオブジェクトを返却します。- `response_mode`が`streaming`の場合、ChunkCompletionResponseストリームを返却します。-- ### ChatCompletionResponse- アプリの完全な結果を返却、`Content-Type`は`application/json`です。- - `message_id` (string) 一意のメッセージID- - `mode` (string) アプリモード、固定で`chat`- - `answer` (string) 完全な応答内容- - `metadata` (object) メタデータ- - `usage` (Usage) モデル使用情報- - `retriever_resources` (array[RetrieverResource]) 引用と帰属のリスト- - `created_at` (int) メッセージ作成タイムスタンプ、例:1705395332-- ### ChunkChatCompletionResponse- アプリが出力するストリームチャンクを返却、`Content-Type`は`text/event-stream`です。- 各ストリーミングチャンクは`data:`で始まり、2つの改行文字`\n\n`で区切られます:- <CodeGroup>- ```streaming {{ title: 'Response' }}- data: {"event": "message", "task_id": "900bbd43-dc0b-4383-a372-aa6e6c414227", "id": "663c5084-a254-4040-8ad3-51f2a3c1a77c", "answer": "Hi", "created_at": 1705398420}\n\n- ```- </CodeGroup>- ストリーミングチャンクの構造は`event`によって異なります:- - `event: message` LLMがテキストチャンクを返すイベント、つまり完全なテキストがチャンク形式で出力されます。- - `task_id` (string) タスクID、リクエストの追跡と以下の生成停止APIに使用- - `message_id` (string) 一意のメッセージID- - `answer` (string) LLMが返したテキストチャンクの内容- - `created_at` (int) 作成タイムスタンプ、例:1705395332- - `event: message_end` メッセージ終了イベント、このイベントを受信するとストリーミングが終了したことを意味します。- - `task_id` (string) タスクID、リクエストの追跡と以下の生成停止APIに使用- - `message_id` (string) 一意のメッセージID- - `metadata` (object) メタデータ- - `usage` (Usage) モデル使用情報- - `retriever_resources` (array[RetrieverResource]) 引用と帰属のリスト- - `event: tts_message` TTS音声ストリームイベント、つまり音声合成出力。内容はMp3形式の音声ブロックで、base64文字列としてエンコードされています。再生時は単にbase64をデコードしてプレーヤーに供給するだけです。(このメッセージは自動再生が有効な場合のみ利用可能)- - `task_id` (string) タスクID、リクエストの追跡と以下の応答停止インターフェースに使用- - `message_id` (string) 一意のメッセージID- - `audio` (string) 音声合成後の音声、base64テキストコンテンツとしてエンコード、再生時は単にbase64をデコードしてプレーヤーに供給- - `created_at` (int) 作成タイムスタンプ、例:1705395332- - `event: tts_message_end` TTS音声ストリーム終了イベント、このイベントを受信すると音声ストリームが終了したことを示します。- - `task_id` (string) タスクID、リクエストの追跡と以下の応答停止インターフェースに使用- - `message_id` (string) 一意のメッセージID- - `audio` (string) 終了イベントには音声がないため、空文字列- - `created_at` (int) 作成タイムスタンプ、例:1705395332- - `event: message_replace` メッセージ内容置換イベント。- 出力内容のモデレーションが有効な場合、コンテンツがフラグ付けされると、このイベントを通じてメッセージ内容が事前設定された返信に置き換えられます。- - `task_id` (string) タスクID、リクエストの追跡と以下の生成停止APIに使用- - `message_id` (string) 一意のメッセージID- - `answer` (string) 置換内容(LLMの返信テキストすべてを直接置換)- - `created_at` (int) 作成タイムスタンプ、例:1705395332- - `event: error`- ストリーミング処理中に発生した例外は、ストリームイベントの形式で出力され、エラーイベントを受信するとストリームが終了します。- - `task_id` (string) タスクID、リクエストの追跡と以下の生成停止APIに使用- - `message_id` (string) 一意のメッセージID- - `status` (int) HTTPステータスコード- - `code` (string) エラーコード- - `message` (string) エラーメッセージ- - `event: ping` 接続を維持するため10秒ごとのPingイベント。-- ### エラー- - 404, 会話が存在しません- - 400, `invalid_param`, パラメータ入力異常- - 400, `app_unavailable`, アプリ設定が利用できません- - 400, `provider_not_initialize`, 利用可能なモデル認証情報設定がありません- - 400, `provider_quota_exceeded`, モデル呼び出しクォータ不足- - 400, `model_currently_not_support`, 現在のモデルは利用できません- - 400, `completion_request_error`, テキスト生成に失敗しました- - 500, 内部サーバーエラー-- </Col>- <Col sticky>-- <CodeGroup- title="Request"- tag="POST"- label="/completion-messages"- targetCode={`curl -X POST '${props.appDetail.api_base_url}/completion-messages' \\---header 'Authorization: Bearer {api_key}' \\---header 'Content-Type: application/json' \\---data-raw '{- "inputs": {"query": "Hello, world!"},- "response_mode": "streaming",- "user": "abc-123"-}'`}- />- ### ブロッキングモード- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "event": "message",- "message_id": "9da23599-e713-473b-982c-4328d4f5c78a",- "mode": "completion",- "answer": "Hello World!...",- "metadata": {- "usage": {- "prompt_tokens": 1033,- "prompt_unit_price": "0.001",- "prompt_price_unit": "0.001",- "prompt_price": "0.0010330",- "completion_tokens": 128,- "completion_unit_price": "0.002",- "completion_price_unit": "0.001",- "completion_price": "0.0002560",- "total_tokens": 1161,- "total_price": "0.0012890",- "currency": "USD",- "latency": 0.7682376249867957- }- },- "created_at": 1705407629- }- ```- </CodeGroup>- ### ストリーミングモード- <CodeGroup title="Response">- ```streaming {{ title: 'Response' }}- data: {"event": "message", "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "answer": " I", "created_at": 1679586595}- data: {"event": "message", "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "answer": "'m", "created_at": 1679586595}- data: {"event": "message", "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "answer": " glad", "created_at": 1679586595}- data: {"event": "message", "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "answer": " to", "created_at": 1679586595}- data: {"event": "message", "message_id" : "5ad4cb98-f0c7-4085-b384-88c403be6290", "answer": " meet", "created_at": 1679586595}- data: {"event": "message", "message_id" : "5ad4cb98-f0c7-4085-b384-88c403be6290", "answer": " you", "created_at": 1679586595}- data: {"event": "message_end", "id": "5e52ce04-874b-4d27-9045-b3bc80def685", "metadata": {"usage": {"prompt_tokens": 1033, "prompt_unit_price": "0.001", "prompt_price_unit": "0.001", "prompt_price": "0.0010330", "completion_tokens": 135, "completion_unit_price": "0.002", "completion_price_unit": "0.001", "completion_price": "0.0002700", "total_tokens": 1168, "total_price": "0.0013030", "currency": "USD", "latency": 1.381760165997548}}}- data: {"event": "tts_message", "conversation_id": "23dd85f3-1a41-4ea0-b7a9-062734ccfaf9", "message_id": "a8bdc41c-13b2-4c18-bfd9-054b9803038c", "created_at": 1721205487, "task_id": "3bf8a0bb-e73b-4690-9e66-4e429bad8ee7", "audio": "qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq"}- data: {"event": "tts_message_end", "conversation_id": "23dd85f3-1a41-4ea0-b7a9-062734ccfaf9", "message_id": "a8bdc41c-13b2-4c18-bfd9-054b9803038c", "created_at": 1721205487, "task_id": "3bf8a0bb-e73b-4690-9e66-4e429bad8ee7", "audio": ""}- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/files/upload'- method='POST'- title='ファイルアップロード'- name='#file-upload'-/>-<Row>- <Col>- メッセージ送信時に使用するファイル(現在は画像のみ対応)をアップロードし、画像とテキストのマルチモーダルな理解を可能にします。- png、jpg、jpeg、webp、gif 形式に対応しています。- <i>アップロードされたファイルは、現在のエンドユーザーのみが使用できます。</i>-- ### リクエストボディ- このインターフェースは`multipart/form-data`リクエストが必要です。- - `file` (File) 必須- アップロードするファイル。- - `user` (string) 必須- 開発者のルールで定義されたユーザー識別子。アプリケーション内で一意である必要があります。サービス API は WebApp によって作成された会話を共有しません。-- ### レスポンス- アップロードが成功すると、サーバーはファイルの ID と関連情報を返します。- - `id` (uuid) ID- - `name` (string) ファイル名- - `size` (int) ファイルサイズ(バイト)- - `extension` (string) ファイル拡張子- - `mime_type` (string) ファイルの MIME タイプ- - `created_by` (uuid) エンドユーザーID- - `created_at` (timestamp) 作成タイムスタンプ、例:1705395332-- ### エラー- - 400, `no_file_uploaded`, ファイルを提供する必要があります- - 400, `too_many_files`, 現在は 1 つのファイルのみ受け付けています- - 400, `unsupported_preview`, ファイルがプレビューに対応していません- - 400, `unsupported_estimate`, ファイルが推定に対応していません- - 413, `file_too_large`, ファイルが大きすぎます- - 415, `unsupported_file_type`, サポートされていない拡張子です。現在はドキュメントファイルのみ受け付けています- - 503, `s3_connection_failed`, S3 サービスに接続できません- - 503, `s3_permission_denied`, S3 へのファイルアップロード権限がありません- - 503, `s3_file_too_large`, ファイルが S3 のサイズ制限を超えています- - 500, 内部サーバーエラー-- </Col>- <Col sticky>- ### リクエスト例- <CodeGroup- title="Request"- tag="POST"- label="/files/upload"- targetCode={`curl -X POST '${props.appDetail.api_base_url}/files/upload' \\---header 'Authorization: Bearer {api_key}' \\---form 'file=@localfile;type=image/[png|jpeg|jpg|webp|gif]' \\---form 'user=abc-123'`}- />--- ### レスポンス例- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "id": "72fa9618-8f89-4a37-9b33-7e1178a24a67",- "name": "example.png",- "size": 1024,- "extension": "png",- "mime_type": "image/png",- "created_by": "6ad1ab0a-73ff-4ac1-b9e4-cdb312f71f13",- "created_at": 1577836800,- }- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/end-users/:end_user_id'- method='GET'- title='エンドユーザーを取得'- name='#end-user'-/>-<Row>- <Col>- エンドユーザー ID からエンドユーザー情報を取得します。-- 他の API がエンドユーザー ID(例:ファイルアップロードの `created_by`)を返す場合に利用できます。-- ### パスパラメータ- - `end_user_id` (uuid) 必須- エンドユーザー ID。-- ### レスポンス- EndUser オブジェクトを返します。- - `id` (uuid) ID- - `tenant_id` (uuid) テナント ID- - `app_id` (uuid) アプリ ID- - `type` (string) エンドユーザー種別- - `external_user_id` (string) 外部ユーザー ID- - `name` (string) 名前- - `is_anonymous` (boolean) 匿名ユーザーかどうか- - `session_id` (string) セッション ID- - `created_at` (string) ISO 8601 日時- - `updated_at` (string) ISO 8601 日時-- ### エラー- - 404, `end_user_not_found`, エンドユーザーが見つかりません- - 500, 内部サーバーエラー-- </Col>- <Col sticky>- ### リクエスト例- <CodeGroup- title="Request"- tag="GET"- label="/end-users/:end_user_id"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/end-users/6ad1ab0a-73ff-4ac1-b9e4-cdb312f71f13' \\---header 'Authorization: Bearer {api_key}'`}- />-- ### レスポンス例- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "id": "6ad1ab0a-73ff-4ac1-b9e4-cdb312f71f13",- "tenant_id": "8c0f3f3a-66b0-4b55-a0bf-8b8e0d6aee7d",- "app_id": "6c8c3f41-2c6f-4e1b-8f4f-7f11c8f2ad2a",- "type": "service_api",- "external_user_id": "abc-123",- "name": "Alice",- "is_anonymous": false,- "session_id": "abc-123",- "created_at": "2024-01-01T00:00:00Z",- "updated_at": "2024-01-01T00:00:00Z"- }- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/files/:file_id/preview'- method='GET'- title='ファイルプレビュー'- name='#file-preview'-/>-<Row>- <Col>- アップロードされたファイルをプレビューまたはダウンロードします。このエンドポイントを使用すると、以前にファイルアップロード API でアップロードされたファイルにアクセスできます。-- <i>ファイルは、リクエストしているアプリケーションのメッセージ範囲内にある場合のみアクセス可能です。</i>-- ### パスパラメータ- - `file_id` (string) 必須- プレビューするファイルの一意識別子。ファイルアップロード API レスポンスから取得します。-- ### クエリパラメータ- - `as_attachment` (boolean) オプション- ファイルを添付ファイルとして強制ダウンロードするかどうか。デフォルトは `false`(ブラウザでプレビュー)。-- ### レスポンス- ブラウザ表示またはダウンロード用の適切なヘッダー付きでファイル内容を返します。- - `Content-Type` ファイル MIME タイプに基づいて設定- - `Content-Length` ファイルサイズ(バイト、利用可能な場合)- - `Content-Disposition` `as_attachment=true` の場合は "attachment" に設定- - `Cache-Control` パフォーマンス向上のためのキャッシュヘッダー- - `Accept-Ranges` 音声/動画ファイルの場合は "bytes" に設定-- ### エラー- - 400, `invalid_param`, パラメータ入力異常- - 403, `file_access_denied`, ファイルアクセス拒否またはファイルが現在のアプリケーションに属していません- - 404, `file_not_found`, ファイルが見つからないか削除されています- - 500, サーバー内部エラー-- </Col>- <Col sticky>- ### リクエスト例- <CodeGroup- title="Request"- tag="GET"- label="/files/:file_id/preview"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/files/72fa9618-8f89-4a37-9b33-7e1178a24a67/preview' \\---header 'Authorization: Bearer {api_key}'`}- />-- ### 添付ファイルとしてダウンロード- <CodeGroup- title="Request"- tag="GET"- label="/files/:file_id/preview"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/files/72fa9618-8f89-4a37-9b33-7e1178a24a67/preview?as_attachment=true' \\---header 'Authorization: Bearer {api_key}' \\---output downloaded_file.png`}- />-- ### レスポンスヘッダー例- <CodeGroup title="Response Headers">- ```http {{ title: 'ヘッダー - 画像プレビュー' }}- Content-Type: image/png- Content-Length: 1024- Cache-Control: public, max-age=3600- ```- </CodeGroup>-- ### ファイルダウンロードレスポンスヘッダー- <CodeGroup title="Response Headers">- ```http {{ title: 'ヘッダー - ファイルダウンロード' }}- Content-Type: image/png- Content-Length: 1024- Content-Disposition: attachment; filename*=UTF-8''example.png- Cache-Control: public, max-age=3600- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/completion-messages/:task_id/stop'- method='POST'- title='生成の停止'- name='#stop-generatebacks'-/>-<Row>- <Col>- ストリーミングモードでのみサポートされています。- ### パス- - `task_id` (string) タスク ID、ストリーミングチャンクの返信から取得可能- リクエストボディ- - `user` (string) 必須- ユーザー識別子。エンドユーザーの身元を定義するために使用され、メッセージ送信インターフェースで渡されたユーザーと一致する必要があります。サービス API は WebApp によって作成された会話を共有しません。- ### レスポンス- - `result` (string) 常に"success"を返します- </Col>- <Col sticky>- ### リクエスト例- <CodeGroup- title="Request"- tag="POST"- label="/completion-messages/:task_id/stop"- targetCode={`curl -X POST '${props.appDetail.api_base_url}/completion-messages/:task_id/stop' \\--H 'Authorization: Bearer {api_key}' \\--H 'Content-Type: application/json' \\---data-raw '{ "user": "abc-123"}'`}- />-- ### レスポンス例- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "result": "success"- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/messages/:message_id/feedbacks'- method='POST'- title='メッセージフィードバック'- name='#feedbacks'-/>-<Row>- <Col>- エンドユーザーはフィードバックメッセージを提供でき、アプリケーション開発者が期待される出力を最適化するのに役立ちます。-- ### パス- <Properties>- <Property name='message_id' type='string' key='message_id'>- メッセージID- </Property>- </Properties>-- ### リクエストボディ-- <Properties>- <Property name='rating' type='string' key='rating'>- 高評価は`like`、低評価は`dislike`、高評価の取り消しは`null`- </Property>- <Property name='user' type='string' key='user'>- 開発者のルールで定義されたユーザー識別子。アプリケーション内で一意である必要があります。- </Property>- <Property name='content' type='string' key='content'>- メッセージのフィードバックです。- </Property>- </Properties>-- ### レスポンス- - `result` (string) 常に"success"を返します- </Col>- <Col sticky>-- <CodeGroup- title="Request"- tag="POST"- label="/messages/:message_id/feedbacks"- targetCode={`curl -X POST '${props.appDetail.api_base_url}/messages/:message_id/feedbacks \\---header 'Authorization: Bearer {api_key}' \\---header 'Content-Type: application/json' \\---data-raw '{- "rating": "like",- "user": "abc-123",- "content": "message feedback information"-}'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "result": "success"- }- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/app/feedbacks'- method='GET'- title='アプリのメッセージの「いいね」とフィードバックを取得'- name='#app-feedbacks'-/>-<Row>- <Col>- アプリのエンドユーザーからのフィードバックや「いいね」を取得します。-- ### クエリ- <Properties>- <Property name='page' type='string' key='page'>- (任意)ページ番号。デフォルト値:1- </Property>- </Properties>-- <Properties>- <Property name='limit' type='string' key='limit'>- (任意)1ページあたりの件数。デフォルト値:20- </Property>- </Properties>-- ### レスポンス- - `data` (リスト) このアプリの「いいね」とフィードバックの一覧を返します。- </Col>- <Col sticky>-- <CodeGroup- title="Request"- tag="GET"- label="/app/feedbacks"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/app/feedbacks?page=1&limit=20'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "data": [- {- "id": "8c0fbed8-e2f9-49ff-9f0e-15a35bdd0e25",- "app_id": "f252d396-fe48-450e-94ec-e184218e7346",- "conversation_id": "2397604b-9deb-430e-b285-4726e51fd62d",- "message_id": "709c0b0f-0a96-4a4e-91a4-ec0889937b11",- "rating": "like",- "content": "message feedback information-3",- "from_source": "user",- "from_end_user_id": "74286412-9a1a-42c1-929c-01edb1d381d5",- "from_account_id": null,- "created_at": "2025-04-24T09:24:38",- "updated_at": "2025-04-24T09:24:38"- }- ]- }- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/text-to-audio'- method='POST'- title='テキストから音声'- name='#text-to-audio'-/>-<Row>- <Col>- テキストを音声に変換します。-- ### リクエストボディ-- <Properties>- <Property name='message_id' type='str' key='message_id'>- Difyが生成したテキストメッセージの場合、生成されたmessage-idを直接渡すだけです。バックエンドはmessage-idを使用して対応するコンテンツを検索し、音声情報を直接合成します。message_idとtextの両方が同時に提供された場合、message_idが優先されます。- </Property>- <Property name='text' type='str' key='text'>- 音声生成コンテンツ。- </Property>- <Property name='user' type='string' key='user'>- 開発者が定義したユーザー識別子。アプリ内で一意性を確保する必要があります。- </Property>- </Properties>- </Col>- <Col sticky>-- <CodeGroup- title="Request"- tag="POST"- label="/text-to-audio"- targetCode={`curl -o text-to-audio.mp3 -X POST '${props.appDetail.api_base_url}/text-to-audio' \\---header 'Authorization: Bearer {api_key}' \\---header 'Content-Type: application/json' \\---data-raw '{- "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290",- "text": "Hello Dify",- "user": "abc-123"-}'`}- />-- <CodeGroup title="headers">- ```json {{ title: 'headers' }}- {- "Content-Type": "audio/wav"- }- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/info'- method='GET'- title='アプリケーションの基本情報を取得'- name='#info'-/>-<Row>- <Col>- このアプリケーションの基本情報を取得するために使用されます-- ### Response- - `name` (string) アプリケーションの名前- - `description` (string) アプリケーションの説明- - `tags` (array[string]) アプリケーションのタグ- - `mode` (string) アプリケーションのモード- - `author_name` (string) 作者の名前- </Col>- <Col>- <CodeGroup- title="Request"- tag="GET"- label="/info"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/info' \\--H 'Authorization: Bearer {api_key}'`}- />- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "name": "My App",- "description": "This is my app.",- "tags": [- "tag1",- "tag2"- ],- "mode": "chat",- "author_name": "Dify"- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/parameters'- method='GET'- title='アプリケーションのパラメータ情報を取得'- name='#parameters'-/>-<Row>- <Col>- ページ開始時に、機能、入力パラメータ名、タイプ、デフォルト値などの情報を取得するために使用されます。-- ### レスポンス- - `opening_statement` (string) 開始文- - `suggested_questions` (array[string]) 開始時の提案質問リスト- - `suggested_questions_after_answer` (object) 回答後の提案質問を有効にします。- - `enabled` (bool) 有効かどうか- - `speech_to_text` (object) 音声からテキスト- - `enabled` (bool) 有効かどうか- - `retriever_resource` (object) 引用と帰属- - `enabled` (bool) 有効かどうか- - `annotation_reply` (object) 注釈付き返信- - `enabled` (bool) 有効かどうか- - `user_input_form` (array[object]) ユーザー入力フォーム設定- - `text-input` (object) テキスト入力コントロール- - `label` (string) 変数表示ラベル名- - `variable` (string) 変数ID- - `required` (bool) 必須かどうか- - `default` (string) デフォルト値- - `paragraph` (object) 段落テキスト入力コントロール- - `label` (string) 変数表示ラベル名- - `variable` (string) 変数ID- - `required` (bool) 必須かどうか- - `default` (string) デフォルト値- - `select` (object) ドロップダウンコントロール- - `label` (string) 変数表示ラベル名- - `variable` (string) 変数ID- - `required` (bool) 必須かどうか- - `default` (string) デフォルト値- - `options` (array[string]) オプション値- - `file_upload` (object) ファイルアップロード設定- - `document` (object) ドキュメント設定- 現在サポートされているドキュメントタイプ:`txt`, `md`, `markdown`, `pdf`, `html`, `xlsx`, `xls`, `docx`, `csv`, `eml`, `msg`, `pptx`, `ppt`, `xml`, `epub`。- - `enabled` (bool) 有効かどうか- - `number_limits` (int) ドキュメント数の上限。デフォルトは 3- - `transfer_methods` (array[string]) 転送方法リスト:`remote_url`, `local_file`。いずれかを選択する必要があります。- - `image` (object) 画像設定- 現在サポートされている画像タイプ:`png`, `jpg`, `jpeg`, `webp`, `gif`。- - `enabled` (bool) 有効かどうか- - `number_limits` (int) 画像数の上限。デフォルトは 3- - `transfer_methods` (array[string]) 転送方法リスト:`remote_url`, `local_file`。いずれかを選択する必要があります。- - `audio` (object) オーディオ設定- 現在サポートされているオーディオタイプ:`mp3`, `m4a`, `wav`, `webm`, `amr`。- - `enabled` (bool) 有効かどうか- - `number_limits` (int) オーディオ数の上限。デフォルトは 3- - `transfer_methods` (array[string]) 転送方法リスト:`remote_url`, `local_file`。いずれかを選択する必要があります。- - `video` (object) ビデオ設定- 現在サポートされているビデオタイプ:`mp4`, `mov`, `mpeg`, `mpga`。- - `enabled` (bool) 有効かどうか- - `number_limits` (int) ビデオ数の上限。デフォルトは 3- - `transfer_methods` (array[string]) 転送方法リスト:`remote_url`, `local_file`。いずれかを選択する必要があります。- - `custom` (object) カスタム設定- - `enabled` (bool) 有効かどうか- - `number_limits` (int) カスタム数の上限。デフォルトは 3- - `transfer_methods` (array[string]) 転送方法リスト:`remote_url`, `local_file`。いずれかを選択する必要があります。- - `system_parameters` (object) システムパラメータ- - `file_size_limit` (int) ドキュメントアップロードサイズ制限(MB)- - `image_file_size_limit` (int) 画像ファイルアップロードサイズ制限(MB)- - `audio_file_size_limit` (int) 音声ファイルアップロードサイズ制限(MB)- - `video_file_size_limit` (int) 動画ファイルアップロードサイズ制限(MB)-- </Col>- <Col sticky>-- <CodeGroup- title="Request"- tag="GET"- label="/parameters"- targetCode={` curl -X GET '${props.appDetail.api_base_url}/parameters'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "opening_statement": "Hello!",- "suggested_questions_after_answer": {- "enabled": true- },- "speech_to_text": {- "enabled": true- },- "retriever_resource": {- "enabled": true- },- "annotation_reply": {- "enabled": true- },- "user_input_form": [- {- "paragraph": {- "label": "Query",- "variable": "query",- "required": true,- "default": ""- }- }- ],- "file_upload": {- "image": {- "enabled": false,- "number_limits": 3,- "detail": "high",- "transfer_methods": [- "remote_url",- "local_file"- ]- }- },- "system_parameters": {- "file_size_limit": 15,- "image_file_size_limit": 10,- "audio_file_size_limit": 50,- "video_file_size_limit": 100- }- }- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/site'- method='GET'- title='アプリのWebApp設定を取得'- name='#site'-/>-<Row>- <Col>- アプリの WebApp 設定を取得するために使用します。- ### レスポンス- - `title` (string) WebApp 名- - `chat_color_theme` (string) チャットの色テーマ、16 進数形式- - `chat_color_theme_inverted` (bool) チャットの色テーマを反転するかどうか- - `icon_type` (string) アイコンタイプ、`emoji`-絵文字、`image`-画像- - `icon` (string) アイコン。`emoji`タイプの場合は絵文字、`image`タイプの場合は画像 URL- - `icon_background` (string) 16 進数形式の背景色- - `icon_url` (string) アイコンの URL- - `description` (string) 説明- - `copyright` (string) 著作権情報- - `privacy_policy` (string) プライバシーポリシーのリンク- - `custom_disclaimer` (string) カスタム免責事項- - `default_language` (string) デフォルト言語- - `show_workflow_steps` (bool) ワークフローの詳細を表示するかどうか- - `use_icon_as_answer_icon` (bool) WebApp のアイコンをチャット内の🤖に置き換えるかどうか- </Col>- <Col>- <CodeGroup- title="Request"- tag="GET"- label="/site"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/site' \\- -H 'Authorization: Bearer {api_key}'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "title": "My App",- "chat_color_theme": "#ff4a4a",- "chat_color_theme_inverted": false,- "icon_type": "emoji",- "icon": "😄",- "icon_background": "#FFEAD5",- "icon_url": null,- "description": "This is my app.",- "copyright": "all rights reserved",- "privacy_policy": "",- "custom_disclaimer": "All generated by AI",- "default_language": "en-US",- "show_workflow_steps": false,- "use_icon_as_answer_icon": false,- }- ```- </CodeGroup>- </Col>-</Row>-___diff --git a/web/app/components/develop/template/template.zh.mdx b/web/app/components/develop/template/template.zh.mdxdeleted file mode 100755index 6c412cc3cbb..00000000000--- a/web/app/components/develop/template/template.zh.mdx+++ /dev/null@@ -1,1101 +0,0 @@-import { CodeGroup } from '../code.tsx'-import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx'--# 文本生成型应用 API--文本生成应用无会话支持,适合用于翻译/文章写作/总结 AI 等等。--<div>- ### 基础 URL- <CodeGroup title="Code" targetCode={props.appDetail.api_base_url} />-- ### 鉴权--- Service API 使用 `API-Key` 进行鉴权。- <i>**强烈建议开发者把 `API-Key` 放在后端存储,而非分享或者放在客户端存储,以免 `API-Key` 泄露,导致财产损失。**</i>- 所有 API 请求都应在 **`Authorization`** HTTP Header 中包含您的 `API-Key`,如下所示:-- <CodeGroup title="Code" targetCode='Authorization: Bearer {API_KEY}' />-</div>-------<Heading- url='/completion-messages'- method='POST'- title='发送消息'- name='#Create-Completion-Message'-/>-<Row>- <Col>- 发送请求给文本生成型应用。-- ### Request Body-- <Properties>- <Property name='inputs' type='object' key='inputs'>- (选填)允许传入 App 定义的各变量值。- inputs 参数包含了多组键值对(Key/Value pairs),每组的键对应一个特定变量,每组的值则是该变量的具体值。- 文本生成型应用要求至少传入一组键值对。- - `query` (string) 必填- 用户输入的文本内容。- </Property>- <Property name='response_mode' type='string' key='response_mode'>- - `streaming` 流式模式(推荐)。基于 SSE(**[Server-Sent Events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events)**)实现类似打字机输出方式的流式返回。- - `blocking` 阻塞模式,等待执行完毕后返回结果。(请求若流程较长可能会被中断)。- <i>由于 Cloudflare 限制,请求会在 100 秒超时无返回后中断。</i>- </Property>- <Property name='user' type='string' key='user'>- 用户标识,用于定义终端用户的身份,方便检索、统计。- 由开发者定义规则,需保证用户标识在应用内唯一。- </Property>- <Property name='files' type='array[object]' key='files'>- 文件列表,适用于传入文件结合文本理解并回答问题,仅当模型支持 Vision/Video 能力时可用。- - `type` (string) 支持类型:- - `document` 具体类型包含:'TXT', 'MD', 'MARKDOWN', 'MDX', 'PDF', 'HTML', 'XLSX', 'XLS', 'VTT', 'PROPERTIES', 'DOC', 'DOCX', 'CSV', 'EML', 'MSG', 'PPTX', 'PPT', 'XML', 'EPUB'- - `image` 具体类型包含:'JPG', 'JPEG', 'PNG', 'GIF', 'WEBP', 'SVG'- - `audio` 具体类型包含:'MP3', 'M4A', 'WAV', 'WEBM', 'MPGA'- - `video` 具体类型包含:'MP4', 'MOV', 'MPEG', 'WEBM'- - `custom` 具体类型包含:其他文件类型- - `transfer_method` (string) 传递方式:- - `remote_url`: 文件地址。- - `local_file`: 上传文件。- - `url` 文件地址。(仅当传递方式为 `remote_url` 时)。- - `upload_file_id` 上传文件 ID。(仅当传递方式为 `local_file `时)。- </Property>- <Property name='trace_session_id' type='string' key='trace_session_id'>- (选填)用于可观测性分组的链路会话 ID。支持会话分组的追踪提供商可将该值用作导出的会话标识。它不会改变 conversation_id、workflow_run_id、trace_id 或 span 关系。支持以下三种方式传递,具体优先级依次为:<br/>- - Header:通过 HTTP Header <code>X-Trace-Session-Id</code> 传递,优先级最高。<br/>- - Query 参数:通过 URL 查询参数 <code>trace_session_id</code> 传递。<br/>- - Request Body:通过请求体字段 <code>trace_session_id</code> 传递(即本字段)。<br/>- </Property>- </Properties>-- ### Response- <Properties>- 当 `response_mode` 为 `blocking` 时,返回 ChatCompletionResponse object。- 当 `response_mode` 为 `streaming`时,返回 ChunkChatCompletionResponse object 流式序列。-- ### ChatCompletionResponse- 返回完整的 App 结果,`Content-Type` 为 `application/json`。- - `message_id` (string) 消息唯一 ID- - `mode` (string) App 模式,固定为 chat- - `answer` (string) 完整回复内容- - `metadata` (object) 元数据- - `usage` (Usage) 模型用量信息- - `retriever_resources` (array[RetrieverResource]) 引用和归属分段列表- - `created_at` (int) 消息创建时间戳,如:1705395332-- ### ChunkChatCompletionResponse- 返回 App 输出的流式块,`Content-Type` 为 `text/event-stream`。- 每个流式块均为 data: 开头,块之间以 `\n\n` 即两个换行符分隔,如下所示:- <CodeGroup>- ```streaming {{ title: 'Response' }}- data: {"event": "message", "task_id": "900bbd43-dc0b-4383-a372-aa6e6c414227", "id": "663c5084-a254-4040-8ad3-51f2a3c1a77c", "answer": "Hi", "created_at": 1705398420}\n\n- ```- </CodeGroup>- 流式块中根据 `event` 不同,结构也不同:- - `event: message` LLM 返回文本块事件,即:完整的文本以分块的方式输出。- - `task_id` (string) 任务 ID,用于请求跟踪和下方的停止响应接口- - `message_id` (string) 消息唯一 ID- - `answer` (string) LLM 返回文本块内容- - `created_at` (int) 创建时间戳,如:1705395332- - `event: message_end` 消息结束事件,收到此事件则代表文本流式返回结束。- - `task_id` (string) 任务 ID,用于请求跟踪和下方的停止响应接口- - `message_id` (string) 消息唯一 ID- - `metadata` (object) 元数据- - `usage` (Usage) 模型用量信息- - `retriever_resources` (array[RetrieverResource]) 引用和归属分段列表- - `event: tts_message` TTS 音频流事件,即:语音合成输出。内容是Mp3格式的音频块,使用 base64 编码后的字符串,播放的时候直接解码即可。(开启自动播放才有此消息)- - `task_id` (string) 任务 ID,用于请求跟踪和下方的停止响应接口- - `message_id` (string) 消息唯一 ID- - `audio` (string) 语音合成之后的音频块使用 Base64 编码之后的文本内容,播放的时候直接 base64 解码送入播放器即可- - `created_at` (int) 创建时间戳,如:1705395332- - `event: tts_message_end` TTS 音频流结束事件,收到这个事件表示音频流返回结束。- - `task_id` (string) 任务 ID,用于请求跟踪和下方的停止响应接口- - `message_id` (string) 消息唯一 ID- - `audio` (string) 结束事件是没有音频的,所以这里是空字符串- - `created_at` (int) 创建时间戳,如:1705395332- - `event: message_replace` 消息内容替换事件。- 开启内容审查和审查输出内容时,若命中了审查条件,则会通过此事件替换消息内容为预设回复。- - `task_id` (string) 任务 ID,用于请求跟踪和下方的停止响应接口- - `message_id` (string) 消息唯一 ID- - `answer` (string) 替换内容(直接替换 LLM 所有回复文本)- - `created_at` (int) 创建时间戳,如:1705395332- - `event: error`- 流式输出过程中出现的异常会以 stream event 形式输出,收到异常事件后即结束。- - `task_id` (string) 任务 ID,用于请求跟踪和下方的停止响应接口- - `message_id` (string) 消息唯一 ID- - `status` (int) HTTP 状态码- - `code` (string) 错误码- - `message` (string) 错误消息- - `event: ping` 每 10s 一次的 ping 事件,保持连接存活。-- ### Errors- - 404,对话不存在- - 400,`invalid_param`,传入参数异常- - 400,`app_unavailable`,App 配置不可用- - 400,`provider_not_initialize`,无可用模型凭据配置- - 400,`provider_quota_exceeded`,模型调用额度不足- - 400,`model_currently_not_support`,当前模型不可用- - 400,`completion_request_error`,文本生成失败- - 500,服务内部异常-- </Properties>- </Col>- <Col sticky>-- <CodeGroup- title="Request"- tag="POST"- label="/completion-messages"- targetCode={`curl -X POST '${props.appDetail.api_base_url}/completion-messages' \\---header 'Authorization: Bearer {api_key}' \\---header 'Content-Type: application/json' \\---data-raw '{- "inputs": {"query": "Hello, world!"},- "response_mode": "streaming",- "user": "abc-123"-}'`}- />- ### blocking- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "id": "0b089b9a-24d9-48cc-94f8-762677276261",- "answer": "how are you?",- "created_at": 1679586667- }- ```- </CodeGroup>- ### streaming- <CodeGroup title="Response">- ```streaming {{ title: 'Response' }}- data: {"id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "answer": " I", "created_at": 1679586595}- data: {"id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "answer": " I", "created_at": 1679586595}- data: {"event": "tts_message", "conversation_id": "23dd85f3-1a41-4ea0-b7a9-062734ccfaf9", "message_id": "a8bdc41c-13b2-4c18-bfd9-054b9803038c", "created_at": 1721205487, "task_id": "3bf8a0bb-e73b-4690-9e66-4e429bad8ee7", "audio": "qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq"}- data: {"event": "tts_message_end", "conversation_id": "23dd85f3-1a41-4ea0-b7a9-062734ccfaf9", "message_id": "a8bdc41c-13b2-4c18-bfd9-054b9803038c", "created_at": 1721205487, "task_id": "3bf8a0bb-e73b-4690-9e66-4e429bad8ee7", "audio": ""}- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/files/upload'- method='POST'- title='上传文件'- name='#files-upload'-/>-<Row>- <Col>- 上传文件(目前仅支持图片)并在发送消息时使用,可实现图文多模态理解。- 支持 png, jpg, jpeg, webp, gif 格式。- <i>上传的文件仅供当前终端用户使用。</i>-- ### Request Body- 该接口需使用 `multipart/form-data` 进行请求。- <Properties>- <Property name='file' type='file' key='file'>- 要上传的文件。- </Property>- <Property name='user' type='string' key='user'>- 用户标识,用于定义终端用户的身份,必须和发送消息接口传入 user 保持一致。- </Property>- </Properties>-- ### Response- 成功上传后,服务器会返回文件的 ID 和相关信息。- - `id` (uuid) ID- - `name` (string) 文件名- - `size` (int) 文件大小(byte)- - `extension` (string) 文件后缀- - `mime_type` (string) 文件 mime-type- - `created_by` (uuid) 上传人 ID- - `created_at` (timestamp) 上传时间-- ### Errors- - 400,`no_file_uploaded`,必须提供文件- - 400,`too_many_files`,目前只接受一个文件- - 400,`unsupported_preview`,该文件不支持预览- - 400,`unsupported_estimate`,该文件不支持估算- - 413,`file_too_large`,文件太大- - 415,`unsupported_file_type`,不支持的扩展名,当前只接受文档类文件- - 503,`s3_connection_failed`,无法连接到 S3 服务- - 503,`s3_permission_denied`,无权限上传文件到 S3- - 503,`s3_file_too_large`,文件超出 S3 大小限制- </Col>- <Col sticky>-- <CodeGroup- title="Request"- tag="POST"- label="/files/upload"- targetCode={`curl -X POST '${props.appDetail.api_base_url}/files/upload' \\---header 'Authorization: Bearer {api_key}' \\---form 'file=@localfile;type=image/[png|jpeg|jpg|webp|gif]' \\---form 'user=abc-123'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "id": "72fa9618-8f89-4a37-9b33-7e1178a24a67",- "name": "example.png",- "size": 1024,- "extension": "png",- "mime_type": "image/png",- "created_by": 123,- "created_at": 1577836800,- }- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/end-users/:end_user_id'- method='GET'- title='获取终端用户'- name='#end-user'-/>-<Row>- <Col>- 通过终端用户 ID 获取终端用户信息。-- 当其他 API 返回终端用户 ID(例如:上传文件接口返回的 `created_by`)时,可使用该接口查询对应的终端用户信息。-- ### 路径参数- - `end_user_id` (uuid) 必需- 终端用户 ID。-- ### Response- 返回 EndUser 对象。- - `id` (uuid) ID- - `tenant_id` (uuid) 工作空间(Tenant)ID- - `app_id` (uuid) 应用 ID- - `type` (string) 终端用户类型- - `external_user_id` (string) 外部用户 ID- - `name` (string) 名称- - `is_anonymous` (boolean) 是否匿名- - `session_id` (string) 会话 ID- - `created_at` (string) ISO 8601 时间- - `updated_at` (string) ISO 8601 时间-- ### Errors- - 404,`end_user_not_found`,终端用户不存在- - 500,内部服务器错误-- </Col>- <Col sticky>- <CodeGroup- title="Request"- tag="GET"- label="/end-users/:end_user_id"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/end-users/6ad1ab0a-73ff-4ac1-b9e4-cdb312f71f13' \\---header 'Authorization: Bearer {api_key}'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "id": "6ad1ab0a-73ff-4ac1-b9e4-cdb312f71f13",- "tenant_id": "8c0f3f3a-66b0-4b55-a0bf-8b8e0d6aee7d",- "app_id": "6c8c3f41-2c6f-4e1b-8f4f-7f11c8f2ad2a",- "type": "service_api",- "external_user_id": "abc-123",- "name": "Alice",- "is_anonymous": false,- "session_id": "abc-123",- "created_at": "2024-01-01T00:00:00Z",- "updated_at": "2024-01-01T00:00:00Z"- }- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/files/:file_id/preview'- method='GET'- title='文件预览'- name='#file-preview'-/>-<Row>- <Col>- 预览或下载已上传的文件。此端点允许您访问先前通过文件上传 API 上传的文件。-- <i>文件只能在属于请求应用程序的消息范围内访问。</i>-- ### 路径参数- - `file_id` (string) 必需- 要预览的文件的唯一标识符,从文件上传 API 响应中获得。-- ### 查询参数- - `as_attachment` (boolean) 可选- 是否强制将文件作为附件下载。默认为 `false`(在浏览器中预览)。-- ### 响应- 返回带有适当浏览器显示或下载标头的文件内容。- - `Content-Type` 根据文件 MIME 类型设置- - `Content-Length` 文件大小(以字节为单位,如果可用)- - `Content-Disposition` 如果 `as_attachment=true` 则设置为 "attachment"- - `Cache-Control` 用于性能的缓存标头- - `Accept-Ranges` 对于音频/视频文件设置为 "bytes"-- ### 错误- - 400, `invalid_param`, 参数输入异常- - 403, `file_access_denied`, 文件访问被拒绝或文件不属于当前应用程序- - 404, `file_not_found`, 文件未找到或已被删除- - 500, 服务内部错误-- </Col>- <Col sticky>- ### 请求示例- <CodeGroup- title="Request"- tag="GET"- label="/files/:file_id/preview"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/files/72fa9618-8f89-4a37-9b33-7e1178a24a67/preview' \\---header 'Authorization: Bearer {api_key}'`}- />-- ### 作为附件下载- <CodeGroup- title="下载请求"- tag="GET"- label="/files/:file_id/preview?as_attachment=true"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/files/72fa9618-8f89-4a37-9b33-7e1178a24a67/preview?as_attachment=true' \\---header 'Authorization: Bearer {api_key}' \\---output downloaded_file.png`}- />-- ### 响应标头示例- <CodeGroup title="Response Headers">- ```http {{ title: 'Headers - 图片预览' }}- Content-Type: image/png- Content-Length: 1024- Cache-Control: public, max-age=3600- ```- </CodeGroup>-- ### 文件下载响应标头- <CodeGroup title="Download Response Headers">- ```http {{ title: 'Headers - 文件下载' }}- Content-Type: image/png- Content-Length: 1024- Content-Disposition: attachment; filename*=UTF-8''example.png- Cache-Control: public, max-age=3600- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/completion-messages/:task_id/stop'- method='POST'- title='停止响应'- name='#Stop'-/>-<Row>- <Col>- 仅支持流式模式。- ### Path- - `task_id` (string) 任务 ID,可在流式返回 Chunk 中获取-- ### Request Body- - `user` (string) Required- 用户标识,用于定义终端用户的身份,必须和发送消息接口传入 user 保持一致。API 无法访问 WebApp 创建的会话。- ### Response- - `result` (string) 固定返回 success- </Col>- <Col sticky>- <CodeGroup- title="Request"- tag="POST"- label="/completion-messages/:task_id/stop"- targetCode={`curl -X POST '${props.appDetail.api_base_url}/completion-messages/:task_id/stop' \\--H 'Authorization: Bearer {api_key}' \\--H 'Content-Type: application/json' \\---data-raw '{ "user": "abc-123"}'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "result": "success"- }- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/messages/:message_id/feedbacks'- method='POST'- title='消息反馈(点赞)'- name='#feedbacks'-/>-<Row>- <Col>- 消息终端用户反馈、点赞,方便应用开发者优化输出预期。-- ### Path Params- <Properties>- <Property name='message_id' type='string' key='message_id'>- 消息 ID- </Property>- </Properties>-- ### Request Body-- <Properties>- <Property name='rating' type='string' key='rating'>- 点赞 like, 点踩 dislike, 撤销点赞 null- </Property>- <Property name='user' type='string' key='user'>- 用户标识,由开发者定义规则,需保证用户标识在应用内唯一。- </Property>- <Property name='content' type='string' key='content'>- 消息反馈的具体信息。- </Property>- </Properties>-- ### Response- - `result` (string) 固定返回 success- </Col>- <Col sticky>-- <CodeGroup- title="Request"- tag="POST"- label="/messages/:message_id/feedbacks"- targetCode={`curl -X POST '${props.appDetail.api_base_url}/messages/:message_id/feedbacks \\---header 'Authorization: Bearer {api_key}' \\---header 'Content-Type: application/json' \\---data-raw '{- "rating": "like",- "user": "abc-123",- "content": "message feedback information"-}'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "result": "success"- }- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/app/feedbacks'- method='GET'- title='Get feedbacks of application'- name='#app-feedbacks'-/>-<Row>- <Col>- Get application's feedbacks.-- ### Query- <Properties>- <Property name='page' type='string' key='page'>- (optional)pagination,default:1- </Property>- </Properties>-- <Properties>- <Property name='limit' type='string' key='limit'>- (optional) records per page default:20- </Property>- </Properties>-- ### Response- - `data` (List) return apps feedback list.- </Col>- <Col sticky>-- <CodeGroup- title="Request"- tag="GET"- label="/app/feedbacks"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/app/feedbacks?page=1&limit=20'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "data": [- {- "id": "8c0fbed8-e2f9-49ff-9f0e-15a35bdd0e25",- "app_id": "f252d396-fe48-450e-94ec-e184218e7346",- "conversation_id": "2397604b-9deb-430e-b285-4726e51fd62d",- "message_id": "709c0b0f-0a96-4a4e-91a4-ec0889937b11",- "rating": "like",- "content": "message feedback information-3",- "from_source": "user",- "from_end_user_id": "74286412-9a1a-42c1-929c-01edb1d381d5",- "from_account_id": null,- "created_at": "2025-04-24T09:24:38",- "updated_at": "2025-04-24T09:24:38"- }- ]- }- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/text-to-audio'- method='POST'- title='文字转语音'- name='#text-to-audio'-/>-<Row>- <Col>- 文字转语音。-- ### Request Body-- <Properties>- <Property name='message_id' type='str' key='message_id'>- Dify 生成的文本消息,那么直接传递生成的message-id 即可,后台会通过 message_id 查找相应的内容直接合成语音信息。如果同时传 message_id 和 text,优先使用 message_id。- </Property>- <Property name='text' type='str' key='text'>- 语音生成内容。如果没有传 message-id的话,则会使用这个字段的内容- </Property>- <Property name='user' type='string' key='user'>- 用户标识,由开发者定义规则,需保证用户标识在应用内唯一。- </Property>- </Properties>- </Col>- <Col sticky>-- <CodeGroup- title="Request"- tag="POST"- label="/text-to-audio"- targetCode={`curl -o text-to-audio.mp3 -X POST '${props.appDetail.api_base_url}/text-to-audio' \\---header 'Authorization: Bearer {api_key}' \\---header 'Content-Type: application/json' \\---data-raw '{- "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290",- "text": "你好Dify",- "user": "abc-123"-}'`}- />-- <CodeGroup title="headers">- ```json {{ title: 'headers' }}- {- "Content-Type": "audio/wav"- }- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/info'- method='GET'- title='获取应用基本信息'- name='#info'-/>-<Row>- <Col>- 用于获取应用的基本信息- ### Response- - `name` (string) 应用名称- - `description` (string) 应用描述- - `tags` (array[string]) 应用标签- - `mode` (string) 应用模式- - 'author_name' (string) 作者名称- </Col>- <Col>- <CodeGroup- title="Request"- tag="GET"- label="/info"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/info' \\--H 'Authorization: Bearer {api_key}'`}- />- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "name": "My App",- "description": "This is my app.",- "tags": [- "tag1",- "tag2"- ],- "mode": "chat",- "author_name": "Dify"- }- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/parameters'- method='GET'- title='获取应用参数'- name='#parameters'-/>-<Row>- <Col>- 用于进入页面一开始,获取功能开关、输入参数名称、类型及默认值等使用。-- ### Response- - `opening_statement` (string) 开场白- - `suggested_questions` (array[string]) 开场推荐问题列表- - `suggested_questions_after_answer` (object) 启用回答后给出推荐问题。- - `enabled` (bool) 是否开启- - `speech_to_text` (object) 语音转文本- - `enabled` (bool) 是否开启- - `retriever_resource` (object) 引用和归属- - `enabled` (bool) 是否开启- - `annotation_reply` (object) 标记回复- - `enabled` (bool) 是否开启- - `user_input_form` (array[object]) 用户输入表单配置- - `text-input` (object) 文本输入控件- - `label` (string) 控件展示标签名- - `variable` (string) 控件 ID- - `required` (bool) 是否必填- - `default` (string) 默认值- - `paragraph` (object) 段落文本输入控件- - `label` (string) 控件展示标签名- - `variable` (string) 控件 ID- - `required` (bool) 是否必填- - `default` (string) 默认值- - `select` (object) 下拉控件- - `label` (string) 控件展示标签名- - `variable` (string) 控件 ID- - `required` (bool) 是否必填- - `default` (string) 默认值- - `options` (array[string]) 选项值- - `file_upload` (object) 文件上传配置- - `document` (object) 文档设置- 当前仅支持文档类型:`txt`, `md`, `markdown`, `pdf`, `html`, `xlsx`, `xls`, `docx`, `csv`, `eml`, `msg`, `pptx`, `ppt`, `xml`, `epub`。- - `enabled` (bool) 是否启用- - `number_limits` (int) 文档数量限制,默认为 3- - `transfer_methods` (array[string]) 传输方式列表:`remote_url`, `local_file`,必须选择一个。- - `image` (object) 图片设置- 当前仅支持图片类型:`png`, `jpg`, `jpeg`, `webp`, `gif`。- - `enabled` (bool) 是否启用- - `number_limits` (int) 图片数量限制,默认为 3- - `transfer_methods` (array[string]) 传输方式列表:`remote_url`, `local_file`,必须选择一个。- - `audio` (object) 音频设置- 当前仅支持音频类型:`mp3`, `m4a`, `wav`, `webm`, `amr`。- - `enabled` (bool) 是否启用- - `number_limits` (int) 音频数量限制,默认为 3- - `transfer_methods` (array[string]) 传输方式列表:`remote_url`, `local_file`,必须选择一个。- - `video` (object) 视频设置- 当前仅支持视频类型:`mp4`, `mov`, `mpeg`, `mpga`。- - `enabled` (bool) 是否启用- - `number_limits` (int) 视频数量限制,默认为 3- - `transfer_methods` (array[string]) 传输方式列表:`remote_url`, `local_file`,必须选择一个。- - `custom` (object) 自定义设置- - `enabled` (bool) 是否启用- - `number_limits` (int) 自定义数量限制,默认为 3- - `transfer_methods` (array[string]) 传输方式列表:`remote_url`, `local_file`,必须选择一个。- - `system_parameters` (object) 系统参数- - `file_size_limit` (int) 文档上传大小限制 (MB)- - `image_file_size_limit` (int) 图片文件上传大小限制(MB)- - `audio_file_size_limit` (int) 音频文件上传大小限制 (MB)- - `video_file_size_limit` (int) 视频文件上传大小限制 (MB)- </Col>- <Col sticky>-- <CodeGroup- title="Request"- tag="GET"- label="/parameters"- targetCode={` curl -X GET '${props.appDetail.api_base_url}/parameters'\\---header 'Authorization: Bearer {api_key}'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "introduction": "nice to meet you",- "user_input_form": [- {- "text-input": {- "label": "a",- "variable": "a",- "required": true,- "max_length": 48,- "default": ""- }- },- {- // ...- }- ],- "file_upload": {- "image": {- "enabled": true,- "number_limits": 3,- "transfer_methods": [- "remote_url",- "local_file"- ]- }- },- "system_parameters": {- "file_size_limit": 15,- "image_file_size_limit": 10,- "audio_file_size_limit": 50,- "video_file_size_limit": 100- }- }- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/site'- method='GET'- title='获取应用 WebApp 设置'- name='#site'-/>-<Row>- <Col>- 用于获取应用的 WebApp 设置- ### Response- - `title` (string) WebApp 名称- - `chat_color_theme` (string) 聊天颜色主题,hex 格式- - `chat_color_theme_inverted` (bool) 聊天颜色主题是否反转- - `icon_type` (string) 图标类型,`emoji`-表情,`image`-图片- - `icon` (string) 图标,如果是 `emoji` 类型,则是 emoji 表情符号,如果是 `image` 类型,则是图片 URL- - `icon_background` (string) hex 格式的背景色- - `icon_url` (string) 图标 URL- - `description` (string) 描述- - `copyright` (string) 版权信息- - `privacy_policy` (string) 隐私政策链接- - `custom_disclaimer` (string) 自定义免责声明- - `default_language` (string) 默认语言- - `show_workflow_steps` (bool) 是否显示工作流详情- - `use_icon_as_answer_icon` (bool) 是否使用 WebApp 图标替换聊天中的 🤖- </Col>- <Col>- <CodeGroup- title="Request"- tag="GET"- label="/site"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/site' \\--H 'Authorization: Bearer {api_key}'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "title": "My App",- "chat_color_theme": "#ff4a4a",- "chat_color_theme_inverted": false,- "icon_type": "emoji",- "icon": "😄",- "icon_background": "#FFEAD5",- "icon_url": null,- "description": "This is my app.",- "copyright": "all rights reserved",- "privacy_policy": "",- "custom_disclaimer": "All generated by AI",- "default_language": "en-US",- "show_workflow_steps": false,- "use_icon_as_answer_icon": false,- }- ```- </CodeGroup>- </Col>-</Row>-___--<Heading- url='/apps/annotations'- method='GET'- title='获取标注列表'- name='#annotation_list'-/>-<Row>- <Col>- ### Query- <Properties>- <Property name='page' type='string' key='page'>- 页码- </Property>- <Property name='limit' type='string' key='limit'>- 每页数量- </Property>- </Properties>- </Col>- <Col sticky>- <CodeGroup- title="Request"- tag="GET"- label="/apps/annotations"- targetCode={`curl --location --request GET '${props.apiBaseUrl}/apps/annotations?page=1&limit=20' \\\n--header 'Authorization: Bearer {api_key}'`}- >- ```bash {{ title: 'cURL' }}- curl --location --request GET '${props.apiBaseUrl}/apps/annotations?page=1&limit=20' \- --header 'Authorization: Bearer {api_key}'- ```- </CodeGroup>-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "data": [- {- "id": "69d48372-ad81-4c75-9c46-2ce197b4d402",- "question": "What is your name?",- "answer": "I am Dify.",- "hit_count": 0,- "created_at": 1735625869- }- ],- "has_more": false,- "limit": 20,- "total": 1,- "page": 1- }- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/apps/annotations'- method='POST'- title='创建标注'- name='#create_annotation'-/>-<Row>- <Col>- ### Query- <Properties>- <Property name='question' type='string' key='question'>- 问题- </Property>- <Property name='answer' type='string' key='answer'>- 答案内容- </Property>- </Properties>- </Col>- <Col sticky>- <CodeGroup- title="Request"- tag="POST"- label="/apps/annotations"- targetCode={`curl --location --request POST '${props.apiBaseUrl}/apps/annotations' \\---header 'Authorization: Bearer {api_key}' \\---header 'Content-Type: application/json' \\---data-raw '{"question": "What is your name?","answer": "I am Dify."}'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "id": "69d48372-ad81-4c75-9c46-2ce197b4d402",- "question": "What is your name?",- "answer": "I am Dify.",- "hit_count": 0,- "created_at": 1735625869- }- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/apps/annotations/{annotation_id}'- method='PUT'- title='更新标注'- name='#update_annotation'-/>-<Row>- <Col>- ### Query- <Properties>- <Property name='annotation_id' type='string' key='annotation_id'>- 标注 ID- </Property>- <Property name='question' type='string' key='question'>- 问题- </Property>- <Property name='answer' type='string' key='answer'>- 答案内容- </Property>- </Properties>- </Col>- <Col sticky>- <CodeGroup- title="Request"- tag="PUT"- label="/apps/annotations/{annotation_id}"- targetCode={`curl --location --request PUT '${props.apiBaseUrl}/apps/annotations/{annotation_id}' \\---header 'Authorization: Bearer {api_key}' \\---header 'Content-Type: application/json' \\---data-raw '{"question": "What is your name?","answer": "I am Dify."}'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "id": "69d48372-ad81-4c75-9c46-2ce197b4d402",- "question": "What is your name?",- "answer": "I am Dify.",- "hit_count": 0,- "created_at": 1735625869- }- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/apps/annotations/{annotation_id}'- method='DELETE'- title='删除标注'- name='#delete_annotation'-/>-<Row>- <Col>- ### Query- <Properties>- <Property name='annotation_id' type='string' key='annotation_id'>- 标注 ID- </Property>- </Properties>- </Col>- <Col sticky>- <CodeGroup- title="Request"- tag="PUT"- label="/apps/annotations/{annotation_id}"- targetCode={`curl --location --request DELETE '${props.apiBaseUrl}/apps/annotations/{annotation_id}' \\---header 'Authorization: Bearer {api_key}' \\---header 'Content-Type: application/json'`}- >- ```bash {{ title: 'cURL' }}- curl --location --request DELETE '${props.apiBaseUrl}/apps/annotations/{annotation_id}' \- --header 'Authorization: Bearer {api_key}'- ```- </CodeGroup>-- <CodeGroup title="Response">- ```text {{ title: 'Response' }}- 204 No Content- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/apps/annotation-reply/{action}'- method='POST'- title='标注回复初始设置'- name='#initial_annotation_reply_settings'-/>-<Row>- <Col>- ### Query- <Properties>- <Property name='action' type='string' key='action'>- 动作,只能是 'enable' 或 'disable'- </Property>- <Property name='embedding_provider_name' type='string' key='embedding_provider_name'>- 指定的嵌入模型提供商,必须先在系统内设定好接入的模型,对应的是 provider 字段- </Property>- <Property name='embedding_model_name' type='string' key='embedding_model_name'>- 指定的嵌入模型,对应的是 model 字段- </Property>- <Property name='score_threshold' type='number' key='score_threshold'>- 相似度阈值,当相似度大于该阈值时,系统会自动回复,否则不回复- </Property>- </Properties>- </Col>- <Col sticky>- 嵌入模型的提供商和模型名称可以通过以下接口获取:v1/workspaces/current/models/model-types/text-embedding,具体见:通过 API 维护知识库。使用的 Authorization 是 Dataset 的 API Token。- 该接口是异步执行,所以会返回一个 job_id,通过查询 job 状态接口可以获取到最终的执行结果。- <CodeGroup- title="Request"- tag="POST"- label="/apps/annotation-reply/{action}"- targetCode={`curl --location --request POST '${props.apiBaseUrl}/apps/annotation-reply/{action}' \\---header 'Authorization: Bearer {api_key}' \\---header 'Content-Type: application/json' \\---data-raw '{"score_threshold": 0.9, "embedding_provider_name": "zhipu", "embedding_model_name": "embedding_3"}'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "job_id": "b15c8f68-1cf4-4877-bf21-ed7cf2011802",- "job_status": "waiting"- }- ```-- </CodeGroup>- </Col>-</Row>------<Heading- url='/apps/annotation-reply/{action}/status/{job_id}'- method='GET'- title='查询标注回复初始设置任务状态'- name='#initial_annotation_reply_settings_task_status'-/>-<Row>- <Col>- ### Query- <Properties>- <Property name='action' type='string' key='action'>- 动作,只能是 'enable' 或 'disable',并且必须和标注回复初始设置接口的动作一致- </Property>- <Property name='job_id' type='string' key='job_id'>- 任务 ID,从标注回复初始设置接口返回的 job_id- </Property>- </Properties>- </Col>- <Col sticky>- <CodeGroup- title="Request"- tag="GET"- label="/apps/annotations"- targetCode={`curl --location --request GET '${props.apiBaseUrl}/apps/annotation-reply/{action}/status/{job_id}' \\---header 'Authorization: Bearer {api_key}'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "job_id": "b15c8f68-1cf4-4877-bf21-ed7cf2011802",- "job_status": "waiting",- "error_msg": ""- }- ```- </CodeGroup>- </Col>-</Row>diff --git a/web/app/components/develop/template/template_advanced_chat.en.mdx b/web/app/components/develop/template/template_advanced_chat.en.mdxdeleted file mode 100644index 1f37660acd8..00000000000--- a/web/app/components/develop/template/template_advanced_chat.en.mdx+++ /dev/null@@ -1,2449 +0,0 @@-import { CodeGroup, Embed } from '../code.tsx'-import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx'-import { WorkflowVersionApiUpgradeNotice } from '../workflow-version-api-upgrade-notice.tsx'--# Advanced Chat App API--Chat applications support session persistence, allowing previous chat history to be used as context for responses. This can be applicable for chatbot, customer service AI, etc.--<div>- ### Base URL- <CodeGroup title="Code" targetCode={props.appDetail.api_base_url} />-- ### Authentication-- The Service API uses `API-Key` authentication.- <i>**Strongly recommend storing your API Key on the server-side, not shared or stored on the client-side, to avoid possible API-Key leakage that can lead to serious consequences.**</i>-- For all API requests, include your API Key in the `Authorization`HTTP Header, as shown below:-- <CodeGroup title="Code" targetCode='Authorization: Bearer {API_KEY}' />-</div>-------<Heading- url='/chat-messages'- method='POST'- title='Send Chat Message'- name='#Send-Chat-Message'-/>-<Row>- <Col>- Send a request to the chat application.-- ### Request Body-- <Properties>- <Property name='query' type='string' key='query'>- User Input/Question content- </Property>- <Property name='inputs' type='object' key='inputs'>- Allows the entry of various variable values defined by the App.- The `inputs` parameter contains multiple key/value pairs, with each key corresponding to a specific variable and each value being the specific value for that variable.- If the variable is of file type, specify an object that has the keys described in `files` below.- Default `{}`- </Property>- <Property name='response_mode' type='string' key='response_mode'>- The mode of response return, supporting:- - `streaming` Streaming mode (recommended), implements a typewriter-like output through SSE ([Server-Sent Events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events)).- - `blocking` Blocking mode, returns result after execution is complete. (Requests may be interrupted if the process is long)- Due to Cloudflare restrictions, the request will be interrupted without a return after 100 seconds.- </Property>- <Property name='user' type='string' key='user'>- User identifier, used to define the identity of the end-user for retrieval and statistics.- Should be uniquely defined by the developer within the application. The Service API does not share conversations created by the WebApp.- </Property>- <Property name='conversation_id' type='string' key='conversation_id'>- Conversation ID, to continue the conversation based on previous chat records, it is necessary to pass the previous message's conversation_id.- </Property>- <Property name='files' type='array[object]' key='files'>- File list, suitable for inputting files combined with text understanding and answering questions, available only when the model supports Vision/Video capability.- - `type` (string) Supported type:- - `document` Supported types include: 'TXT', 'MD', 'MARKDOWN', 'MDX', 'PDF', 'HTML', 'XLSX', 'XLS', 'VTT', 'PROPERTIES', 'DOC', 'DOCX', 'CSV', 'EML', 'MSG', 'PPTX', 'PPT', 'XML', 'EPUB'- - `image` Supported types include: 'JPG', 'JPEG', 'PNG', 'GIF', 'WEBP', 'SVG'- - `audio` Supported types include: 'MP3', 'M4A', 'WAV', 'WEBM', 'MPGA'- - `video` Supported types include: 'MP4', 'MOV', 'MPEG', 'WEBM'- - `custom` Supported types include: other file types- - `transfer_method` (string) Transfer method:- - `remote_url`: File URL.- - `local_file`: Upload file.- - `url` File URL. (Only when transfer method is `remote_url`).- - `upload_file_id` Upload file ID. (Only when transfer method is `local_file`).- </Property>- <Property name='auto_generate_name' type='bool' key='auto_generate_name'>- Auto-generate title, default is `true`.- If set to `false`, can achieve async title generation by calling the conversation rename API and setting `auto_generate` to `true`.- </Property>- <Property name='workflow_id' type='string' key='workflow_id' nameAction={<WorkflowVersionApiUpgradeNotice />}>- (Optional) Workflow ID to specify a specific version, if not provided, uses the default published version.- </Property>- <Property name='trace_id' type='string' key='trace_id'>- (Optional) Trace ID. Used for integration with existing business trace components to achieve end-to-end distributed tracing. If not provided, the system will automatically generate a trace_id. Supports the following three ways to pass, in order of priority:<br/>- - Header: via HTTP Header <code>X-Trace-Id</code>, highest priority.<br/>- - Query parameter: via URL query parameter <code>trace_id</code>.<br/>- - Request Body: via request body field <code>trace_id</code> (i.e., this field).<br/>- </Property>- <Property name='trace_session_id' type='string' key='trace_session_id'>- (Optional) Trace session ID for observability grouping. Tracing providers that support session grouping can use this value as the exported session identifier. It does not change conversation_id, workflow_run_id, trace_id, or span relationships. Supports the following three ways to pass, in order of priority:<br/>- - Header: via HTTP Header <code>X-Trace-Session-Id</code>, highest priority.<br/>- - Query parameter: via URL query parameter <code>trace_session_id</code>.<br/>- - Request Body: via request body field <code>trace_session_id</code> (i.e., this field).<br/>- </Property>- </Properties>-- ### Response- When response_mode is blocking, return a CompletionResponse object.- When response_mode is streaming, return a ChunkCompletionResponse stream.-- ### ChatCompletionResponse- Returns the complete App result, `Content-Type` is `application/json`.- - `event` (string) Event type, fixed to `message`- - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API- - `id` (string) unique ID- - `message_id` (string) Unique message ID- - `conversation_id` (string) Conversation ID- - `mode` (string) App mode, fixed as `chat`- - `answer` (string) Complete response content- - `metadata` (object) Metadata- - `usage` (Usage) Model usage information- - `retriever_resources` (array[RetrieverResource]) Citation and Attribution List- - `created_at` (int) Message creation timestamp, e.g., 1705395332-- ### ChunkChatCompletionResponse- Returns the stream chunks outputted by the App, `Content-Type` is `text/event-stream`.- Each streaming chunk starts with `data:`, separated by two newline characters `\n\n`, as shown below:- <CodeGroup>- ```streaming {{ title: 'Response' }}- data: {"event": "message", "task_id": "900bbd43-dc0b-4383-a372-aa6e6c414227", "id": "663c5084-a254-4040-8ad3-51f2a3c1a77c", "answer": "Hi", "created_at": 1705398420}\n\n- ```- </CodeGroup>- The structure of the streaming chunks varies depending on the `event`:- - `event: message` LLM returns text chunk event, i.e., the complete text is output in a chunked fashion.- - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API- - `message_id` (string) Unique message ID- - `conversation_id` (string) Conversation ID- - `answer` (string) LLM returned text chunk content- - `created_at` (int) Creation timestamp, e.g., 1705395332- - `event: message_file` Message file event, a new file has created by tool- - `id` (string) File unique ID- - `type` (string) File type,only allow "image" currently- - `belongs_to` (string) Belongs to, it will only be an 'assistant' here- - `url` (string) Remote url of file- - `conversation_id` (string) Conversation ID- - `event: message_end` Message end event, receiving this event means streaming has ended.- - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API- - `message_id` (string) Unique message ID- - `conversation_id` (string) Conversation ID- - `metadata` (object) Metadata- - `usage` (Usage) Model usage information- - `retriever_resources` (array[RetrieverResource]) Citation and Attribution List- - `event: tts_message` TTS audio stream event, that is, speech synthesis output. The content is an audio block in Mp3 format, encoded as a base64 string. When playing, simply decode the base64 and feed it into the player. (This message is available only when auto-play is enabled)- - `task_id` (string) Task ID, used for request tracking and the stop response interface below- - `message_id` (string) Unique message ID- - `audio` (string) The audio after speech synthesis, encoded in base64 text content, when playing, simply decode the base64 and feed it into the player- - `created_at` (int) Creation timestamp, e.g.: 1705395332- - `event: tts_message_end` TTS audio stream end event, receiving this event indicates the end of the audio stream.- - `task_id` (string) Task ID, used for request tracking and the stop response interface below- - `message_id` (string) Unique message ID- - `audio` (string) The end event has no audio, so this is an empty string- - `created_at` (int) Creation timestamp, e.g.: 1705395332- - `event: message_replace` Message content replacement event.- When output content moderation is enabled, if the content is flagged, then the message content will be replaced with a preset reply through this event.- - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API- - `message_id` (string) Unique message ID- - `conversation_id` (string) Conversation ID- - `answer` (string) Replacement content (directly replaces all LLM reply text)- - `created_at` (int) Creation timestamp, e.g., 1705395332- - `event: workflow_started` workflow starts execution- - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API- - `workflow_run_id` (string) Unique ID of workflow execution- - `event` (string) fixed to `workflow_started`- - `data` (object) detail- - `id` (string) Unique ID of workflow execution- - `workflow_id` (string) ID of related workflow- - `created_at` (timestamp) Creation timestamp, e.g., 1705395332- - `event: node_started` node execution started- - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API- - `workflow_run_id` (string) Unique ID of workflow execution- - `event` (string) fixed to `node_started`- - `data` (object) detail- - `id` (string) Unique ID of workflow execution- - `node_id` (string) ID of node- - `node_type` (string) type of node- - `title` (string) name of node- - `index` (int) Execution sequence number, used to display Tracing Node sequence- - `predecessor_node_id` (string) optional Prefix node ID, used for canvas display execution path- - `inputs` (object) Contents of all preceding node variables used in the node- - `created_at` (timestamp) timestamp of start, e.g., 1705395332- - `event: node_finished` node execution ends, success or failure in different states in the same event- - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API- - `workflow_run_id` (string) Unique ID of workflow execution- - `event` (string) fixed to `node_finished`- - `data` (object) detail- - `id` (string) Unique ID of workflow execution- - `node_id` (string) ID of node- - `node_type` (string) type of node- - `title` (string) name of node- - `index` (int) Execution sequence number, used to display Tracing Node sequence- - `predecessor_node_id` (string) optional Prefix node ID, used for canvas display execution path- - `inputs` (object) Contents of all preceding node variables used in the node- - `process_data` (json) Optional node process data- - `outputs` (json) Optional content of output- - `status` (string) status of execution, `running` / `succeeded` / `failed` / `stopped`- - `error` (string) Optional reason of error- - `elapsed_time` (float) Optional total seconds to be used- - `execution_metadata` (json) meta data- - `total_tokens` (int) optional tokens to be used- - `total_price` (decimal) optional Total cost- - `currency` (string) optional e.g. `USD` / `RMB`- - `created_at` (timestamp) timestamp of start, e.g., 1705395332- - `event: human_input_required` Workflow paused and requires Human-in-the-Loop input- - `task_id` (string) Task ID, used for request tracking- - `workflow_run_id` (string) Unique ID of workflow execution- - `event` (string) fixed to `human_input_required`- - `data` (object) detail- - `form_id` (string) Human input form ID- - `node_id` (string) Human input node ID- - `node_title` (string) Human input node title- - `form_content` (string) Rendered form content- - `inputs` (array[object]) Input field definitions- - `actions` (array[object]) User action buttons- - `id` (string) Action ID- - `title` (string) Button text- - `button_style` (string) Button style- - `display_in_ui` (bool) Whether this form should be shown in UI- - `form_token` (string) Token used by `/form/human_input/:form_token` APIs- - `resolved_default_values` (object) Runtime-resolved default values- - `expiration_time` (timestamp) Form expiration time (Unix seconds)- - `event: workflow_finished` workflow execution ends, success or failure in different states in the same event- - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API- - `workflow_run_id` (string) Unique ID of workflow execution- - `event` (string) fixed to `workflow_finished`- - `data` (object) detail- - `id` (string) ID of workflow execution- - `workflow_id` (string) ID of related workflow- - `status` (string) status of execution, `running` / `succeeded` / `failed` / `stopped`- - `outputs` (json) Optional content of output- - `error` (string) Optional reason of error- - `elapsed_time` (float) Optional total seconds to be used- - `total_tokens` (int) Optional tokens to be used- - `total_steps` (int) default 0- - `created_at` (timestamp) start time- - `finished_at` (timestamp) end time- - `event: error`- Exceptions that occur during the streaming process will be output in the form of stream events, and reception of an error event will end the stream.- - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API- - `message_id` (string) Unique message ID- - `status` (int) HTTP status code- - `code` (string) Error code- - `message` (string) Error message- - `event: ping` Ping event every 10 seconds to keep the connection alive.-- ### Errors- - 404, Conversation does not exists- - 400, `invalid_param`, abnormal parameter input- - 400, `app_unavailable`, App configuration unavailable- - 400, `provider_not_initialize`, no available model credential configuration- - 400, `provider_quota_exceeded`, model invocation quota insufficient- - 400, `model_currently_not_support`, current model unavailable- - 400, `workflow_not_found`, specified workflow version not found- - 400, `draft_workflow_error`, cannot use draft workflow version- - 400, `workflow_id_format_error`, invalid workflow_id format, expected UUID format- - 400, `completion_request_error`, text generation failed- - 403, `workflow_version_execution_not_allowed`, Workflow version execution is not available on your current plan. Please upgrade to a paid plan.- - 500, internal server error-- </Col>- <Col sticky>-- <CodeGroup- title="Request"- tag="POST"- label="/chat-messages"- targetCode={`curl -X POST '${props.appDetail.api_base_url}/chat-messages' \\---header 'Authorization: Bearer {api_key}' \\---header 'Content-Type: application/json' \\---data-raw '{- "inputs": ${JSON.stringify(props.inputs)},- "query": "What are the specs of the iPhone 13 Pro Max?",- "response_mode": "streaming",- "conversation_id": "",- "user": "abc-123",- "files": [- {- "type": "image",- "transfer_method": "remote_url",- "url": "https://cloud.dify.ai/logo/logo-site.png"- }- ]-}'`}- />- ### Blocking Mode- Blocking mode can return a normal chat message or a paused workflow response.-- When advanced chat pauses for Human-in-the-Loop, `event` becomes `workflow_paused`.- The payload still includes `message_id`, `conversation_id`, `answer`, and `workflow_run_id`, and `data` adds `paused_nodes` plus `reasons`.- For `human_input_required`, each reason contains the `form_id` and its `expiration_time`.-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "event": "message",- "task_id": "c3800678-a077-43df-a102-53f23ed20b88",- "id": "9da23599-e713-473b-982c-4328d4f5c78a",- "message_id": "9da23599-e713-473b-982c-4328d4f5c78a",- "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2",- "mode": "chat",- "answer": "iPhone 13 Pro Max specs are listed here:...",- "metadata": {- "usage": {- "prompt_tokens": 1033,- "prompt_unit_price": "0.001",- "prompt_price_unit": "0.001",- "prompt_price": "0.0010330",- "completion_tokens": 128,- "completion_unit_price": "0.002",- "completion_price_unit": "0.001",- "completion_price": "0.0002560",- "total_tokens": 1161,- "total_price": "0.0012890",- "currency": "USD",- "latency": 0.7682376249867957- },- "retriever_resources": [- {- "position": 1,- "dataset_id": "101b4c97-fc2e-463c-90b1-5261a4cdcafb",- "dataset_name": "iPhone",- "document_id": "8dd1ad74-0b5f-4175-b735-7d98bbbb4e00",- "document_name": "iPhone List",- "segment_id": "ed599c7f-2766-4294-9d1d-e5235a61270a",- "score": 0.98457545,- "content": "\"Model\",\"Release Date\",\"Display Size\",\"Resolution\",\"Processor\",\"RAM\",\"Storage\",\"Camera\",\"Battery\",\"Operating System\"\n\"iPhone 13 Pro Max\",\"September 24, 2021\",\"6.7 inch\",\"1284 x 2778\",\"Hexa-core (2x3.23 GHz Avalanche + 4x1.82 GHz Blizzard)\",\"6 GB\",\"128, 256, 512 GB, 1TB\",\"12 MP\",\"4352 mAh\",\"iOS 15\""- }- ]- },- "created_at": 1705407629- }- ```- </CodeGroup>- <CodeGroup title="Paused Response Example">- ```json {{ title: 'Paused Response Example' }}- {- "event": "workflow_paused",- "task_id": "8a9cbfcf-e7e0-4b17-aeef-24de57a2659a",- "id": "31714374-88cb-485f-9fa4-e3ab2a9ed95e",- "message_id": "31714374-88cb-485f-9fa4-e3ab2a9ed95e",- "conversation_id": "098e19be-356a-435d-9ec3-a406f4f1a97a",- "mode": "advanced-chat",- "answer": "",- "metadata": {- "annotation_reply": null,- "retriever_resources": [],- "usage": null- },- "created_at": 1776074715,- "workflow_run_id": "7a4d6509-8a65-4c7d-a4fd-cf081dcf169f",- "data": {- "id": "31714374-88cb-485f-9fa4-e3ab2a9ed95e",- "mode": "advanced-chat",- "conversation_id": "098e19be-356a-435d-9ec3-a406f4f1a97a",- "message_id": "31714374-88cb-485f-9fa4-e3ab2a9ed95e",- "workflow_run_id": "7a4d6509-8a65-4c7d-a4fd-cf081dcf169f",- "answer": "",- "metadata": {- "annotation_reply": null,- "retriever_resources": [],- "usage": null- },- "created_at": 1776074715,- "paused_nodes": [- "1775724080699"- ],- "reasons": [- {- "form_id": "019d864d-6f55-752c-9f4c-feee67508d5b",- "form_content": "this is form 2:\n\n{{#$output.some_field_2#}}\n",- "inputs": [- {- "type": "paragraph",- "output_variable_name": "some_field_2",- "default": {- "type": "constant",- "selector": [],- "value": ""- }- }- ],- "actions": [- {- "id": "approve",- "title": "yes",- "button_style": "default"- },- {- "id": "reject",- "title": "no",- "button_style": "default"- }- ],- "display_in_ui": true,- "node_id": "1775724080699",- "node_title": "Human Input 2",- "resolved_default_values": {},- "form_token": "0dvwTdpTFXgCZmAo2FoiJ5",- "type": "human_input_required",- "expiration_time": 1776333914- }- ],- "status": "paused",- "elapsed_time": 0.034081,- "total_tokens": 0,- "total_steps": 2- }- }- ```- </CodeGroup>- ### Streaming Mode- <CodeGroup title="Response">- ```streaming {{ title: 'Response' }}- data: {"event": "workflow_started", "task_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "workflow_run_id": "5ad498-f0c7-4085-b384-88cbe6290", "data": {"id": "5ad498-f0c7-4085-b384-88cbe6290", "workflow_id": "dfjasklfjdslag", "created_at": 1679586595}}- data: {"event": "node_started", "task_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "workflow_run_id": "5ad498-f0c7-4085-b384-88cbe6290", "data": {"id": "5ad498-f0c7-4085-b384-88cbe6290", "node_id": "dfjasklfjdslag", "node_type": "start", "title": "Start", "index": 0, "predecessor_node_id": "fdljewklfklgejlglsd", "inputs": {}, "created_at": 1679586595}}- data: {"event": "node_finished", "task_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "workflow_run_id": "5ad498-f0c7-4085-b384-88cbe6290", "data": {"id": "5ad498-f0c7-4085-b384-88cbe6290", "node_id": "dfjasklfjdslag", "node_type": "start", "title": "Start", "index": 0, "predecessor_node_id": "fdljewklfklgejlglsd", "inputs": {}, "outputs": {}, "status": "succeeded", "elapsed_time": 0.324, "execution_metadata": {"total_tokens": 63127864, "total_price": 2.378, "currency": "USD"}, "created_at": 1679586595}}- data: {"event": "workflow_finished", "task_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "workflow_run_id": "5ad498-f0c7-4085-b384-88cbe6290", "data": {"id": "5ad498-f0c7-4085-b384-88cbe6290", "workflow_id": "dfjasklfjdslag", "outputs": {}, "status": "succeeded", "elapsed_time": 0.324, "total_tokens": 63127864, "total_steps": "1", "created_at": 1679586595, "finished_at": 1679976595}}- data: {"event": "message", "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " I", "created_at": 1679586595}- data: {"event": "message", "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": "'m", "created_at": 1679586595}- data: {"event": "message", "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " glad", "created_at": 1679586595}- data: {"event": "message", "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " to", "created_at": 1679586595}- data: {"event": "message", "message_id" : "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " meet", "created_at": 1679586595}- data: {"event": "message", "message_id" : "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " you", "created_at": 1679586595}- data: {"event": "message_end", "id": "5e52ce04-874b-4d27-9045-b3bc80def685", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "metadata": {"usage": {"prompt_tokens": 1033, "prompt_unit_price": "0.001", "prompt_price_unit": "0.001", "prompt_price": "0.0010330", "completion_tokens": 135, "completion_unit_price": "0.002", "completion_price_unit": "0.001", "completion_price": "0.0002700", "total_tokens": 1168, "total_price": "0.0013030", "currency": "USD", "latency": 1.381760165997548}, "retriever_resources": [{"position": 1, "dataset_id": "101b4c97-fc2e-463c-90b1-5261a4cdcafb", "dataset_name": "iPhone", "document_id": "8dd1ad74-0b5f-4175-b735-7d98bbbb4e00", "document_name": "iPhone List", "segment_id": "ed599c7f-2766-4294-9d1d-e5235a61270a", "score": 0.98457545, "content": "\"Model\",\"Release Date\",\"Display Size\",\"Resolution\",\"Processor\",\"RAM\",\"Storage\",\"Camera\",\"Battery\",\"Operating System\"\n\"iPhone 13 Pro Max\",\"September 24, 2021\",\"6.7 inch\",\"1284 x 2778\",\"Hexa-core (2x3.23 GHz Avalanche + 4x1.82 GHz Blizzard)\",\"6 GB\",\"128, 256, 512 GB, 1TB\",\"12 MP\",\"4352 mAh\",\"iOS 15\""}]}}- data: {"event": "tts_message", "conversation_id": "23dd85f3-1a41-4ea0-b7a9-062734ccfaf9", "message_id": "a8bdc41c-13b2-4c18-bfd9-054b9803038c", "created_at": 1721205487, "task_id": "3bf8a0bb-e73b-4690-9e66-4e429bad8ee7", "audio": "qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq"}- data: {"event": "tts_message_end", "conversation_id": "23dd85f3-1a41-4ea0-b7a9-062734ccfaf9", "message_id": "a8bdc41c-13b2-4c18-bfd9-054b9803038c", "created_at": 1721205487, "task_id": "3bf8a0bb-e73b-4690-9e66-4e429bad8ee7", "audio": ""}- ```- </CodeGroup>- Streaming mode can also pause for Human-in-the-Loop. In that case, the SSE stream emits `human_input_required` first and then `workflow_paused`.-- <CodeGroup title="Paused Streaming Response Example">- ```streaming {{ title: 'Paused Streaming Response Example' }}- event: ping-- data: {- "event": "workflow_started",- "workflow_run_id": "a4959eb4-c852-4e0c-ac7a-348233f7f345",- "task_id": "0399c5c2-181b-4493-a78e-1421914e8a25",- "data": {- "id": "a4959eb4-c852-4e0c-ac7a-348233f7f345",- "workflow_id": "e46514f1-c008-41ff-94b0-4f33d4b97d36",- "inputs": {- "sys.files": [],- "sys.user_id": "abc-123",- "sys.app_id": "d1074979-f67e-4114-8691-e35878df9a89",- "sys.workflow_id": "e46514f1-c008-41ff-94b0-4f33d4b97d36",- "sys.workflow_run_id": "a4959eb4-c852-4e0c-ac7a-348233f7f345"- },- "created_at": 1776129228,- "reason": "initial"- }- }-- data: {- "event": "node_started",- "workflow_run_id": "a4959eb4-c852-4e0c-ac7a-348233f7f345",- "task_id": "0399c5c2-181b-4493-a78e-1421914e8a25",- "data": {- "id": "7d9bb041-5ecb-497f-a674-d8706eed0ab1",- "node_id": "1775717266623",- "node_type": "start",- "title": "User Input",- "index": 1,- "predecessor_node_id": null,- "inputs": null,- "inputs_truncated": false,- "created_at": 1776129228,- "extras": {},- "iteration_id": null,- "loop_id": null,- "agent_strategy": null- }- }-- data: {- "event": "node_finished",- "workflow_run_id": "a4959eb4-c852-4e0c-ac7a-348233f7f345",- "task_id": "0399c5c2-181b-4493-a78e-1421914e8a25",- "data": {- "id": "7d9bb041-5ecb-497f-a674-d8706eed0ab1",- "node_id": "1775717266623",- "node_type": "start",- "title": "User Input",- "index": 1,- "predecessor_node_id": null,- "inputs": {- "sys.files": [],- "sys.user_id": "abc-123",- "sys.app_id": "d1074979-f67e-4114-8691-e35878df9a89",- "sys.workflow_id": "e46514f1-c008-41ff-94b0-4f33d4b97d36",- "sys.workflow_run_id": "a4959eb4-c852-4e0c-ac7a-348233f7f345",- "sys.timestamp": 1776129228- },- "inputs_truncated": false,- "process_data": {},- "process_data_truncated": false,- "outputs": {- "sys.files": [],- "sys.user_id": "abc-123",- "sys.app_id": "d1074979-f67e-4114-8691-e35878df9a89",- "sys.workflow_id": "e46514f1-c008-41ff-94b0-4f33d4b97d36",- "sys.workflow_run_id": "a4959eb4-c852-4e0c-ac7a-348233f7f345",- "sys.timestamp": 1776129228- },- "outputs_truncated": false,- "status": "succeeded",- "error": null,- "elapsed_time": 0.000097,- "execution_metadata": null,- "created_at": 1776129228,- "finished_at": 1776129228,- "files": [],- "iteration_id": null,- "loop_id": null- }- }-- data: {- "event": "node_started",- "workflow_run_id": "a4959eb4-c852-4e0c-ac7a-348233f7f345",- "task_id": "0399c5c2-181b-4493-a78e-1421914e8a25",- "data": {- "id": "c09ff568-1d55-4f0d-9a07-512bcbfeb289",- "node_id": "1775717346519",- "node_type": "human-input",- "title": "Human Input",- "index": 1,- "predecessor_node_id": null,- "inputs": null,- "inputs_truncated": false,- "created_at": 1776129228,- "extras": {},- "iteration_id": null,- "loop_id": null,- "agent_strategy": null- }- }-- data: {- "event": "human_input_required",- "workflow_run_id": "a4959eb4-c852-4e0c-ac7a-348233f7f345",- "task_id": "0399c5c2-181b-4493-a78e-1421914e8a25",- "data": {- "form_id": "019d898d-3d80-7105-b920-9899ead4ff3e",- "node_id": "1775717346519",- "node_title": "Human Input",- "form_content": "this is form 1:\n{{#$output.some_field#}}\n",- "inputs": [- {- "type": "paragraph",- "output_variable_name": "some_field",- "default": {- "type": "variable",- "selector": [- "sys",- "workflow_run_id"- ],- "value": ""- }- }- ],- "actions": [- {- "id": "approve",- "title": "YES",- "button_style": "default"- },- {- "id": "reject",- "title": "NO",- "button_style": "default"- }- ],- "display_in_ui": true,- "form_token": "0Tb1nXYe4hzQUD706nHB4y",- "resolved_default_values": {- "some_field": "a4959eb4-c852-4e0c-ac7a-348233f7f345"- },- "expiration_time": 1776388428- }- }-- data: {- "event": "workflow_paused",- "workflow_run_id": "a4959eb4-c852-4e0c-ac7a-348233f7f345",- "task_id": "0399c5c2-181b-4493-a78e-1421914e8a25",- "data": {- "workflow_run_id": "a4959eb4-c852-4e0c-ac7a-348233f7f345",- "paused_nodes": [- "1775717346519"- ],- "outputs": {},- "reasons": [- {- "form_id": "019d898d-3d80-7105-b920-9899ead4ff3e",- "form_content": "this is form 1:\n{{#$output.some_field#}}\n",- "inputs": [- {- "type": "paragraph",- "output_variable_name": "some_field",- "default": {- "type": "variable",- "selector": [- "sys",- "workflow_run_id"- ],- "value": ""- }- }- ],- "actions": [- {- "id": "approve",- "title": "YES",- "button_style": "default"- },- {- "id": "reject",- "title": "NO",- "button_style": "default"- }- ],- "display_in_ui": true,- "node_id": "1775717346519",- "node_title": "Human Input",- "resolved_default_values": {- "some_field": "a4959eb4-c852-4e0c-ac7a-348233f7f345"- },- "form_token": "0Tb1nXYe4hzQUD706nHB4y",- "type": "human_input_required",- "expiration_time": 1776388428- }- ],- "status": "paused",- "created_at": 1776129228,- "elapsed_time": 0.070478,- "total_tokens": 0,- "total_steps": 2- }- }- ```- </CodeGroup>-- </Col>-</Row>------<Heading- url='/files/upload'- method='POST'- title='File Upload'- name='#file-upload'-/>-<Row>- <Col>- Upload a file for use when sending messages, enabling multimodal understanding of images and text.- Supports any formats that are supported by your application.- Uploaded files are for use by the current end-user only.-- ### Request Body- This interface requires a `multipart/form-data` request.- - `file` (File) Required- The file to be uploaded.- - `user` (string) Required- User identifier, defined by the developer's rules, must be unique within the application. The Service API does not share conversations created by the WebApp.-- ### Response- After a successful upload, the server will return the file's ID and related information.- - `id` (uuid) ID- - `name` (string) File name- - `size` (int) File size (bytes)- - `extension` (string) File extension- - `mime_type` (string) File mime-type- - `created_by` (uuid) End-user ID- - `created_at` (timestamp) Creation timestamp, e.g., 1705395332-- ### Errors- - 400, `no_file_uploaded`, a file must be provided- - 400, `too_many_files`, currently only one file is accepted- - 400, `unsupported_preview`, the file does not support preview- - 400, `unsupported_estimate`, the file does not support estimation- - 413, `file_too_large`, the file is too large- - 415, `unsupported_file_type`, unsupported extension, currently only document files are accepted- - 503, `s3_connection_failed`, unable to connect to S3 service- - 503, `s3_permission_denied`, no permission to upload files to S3- - 503, `s3_file_too_large`, file exceeds S3 size limit- - 500, internal server error--- </Col>- <Col sticky>- ### Request Example- <CodeGroup- title="Request"- tag="POST"- label="/files/upload"- targetCode={`curl -X POST '${props.appDetail.api_base_url}/files/upload' \\---header 'Authorization: Bearer {api_key}' \\---form 'file=@localfile;type=image/[png|jpeg|jpg|webp|gif]' \\---form 'user=abc-123'`}- />-- ### Response Example- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "id": "72fa9618-8f89-4a37-9b33-7e1178a24a67",- "name": "example.png",- "size": 1024,- "extension": "png",- "mime_type": "image/png",- "created_by": "6ad1ab0a-73ff-4ac1-b9e4-cdb312f71f13",- "created_at": 1577836800,- }- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/end-users/:end_user_id'- method='GET'- title='Get End User'- name='#end-user'-/>-<Row>- <Col>- Retrieve an end user by ID.-- This is useful when other APIs return an end-user ID (e.g. `created_by` from File Upload).-- ### Path Parameters- - `end_user_id` (uuid) Required- End user ID.-- ### Response- Returns an EndUser object.- - `id` (uuid) ID- - `tenant_id` (uuid) Tenant ID- - `app_id` (uuid) App ID- - `type` (string) End user type- - `external_user_id` (string) External user ID- - `name` (string) Name- - `is_anonymous` (boolean) Whether anonymous- - `session_id` (string) Session ID- - `created_at` (string) ISO 8601 datetime- - `updated_at` (string) ISO 8601 datetime-- ### Errors- - 404, `end_user_not_found`, end user not found- - 500, internal server error-- </Col>- <Col sticky>- ### Request Example- <CodeGroup- title="Request"- tag="GET"- label="/end-users/:end_user_id"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/end-users/6ad1ab0a-73ff-4ac1-b9e4-cdb312f71f13' \\---header 'Authorization: Bearer {api_key}'`}- />-- ### Response Example- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "id": "6ad1ab0a-73ff-4ac1-b9e4-cdb312f71f13",- "tenant_id": "8c0f3f3a-66b0-4b55-a0bf-8b8e0d6aee7d",- "app_id": "6c8c3f41-2c6f-4e1b-8f4f-7f11c8f2ad2a",- "type": "service_api",- "external_user_id": "abc-123",- "name": "Alice",- "is_anonymous": false,- "session_id": "abc-123",- "created_at": "2024-01-01T00:00:00Z",- "updated_at": "2024-01-01T00:00:00Z"- }- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/files/:file_id/preview'- method='GET'- title='File Preview'- name='#file-preview'-/>-<Row>- <Col>- Preview or download uploaded files. This endpoint allows you to access files that have been previously uploaded via the File Upload API.-- <i>Files can only be accessed if they belong to messages within the requesting application.</i>-- ### Path Parameters- - `file_id` (string) Required- The unique identifier of the file to preview, obtained from the File Upload API response.-- ### Query Parameters- - `as_attachment` (boolean) Optional- Whether to force download the file as an attachment. Default is `false` (preview in browser).-- ### Response- Returns the file content with appropriate headers for browser display or download.- - `Content-Type` Set based on file mime type- - `Content-Length` File size in bytes (if available)- - `Content-Disposition` Set to "attachment" if `as_attachment=true`- - `Cache-Control` Caching headers for performance- - `Accept-Ranges` Set to "bytes" for audio/video files-- ### Errors- - 400, `invalid_param`, abnormal parameter input- - 403, `file_access_denied`, file access denied or file does not belong to current application- - 404, `file_not_found`, file not found or has been deleted- - 500, internal server error-- </Col>- <Col sticky>- ### Request Example- <CodeGroup- title="Request"- tag="GET"- label="/files/:file_id/preview"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/files/72fa9618-8f89-4a37-9b33-7e1178a24a67/preview' \\---header 'Authorization: Bearer {api_key}'`}- />-- ### Download as Attachment- <CodeGroup- title="Download Request"- tag="GET"- label="/files/:file_id/preview?as_attachment=true"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/files/72fa9618-8f89-4a37-9b33-7e1178a24a67/preview?as_attachment=true' \\---header 'Authorization: Bearer {api_key}' \\---output downloaded_file.png`}- />-- ### Response Headers Example- <CodeGroup title="Response Headers">- ```http {{ title: 'Headers - Image Preview' }}- Content-Type: image/png- Content-Length: 1024- Cache-Control: public, max-age=3600- ```- </CodeGroup>-- ### Download Response Headers- <CodeGroup title="Download Response Headers">- ```http {{ title: 'Headers - File Download' }}- Content-Type: image/png- Content-Length: 1024- Content-Disposition: attachment; filename*=UTF-8''example.png- Cache-Control: public, max-age=3600- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/chat-messages/:task_id/stop'- method='POST'- title='Stop Generate'- name='#stop-generatebacks'-/>-<Row>- <Col>- Only supported in streaming mode.- ### Path- - `task_id` (string) Task ID, can be obtained from the streaming chunk return- ### Request Body- - `user` (string) Required- User identifier, used to define the identity of the end-user, must be consistent with the user passed in the message sending interface. The Service API does not share conversations created by the WebApp.- ### Response- - `result` (string) Always returns "success"- </Col>- <Col sticky>- ### Request Example- <CodeGroup- title="Request"- tag="POST"- label="/chat-messages/:task_id/stop"- targetCode={`curl -X POST '${props.appDetail.api_base_url}/chat-messages/:task_id/stop' \\--H 'Authorization: Bearer {api_key}' \\--H 'Content-Type: application/json' \\---data-raw '{- "user": "abc-123"-}'`}- />-- ### Response Example- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "result": "success"- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/form/human_input/:form_token'- method='GET'- title='Get Human Input Form'- name='#get-human-input-form'-/>-<Row>- <Col>- Retrieve a pending Human-in-the-Loop form by `form_token`.-- Use this endpoint when streaming returns `human_input_required` with a `form_token`.-- ### Path- - `form_token` (string) Required, token returned by the pause event.-- ### Response- - `form_content` (string) Rendered form content (markdown/plain text)- - `inputs` (array[object]) Form input definitions- - `resolved_default_values` (object) Default values resolved to strings- - `user_actions` (array[object]) Action buttons- - `expiration_time` (timestamp) Form expiration time (Unix seconds)-- ### Errors- - 404, form not found or does not belong to current app- - 412, `human_input_form_submitted`, form already submitted- - 412, `human_input_form_expired`, form expired- </Col>- <Col sticky>- <CodeGroup- title="Request"- tag="GET"- label="/form/human_input/:form_token"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/form/human_input/{form_token}' \\---header 'Authorization: Bearer {api_key}'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "form_content": "Please confirm the final answer: {{#$output.answer#}}",- "inputs": [- {- "label": "Answer",- "type": "text-input",- "required": true,- "output_variable_name": "answer"- }- ],- "resolved_default_values": {- "answer": "Initial value"- },- "user_actions": [- { "id": "approve", "title": "Approve", "button_style": "primary" },- { "id": "reject", "title": "Reject", "button_style": "warning" }- ],- "expiration_time": 1735689600- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/form/human_input/:form_token'- method='POST'- title='Submit Human Input Form'- name='#submit-human-input-form'-/>-<Row>- <Col>- Submit a pending Human-in-the-Loop form.-- ### Path- - `form_token` (string) Required, token returned by the pause event.-- ### Request Body- - `inputs` (object) Required, key/value pairs for form fields.- - `action` (string) Required, selected action ID from `user_actions`.- - `user` (string) Required, end-user identifier.-- ### Response- Returns an empty object on success.-- ### Errors- - 400, `invalid_form_data`, submitted data does not match the form schema- - 404, form not found or does not belong to current app- - 412, `human_input_form_submitted`, form already submitted- - 412, `human_input_form_expired`, form expired- </Col>- <Col sticky>- <CodeGroup- title="Request"- tag="POST"- label="/form/human_input/:form_token"- targetCode={`curl -X POST '${props.appDetail.api_base_url}/form/human_input/{form_token}' \\---header 'Authorization: Bearer {api_key}' \\---header 'Content-Type: application/json' \\---data-raw '{- "inputs": {"answer": "Approved answer"},- "action": "approve",- "user": "abc-123"-}'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {}- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/workflow/:task_id/events'- method='GET'- title='Get Workflow Resume Events'- name='#get-workflow-resume-events'-/>-<Row>- <Col>- Continue receiving workflow events after submitting a human input form.-- This endpoint returns `text/event-stream` and can be used to observe resumed execution until completion.-- ### Path- - `task_id` (string) Required, workflow run ID (`workflow_run_id`).-- ### Query- - `user` (string) Required, end-user identifier.- - `include_state_snapshot` (bool) Optional, set to `true` to replay from persisted state snapshot before continuing with live events.- - `continue_on_pause` (bool) Optional, set to `true` to keep the stream open across `workflow_paused` events until `workflow_finished`.-- ### Response- Server-Sent Events stream (`text/event-stream`).- Typical events include `workflow_paused`, `node_started`, `node_finished`, `human_input_form_filled`, `human_input_form_timeout`, and `workflow_finished`.- If the workflow has already finished when you call this endpoint, the server returns a single finished event immediately.- </Col>- <Col sticky>- <CodeGroup- title="Request"- tag="GET"- label="/workflow/:task_id/events"- targetCode={`curl -N -X GET '${props.appDetail.api_base_url}/workflow/{workflow_run_id}/events?user=abc-123&continue_on_pause=true' \\---header 'Authorization: Bearer {api_key}'`}- />-- <CodeGroup title="Response">- ```streaming {{ title: 'Response' }}- event: ping-- data: {"event":"workflow_started","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","data":{"id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","workflow_id":"e46514f1-c008-41ff-94b0-4f33d4b97d36","inputs":{"sys.files":[],"sys.user_id":"abc-123","sys.app_id":"d1074979-f67e-4114-8691-e35878df9a89","sys.workflow_id":"e46514f1-c008-41ff-94b0-4f33d4b97d36","sys.workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","sys.timestamp":1776087863},"created_at":1776087863,"reason":"initial"}}-- data: {"event":"node_started","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","data":{"id":"b552d685-1119-4e6a-9a81-e91a23e5324b","node_id":"1775717266623","node_type":"start","title":"User Input","index":1,"predecessor_node_id":null,"inputs":null,"created_at":1776087863,"extras":{},"iteration_id":null,"loop_id":null}}-- data: {"event":"node_finished","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","data":{"id":"b552d685-1119-4e6a-9a81-e91a23e5324b","node_id":"1775717266623","node_type":"start","title":"User Input","index":1,"predecessor_node_id":null,"inputs":null,"process_data":null,"outputs":null,"status":"succeeded","error":null,"elapsed_time":0.00032,"execution_metadata":null,"created_at":1776087863,"finished_at":1776087863,"files":[],"iteration_id":null,"loop_id":null}}-- data: {"event":"node_started","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","data":{"id":"8d7e8e01-5159-4089-a4b6-3aa394992cc2","node_id":"1775717346519","node_type":"human-input","title":"Human Input","index":2,"predecessor_node_id":null,"inputs":null,"created_at":1776087863,"extras":{},"iteration_id":null,"loop_id":null}}-- data: {"event":"node_finished","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","data":{"id":"8d7e8e01-5159-4089-a4b6-3aa394992cc2","node_id":"1775717346519","node_type":"human-input","title":"Human Input","index":2,"predecessor_node_id":null,"inputs":null,"process_data":null,"outputs":null,"status":"paused","error":null,"elapsed_time":0.007381,"execution_metadata":null,"created_at":1776087863,"finished_at":1776087863,"files":[],"iteration_id":null,"loop_id":null}}-- data: {"event":"workflow_paused","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","data":{"workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","paused_nodes":["1775717346519"],"outputs":{},"reasons":[{"form_id":"019d8716-0fde-75da-8207-1458ccde76e5","form_content":"this is form 1:\n{{#$output.some_field#}}\n","inputs":[{"type":"paragraph","output_variable_name":"some_field","default":{"type":"variable","selector":["sys","workflow_run_id"],"value":""}}],"actions":[{"id":"approve","title":"YES","button_style":"default"},{"id":"reject","title":"NO","button_style":"default"}],"display_in_ui":true,"node_id":"1775717346519","node_title":"Human Input","resolved_default_values":{"some_field":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c"},"form_token":"n7hFG4ZDYdGcgZ5VDc7EGM","type":"human_input_required"}],"status":"paused","created_at":1776087863,"elapsed_time":0.0,"total_tokens":0,"total_steps":2}}-- data: {"event":"workflow_started","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","data":{"id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","workflow_id":"e46514f1-c008-41ff-94b0-4f33d4b97d36","inputs":{"sys.files":[],"sys.user_id":"abc-123","sys.app_id":"d1074979-f67e-4114-8691-e35878df9a89","sys.workflow_id":"e46514f1-c008-41ff-94b0-4f33d4b97d36","sys.workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c"},"created_at":1776087877,"reason":"resumption"}}-- data: {"event":"node_started","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","data":{"id":"8d7e8e01-5159-4089-a4b6-3aa394992cc2","node_id":"1775717346519","node_type":"human-input","title":"Human Input","index":1,"predecessor_node_id":null,"inputs":null,"inputs_truncated":false,"created_at":1776087877,"extras":{},"iteration_id":null,"loop_id":null,"agent_strategy":null}}-- data: {"event":"human_input_form_filled","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","data":{"node_id":"1775717346519","node_title":"Human Input","rendered_content":"this is form 1:\nfield 1 filled!\n","action_id":"approve","action_text":"YES"}}-- data: {"event":"node_finished","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","data":{"id":"8d7e8e01-5159-4089-a4b6-3aa394992cc2","node_id":"1775717346519","node_type":"human-input","title":"Human Input","index":1,"predecessor_node_id":null,"inputs":{},"inputs_truncated":false,"process_data":{},"process_data_truncated":false,"outputs":{"some_field":"field 1 filled!","some_field_2":"from bruno with love","__action_id":"approve","__rendered_content":"this is form 1:\nfield 1 filled!\n"},"outputs_truncated":false,"status":"succeeded","error":null,"elapsed_time":0.004431,"execution_metadata":null,"created_at":1776087877,"finished_at":1776087877,"files":[],"iteration_id":null,"loop_id":null}}-- data: {"event":"node_started","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","data":{"id":"6d8fc3cb-19f7-440b-b83e-eed4e847a332","node_id":"1775717350710","node_type":"template-transform","title":"Template","index":1,"predecessor_node_id":null,"inputs":null,"inputs_truncated":false,"created_at":1776087877,"extras":{},"iteration_id":null,"loop_id":null,"agent_strategy":null}}-- data: {"event":"text_chunk","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","data":{"text":"field 1 filled!","from_variable_selector":["1775717350710","output"]}}-- data: {"event":"node_finished","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","data":{"id":"6d8fc3cb-19f7-440b-b83e-eed4e847a332","node_id":"1775717350710","node_type":"template-transform","title":"Template","index":1,"predecessor_node_id":null,"inputs":{"some_field":"field 1 filled!"},"inputs_truncated":false,"process_data":{},"process_data_truncated":false,"outputs":{"output":"field 1 filled!"},"outputs_truncated":false,"status":"succeeded","error":null,"elapsed_time":0.264614,"execution_metadata":null,"created_at":1776087877,"finished_at":1776087877,"files":[],"iteration_id":null,"loop_id":null}}-- data: {"event":"node_started","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","data":{"id":"e88dec7e-aa2c-41f7-8d73-032b749e23f5","node_id":"1775717354177","node_type":"end","title":"Output","index":1,"predecessor_node_id":null,"inputs":null,"inputs_truncated":false,"created_at":1776087877,"extras":{},"iteration_id":null,"loop_id":null,"agent_strategy":null}}-- data: {"event":"node_finished","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","data":{"id":"e88dec7e-aa2c-41f7-8d73-032b749e23f5","node_id":"1775717354177","node_type":"end","title":"Output","index":1,"predecessor_node_id":null,"inputs":{"output":"field 1 filled!"},"inputs_truncated":false,"process_data":{},"process_data_truncated":false,"outputs":{"output":"field 1 filled!"},"outputs_truncated":false,"status":"succeeded","error":null,"elapsed_time":0.00003,"execution_metadata":null,"created_at":1776087877,"finished_at":1776087877,"files":[],"iteration_id":null,"loop_id":null}}-- data: {"event":"workflow_finished","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","data":{"id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","workflow_id":"e46514f1-c008-41ff-94b0-4f33d4b97d36","status":"succeeded","outputs":{"output":"field 1 filled!"},"error":null,"elapsed_time":0.364935,"total_tokens":0,"total_steps":5,"created_by":{"id":"7932d34c-dcf4-4fba-b770-f2a9de88c0a0","user":"abc-123"},"created_at":1776087877,"finished_at":1776087877,"exceptions_count":0,"files":[]}}- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/messages/:message_id/feedbacks'- method='POST'- title='Message Feedback'- name='#feedbacks'-/>-<Row>- <Col>- End-users can provide feedback messages, facilitating application developers to optimize expected outputs.-- ### Path- <Properties>- <Property name='message_id' type='string' key='message_id'>- Message ID- </Property>- </Properties>-- ### Request Body-- <Properties>- <Property name='rating' type='string' key='rating'>- Upvote as `like`, downvote as `dislike`, revoke upvote as `null`- </Property>- <Property name='user' type='string' key='user'>- User identifier, defined by the developer's rules, must be unique within the application. The Service API does not share conversations created by the WebApp.- </Property>- <Property name='content' type='string' key='content'>- The specific content of message feedback.- </Property>- </Properties>-- ### Response- - `result` (string) Always returns "success"- </Col>- <Col sticky>-- <CodeGroup- title="Request"- tag="POST"- label="/messages/:message_id/feedbacks"- targetCode={`curl -X POST '${props.appDetail.api_base_url}/messages/:message_id/feedbacks' \\---header 'Authorization: Bearer {api_key}' \\---header 'Content-Type: application/json' \\---data-raw '{- "rating": "like",- "user": "abc-123",- "content": "message feedback information"-}'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "result": "success"- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/app/feedbacks'- method='GET'- title='Get feedbacks of application'- name='#app-feedbacks'-/>-<Row>- <Col>- Get application's feedbacks.-- ### Query- <Properties>- <Property name='page' type='string' key='page'>- (optional)pagination,default:1- </Property>- </Properties>-- <Properties>- <Property name='limit' type='string' key='limit'>- (optional) records per page default:20- </Property>- </Properties>-- ### Response- - `data` (List) return apps feedback list.- </Col>- <Col sticky>-- <CodeGroup- title="Request"- tag="GET"- label="/app/feedbacks"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/app/feedbacks?page=1&limit=20' \\---header 'Authorization: Bearer {api_key}' \\---header 'Content-Type: application/json'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "data": [- {- "id": "8c0fbed8-e2f9-49ff-9f0e-15a35bdd0e25",- "app_id": "f252d396-fe48-450e-94ec-e184218e7346",- "conversation_id": "2397604b-9deb-430e-b285-4726e51fd62d",- "message_id": "709c0b0f-0a96-4a4e-91a4-ec0889937b11",- "rating": "like",- "content": "message feedback information-3",- "from_source": "user",- "from_end_user_id": "74286412-9a1a-42c1-929c-01edb1d381d5",- "from_account_id": null,- "created_at": "2025-04-24T09:24:38",- "updated_at": "2025-04-24T09:24:38"- }- ]- }- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/messages/{message_id}/suggested'- method='GET'- title='Next Suggested Questions'- name='#suggested'-/>-<Row>- <Col>- Get next questions suggestions for the current message-- ### Path Params-- <Properties>- <Property name='message_id' type='string' key='message_id'>- Message ID- </Property>- </Properties>-- ### Query- <Properties>- <Property name='user' type='string' key='user'>- User identifier, used to define the identity of the end-user for retrieval and statistics.- Should be uniquely defined by the developer within the application.- </Property>- </Properties>- </Col>- <Col sticky>-- <CodeGroup- title="Request"- tag="GET"- label="/messages/{message_id}/suggested"- targetCode={`curl --location --request GET '${props.appDetail.api_base_url}/messages/{message_id}/suggested?user=abc-123' \\---header 'Authorization: Bearer ENTER-YOUR-SECRET-KEY' \\---header 'Content-Type: application/json'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "result": "success",- "data": [- "a",- "b",- "c"- ]- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/messages'- method='GET'- title='Get Conversation History Messages'- name='#messages'-/>-<Row>- <Col>- Returns historical chat records in a scrolling load format, with the first page returning the latest `{limit}` messages, i.e., in reverse order.-- ### Query-- <Properties>- <Property name='conversation_id' type='string' key='conversation_id'>- Conversation ID- </Property>- <Property name='user' type='string' key='user'>- User identifier, used to define the identity of the end-user for retrieval and statistics.- Should be uniquely defined by the developer within the application.- </Property>- <Property name='first_id' type='string' key='first_id'>- The ID of the first chat record on the current page, default is null.- </Property>- <Property name='limit' type='int' key='limit'>- How many chat history messages to return in one request, default is 20.- </Property>- </Properties>-- ### Response- - `data` (array[object]) Message list- - `id` (string) Message ID- - `conversation_id` (string) Conversation ID- - `inputs` (object) User input parameters.- - `query` (string) User input / question content.- - `message_files` (array[object]) Message files- - `id` (string) ID- - `type` (string) File type, image for images- - `url` (string) File preview URL, use the File Preview API (`/files/{file_id}/preview`) to access the file- - `belongs_to` (string) belongs to,user orassistant- - `answer` (string) Response message content- - `created_at` (timestamp) Creation timestamp, e.g., 1705395332- - `feedback` (object) Feedback information- - `rating` (string) Upvote as `like` / Downvote as `dislike`- - `retriever_resources` (array[RetrieverResource]) Citation and Attribution List- - `has_more` (bool) Whether there is a next page- - `limit` (int) Number of returned items, if input exceeds system limit, returns system limit amount-- </Col>- <Col sticky>-- <CodeGroup- title="Request"- tag="GET"- label="/messages"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/messages?user=abc-123&conversation_id={conversation_id}'---header 'Authorization: Bearer {api_key}'`}- />-- ### Response Example- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "limit": 20,- "has_more": false,- "data": [- {- "id": "a076a87f-31e5-48dc-b452-0061adbbc922",- "conversation_id": "cd78daf6-f9e4-4463-9ff2-54257230a0ce",- "inputs": {- "name": "dify"- },- "query": "iphone 13 pro",- "answer": "The iPhone 13 Pro, released on September 24, 2021, features a 6.1-inch display with a resolution of 1170 x 2532. It is equipped with a Hexa-core (2x3.23 GHz Avalanche + 4x1.82 GHz Blizzard) processor, 6 GB of RAM, and offers storage options of 128 GB, 256 GB, 512 GB, and 1 TB. The camera is 12 MP, the battery capacity is 3095 mAh, and it runs on iOS 15.",- "message_files": [],- "feedback": null,- "retriever_resources": [- {- "position": 1,- "dataset_id": "101b4c97-fc2e-463c-90b1-5261a4cdcafb",- "dataset_name": "iPhone",- "document_id": "8dd1ad74-0b5f-4175-b735-7d98bbbb4e00",- "document_name": "iPhone List",- "segment_id": "ed599c7f-2766-4294-9d1d-e5235a61270a",- "score": 0.98457545,- "content": "\"Model\",\"Release Date\",\"Display Size\",\"Resolution\",\"Processor\",\"RAM\",\"Storage\",\"Camera\",\"Battery\",\"Operating System\"\n\"iPhone 13 Pro Max\",\"September 24, 2021\",\"6.7 inch\",\"1284 x 2778\",\"Hexa-core (2x3.23 GHz Avalanche + 4x1.82 GHz Blizzard)\",\"6 GB\",\"128, 256, 512 GB, 1TB\",\"12 MP\",\"4352 mAh\",\"iOS 15\""- }- ],- "created_at": 1705569239,- }- ]- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/conversations'- method='GET'- title='Get Conversations'- name='#conversations'-/>-<Row>- <Col>- Retrieve the conversation list for the current user, defaulting to the most recent 20 entries.-- ### Query-- <Properties>- <Property name='user' type='string' key='user'>- User identifier, used to define the identity of the end-user for retrieval and statistics.- Should be uniquely defined by the developer within the application.- </Property>- <Property name='last_id' type='string' key='last_id'>- (Optional) The ID of the last record on the current page, default is null.- </Property>- <Property name='limit' type='int' key='limit'>- (Optional) How many records to return in one request, default is the most recent 20 entries. Maximum 100, minimum 1.- </Property>- <Property name='sort_by' type='string' key='sort_by'>- (Optional) Sorting Field, Default: -updated_at (sorted in descending order by update time)- - Available Values: created_at, -created_at, updated_at, -updated_at- - The symbol before the field represents the order or reverse, "-" represents reverse order.- </Property>- </Properties>-- ### Response- - `data` (array[object]) List of conversations- - `id` (string) Conversation ID- - `name` (string) Conversation name, by default, is generated by LLM.- - `inputs` (object) User input parameters.- - `status` (string) Conversation status- - `introduction` (string) Introduction- - `created_at` (timestamp) Creation timestamp, e.g., 1705395332- - `updated_at` (timestamp) Update timestamp, e.g., 1705395332- - `has_more` (bool)- - `limit` (int) Number of entries returned, if input exceeds system limit, system limit number is returned-- </Col>- <Col sticky>-- <CodeGroup- title="Request"- tag="GET"- label="/conversations"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/conversations?user=abc-123&last_id=&limit=20' \\---header 'Authorization: Bearer {api_key}'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "limit": 20,- "has_more": false,- "data": [- {- "id": "10799fb8-64f7-4296-bbf7-b42bfbe0ae54",- "name": "New chat",- "inputs": {- "book": "book",- "myName": "Lucy"- },- "status": "normal",- "created_at": 1679667915,- "updated_at": 1679667915- },- {- "id": "hSIhXBhNe8X1d8Et"- // ...- }- ]- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/conversations/:conversation_id'- method='DELETE'- title='Delete Conversation'- name='#delete'-/>-<Row>- <Col>- Delete a conversation.-- ### Path- - `conversation_id` (string) Conversation ID-- ### Request Body-- <Properties>- <Property name='user' type='string' key='user'>- The user identifier, defined by the developer, must ensure uniqueness within the application.- </Property>- </Properties>-- ### Response- - `result` (string) Always returns "success"- </Col>- <Col sticky>-- <CodeGroup- title="Request"- tag="DELETE"- label="/conversations/:conversation_id"- targetCode={`curl -X DELETE '${props.appDetail.api_base_url}/conversations/{conversation_id}' \\---header 'Content-Type: application/json' \\---header 'Accept: application/json' \\---header 'Authorization: Bearer {api_key}' \\---data '{- "user": "abc-123"-}'`}- />-- <CodeGroup title="Response">- ```text {{ title: 'Response' }}- 204 No Content- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/conversations/:conversation_id/name'- method='POST'- title='Conversation Rename'- name='#rename'-/>-<Row>- <Col>- ### Request Body- Rename the session, the session name is used for display on clients that support multiple sessions.-- ### Path- - `conversation_id` (string) Conversation ID-- <Properties>- <Property name='name' type='string' key='name'>- (Optional) The name of the conversation. This parameter can be omitted if `auto_generate` is set to `true`.- </Property>- <Property name='auto_generate' type='bool' key='auto_generate'>- (Optional) Automatically generate the title, default is `false`- </Property>- <Property name='user' type='string' key='user'>- The user identifier, defined by the developer, must ensure uniqueness within the application.- </Property>- </Properties>-- ### Response- - `id` (string) Conversation ID- - `name` (string) Conversation name- - `inputs` (object) User input parameters- - `status` (string) Conversation status- - `introduction` (string) Introduction- - `created_at` (timestamp) Creation timestamp, e.g., 1705395332- - `updated_at` (timestamp) Update timestamp, e.g., 1705395332- </Col>- <Col sticky>-- <CodeGroup- title="Request"- tag="POST"- label="/conversations/:conversation_id/name"- targetCode={`curl -X POST '${props.appDetail.api_base_url}/conversations/{conversation_id}/name' \\---header 'Content-Type: application/json' \\---header 'Authorization: Bearer {api_key}' \\---data-raw '{- "name": "",- "auto_generate": true,- "user": "abc-123"-}'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "id": "cd78daf6-f9e4-4463-9ff2-54257230a0ce",- "name": "Chat vs AI",- "inputs": {},- "status": "normal",- "introduction": "",- "created_at": 1705569238,- "updated_at": 1705569238- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/conversations/:conversation_id/variables'- method='GET'- title='Get Conversation Variables'- name='#conversation-variables'-/>-<Row>- <Col>- Retrieve variables from a specific conversation. This endpoint is useful for extracting structured data that was captured during the conversation.-- ### Path Parameters-- <Properties>- <Property name='conversation_id' type='string' key='conversation_id'>- The ID of the conversation to retrieve variables from.- </Property>- </Properties>-- ### Query Parameters-- <Properties>- <Property name='user' type='string' key='user'>- The user identifier, defined by the developer, must ensure uniqueness within the application- </Property>- <Property name='last_id' type='string' key='last_id'>- (Optional) The ID of the last record on the current page, default is null.- </Property>- <Property name='limit' type='int' key='limit'>- (Optional) How many records to return in one request, default is the most recent 20 entries. Maximum 100, minimum 1.- </Property>- </Properties>-- ### Response-- - `limit` (int) Number of items per page- - `has_more` (bool) Whether there is a next page- - `data` (array[object]) List of variables- - `id` (string) Variable ID- - `name` (string) Variable name- - `value_type` (string) Variable type (string, number, object, etc.)- - `value` (string) Variable value- - `description` (string) Variable description- - `created_at` (int) Creation timestamp- - `updated_at` (int) Last update timestamp-- ### Errors- - 404, `conversation_not_exists`, Conversation not found-- </Col>- <Col sticky>-- <CodeGroup- title="Request"- tag="GET"- label="/conversations/:conversation_id/variables"- debug="true"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/conversations/{conversation_id}/variables?user=abc-123' \\---header 'Authorization: Bearer {api_key}'`} />-- <CodeGroup- title="Request with variable name filter"- language="bash"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/conversations/{conversation_id}/variables?user=abc-123&variable_name=customer_name' \\---header 'Authorization: Bearer {api_key}'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "limit": 100,- "has_more": false,- "data": [- {- "id": "variable-uuid-1",- "name": "customer_name",- "value_type": "string",- "value": "John Doe",- "description": "Customer name extracted from the conversation",- "created_at": 1650000000000,- "updated_at": 1650000000000- },- {- "id": "variable-uuid-2",- "name": "order_details",- "value_type": "json",- "value": "{\"product\":\"Widget\",\"quantity\":5,\"price\":19.99}",- "description": "Order details from the customer",- "created_at": 1650000000000,- "updated_at": 1650000000000- }- ]- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/conversations/:conversation_id/variables/:variable_id'- method='PUT'- title='Update Conversation Variable'- name='#update-conversation-variable'-/>-<Row>- <Col>- Update the value of a specific conversation variable. This endpoint allows you to modify the value of a variable that was captured during the conversation while preserving its name, type, and description.-- ### Path Parameters-- <Properties>- <Property name='conversation_id' type='string' key='conversation_id'>- The ID of the conversation containing the variable to update.- </Property>- <Property name='variable_id' type='string' key='variable_id'>- The ID of the variable to update.- </Property>- </Properties>-- ### Request Body-- <Properties>- <Property name='value' type='any' key='value'>- The new value for the variable. Must match the variable's expected type (string, number, object, etc.).- </Property>- <Property name='user' type='string' key='user'>- The user identifier, defined by the developer, must ensure uniqueness within the application.- </Property>- </Properties>-- ### Response-- Returns the updated variable object with:- - `id` (string) Variable ID- - `name` (string) Variable name- - `value_type` (string) Variable type (string, number, object, etc.)- - `value` (any) Updated variable value- - `description` (string) Variable description- - `created_at` (int) Creation timestamp- - `updated_at` (int) Last update timestamp-- ### Errors- - 400, `Type mismatch: variable expects {expected_type}, but got {actual_type} type`, Value type doesn't match variable's expected type- - 404, `conversation_not_exists`, Conversation not found- - 404, `conversation_variable_not_exists`, Variable not found-- </Col>- <Col sticky>-- <CodeGroup- title="Request"- tag="PUT"- label="/conversations/:conversation_id/variables/:variable_id"- targetCode={`curl -X PUT '${props.appDetail.api_base_url}/conversations/{conversation_id}/variables/{variable_id}' \\---header 'Content-Type: application/json' \\---header 'Authorization: Bearer {api_key}' \\---data-raw '{- "value": "Updated Value",- "user": "abc-123"-}'`}- />-- <CodeGroup- title="Update with different value types"- targetCode={[- {- title: 'String',- code: `curl -X PUT '${props.appDetail.api_base_url}/conversations/{conversation_id}/variables/{variable_id}' \\---header 'Content-Type: application/json' \\---header 'Authorization: Bearer {api_key}' \\---data-raw '{- "value": "New string value",- "user": "abc-123"-}'`,- }, {- title: 'Number',- code: `curl -X PUT '${props.appDetail.api_base_url}/conversations/{conversation_id}/variables/{variable_id}' \\---header 'Content-Type: application/json' \\---header 'Authorization: Bearer {api_key}' \\---data-raw '{- "value": 42,- "user": "abc-123"-}'`,- }, {- title: 'Object',- code: `curl -X PUT '${props.appDetail.api_base_url}/conversations/{conversation_id}/variables/{variable_id}' \\---header 'Content-Type: application/json' \\---header 'Authorization: Bearer {api_key}' \\---data-raw '{- "value": {"product": "Widget", "quantity": 10, "price": 29.99},- "user": "abc-123"-}'`,- },- ]}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "id": "variable-uuid-1",- "name": "customer_name",- "value_type": "string",- "value": "Updated Value",- "description": "Customer name extracted from the conversation",- "created_at": 1650000000000,- "updated_at": 1650000001000- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/audio-to-text'- method='POST'- title='Speech to Text'- name='#audio-to-text'-/>-<Row>- <Col>- This endpoint requires a multipart/form-data request.-- ### Request Body-- <Properties>- <Property name='file' type='file' key='file'>- Audio file.- Supported formats: `['mp3', 'mp4', 'mpeg', 'mpga', 'm4a', 'wav', 'webm']`- File size limit: 15MB- </Property>- <Property name='user' type='string' key='user'>- User identifier, defined by the developer's rules, must be unique within the application.- </Property>- </Properties>-- ### Response- - `text` (string) Output text-- </Col>- <Col sticky>-- <CodeGroup- title="Request"- tag="POST"- label="/audio-to-text"- targetCode={`curl -X POST '${props.appDetail.api_base_url}/audio-to-text' \\---header 'Authorization: Bearer {api_key}' \\---form 'file=@localfile;type=audio/[mp3|mp4|mpeg|mpga|m4a|wav|webm]'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "text": ""- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/text-to-audio'- method='POST'- title='Text to Audio'- name='#text-to-audio'-/>-<Row>- <Col>- Text to speech.-- ### Request Body-- <Properties>- <Property name='message_id' type='str' key='message_id'>- For text messages generated by Dify, simply pass the generated message-id directly. The backend will use the message-id to look up the corresponding content and synthesize the voice information directly. If both message_id and text are provided simultaneously, the message_id is given priority.- </Property>- <Property name='text' type='str' key='text'>- Speech generated content。- </Property>- <Property name='user' type='string' key='user'>- The user identifier, defined by the developer, must ensure uniqueness within the app.- </Property>- </Properties>- </Col>- <Col sticky>-- <CodeGroup- title="Request"- tag="POST"- label="/text-to-audio"- targetCode={`curl -o text-to-audio.mp3 -X POST '${props.appDetail.api_base_url}/text-to-audio' \\---header 'Authorization: Bearer {api_key}' \\---header 'Content-Type: application/json' \\---data-raw '{- "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290",- "text": "Hello Dify",- "user": "abc-123",-}'`}- />-- <CodeGroup title="headers">- ```json {{ title: 'headers' }}- {- "Content-Type": "audio/wav"- }- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/info'- method='GET'- title='Get Application Basic Information'- name='#info'-/>-<Row>- <Col>- Used to get basic information about this application-- ### Response- - `name` (string) application name- - `description` (string) application description- - `tags` (array[string]) application tags- - `mode` (string) application mode- - `author_name` (string) application author name- </Col>- <Col>- <CodeGroup- title="Request"- tag="GET"- label="/info"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/info' \\--H 'Authorization: Bearer {api_key}'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "name": "My App",- "description": "This is my app.",- "tags": [- "tag1",- "tag2"- ],- "mode": "advanced-chat",- "author_name": "Dify"- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/parameters'- method='GET'- title='Get Application Parameters Information'- name='#parameters'-/>-<Row>- <Col>- Used at the start of entering the page to obtain information such as features, input parameter names, types, and default values.-- ### Response- - `opening_statement` (string) Opening statement- - `suggested_questions` (array[string]) List of suggested questions for the opening- - `suggested_questions_after_answer` (object) Suggest questions after enabling the answer.- - `enabled` (bool) Whether it is enabled- - `speech_to_text` (object) Speech to text- - `enabled` (bool) Whether it is enabled- - `text_to_speech` (object) Text to speech- - `enabled` (bool) Whether it is enabled- - `voice` (string) Voice type- - `language` (string) Language- - `autoPlay` (string) Auto play- - `enabled` Enabled- - `disabled` Disabled- - `retriever_resource` (object) Citation and Attribution- - `enabled` (bool) Whether it is enabled- - `annotation_reply` (object) Annotation reply- - `enabled` (bool) Whether it is enabled- - `user_input_form` (array[object]) User input form configuration- - `text-input` (object) Text input control- - `label` (string) Variable display label name- - `variable` (string) Variable ID- - `required` (bool) Whether it is required- - `default` (string) Default value- - `paragraph` (object) Paragraph text input control- - `label` (string) Variable display label name- - `variable` (string) Variable ID- - `required` (bool) Whether it is required- - `default` (string) Default value- - `select` (object) Dropdown control- - `label` (string) Variable display label name- - `variable` (string) Variable ID- - `required` (bool) Whether it is required- - `default` (string) Default value- - `options` (array[string]) Option values- - `file_upload` (object) File upload configuration- - `document` (object) Document settings- Currently only supports document types: `txt`, `md`, `markdown`, `pdf`, `html`, `xlsx`, `xls`, `docx`, `csv`, `eml`, `msg`, `pptx`, `ppt`, `xml`, `epub`.- - `enabled` (bool) Whether it is enabled- - `number_limits` (int) Document number limit, default is 3- - `transfer_methods` (array[string]) List of transfer methods: `remote_url`, `local_file`. Must choose one.- - `image` (object) Image settings- Currently only supports image types: `png`, `jpg`, `jpeg`, `webp`, `gif`.- - `enabled` (bool) Whether it is enabled- - `number_limits` (int) Image number limit, default is 3- - `transfer_methods` (array[string]) List of transfer methods: `remote_url`, `local_file`. Must choose one.- - `audio` (object) Audio settings- Currently only supports audio types: `mp3`, `m4a`, `wav`, `webm`, `amr`.- - `enabled` (bool) Whether it is enabled- - `number_limits` (int) Audio number limit, default is 3- - `transfer_methods` (array[string]) List of transfer methods: `remote_url`, `local_file`. Must choose one.- - `video` (object) Video settings- Currently only supports video types: `mp4`, `mov`, `mpeg`, `mpga`.- - `enabled` (bool) Whether it is enabled- - `number_limits` (int) Video number limit, default is 3- - `transfer_methods` (array[string]) List of transfer methods: `remote_url`, `local_file`. Must choose one.- - `custom` (object) Custom settings- - `enabled` (bool) Whether it is enabled- - `number_limits` (int) Custom number limit, default is 3- - `transfer_methods` (array[string]) List of transfer methods: `remote_url`, `local_file`. Must choose one.- - `system_parameters` (object) System parameters- - `file_size_limit` (int) Document upload size limit (MB)- - `image_file_size_limit` (int) Image file upload size limit (MB)- - `audio_file_size_limit` (int) Audio file upload size limit (MB)- - `video_file_size_limit` (int) Video file upload size limit (MB)-- </Col>- <Col sticky>-- <CodeGroup- title="Request"- tag="GET"- label="/parameters"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/parameters'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "opening_statement": "Hello!",- "suggested_questions_after_answer": {- "enabled": true- },- "speech_to_text": {- "enabled": true- },- "text_to_speech": {- "enabled": true,- "voice": "sambert-zhinan-v1",- "language": "zh-Hans",- "autoPlay": "disabled"- },- "retriever_resource": {- "enabled": true- },- "annotation_reply": {- "enabled": true- },- "user_input_form": [- {- "paragraph": {- "label": "Query",- "variable": "query",- "required": true,- "default": ""- }- }- ],- "file_upload": {- "image": {- "enabled": false,- "number_limits": 3,- "detail": "high",- "transfer_methods": [- "remote_url",- "local_file"- ]- }- },- "system_parameters": {- "file_size_limit": 15,- "image_file_size_limit": 10,- "audio_file_size_limit": 50,- "video_file_size_limit": 100- }- }- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/meta'- method='GET'- title='Get Application Meta Information'- name='#meta'-/>-<Row>- <Col>- Used to get icons of tools in this application-- ### Response- - `tool_icons`(object[string]) tool icons- - `tool_name` (string)- - `icon` (object|string)- - (object) icon object- - `background` (string) background color in hex format- - `content`(string) emoji- - (string) url of icon- </Col>- <Col>- <CodeGroup- title="Request"- tag="GET"- label="/meta"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/meta' \\--H 'Authorization: Bearer {api_key}'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "tool_icons": {- "dalle2": "https://cloud.dify.ai/console/api/workspaces/current/tool-provider/builtin/dalle/icon",- "api_tool": {- "background": "#252525",- "content": "\ud83d\ude01"- }- }- }- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/site'- method='GET'- title='Get Application WebApp Settings'- name='#site'-/>-<Row>- <Col>- Used to get the WebApp settings of the application.- ### Response- - `title` (string) WebApp name- - `chat_color_theme` (string) Chat color theme, in hex format- - `chat_color_theme_inverted` (bool) Whether the chat color theme is inverted- - `icon_type` (string) Icon type, `emoji` - emoji, `image` - picture- - `icon` (string) Icon. If it's `emoji` type, it's an emoji symbol; if it's `image` type, it's an image URL- - `icon_background` (string) Background color in hex format- - `icon_url` (string) Icon URL- - `description` (string) Description- - `copyright` (string) Copyright information- - `privacy_policy` (string) Privacy policy link- - `custom_disclaimer` (string) Custom disclaimer- - `default_language` (string) Default language- - `show_workflow_steps` (bool) Whether to show workflow details- - `use_icon_as_answer_icon` (bool) Whether to replace 🤖 in chat with the WebApp icon- </Col>- <Col>- <CodeGroup- title="Request"- tag="GET"- label="/site"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/site' \\--H 'Authorization: Bearer {api_key}'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "title": "My App",- "chat_color_theme": "#ff4a4a",- "chat_color_theme_inverted": false,- "icon_type": "emoji",- "icon": "😄",- "icon_background": "#FFEAD5",- "icon_url": null,- "description": "This is my app.",- "copyright": "all rights reserved",- "privacy_policy": "",- "custom_disclaimer": "All generated by AI",- "default_language": "en-US",- "show_workflow_steps": false,- "use_icon_as_answer_icon": false,- }- ```- </CodeGroup>- </Col>-</Row>-___--<Heading- url='/apps/annotations'- method='GET'- title='Get Annotation List'- name='#annotation_list'-/>-<Row>- <Col>- ### Query- <Properties>- <Property name='page' type='string' key='page'>- Page number- </Property>- <Property name='limit' type='string' key='limit'>- Number of items returned, default 20, range 1-100- </Property>- </Properties>- </Col>- <Col sticky>- <CodeGroup- title="Request"- tag="GET"- label="/apps/annotations"- targetCode={`curl --location --request GET '${props.appDetail.api_base_url}/apps/annotations?page=1&limit=20' \\---header 'Authorization: Bearer {api_key}'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "data": [- {- "id": "69d48372-ad81-4c75-9c46-2ce197b4d402",- "question": "What is your name?",- "answer": "I am Dify.",- "hit_count": 0,- "created_at": 1735625869- }- ],- "has_more": false,- "limit": 20,- "total": 1,- "page": 1- }- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/apps/annotations'- method='POST'- title='Create Annotation'- name='#create_annotation'-/>-<Row>- <Col>- ### Query- <Properties>- <Property name='question' type='string' key='question'>- Question- </Property>- <Property name='answer' type='string' key='answer'>- Answer- </Property>- </Properties>- </Col>- <Col sticky>- <CodeGroup- title="Request"- tag="POST"- label="/apps/annotations"- targetCode={`curl --location --request POST '${props.appDetail.api_base_url}/apps/annotations' \\---header 'Authorization: Bearer {api_key}' \\---header 'Content-Type: application/json' \\---data-raw '{- "question": "What is your name?",- "answer": "I am Dify."-}'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "id": "69d48372-ad81-4c75-9c46-2ce197b4d402",- "question": "What is your name?",- "answer": "I am Dify.",- "hit_count": 0,- "created_at": 1735625869- }- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/apps/annotations/{annotation_id}'- method='PUT'- title='Update Annotation'- name='#update_annotation'-/>-<Row>- <Col>- ### Query- <Properties>- <Property name='annotation_id' type='string' key='annotation_id'>- Annotation ID- </Property>- <Property name='question' type='string' key='question'>- Question- </Property>- <Property name='answer' type='string' key='answer'>- Answer- </Property>- </Properties>- </Col>- <Col sticky>- <CodeGroup- title="Request"- tag="PUT"- label="/apps/annotations/{annotation_id}"- targetCode={`curl --location --request PUT '${props.appDetail.api_base_url}/apps/annotations/{annotation_id}' \\---header 'Authorization: Bearer {api_key}' \\---header 'Content-Type: application/json' \\---data-raw '{- "question": "What is your name?",- "answer": "I am Dify."-}'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "id": "69d48372-ad81-4c75-9c46-2ce197b4d402",- "question": "What is your name?",- "answer": "I am Dify.",- "hit_count": 0,- "created_at": 1735625869- }- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/apps/annotations/{annotation_id}'- method='DELETE'- title='Delete Annotation'- name='#delete_annotation'-/>-<Row>- <Col>- ### Query- <Properties>- <Property name='annotation_id' type='string' key='annotation_id'>- Annotation ID- </Property>- </Properties>- </Col>- <Col sticky>- <CodeGroup- title="Request"- tag="DELETE"- label="/apps/annotations/{annotation_id}"- targetCode={`curl --location --request DELETE '${props.appDetail.api_base_url}/apps/annotations/{annotation_id}' \\---header 'Authorization: Bearer {api_key}' \\---header 'Content-Type: application/json'`}- />-- <CodeGroup title="Response">- ```text {{ title: 'Response' }}- 204 No Content- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/apps/annotation-reply/{action}'- method='POST'- title='Initial Annotation Reply Settings'- name='#initial_annotation_reply_settings'-/>-<Row>- <Col>- ### Query- <Properties>- <Property name='action' type='string' key='action'>- Action, can only be 'enable' or 'disable'- </Property>- <Property name='embedding_provider_name' type='string' key='embedding_provider_name'>- Specified embedding model provider, must be set up in the system first, corresponding to the provider field(Optional)- </Property>- <Property name='embedding_model_name' type='string' key='embedding_model_name'>- Specified embedding model, corresponding to the model field(Optional)- </Property>- <Property name='score_threshold' type='number' key='score_threshold'>- The similarity threshold for matching annotated replies. Only annotations with scores above this threshold will be recalled.- </Property>- </Properties>- </Col>- <Col sticky>- The provider and model name of the embedding model can be obtained through the following interface: v1/workspaces/current/models/model-types/text-embedding. For specific instructions, see: Maintain Knowledge Base via API. The Authorization used is the Dataset API Token.- <CodeGroup- title="Request"- tag="POST"- label="/apps/annotation-reply/{action}"- targetCode={`curl --location --request POST '${props.appDetail.api_base_url}/apps/annotation-reply/{action}' \\---header 'Authorization: Bearer {api_key}' \\---header 'Content-Type: application/json' \\---data-raw '{- "score_threshold": 0.9,- "embedding_provider_name": "zhipu",- "embedding_model_name": "embedding_3"-}'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "job_id": "b15c8f68-1cf4-4877-bf21-ed7cf2011802",- "job_status": "waiting"- }- ```- </CodeGroup>- This interface is executed asynchronously, so it will return a job_id. You can get the final execution result by querying the job status interface.- </Col>-</Row>------<Heading- url='/apps/annotation-reply/{action}/status/{job_id}'- method='GET'- title='Query Initial Annotation Reply Settings Task Status'- name='#initial_annotation_reply_settings_task_status'-/>-<Row>- <Col>- ### Query- <Properties>- <Property name='action' type='string' key='action'>- Action, can only be 'enable' or 'disable', must be the same as the action in the initial annotation reply settings interface- </Property>- <Property name='job_id' type='string' key='job_id'>- Job ID, obtained from the initial annotation reply settings interface- </Property>- </Properties>- </Col>- <Col sticky>- <CodeGroup- title="Request"- tag="GET"- label="/apps/annotations"- targetCode={`curl --location --request GET '${props.appDetail.api_base_url}/apps/annotation-reply/{action}/status/{job_id}' \\---header 'Authorization: Bearer {api_key}'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "job_id": "b15c8f68-1cf4-4877-bf21-ed7cf2011802",- "job_status": "waiting",- "error_msg": ""- }- ```- </CodeGroup>- </Col>-</Row>diff --git a/web/app/components/develop/template/template_advanced_chat.ja.mdx b/web/app/components/develop/template/template_advanced_chat.ja.mdxdeleted file mode 100644index 5a722ef8380..00000000000--- a/web/app/components/develop/template/template_advanced_chat.ja.mdx+++ /dev/null@@ -1,2178 +0,0 @@-import { CodeGroup } from '../code.tsx'-import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx'-import { WorkflowVersionApiUpgradeNotice } from '../workflow-version-api-upgrade-notice.tsx'--# 高度なチャットアプリ API--チャットアプリケーションはセッションの持続性をサポートしており、以前のチャット履歴を応答のコンテキストとして使用できます。これは、チャットボットやカスタマーサービス AI などに適用できます。--<div>- ### ベース URL- <CodeGroup title="コード" targetCode={props.appDetail.api_base_url} />-- ### 認証-- サービス API は `API-Key` 認証を使用します。- <i>**API キーはサーバー側に保存し、クライアント側で共有または保存しないことを強くお勧めします。API キーの漏洩は深刻な結果を招く可能性があります。**</i>-- すべての API リクエストには、以下のように `Authorization`HTTP ヘッダーに API キーを含めてください:-- <CodeGroup title="コード" targetCode='Authorization: Bearer {API_KEY}' />-</div>-------<Heading- url='/chat-messages'- method='POST'- title='チャットメッセージを送信'- name='#Send-Chat-Message'-/>-<Row>- <Col>- チャットアプリケーションにリクエストを送信します。-- ### リクエストボディ-- <Properties>- <Property name='query' type='string' key='query'>- ユーザー入力/質問内容- </Property>- <Property name='inputs' type='object' key='inputs'>- アプリによって定義されたさまざまな変数値の入力を許可します。- `inputs`パラメータには複数のキー/値ペアが含まれ、各キーは特定の変数に対応し、各値はその変数の特定の値です。- 変数がファイルタイプの場合、以下の`files`で説明されているキーを持つオブジェクトを指定します。- デフォルト`{}`- </Property>- <Property name='response_mode' type='string' key='response_mode'>- 応答の返却モードを指定します。サポートされているモード:- - `streaming` ストリーミングモード(推奨)、SSE([サーバー送信イベント](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events))を通じてタイプライターのような出力を実装します。- - `blocking` ブロッキングモード、実行完了後に結果を返します。(プロセスが長い場合、リクエストが中断される可能性があります)- Cloudflareの制限により、リクエストは100秒後に返答なしで中断されます。- </Property>- <Property name='user' type='string' key='user'>- ユーザー識別子、エンドユーザーの身元を定義するために使用され、統計のために使用されます。- アプリケーション内で開発者によって一意に定義されるべきです。サービス API は WebApp によって作成された会話を共有しません。- </Property>- <Property name='conversation_id' type='string' key='conversation_id'>- 会話ID、以前のチャット記録に基づいて会話を続けるには、以前のメッセージのconversation_idを渡す必要があります。- </Property>- <Property name='files' type='array[object]' key='files'>- ファイルリスト、モデルが Vision/Video 機能をサポートしている場合に限り、ファイルをテキスト理解および質問応答に組み合わせて入力するのに適しています。- - `type` (string) サポートされるタイプ:- - `document` サポートされるタイプには以下が含まれます:'TXT', 'MD', 'MARKDOWN', 'MDX', 'PDF', 'HTML', 'XLSX', 'XLS', 'VTT', 'PROPERTIES', 'DOC', 'DOCX', 'CSV', 'EML', 'MSG', 'PPTX', 'PPT', 'XML', 'EPUB'- - `image` サポートされるタイプには以下が含まれます:'JPG', 'JPEG', 'PNG', 'GIF', 'WEBP', 'SVG'- - `audio` サポートされるタイプには以下が含まれます:'MP3', 'M4A', 'WAV', 'WEBM', 'MPGA'- - `video` サポートされるタイプには以下が含まれます:'MP4', 'MOV', 'MPEG', 'WEBM'- - `custom` サポートされるタイプには以下が含まれます:その他のファイルタイプ- - `transfer_method` (string) 転送方法:- - `remote_url`: ファイルのURL。- - `local_file`: ファイルをアップロード。- - `url` ファイルのURL。(転送方法が `remote_url` の場合のみ)。- - `upload_file_id` アップロードされたファイルID。(転送方法が `local_file` の場合のみ)。- </Property>- <Property name='auto_generate_name' type='bool' key='auto_generate_name'>- タイトルを自動生成、デフォルトは`true`。- `false`に設定すると、会話のリネームAPIを呼び出し、`auto_generate`を`true`に設定することで非同期タイトル生成を実現できます。- </Property>- <Property name='workflow_id' type='string' key='workflow_id' nameAction={<WorkflowVersionApiUpgradeNotice />}>- (オプション)ワークフローID、特定のバージョンを指定するために使用、提供されない場合はデフォルトの公開バージョンを使用。- </Property>- <Property name='trace_id' type='string' key='trace_id'>- (オプション)トレースID。既存の業務システムのトレースコンポーネントと連携し、エンドツーエンドの分散トレーシングを実現するために使用します。指定がない場合、システムが自動的に trace_id を生成します。以下の3つの方法で渡すことができ、優先順位は次のとおりです:<br/>- - Header:HTTPヘッダー <code>X-Trace-Id</code> で渡す(最優先)。<br/>- - クエリパラメータ:URLクエリパラメータ <code>trace_id</code> で渡す。<br/>- - リクエストボディ:リクエストボディの <code>trace_id</code> フィールドで渡す(本フィールド)。<br/>- </Property>- <Property name='trace_session_id' type='string' key='trace_session_id'>- (オプション)可観測性のグルーピングに使用するトレースセッションID。セッションのグルーピングに対応するトレースプロバイダーは、この値をエクスポートされるセッション識別子として使用できます。conversation_id、workflow_run_id、trace_id、または span の関係は変更しません。以下の3つの方法で渡すことができ、優先順位は次のとおりです:<br/>- - Header:HTTPヘッダー <code>X-Trace-Session-Id</code> で渡す(最優先)。<br/>- - クエリパラメータ:URLクエリパラメータ <code>trace_session_id</code> で渡す。<br/>- - リクエストボディ:リクエストボディの <code>trace_session_id</code> フィールドで渡す(本フィールド)。<br/>- </Property>- </Properties>-- ### 応答- response_modeがブロッキングの場合、CompletionResponseオブジェクトを返します。- response_modeがストリーミングの場合、ChunkCompletionResponseストリームを返します。-- ### ChatCompletionResponse- 完全なアプリ結果を返します。`Content-Type`は`application/json`です。- - `event` (string) イベントタイプ、固定で `message`- - `task_id` (string) タスクID、リクエスト追跡と以下のStop Generate APIに使用- - `id` (string) ユニークID- - `message_id` (string) 一意のメッセージID- - `conversation_id` (string) 会話ID- - `mode` (string) アプリモード、`chat`として固定- - `answer` (string) 完全な応答内容- - `metadata` (object) メタデータ- - `usage` (Usage) モデル使用情報- - `retriever_resources` (array[RetrieverResource]) 引用と帰属リスト- - `created_at` (int) メッセージ作成タイムスタンプ、例:1705395332-- ### ChunkChatCompletionResponse- アプリによって出力されたストリームチャンクを返します。`Content-Type`は`text/event-stream`です。- 各ストリーミングチャンクは`data:`で始まり、2つの改行文字`\n\n`で区切られます。以下のように表示されます:- <CodeGroup>- ```streaming {{ title: '応答' }}- data: {"event": "message", "task_id": "900bbd43-dc0b-4383-a372-aa6e6c414227", "id": "663c5084-a254-4040-8ad3-51f2a3c1a77c", "answer": "Hi", "created_at": 1705398420}\n\n- ```- </CodeGroup>- ストリーミングチャンクの構造は`event`に応じて異なります:- - `event: message` LLMがテキストチャンクイベントを返します。つまり、完全なテキストがチャンク形式で出力されます。- - `task_id` (string) タスクID、リクエスト追跡と以下のStop Generate APIに使用- - `message_id` (string) 一意のメッセージID- - `conversation_id` (string) 会話ID- - `answer` (string) LLMが返したテキストチャンク内容- - `created_at` (int) 作成タイムスタンプ、例:1705395332- - `event: message_file` メッセージファイルイベント、ツールによって新しいファイルが作成されました- - `id` (string) ファイル一意ID- - `type` (string) ファイルタイプ、現在は"image"のみ許可- - `belongs_to` (string) 所属、ここでは'assistant'のみ- - `url` (string) ファイルのリモートURL- - `conversation_id` (string) 会話ID- - `event: message_end` メッセージ終了イベント、このイベントを受信するとストリーミングが終了したことを意味します。- - `task_id` (string) タスクID、リクエスト追跡と以下のStop Generate APIに使用- - `message_id` (string) 一意のメッセージID- - `conversation_id` (string) 会話ID- - `metadata` (object) メタデータ- - `usage` (Usage) モデル使用情報- - `retriever_resources` (array[RetrieverResource]) 引用と帰属リスト- - `event: tts_message` TTSオーディオストリームイベント、つまり音声合成出力。内容はMp3形式のオーディオブロックで、base64文字列としてエンコードされています。再生時には、base64をデコードしてプレーヤーに入力するだけです。(このメッセージは自動再生が有効な場合にのみ利用可能)- - `task_id` (string) タスクID、リクエスト追跡と以下のストップ応答インターフェースに使用- - `message_id` (string) 一意のメッセージID- - `audio` (string) 音声合成後のオーディオ、base64テキストコンテンツとしてエンコードされており、再生時にはbase64をデコードしてプレーヤーに入力するだけです- - `created_at` (int) 作成タイムスタンプ、例:1705395332- - `event: tts_message_end` TTSオーディオストリーム終了イベント、このイベントを受信するとオーディオストリームが終了したことを示します。- - `task_id` (string) タスクID、リクエスト追跡と以下のストップ応答インターフェースに使用- - `message_id` (string) 一意のメッセージID- - `audio` (string) 終了イベントにはオーディオがないため、これは空の文字列です- - `created_at` (int) 作成タイムスタンプ、例:1705395332- - `event: message_replace` メッセージ内容置換イベント。- 出力内容のモデレーションが有効な場合、内容がフラグ付けされると、このイベントを通じてメッセージ内容がプリセットの返信に置き換えられます。- - `task_id` (string) タスクID、リクエスト追跡と以下のStop Generate APIに使用- - `message_id` (string) 一意のメッセージID- - `conversation_id` (string) 会話ID- - `answer` (string) 置換内容(すべてのLLM返信テキストを直接置き換えます)- - `created_at` (int) 作成タイムスタンプ、例:1705395332- - `event: workflow_started` ワークフローが実行を開始- - `task_id` (string) タスクID、リクエスト追跡と以下のStop Generate APIに使用- - `workflow_run_id` (string) ワークフロー実行の一意ID- - `event` (string) `workflow_started`に固定- - `data` (object) 詳細- - `id` (string) ワークフロー実行の一意ID- - `workflow_id` (string) 関連ワークフローのID- - `created_at` (timestamp) 作成タイムスタンプ、例:1705395332- - `event: node_started` ノード実行が開始- - `task_id` (string) タスクID、リクエスト追跡と以下のStop Generate APIに使用- - `workflow_run_id` (string) ワークフロー実行の一意ID- - `event` (string) `node_started`に固定- - `data` (object) 詳細- - `id` (string) ワークフロー実行の一意ID- - `node_id` (string) ノードのID- - `node_type` (string) ノードのタイプ- - `title` (string) ノードの名前- - `index` (int) 実行シーケンス番号、トレースノードシーケンスを表示するために使用- - `predecessor_node_id` (string) オプションのプレフィックスノードID、キャンバス表示実行パスに使用- - `inputs` (object) ノードで使用されるすべての前のノード変数の内容- - `created_at` (timestamp) 開始のタイムスタンプ、例:1705395332- - `event: node_finished` ノード実行が終了、成功または失敗は同じイベント内で異なる状態で示されます- - `task_id` (string) タスクID、リクエスト追跡と以下のStop Generate APIに使用- - `workflow_run_id` (string) ワークフロー実行の一意ID- - `event` (string) `node_finished`に固定- - `data` (object) 詳細- - `id` (string) ワークフロー実行の一意ID- - `node_id` (string) ノードのID- - `node_type` (string) ノードのタイプ- - `title` (string) ノードの名前- - `index` (int) 実行シーケンス番号、トレースノードシーケンスを表示するために使用- - `predecessor_node_id` (string) オプションのプレフィックスノードID、キャンバス表示実行パスに使用- - `inputs` (object) ノードで使用されるすべての前のノード変数の内容- - `process_data` (json) オプションのノードプロセスデータ- - `outputs` (json) オプションの出力内容- - `status` (string) 実行の状態、`running` / `succeeded` / `failed` / `stopped`- - `error` (string) オプションのエラー理由- - `elapsed_time` (float) オプションの使用される合計秒数- - `execution_metadata` (json) メタデータ- - `total_tokens` (int) オプションの使用されるトークン数- - `total_price` (decimal) オプションの合計コスト- - `currency` (string) オプション、例:`USD` / `RMB`- - `created_at` (timestamp) 開始のタイムスタンプ、例:1705395332- - `event: human_input_required` ワークフローが一時停止し、Human-in-the-Loop 入力が必要- - `task_id` (string) タスク ID、リクエスト追跡に使用- - `workflow_run_id` (string) ワークフロー実行の一意 ID- - `event` (string) `human_input_required`に固定- - `data` (object) 詳細- - `form_id` (string) ヒューマン入力フォーム ID- - `node_id` (string) Human Input ノード ID- - `node_title` (string) Human Input ノードタイトル- - `form_content` (string) レンダリング済みフォーム内容- - `inputs` (array[object]) フォーム入力項目の定義- - `actions` (array[object]) ユーザーが選択できるアクションボタン- - `id` (string) アクション ID- - `title` (string) ボタンラベル- - `button_style` (string) ボタンスタイル- - `display_in_ui` (bool) UI にこのフォームを表示するかどうか- - `form_token` (string) `/form/human_input/:form_token` API で使用するトークン- - `resolved_default_values` (object) 実行時に解決されたデフォルト値- - `expiration_time` (timestamp) フォームの有効期限(Unix 秒)- - `event: workflow_finished` ワークフロー実行が終了、成功または失敗は同じイベント内で異なる状態で示されます- - `task_id` (string) タスクID、リクエスト追跡と以下のStop Generate APIに使用- - `workflow_run_id` (string) ワークフロー実行の一意ID- - `event` (string) `workflow_finished`に固定- - `data` (object) 詳細- - `id` (string) ワークフロー実行のID- - `workflow_id` (string) 関連ワークフローのID- - `status` (string) 実行の状態、`running` / `succeeded` / `failed` / `stopped`- - `outputs` (json) オプションの出力内容- - `error` (string) オプションのエラー理由- - `elapsed_time` (float) オプションの使用される合計秒数- - `total_tokens` (int) オプションの使用されるトークン数- - `total_steps` (int) デフォルト0- - `created_at` (timestamp) 開始時間- - `finished_at` (timestamp) 終了時間- - `event: error`- ストリーミングプロセス中に発生する例外はストリームイベントの形式で出力され、エラーイベントを受信するとストリームが終了します。- - `task_id` (string) タスクID、リクエスト追跡と以下のStop Generate APIに使用- - `message_id` (string) 一意のメッセージID- - `status` (int) HTTPステータスコード- - `code` (string) エラーコード- - `message` (string) エラーメッセージ- - `event: ping` 接続を維持するために10秒ごとにpingイベントが発生します。-- ### エラー- - 404, 会話が存在しません- - 400, `invalid_param`, 異常なパラメータ入力- - 400, `app_unavailable`, アプリ構成が利用できません- - 400, `provider_not_initialize`, 利用可能なモデル資格情報構成がありません- - 400, `provider_quota_exceeded`, モデル呼び出しクォータが不足しています- - 400, `model_currently_not_support`, 現在のモデルが利用できません- - 400, `workflow_not_found`, 指定されたワークフローバージョンが見つかりません- - 400, `draft_workflow_error`, ドラフトワークフローバージョンは使用できません- - 400, `workflow_id_format_error`, ワークフローID形式エラー、UUID形式が必要です- - 400, `completion_request_error`, テキスト生成に失敗しました- - 403, `workflow_version_execution_not_allowed`, 現在のプランではワークフローバージョンを実行できません。有料プランにアップグレードしてください- - 500, 内部サーバーエラー-- </Col>- <Col sticky>-- <CodeGroup- title="リクエスト"- tag="POST"- label="/chat-messages"- targetCode={`curl -X POST '${props.appDetail.api_base_url}/chat-messages' \\---header 'Authorization: Bearer {api_key}' \\---header 'Content-Type: application/json' \\---data-raw '{- "inputs": ${JSON.stringify(props.inputs)},- "query": "What are the specs of the iPhone 13 Pro Max?",- "response_mode": "streaming",- "conversation_id": "",- "user": "abc-123",- "files": [- {- "type": "image",- "transfer_method": "remote_url",- "url": "https://cloud.dify.ai/logo/logo-site.png"- }- ]-}'`}- />- ### ブロッキングモード- ブロッキングモードでは、通常のチャット応答、または一時停止したワークフロー応答のいずれかが返されます。-- Advanced Chat が Human-in-the-Loop で一時停止すると、`event` は `workflow_paused` になります。- それでもペイロードには `message_id`、`conversation_id`、`answer`、`workflow_run_id` が含まれ、`data` には `paused_nodes` と `reasons` が追加されます。- `human_input_required` の各 reason には `form_id` と `expiration_time` が含まれます。-- <CodeGroup title="応答">- ```json {{ title: '応答' }}- {- "event": "message",- "task_id": "c3800678-a077-43df-a102-53f23ed20b88",- "id": "9da23599-e713-473b-982c-4328d4f5c78a",- "message_id": "9da23599-e713-473b-982c-4328d4f5c78a",- "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2",- "mode": "chat",- "answer": "iPhone 13 Pro Maxの仕様は次のとおりです:...",- "metadata": {- "usage": {- "prompt_tokens": 1033,- "prompt_unit_price": "0.001",- "prompt_price_unit": "0.001",- "prompt_price": "0.0010330",- "completion_tokens": 128,- "completion_unit_price": "0.002",- "completion_price_unit": "0.001",- "completion_price": "0.0002560",- "total_tokens": 1161,- "total_price": "0.0012890",- "currency": "USD",- "latency": 0.7682376249867957- },- "retriever_resources": [- {- "position": 1,- "dataset_id": "101b4c97-fc2e-463c-90b1-5261a4cdcafb",- "dataset_name": "iPhone",- "document_id": "8dd1ad74-0b5f-4175-b735-7d98bbbb4e00",- "document_name": "iPhone List",- "segment_id": "ed599c7f-2766-4294-9d1d-e5235a61270a",- "score": 0.98457545,- "content": "\"Model\",\"Release Date\",\"Display Size\",\"Resolution\",\"Processor\",\"RAM\",\"Storage\",\"Camera\",\"Battery\",\"Operating System\"\n\"iPhone 13 Pro Max\",\"September 24, 2021\",\"6.7 inch\",\"1284 x 2778\",\"Hexa-core (2x3.23 GHz Avalanche + 4x1.82 GHz Blizzard)\",\"6 GB\",\"128, 256, 512 GB, 1TB\",\"12 MP\",\"4352 mAh\",\"iOS 15\""- }- ]- },- "created_at": 1705407629- }- ```- </CodeGroup>- <CodeGroup title="一時停止レスポンス例">- ```json {{ title: '一時停止レスポンス例' }}- {- "event": "workflow_paused",- "task_id": "8a9cbfcf-e7e0-4b17-aeef-24de57a2659a",- "id": "31714374-88cb-485f-9fa4-e3ab2a9ed95e",- "message_id": "31714374-88cb-485f-9fa4-e3ab2a9ed95e",- "conversation_id": "098e19be-356a-435d-9ec3-a406f4f1a97a",- "mode": "advanced-chat",- "answer": "",- "metadata": {- "annotation_reply": null,- "retriever_resources": [],- "usage": null- },- "created_at": 1776074715,- "workflow_run_id": "7a4d6509-8a65-4c7d-a4fd-cf081dcf169f",- "data": {- "id": "31714374-88cb-485f-9fa4-e3ab2a9ed95e",- "mode": "advanced-chat",- "conversation_id": "098e19be-356a-435d-9ec3-a406f4f1a97a",- "message_id": "31714374-88cb-485f-9fa4-e3ab2a9ed95e",- "workflow_run_id": "7a4d6509-8a65-4c7d-a4fd-cf081dcf169f",- "answer": "",- "metadata": {- "annotation_reply": null,- "retriever_resources": [],- "usage": null- },- "created_at": 1776074715,- "paused_nodes": [- "1775724080699"- ],- "reasons": [- {- "form_id": "019d864d-6f55-752c-9f4c-feee67508d5b",- "form_content": "this is form 2:\n\n{{#$output.some_field_2#}}\n",- "inputs": [- {- "type": "paragraph",- "output_variable_name": "some_field_2",- "default": {- "type": "constant",- "selector": [],- "value": ""- }- }- ],- "actions": [- {- "id": "approve",- "title": "yes",- "button_style": "default"- },- {- "id": "reject",- "title": "no",- "button_style": "default"- }- ],- "display_in_ui": true,- "node_id": "1775724080699",- "node_title": "Human Input 2",- "resolved_default_values": {},- "form_token": "0dvwTdpTFXgCZmAo2FoiJ5",- "type": "human_input_required",- "expiration_time": 1776333914- }- ],- "status": "paused",- "elapsed_time": 0.034081,- "total_tokens": 0,- "total_steps": 2- }- }- ```- </CodeGroup>- ### ストリーミングモード- <CodeGroup title="応答">- ```streaming {{ title: '応答' }}- data: {"event": "workflow_started", "task_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "workflow_run_id": "5ad498-f0c7-4085-b384-88cbe6290", "data": {"id": "5ad498-f0c7-4085-b384-88cbe6290", "workflow_id": "dfjasklfjdslag", "created_at": 1679586595}}- data: {"event": "node_started", "task_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "workflow_run_id": "5ad498-f0c7-4085-b384-88cbe6290", "data": {"id": "5ad498-f0c7-4085-b384-88cbe6290", "node_id": "dfjasklfjdslag", "node_type": "start", "title": "Start", "index": 0, "predecessor_node_id": "fdljewklfklgejlglsd", "inputs": {}, "created_at": 1679586595}}- data: {"event": "node_finished", "task_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "workflow_run_id": "5ad498-f0c7-4085-b384-88cbe6290", "data": {"id": "5ad498-f0c7-4085-b384-88cbe6290", "node_id": "dfjasklfjdslag", "node_type": "start", "title": "Start", "index": 0, "predecessor_node_id": "fdljewklfklgejlglsd", "inputs": {}, "outputs": {}, "status": "succeeded", "elapsed_time": 0.324, "execution_metadata": {"total_tokens": 63127864, "total_price": 2.378, "currency": "USD"}, "created_at": 1679586595}}- data: {"event": "workflow_finished", "task_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "workflow_run_id": "5ad498-f0c7-4085-b384-88cbe6290", "data": {"id": "5ad498-f0c7-4085-b384-88cbe6290", "workflow_id": "dfjasklfjdslag", "outputs": {}, "status": "succeeded", "elapsed_time": 0.324, "total_tokens": 63127864, "total_steps": "1", "created_at": 1679586595, "finished_at": 1679976595}}- data: {"event": "message", "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " I", "created_at": 1679586595}- data: {"event": "message", "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": "'m", "created_at": 1679586595}- data: {"event": "message", "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " glad", "created_at": 1679586595}- data: {"event": "message", "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " to", "created_at": 1679586595}- data: {"event": "message", "message_id" : "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " meet", "created_at": 1679586595}- data: {"event": "message", "message_id" : "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " you", "created_at": 1679586595}- data: {"event": "message_end", "id": "5e52ce04-874b-4d27-9045-b3bc80def685", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "metadata": {"usage": {"prompt_tokens": 1033, "prompt_unit_price": "0.001", "prompt_price_unit": "0.001", "prompt_price": "0.0010330", "completion_tokens": 135, "completion_unit_price": "0.002", "completion_price_unit": "0.001", "completion_price": "0.0002700", "total_tokens": 1168, "total_price": "0.0013030", "currency": "USD", "latency": 1.381760165997548}, "retriever_resources": [{"position": 1, "dataset_id": "101b4c97-fc2e-463c-90b1-5261a4cdcafb", "dataset_name": "iPhone", "document_id": "8dd1ad74-0b5f-4175-b735-7d98bbbb4e00", "document_name": "iPhone List", "segment_id": "ed599c7f-2766-4294-9d1d-e5235a61270a", "score": 0.98457545, "content": "\"Model\",\"Release Date\",\"Display Size\",\"Resolution\",\"Processor\",\"RAM\",\"Storage\",\"Camera\",\"Battery\",\"Operating System\"\n\"iPhone 13 Pro Max\",\"September 24, 2021\",\"6.7 inch\",\"1284 x 2778\",\"Hexa-core (2x3.23 GHz Avalanche + 4x1.82 GHz Blizzard)\",\"6 GB\",\"128, 256, 512 GB, 1TB\",\"12 MP\",\"4352 mAh\",\"iOS 15\""}]}}- data: {"event": "tts_message", "conversation_id": "23dd85f3-1a41-4ea0-b7a9-062734ccfaf9", "message_id": "a8bdc41c-13b2-4c18-bfd9-054b9803038c", "created_at": 1721205487, "task_id": "3bf8a0bb-e73b-4690-9e66-4e429bad8ee7", "audio": "qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq"}- data: {"event": "tts_message_end", "conversation_id": "23dd85f3-1a41-4ea0-b7a9-062734ccfaf9", "message_id": "a8bdc41c-13b2-4c18-bfd9-054b9803038c", "created_at": 1721205487, "task_id": "3bf8a0bb-e73b-4690-9e66-4e429bad8ee7", "audio": ""}- ```- </CodeGroup>- ストリーミングモードでも Human-in-the-Loop により一時停止する場合があります。その場合、SSE ストリームではまず `human_input_required` が送られ、その後に `workflow_paused` が送られます。-- <CodeGroup title="一時停止ストリーミングレスポンス例">- ```streaming {{ title: '一時停止ストリーミングレスポンス例' }}- event: ping-- data: {- "event": "workflow_started",- "workflow_run_id": "a4959eb4-c852-4e0c-ac7a-348233f7f345",- "task_id": "0399c5c2-181b-4493-a78e-1421914e8a25",- "data": {- "id": "a4959eb4-c852-4e0c-ac7a-348233f7f345",- "workflow_id": "e46514f1-c008-41ff-94b0-4f33d4b97d36",- "inputs": {- "sys.files": [],- "sys.user_id": "abc-123",- "sys.app_id": "d1074979-f67e-4114-8691-e35878df9a89",- "sys.workflow_id": "e46514f1-c008-41ff-94b0-4f33d4b97d36",- "sys.workflow_run_id": "a4959eb4-c852-4e0c-ac7a-348233f7f345"- },- "created_at": 1776129228,- "reason": "initial"- }- }-- data: {- "event": "node_started",- "workflow_run_id": "a4959eb4-c852-4e0c-ac7a-348233f7f345",- "task_id": "0399c5c2-181b-4493-a78e-1421914e8a25",- "data": {- "id": "7d9bb041-5ecb-497f-a674-d8706eed0ab1",- "node_id": "1775717266623",- "node_type": "start",- "title": "User Input",- "index": 1,- "predecessor_node_id": null,- "inputs": null,- "inputs_truncated": false,- "created_at": 1776129228,- "extras": {},- "iteration_id": null,- "loop_id": null,- "agent_strategy": null- }- }-- data: {- "event": "node_finished",- "workflow_run_id": "a4959eb4-c852-4e0c-ac7a-348233f7f345",- "task_id": "0399c5c2-181b-4493-a78e-1421914e8a25",- "data": {- "id": "7d9bb041-5ecb-497f-a674-d8706eed0ab1",- "node_id": "1775717266623",- "node_type": "start",- "title": "User Input",- "index": 1,- "predecessor_node_id": null,- "inputs": {- "sys.files": [],- "sys.user_id": "abc-123",- "sys.app_id": "d1074979-f67e-4114-8691-e35878df9a89",- "sys.workflow_id": "e46514f1-c008-41ff-94b0-4f33d4b97d36",- "sys.workflow_run_id": "a4959eb4-c852-4e0c-ac7a-348233f7f345",- "sys.timestamp": 1776129228- },- "inputs_truncated": false,- "process_data": {},- "process_data_truncated": false,- "outputs": {- "sys.files": [],- "sys.user_id": "abc-123",- "sys.app_id": "d1074979-f67e-4114-8691-e35878df9a89",- "sys.workflow_id": "e46514f1-c008-41ff-94b0-4f33d4b97d36",- "sys.workflow_run_id": "a4959eb4-c852-4e0c-ac7a-348233f7f345",- "sys.timestamp": 1776129228- },- "outputs_truncated": false,- "status": "succeeded",- "error": null,- "elapsed_time": 0.000097,- "execution_metadata": null,- "created_at": 1776129228,- "finished_at": 1776129228,- "files": [],- "iteration_id": null,- "loop_id": null- }- }-- data: {- "event": "node_started",- "workflow_run_id": "a4959eb4-c852-4e0c-ac7a-348233f7f345",- "task_id": "0399c5c2-181b-4493-a78e-1421914e8a25",- "data": {- "id": "c09ff568-1d55-4f0d-9a07-512bcbfeb289",- "node_id": "1775717346519",- "node_type": "human-input",- "title": "Human Input",- "index": 1,- "predecessor_node_id": null,- "inputs": null,- "inputs_truncated": false,- "created_at": 1776129228,- "extras": {},- "iteration_id": null,- "loop_id": null,- "agent_strategy": null- }- }-- data: {- "event": "human_input_required",- "workflow_run_id": "a4959eb4-c852-4e0c-ac7a-348233f7f345",- "task_id": "0399c5c2-181b-4493-a78e-1421914e8a25",- "data": {- "form_id": "019d898d-3d80-7105-b920-9899ead4ff3e",- "node_id": "1775717346519",- "node_title": "Human Input",- "form_content": "this is form 1:\n{{#$output.some_field#}}\n",- "inputs": [- {- "type": "paragraph",- "output_variable_name": "some_field",- "default": {- "type": "variable",- "selector": [- "sys",- "workflow_run_id"- ],- "value": ""- }- }- ],- "actions": [- {- "id": "approve",- "title": "YES",- "button_style": "default"- },- {- "id": "reject",- "title": "NO",- "button_style": "default"- }- ],- "display_in_ui": true,- "form_token": "0Tb1nXYe4hzQUD706nHB4y",- "resolved_default_values": {- "some_field": "a4959eb4-c852-4e0c-ac7a-348233f7f345"- },- "expiration_time": 1776388428- }- }-- data: {- "event": "workflow_paused",- "workflow_run_id": "a4959eb4-c852-4e0c-ac7a-348233f7f345",- "task_id": "0399c5c2-181b-4493-a78e-1421914e8a25",- "data": {- "workflow_run_id": "a4959eb4-c852-4e0c-ac7a-348233f7f345",- "paused_nodes": [- "1775717346519"- ],- "outputs": {},- "reasons": [- {- "form_id": "019d898d-3d80-7105-b920-9899ead4ff3e",- "form_content": "this is form 1:\n{{#$output.some_field#}}\n",- "inputs": [- {- "type": "paragraph",- "output_variable_name": "some_field",- "default": {- "type": "variable",- "selector": [- "sys",- "workflow_run_id"- ],- "value": ""- }- }- ],- "actions": [- {- "id": "approve",- "title": "YES",- "button_style": "default"- },- {- "id": "reject",- "title": "NO",- "button_style": "default"- }- ],- "display_in_ui": true,- "node_id": "1775717346519",- "node_title": "Human Input",- "resolved_default_values": {- "some_field": "a4959eb4-c852-4e0c-ac7a-348233f7f345"- },- "form_token": "0Tb1nXYe4hzQUD706nHB4y",- "type": "human_input_required",- "expiration_time": 1776388428- }- ],- "status": "paused",- "created_at": 1776129228,- "elapsed_time": 0.070478,- "total_tokens": 0,- "total_steps": 2- }- }- ```- </CodeGroup>-- </Col>-</Row>------<Heading- url='/files/upload'- method='POST'- title='ファイルアップロード'- name='#file-upload'-/>-<Row>- <Col>- メッセージ送信時に使用するファイルをアップロードし、画像とテキストのマルチモーダル理解を可能にします。- アプリケーションでサポートされている形式をサポートします。- アップロードされたファイルは現在のエンドユーザーのみが使用できます。-- ### リクエストボディ- このインターフェースは`multipart/form-data`リクエストを必要とします。- - `file` (File) 必須- アップロードするファイル。- - `user` (string) 必須- ユーザー識別子、開発者のルールによって定義され、アプリケーション内で一意でなければなりません。サービス API は WebApp によって作成された会話を共有しません。-- ### 応答- アップロードが成功すると、サーバーはファイルの ID と関連情報を返します。- - `id` (uuid) ID- - `name` (string) ファイル名- - `size` (int) ファイルサイズ(バイト)- - `extension` (string) ファイル拡張子- - `mime_type` (string) ファイルの MIME タイプ- - `created_by` (uuid) エンドユーザーID- - `created_at` (timestamp) 作成タイムスタンプ、例:1705395332-- ### エラー- - 400, `no_file_uploaded`, ファイルが提供されなければなりません- - 400, `too_many_files`, 現在は 1 つのファイルのみ受け付けます- - 400, `unsupported_preview`, ファイルはプレビューをサポートしていません- - 400, `unsupported_estimate`, ファイルは推定をサポートしていません- - 413, `file_too_large`, ファイルが大きすぎます- - 415, `unsupported_file_type`, サポートされていない拡張子、現在はドキュメントファイルのみ受け付けます- - 503, `s3_connection_failed`, S3 サービスに接続できません- - 503, `s3_permission_denied`, S3 にファイルをアップロードする権限がありません- - 503, `s3_file_too_large`, ファイルが S3 のサイズ制限を超えています- - 500, 内部サーバーエラー--- </Col>- <Col sticky>- ### リクエスト例-- <CodeGroup- title="リクエスト"- tag="POST"- label="/files/upload"- targetCode={`curl -X POST '${props.appDetail.api_base_url}/files/upload' \\---header 'Authorization: Bearer {api_key}' \\---form 'file=@localfile;type=image/[png|jpeg|jpg|webp|gif]' \\---form 'user=abc-123'`}- />-- ### 応答例- <CodeGroup title="応答">- ```json {{ title: '応答' }}- {- "id": "72fa9618-8f89-4a37-9b33-7e1178a24a67",- "name": "example.png",- "size": 1024,- "extension": "png",- "mime_type": "image/png",- "created_by": "6ad1ab0a-73ff-4ac1-b9e4-cdb312f71f13",- "created_at": 1577836800,- }- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/end-users/:end_user_id'- method='GET'- title='エンドユーザーを取得'- name='#end-user'-/>-<Row>- <Col>- エンドユーザー ID からエンドユーザー情報を取得します。-- 他の API がエンドユーザー ID(例:ファイルアップロードの `created_by`)を返す場合に利用できます。-- ### パスパラメータ- - `end_user_id` (uuid) 必須- エンドユーザー ID。-- ### レスポンス- EndUser オブジェクトを返します。- - `id` (uuid) ID- - `tenant_id` (uuid) テナント ID- - `app_id` (uuid) アプリ ID- - `type` (string) エンドユーザー種別- - `external_user_id` (string) 外部ユーザー ID- - `name` (string) 名前- - `is_anonymous` (boolean) 匿名ユーザーかどうか- - `session_id` (string) セッション ID- - `created_at` (string) ISO 8601 日時- - `updated_at` (string) ISO 8601 日時-- ### エラー- - 404, `end_user_not_found`, エンドユーザーが見つかりません- - 500, 内部サーバーエラー-- </Col>- <Col sticky>- ### リクエスト例- <CodeGroup- title="Request"- tag="GET"- label="/end-users/:end_user_id"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/end-users/6ad1ab0a-73ff-4ac1-b9e4-cdb312f71f13' \\---header 'Authorization: Bearer {api_key}'`}- />-- ### レスポンス例- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "id": "6ad1ab0a-73ff-4ac1-b9e4-cdb312f71f13",- "tenant_id": "8c0f3f3a-66b0-4b55-a0bf-8b8e0d6aee7d",- "app_id": "6c8c3f41-2c6f-4e1b-8f4f-7f11c8f2ad2a",- "type": "service_api",- "external_user_id": "abc-123",- "name": "Alice",- "is_anonymous": false,- "session_id": "abc-123",- "created_at": "2024-01-01T00:00:00Z",- "updated_at": "2024-01-01T00:00:00Z"- }- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/files/:file_id/preview'- method='GET'- title='ファイルプレビュー'- name='#file-preview'-/>-<Row>- <Col>- アップロードされたファイルをプレビューまたはダウンロードします。このエンドポイントを使用すると、以前にファイルアップロード API でアップロードされたファイルにアクセスできます。-- <i>ファイルは、リクエストしているアプリケーションのメッセージ範囲内にある場合のみアクセス可能です。</i>-- ### パスパラメータ- - `file_id` (string) 必須- プレビューするファイルの一意識別子。ファイルアップロード API レスポンスから取得します。-- ### クエリパラメータ- - `as_attachment` (boolean) オプション- ファイルを添付ファイルとして強制ダウンロードするかどうか。デフォルトは `false`(ブラウザでプレビュー)。-- ### レスポンス- ブラウザ表示またはダウンロード用の適切なヘッダー付きでファイル内容を返します。- - `Content-Type` ファイル MIME タイプに基づいて設定- - `Content-Length` ファイルサイズ(バイト、利用可能な場合)- - `Content-Disposition` `as_attachment=true` の場合は "attachment" に設定- - `Cache-Control` パフォーマンス向上のためのキャッシュヘッダー- - `Accept-Ranges` 音声/動画ファイルの場合は "bytes" に設定-- ### エラー- - 400, `invalid_param`, パラメータ入力異常- - 403, `file_access_denied`, ファイルアクセス拒否またはファイルが現在のアプリケーションに属していません- - 404, `file_not_found`, ファイルが見つからないか削除されています- - 500, サーバー内部エラー-- </Col>- <Col sticky>- ### リクエスト例- <CodeGroup- title="リクエスト"- tag="GET"- label="/files/:file_id/preview"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/files/72fa9618-8f89-4a37-9b33-7e1178a24a67/preview' \\---header 'Authorization: Bearer {api_key}'`}- />-- ### 添付ファイルとしてダウンロード- <CodeGroup- title="ダウンロードリクエスト"- tag="GET"- label="/files/:file_id/preview?as_attachment=true"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/files/72fa9618-8f89-4a37-9b33-7e1178a24a67/preview?as_attachment=true' \\---header 'Authorization: Bearer {api_key}' \\---output downloaded_file.png`}- />-- ### レスポンスヘッダー例- <CodeGroup title="Response Headers">- ```http {{ title: 'ヘッダー - 画像プレビュー' }}- Content-Type: image/png- Content-Length: 1024- Cache-Control: public, max-age=3600- ```- </CodeGroup>-- ### ダウンロードレスポンスヘッダー- <CodeGroup title="Download Response Headers">- ```http {{ title: 'ヘッダー - ファイルダウンロード' }}- Content-Type: image/png- Content-Length: 1024- Content-Disposition: attachment; filename*=UTF-8''example.png- Cache-Control: public, max-age=3600- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/chat-messages/:task_id/stop'- method='POST'- title='生成を停止'- name='#stop-generatebacks'-/>-<Row>- <Col>- ストリーミングモードでのみサポートされています。- ### パス- - `task_id` (string) タスク ID、ストリーミングチャンクの返り値から取得できます- ### リクエストボディ- - `user` (string) 必須- ユーザー識別子、エンドユーザーの身元を定義するために使用され、送信メッセージインターフェースで渡されたユーザーと一致している必要があります。サービス API は WebApp によって作成された会話を共有しません。- ### 応答- - `result` (string) 常に"success"を返します- </Col>- <Col sticky>- ### リクエスト例- <CodeGroup- title="リクエスト"- tag="POST"- label="/chat-messages/:task_id/stop"- targetCode={`curl -X POST '${props.appDetail.api_base_url}/chat-messages/:task_id/stop' \\--H 'Authorization: Bearer {api_key}' \\--H 'Content-Type: application/json' \\---data-raw '{- "user": "abc-123"-}'`}- />- ### 応答例- <CodeGroup title="応答">- ```json {{ title: '応答' }}- {- "result": "success"- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/form/human_input/:form_token'- method='GET'- title='Human Input フォームを取得'- name='#get-human-input-form'-/>-<Row>- <Col>- `form_token` から保留中の Human-in-the-Loop フォームを取得します。-- ストリーミングイベントで `human_input_required`(`form_token` を含む)が返された際に使用します。-- ### パス- - `form_token` (string) 必須、一時停止イベントで返されたフォームトークン-- ### 応答- - `form_content` (string) レンダリング済みフォーム内容(markdown/plain text)- - `inputs` (array[object]) 入力項目定義- - `resolved_default_values` (object) 解決済みデフォルト値(文字列)- - `user_actions` (array[object]) アクションボタン一覧- - `expiration_time` (timestamp) フォーム有効期限(Unix 秒)-- ### エラー- - 404, フォームが存在しない、または現在のアプリに属していない- - 412, `human_input_form_submitted`, 既に送信済み- - 412, `human_input_form_expired`, 期限切れ- </Col>- <Col sticky>- <CodeGroup- title="リクエスト"- tag="GET"- label="/form/human_input/:form_token"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/form/human_input/{form_token}' \\---header 'Authorization: Bearer {api_key}'`}- />-- <CodeGroup title="応答">- ```json {{ title: '応答' }}- {- "form_content": "最終回答を確認してください: {{#$output.answer#}}",- "inputs": [- {- "label": "回答",- "type": "text-input",- "required": true,- "output_variable_name": "answer"- }- ],- "resolved_default_values": {- "answer": "初期値"- },- "user_actions": [- { "id": "approve", "title": "承認", "button_style": "primary" },- { "id": "reject", "title": "却下", "button_style": "warning" }- ],- "expiration_time": 1735689600- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/form/human_input/:form_token'- method='POST'- title='Human Input フォームを送信'- name='#submit-human-input-form'-/>-<Row>- <Col>- 保留中の Human-in-the-Loop フォームを送信します。-- ### パス- - `form_token` (string) 必須、一時停止イベントで返されたフォームトークン-- ### リクエストボディ- - `inputs` (object) 必須、フォーム項目の key/value- - `action` (string) 必須、`user_actions` から選択したアクション ID- - `user` (string) 必須、エンドユーザー識別子-- ### 応答- 成功時は空オブジェクトを返します。-- ### エラー- - 400, `invalid_form_data`, 送信データがフォームスキーマに一致しない- - 404, フォームが存在しない、または現在のアプリに属していない- - 412, `human_input_form_submitted`, 既に送信済み- - 412, `human_input_form_expired`, 期限切れ- </Col>- <Col sticky>- <CodeGroup- title="リクエスト"- tag="POST"- label="/form/human_input/:form_token"- targetCode={`curl -X POST '${props.appDetail.api_base_url}/form/human_input/{form_token}' \\---header 'Authorization: Bearer {api_key}' \\---header 'Content-Type: application/json' \\---data-raw '{- "inputs": {"answer": "承認済み回答"},- "action": "approve",- "user": "abc-123"-}'`}- />-- <CodeGroup title="応答">- ```json {{ title: '応答' }}- {}- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/workflow/:task_id/events'- method='GET'- title='再開後の Workflow イベントを取得'- name='#get-workflow-resume-events'-/>-<Row>- <Col>- Human Input フォーム送信後に、ワークフロー再開後のイベントを継続受信します。-- このエンドポイントは `text/event-stream` を返し、完了までイベントを購読できます。-- ### パス- - `task_id` (string) 必須、workflow 実行 ID(`workflow_run_id`)-- ### クエリ- - `user` (string) 必須、エンドユーザー識別子- - `include_state_snapshot` (bool) 任意、`true` の場合は永続化済み状態スナップショットを先に再生してからリアルタイムイベントへ移行- - `continue_on_pause` (bool) 任意、`true` にすると `workflow_paused` イベントをまたいでもストリームを維持し、`workflow_finished` で終了します-- ### 応答- Server-Sent Events ストリーム(`text/event-stream`)。- 主なイベントは `workflow_paused`、`node_started`、`node_finished`、`human_input_form_filled`、`human_input_form_timeout`、`workflow_finished` です。- 呼び出し時点でワークフローがすでに完了している場合、このエンドポイントは完了イベントを 1 件だけ即座に返します。- </Col>- <Col sticky>- <CodeGroup- title="リクエスト"- tag="GET"- label="/workflow/:task_id/events"- targetCode={`curl -N -X GET '${props.appDetail.api_base_url}/workflow/{workflow_run_id}/events?user=abc-123&continue_on_pause=true' \\---header 'Authorization: Bearer {api_key}'`}- />-- <CodeGroup title="応答">- ```streaming {{ title: '応答' }}- event: ping-- data: {"event":"workflow_started","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","data":{"id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","workflow_id":"e46514f1-c008-41ff-94b0-4f33d4b97d36","inputs":{"sys.files":[],"sys.user_id":"abc-123","sys.app_id":"d1074979-f67e-4114-8691-e35878df9a89","sys.workflow_id":"e46514f1-c008-41ff-94b0-4f33d4b97d36","sys.workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","sys.timestamp":1776087863},"created_at":1776087863,"reason":"initial"}}-- data: {"event":"node_started","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","data":{"id":"b552d685-1119-4e6a-9a81-e91a23e5324b","node_id":"1775717266623","node_type":"start","title":"User Input","index":1,"predecessor_node_id":null,"inputs":null,"created_at":1776087863,"extras":{},"iteration_id":null,"loop_id":null}}-- data: {"event":"node_finished","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","data":{"id":"b552d685-1119-4e6a-9a81-e91a23e5324b","node_id":"1775717266623","node_type":"start","title":"User Input","index":1,"predecessor_node_id":null,"inputs":null,"process_data":null,"outputs":null,"status":"succeeded","error":null,"elapsed_time":0.00032,"execution_metadata":null,"created_at":1776087863,"finished_at":1776087863,"files":[],"iteration_id":null,"loop_id":null}}-- data: {"event":"node_started","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","data":{"id":"8d7e8e01-5159-4089-a4b6-3aa394992cc2","node_id":"1775717346519","node_type":"human-input","title":"Human Input","index":2,"predecessor_node_id":null,"inputs":null,"created_at":1776087863,"extras":{},"iteration_id":null,"loop_id":null}}-- data: {"event":"node_finished","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","data":{"id":"8d7e8e01-5159-4089-a4b6-3aa394992cc2","node_id":"1775717346519","node_type":"human-input","title":"Human Input","index":2,"predecessor_node_id":null,"inputs":null,"process_data":null,"outputs":null,"status":"paused","error":null,"elapsed_time":0.007381,"execution_metadata":null,"created_at":1776087863,"finished_at":1776087863,"files":[],"iteration_id":null,"loop_id":null}}-- data: {"event":"workflow_paused","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","data":{"workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","paused_nodes":["1775717346519"],"outputs":{},"reasons":[{"form_id":"019d8716-0fde-75da-8207-1458ccde76e5","form_content":"this is form 1:\n{{#$output.some_field#}}\n","inputs":[{"type":"paragraph","output_variable_name":"some_field","default":{"type":"variable","selector":["sys","workflow_run_id"],"value":""}}],"actions":[{"id":"approve","title":"YES","button_style":"default"},{"id":"reject","title":"NO","button_style":"default"}],"display_in_ui":true,"node_id":"1775717346519","node_title":"Human Input","resolved_default_values":{"some_field":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c"},"form_token":"n7hFG4ZDYdGcgZ5VDc7EGM","type":"human_input_required"}],"status":"paused","created_at":1776087863,"elapsed_time":0.0,"total_tokens":0,"total_steps":2}}-- data: {"event":"workflow_started","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","data":{"id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","workflow_id":"e46514f1-c008-41ff-94b0-4f33d4b97d36","inputs":{"sys.files":[],"sys.user_id":"abc-123","sys.app_id":"d1074979-f67e-4114-8691-e35878df9a89","sys.workflow_id":"e46514f1-c008-41ff-94b0-4f33d4b97d36","sys.workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c"},"created_at":1776087877,"reason":"resumption"}}-- data: {"event":"node_started","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","data":{"id":"8d7e8e01-5159-4089-a4b6-3aa394992cc2","node_id":"1775717346519","node_type":"human-input","title":"Human Input","index":1,"predecessor_node_id":null,"inputs":null,"inputs_truncated":false,"created_at":1776087877,"extras":{},"iteration_id":null,"loop_id":null,"agent_strategy":null}}-- data: {"event":"human_input_form_filled","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","data":{"node_id":"1775717346519","node_title":"Human Input","rendered_content":"this is form 1:\nfield 1 filled!\n","action_id":"approve","action_text":"YES"}}-- data: {"event":"node_finished","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","data":{"id":"8d7e8e01-5159-4089-a4b6-3aa394992cc2","node_id":"1775717346519","node_type":"human-input","title":"Human Input","index":1,"predecessor_node_id":null,"inputs":{},"inputs_truncated":false,"process_data":{},"process_data_truncated":false,"outputs":{"some_field":"field 1 filled!","some_field_2":"from bruno with love","__action_id":"approve","__rendered_content":"this is form 1:\nfield 1 filled!\n"},"outputs_truncated":false,"status":"succeeded","error":null,"elapsed_time":0.004431,"execution_metadata":null,"created_at":1776087877,"finished_at":1776087877,"files":[],"iteration_id":null,"loop_id":null}}-- data: {"event":"node_started","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","data":{"id":"6d8fc3cb-19f7-440b-b83e-eed4e847a332","node_id":"1775717350710","node_type":"template-transform","title":"Template","index":1,"predecessor_node_id":null,"inputs":null,"inputs_truncated":false,"created_at":1776087877,"extras":{},"iteration_id":null,"loop_id":null,"agent_strategy":null}}-- data: {"event":"text_chunk","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","data":{"text":"field 1 filled!","from_variable_selector":["1775717350710","output"]}}-- data: {"event":"node_finished","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","data":{"id":"6d8fc3cb-19f7-440b-b83e-eed4e847a332","node_id":"1775717350710","node_type":"template-transform","title":"Template","index":1,"predecessor_node_id":null,"inputs":{"some_field":"field 1 filled!"},"inputs_truncated":false,"process_data":{},"process_data_truncated":false,"outputs":{"output":"field 1 filled!"},"outputs_truncated":false,"status":"succeeded","error":null,"elapsed_time":0.264614,"execution_metadata":null,"created_at":1776087877,"finished_at":1776087877,"files":[],"iteration_id":null,"loop_id":null}}-- data: {"event":"node_started","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","data":{"id":"e88dec7e-aa2c-41f7-8d73-032b749e23f5","node_id":"1775717354177","node_type":"end","title":"Output","index":1,"predecessor_node_id":null,"inputs":null,"inputs_truncated":false,"created_at":1776087877,"extras":{},"iteration_id":null,"loop_id":null,"agent_strategy":null}}-- data: {"event":"node_finished","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","data":{"id":"e88dec7e-aa2c-41f7-8d73-032b749e23f5","node_id":"1775717354177","node_type":"end","title":"Output","index":1,"predecessor_node_id":null,"inputs":{"output":"field 1 filled!"},"inputs_truncated":false,"process_data":{},"process_data_truncated":false,"outputs":{"output":"field 1 filled!"},"outputs_truncated":false,"status":"succeeded","error":null,"elapsed_time":0.00003,"execution_metadata":null,"created_at":1776087877,"finished_at":1776087877,"files":[],"iteration_id":null,"loop_id":null}}-- data: {"event":"workflow_finished","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","data":{"id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","workflow_id":"e46514f1-c008-41ff-94b0-4f33d4b97d36","status":"succeeded","outputs":{"output":"field 1 filled!"},"error":null,"elapsed_time":0.364935,"total_tokens":0,"total_steps":5,"created_by":{"id":"7932d34c-dcf4-4fba-b770-f2a9de88c0a0","user":"abc-123"},"created_at":1776087877,"finished_at":1776087877,"exceptions_count":0,"files":[]}}- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/messages/:message_id/feedbacks'- method='POST'- title='メッセージフィードバック'- name='#feedbacks'-/>-<Row>- <Col>- エンドユーザーはフィードバックメッセージを提供でき、アプリケーション開発者が期待される出力を最適化するのを支援します。-- ### パス- <Properties>- <Property name='message_id' type='string' key='message_id'>- メッセージID- </Property>- </Properties>-- ### リクエストボディ-- <Properties>- <Property name='rating' type='string' key='rating'>- アップボートは`like`、ダウンボートは`dislike`、アップボートの取り消しは`null`- </Property>- <Property name='user' type='string' key='user'>- ユーザー識別子、開発者のルールによって定義され、アプリケーション内で一意でなければなりません。- </Property>- <Property name='content' type='string' key='content'>- メッセージのフィードバックです。- </Property>- </Properties>-- ### 応答- - `result` (string) 常に"success"を返します- </Col>- <Col sticky>-- <CodeGroup- title="リクエスト"- tag="POST"- label="/messages/:message_id/feedbacks"- targetCode={`curl -X POST '${props.appDetail.api_base_url}/messages/:message_id/feedbacks' \\---header 'Authorization: Bearer {api_key}' \\---header 'Content-Type: application/json' \\---data-raw '{- "rating": "like",- "user": "abc-123",- "content": "message feedback information"-}'`}- />-- <CodeGroup title="応答">- ```json {{ title: '応答' }}- {- "result": "success"- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/app/feedbacks'- method='GET'- title='アプリのメッセージの「いいね」とフィードバックを取得'- name='#app-feedbacks'-/>-<Row>- <Col>- アプリのエンドユーザーからのフィードバックや「いいね」を取得します。-- ### クエリ- <Properties>- <Property name='page' type='string' key='page'>- (任意)ページ番号。デフォルト値:1- </Property>- </Properties>-- <Properties>- <Property name='limit' type='string' key='limit'>- (任意)1ページあたりの件数。デフォルト値:20- </Property>- </Properties>-- ### レスポンス- - `data` (リスト) このアプリの「いいね」とフィードバックの一覧を返します。- </Col>- <Col sticky>-- <CodeGroup- title="リクエスト"- tag="GET"- label="/app/feedbacks"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/app/feedbacks?page=1&limit=20' \\---header 'Authorization: Bearer {api_key}' \\---header 'Content-Type: application/json'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "data": [- {- "id": "8c0fbed8-e2f9-49ff-9f0e-15a35bdd0e25",- "app_id": "f252d396-fe48-450e-94ec-e184218e7346",- "conversation_id": "2397604b-9deb-430e-b285-4726e51fd62d",- "message_id": "709c0b0f-0a96-4a4e-91a4-ec0889937b11",- "rating": "like",- "content": "message feedback information-3",- "from_source": "user",- "from_end_user_id": "74286412-9a1a-42c1-929c-01edb1d381d5",- "from_account_id": null,- "created_at": "2025-04-24T09:24:38",- "updated_at": "2025-04-24T09:24:38"- }- ]- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/messages/{message_id}/suggested'- method='GET'- title='次の推奨質問'- name='#suggested'-/>-<Row>- <Col>- 現在のメッセージに対する次の質問の提案を取得します-- ### パスパラメータ-- <Properties>- <Property name='message_id' type='string' key='message_id'>- メッセージID- </Property>- </Properties>-- ### クエリ- <Properties>- <Property name='user' type='string' key='user'>- ユーザー識別子、エンドユーザーの身元を定義するために使用され、統計のために使用されます。- アプリケーション内で開発者によって一意に定義されるべきです。- </Property>- </Properties>- </Col>- <Col sticky>-- <CodeGroup- title="リクエスト"- tag="GET"- label="/messages/{message_id}/suggested"- targetCode={`curl --location --request GET '${props.appDetail.api_base_url}/messages/{message_id}/suggested?user=abc-123' \\---header 'Authorization: Bearer ENTER-YOUR-SECRET-KEY' \\---header 'Content-Type: application/json'`}- />-- <CodeGroup title="応答">- ```json {{ title: '応答' }}- {- "result": "success",- "data": [- "a",- "b",- "c"- ]- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/messages'- method='GET'- title='会話履歴メッセージを取得'- name='#messages'-/>-<Row>- <Col>- スクロールロード形式で履歴チャット記録を返し、最初のページは最新の`{limit}`メッセージを返します。つまり、逆順です。-- ### クエリ-- <Properties>- <Property name='conversation_id' type='string' key='conversation_id'>- 会話ID- </Property>- <Property name='user' type='string' key='user'>- ユーザー識別子、エンドユーザーの身元を定義するために使用され、統計のために使用されます。- アプリケーション内で開発者によって一意に定義されるべきです。- </Property>- <Property name='first_id' type='string' key='first_id'>- 現在のページの最初のチャット記録のID、デフォルトはnullです。- </Property>- <Property name='limit' type='int' key='limit'>- 1回のリクエストで返すチャット履歴メッセージの数、デフォルトは20です。- </Property>- </Properties>-- ### 応答- - `data` (array[object]) メッセージリスト- - `id` (string) メッセージID- - `conversation_id` (string) 会話ID- - `inputs` (object) ユーザー入力パラメータ。- - `query` (string) ユーザー入力/質問内容。- - `message_files` (array[object]) メッセージファイル- - `id` (string) ID- - `type` (string) ファイルタイプ、画像の場合はimage- - `url` (string) ファイルプレビューURL、ファイルアクセスにはファイルプレビューAPI(`/files/{file_id}/preview`)を使用してください- - `belongs_to` (string) 所属、userまたはassistant- - `answer` (string) 応答メッセージ内容- - `created_at` (timestamp) 作成タイムスタンプ、例:1705395332- - `feedback` (object) フィードバック情報- - `rating` (string) アップボートは`like` / ダウンボートは`dislike`- - `retriever_resources` (array[RetrieverResource]) 引用と帰属リスト- - `has_more` (bool) 次のページがあるかどうか- - `limit` (int) 返された項目数、入力がシステム制限を超える場合、システム制限数を返します-- </Col>- <Col sticky>-- <CodeGroup- title="リクエスト"- tag="GET"- label="/messages"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/messages?user=abc-123&conversation_id={conversation_id}'---header 'Authorization: Bearer {api_key}'`}- />- ### 応答例- <CodeGroup title="応答">- ```json {{ title: '応答' }}- {- "limit": 20,- "has_more": false,- "data": [- {- "id": "a076a87f-31e5-48dc-b452-0061adbbc922",- "conversation_id": "cd78daf6-f9e4-4463-9ff2-54257230a0ce",- "inputs": {- "name": "dify"- },- "query": "iphone 13 pro",- "answer": "iPhone 13 Proは2021年9月24日に発売され、6.1インチのディスプレイと1170 x 2532の解像度を備えています。Hexa-core (2x3.23 GHz Avalanche + 4x1.82 GHz Blizzard)プロセッサ、6 GBのRAMを搭載し、128 GB、256 GB、512 GB、1 TBのストレージオプションを提供します。カメラは12 MP、バッテリー容量は3095 mAhで、iOS 15を搭載しています。",- "message_files": [],- "feedback": null,- "retriever_resources": [- {- "position": 1,- "dataset_id": "101b4c97-fc2e-463c-90b1-5261a4cdcafb",- "dataset_name": "iPhone",- "document_id": "8dd1ad74-0b5f-4175-b735-7d98bbbb4e00",- "document_name": "iPhone List",- "segment_id": "ed599c7f-2766-4294-9d1d-e5235a61270a",- "score": 0.98457545,- "content": "\"Model\",\"Release Date\",\"Display Size\",\"Resolution\",\"Processor\",\"RAM\",\"Storage\",\"Camera\",\"Battery\",\"Operating System\"\n\"iPhone 13 Pro Max\",\"September 24, 2021\",\"6.7 inch\",\"1284 x 2778\",\"Hexa-core (2x3.23 GHz Avalanche + 4x1.82 GHz Blizzard)\",\"6 GB\",\"128, 256, 512 GB, 1TB\",\"12 MP\",\"4352 mAh\",\"iOS 15\""- }- ],- "created_at": 1705569239,- }- ]- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/conversations'- method='GET'- title='会話を取得'- name='#conversations'-/>-<Row>- <Col>- 現在のユーザーの会話リストを取得し、デフォルトで最新の 20 件を返します。-- ### クエリ-- <Properties>- <Property name='user' type='string' key='user'>- ユーザー識別子、エンドユーザーの身元を定義するために使用され、統計のために使用されます。- アプリケーション内で開発者によって一意に定義されるべきです。- </Property>- <Property name='last_id' type='string' key='last_id'>- (Optional)現在のページの最後の記録のID、デフォルトはnullです。- </Property>- <Property name='limit' type='int' key='limit'>- (Optional)1回のリクエストで返す記録の数、デフォルトは最新の20件です。最大100、最小1。- </Property>- <Property name='sort_by' type='string' key='sort_by'>- (Optional)ソートフィールド、デフォルト:-updated_at(更新時間で降順にソート)- - 利用可能な値:created_at, -created_at, updated_at, -updated_at- - フィールドの前の記号は順序または逆順を表し、"-"は逆順を表します。- </Property>- </Properties>-- ### 応答- - `data` (array[object]) 会話のリスト- - `id` (string) 会話ID- - `name` (string) 会話名、デフォルトではLLMによって生成されます。- - `inputs` (object) ユーザー入力パラメータ。- - `introduction` (string) 紹介- - `created_at` (timestamp) 作成タイムスタンプ、例:1705395332- - `updated_at` (timestamp) 更新タイムスタンプ、例:1705395332- - `has_more` (bool)- - `limit` (int) 返されたエントリ数、入力がシステム制限を超える場合、システム制限数が返されます-- </Col>- <Col sticky>-- <CodeGroup- title="リクエスト"- tag="GET"- label="/conversations"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/conversations?user=abc-123&last_id=&limit=20' \\---header 'Authorization: Bearer {api_key}'`}- />-- <CodeGroup title="応答">- ```json {{ title: '応答' }}- {- "limit": 20,- "has_more": false,- "data": [- {- "id": "10799fb8-64f7-4296-bbf7-b42bfbe0ae54",- "name": "新しいチャット",- "inputs": {- "book": "book",- "myName": "Lucy"- },- "status": "normal",- "created_at": 1679667915,- "updated_at": 1679667915- },- {- "id": "hSIhXBhNe8X1d8Et"- // ...- }- ]- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/conversations/:conversation_id'- method='DELETE'- title='会話を削除'- name='#delete'-/>-<Row>- <Col>- 会話を削除します。-- ### パス- - `conversation_id` (string) 会話ID-- ### リクエストボディ-- <Properties>- <Property name='user' type='string' key='user'>- ユーザー識別子、開発者によって定義され、アプリケーション内で一意であることを保証しなければなりません。- </Property>- </Properties>-- ### 応答- - `result` (string) 常に"success"を返します- </Col>- <Col sticky>-- <CodeGroup- title="リクエスト"- tag="DELETE"- label="/conversations/:conversation_id"- targetCode={`curl -X DELETE '${props.appDetail.api_base_url}/conversations/{conversation_id}' \\---header 'Content-Type: application/json' \\---header 'Accept: application/json' \\---header 'Authorization: Bearer {api_key}' \\---data '{- "user": "abc-123"-}'`}- />-- <CodeGroup title="応答">- ```text {{ title: '応答' }}- 204 No Content- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/conversations/:conversation_id/name'- method='POST'- title='会話の名前を変更'- name='#rename'-/>-<Row>- <Col>- ### リクエストボディ- セッションの名前を変更します。セッション名は、複数のセッションをサポートするクライアントでの表示に使用されます。-- ### パス- - `conversation_id` (string) 会話ID-- <Properties>- <Property name='name' type='string' key='name'>- (Optional)会話の名前。`auto_generate`が`true`に設定されている場合、このパラメータは省略できます。- </Property>- <Property name='auto_generate' type='bool' key='auto_generate'>- (Optional)タイトルを自動生成、デフォルトは`false`- </Property>- <Property name='user' type='string' key='user'>- ユーザー識別子、開発者によって定義され、アプリケーション内で一意であることを保証しなければなりません。- </Property>- </Properties>-- ### 応答- - `id` (string) 会話ID- - `name` (string) 会話名- - `inputs` (object) ユーザー入力パラメータ- - `status` (string) 会話状態- - `introduction` (string) 紹介- - `created_at` (timestamp) 作成タイムスタンプ、例:1705395332- - `updated_at` (timestamp) 更新タイムスタンプ、例:1705395332- </Col>- <Col sticky>-- <CodeGroup- title="リクエスト"- tag="POST"- label="/conversations/:conversation_id/name"- targetCode={`curl -X POST '${props.appDetail.api_base_url}/conversations/{conversation_id}/name' \\---header 'Content-Type: application/json' \\---header 'Authorization: Bearer {api_key}' \\---data-raw '{- "name": "",- "auto_generate": true,- "user": "abc-123"-}'`}- />-- <CodeGroup title="応答">- ```json {{ title: '応答' }}- {- "id": "cd78daf6-f9e4-4463-9ff2-54257230a0ce",- "name": "チャット vs AI",- "inputs": {},- "status": "normal",- "introduction": "",- "created_at": 1705569238,- "updated_at": 1705569238- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/conversations/:conversation_id/variables'- method='GET'- title='会話変数の取得'- name='#conversation-variables'-/>-<Row>- <Col>- 特定の会話から変数を取得します。このエンドポイントは、会話中に取得された構造化データを抽出するのに役立ちます。-- ### パスパラメータ-- <Properties>- <Property name='conversation_id' type='string' key='conversation_id'>- 変数を取得する会話のID。- </Property>- </Properties>-- ### クエリパラメータ-- <Properties>- <Property name='user' type='string' key='user'>- ユーザー識別子。開発者によって定義されたルールに従い、アプリケーション内で一意である必要があります。- </Property>- <Property name='last_id' type='string' key='last_id'>- (Optional)現在のページの最後の記録のID、デフォルトはnullです。- </Property>- <Property name='limit' type='int' key='limit'>- (Optional)1回のリクエストで返す記録の数、デフォルトは最新の20件です。最大100、最小1。- </Property>- </Properties>-- ### レスポンス-- - `limit` (int) ページごとのアイテム数- - `has_more` (bool) さらにアイテムがあるかどうか- - `data` (array[object]) 変数のリスト- - `id` (string) 変数 ID- - `name` (string) 変数名- - `value_type` (string) 変数タイプ(文字列、数値、真偽値など)- - `value` (string) 変数値- - `description` (string) 変数の説明- - `created_at` (int) 作成タイムスタンプ- - `updated_at` (int) 最終更新タイムスタンプ-- ### エラー- - 404, `conversation_not_exists`, 会話が見つかりません-- </Col>- <Col sticky>-- <CodeGroup- title="リクエスト"- tag="GET"- label="/conversations/:conversation_id/variables"- debug="true"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/conversations/{conversation_id}/variables?user=abc-123' \\---header 'Authorization: Bearer {api_key}'`} />-- <CodeGroup- title="変数名フィルター付きリクエスト"- language="bash"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/conversations/{conversation_id}/variables?user=abc-123&variable_name=customer_name' \\---header 'Authorization: Bearer {api_key}'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "limit": 100,- "has_more": false,- "data": [- {- "id": "variable-uuid-1",- "name": "customer_name",- "value_type": "string",- "value": "John Doe",- "description": "会話から抽出された顧客名",- "created_at": 1650000000000,- "updated_at": 1650000000000- },- {- "id": "variable-uuid-2",- "name": "order_details",- "value_type": "json",- "value": "{\"product\":\"Widget\",\"quantity\":5,\"price\":19.99}",- "description": "顧客の注文詳細",- "created_at": 1650000000000,- "updated_at": 1650000000000- }- ]- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/conversations/:conversation_id/variables/:variable_id'- method='PUT'- title='会話変数の更新'- name='#update-conversation-variable'-/>-<Row>- <Col>- 特定の会話変数の値を更新します。このエンドポイントは、名前、型、説明を保持しながら、会話中にキャプチャされた変数の値を変更することを可能にします。-- ### パスパラメータ-- <Properties>- <Property name='conversation_id' type='string' key='conversation_id'>- 更新する変数を含む会話のID。- </Property>- <Property name='variable_id' type='string' key='variable_id'>- 更新する変数のID。- </Property>- </Properties>-- ### リクエストボディ-- <Properties>- <Property name='value' type='any' key='value'>- 変数の新しい値。変数の期待される型(文字列、数値、オブジェクトなど)と一致する必要があります。- </Property>- <Property name='user' type='string' key='user'>- ユーザー識別子。開発者によって定義されたルールに従い、アプリケーション内で一意である必要があります。- </Property>- </Properties>-- ### レスポンス-- 以下を含む更新された変数オブジェクトを返します:- - `id` (string) 変数ID- - `name` (string) 変数名- - `value_type` (string) 変数型(文字列、数値、オブジェクトなど)- - `value` (any) 更新された変数値- - `description` (string) 変数の説明- - `created_at` (int) 作成タイムスタンプ- - `updated_at` (int) 最終更新タイムスタンプ-- ### エラー- - 400, `Type mismatch: variable expects {expected_type}, but got {actual_type} type`, 値の型が変数の期待される型と一致しません- - 404, `conversation_not_exists`, 会話が見つかりません- - 404, `conversation_variable_not_exists`, 変数が見つかりません-- </Col>- <Col sticky>-- <CodeGroup- title="リクエスト"- tag="PUT"- label="/conversations/:conversation_id/variables/:variable_id"- targetCode={`curl -X PUT '${props.appDetail.api_base_url}/conversations/{conversation_id}/variables/{variable_id}' \\---header 'Content-Type: application/json' \\---header 'Authorization: Bearer {api_key}' \\---data-raw '{- "value": "Updated Value",- "user": "abc-123"-}'`}- />-- <CodeGroup- title="異なる値型での更新"- targetCode={[- {- title: '文字列値',- code: `curl -X PUT '${props.appDetail.api_base_url}/conversations/{conversation_id}/variables/{variable_id}' \\---header 'Content-Type: application/json' \\---header 'Authorization: Bearer {api_key}' \\---data-raw '{- "value": "新しい文字列値",- "user": "abc-123"-}'`,- }, {- title: '数値',- code: `curl -X PUT '${props.appDetail.api_base_url}/conversations/{conversation_id}/variables/{variable_id}' \\---header 'Content-Type: application/json' \\---header 'Authorization: Bearer {api_key}' \\---data-raw '{- "value": 42,- "user": "abc-123"-}'`,- }, {- title: 'オブジェクト値',- code: `curl -X PUT '${props.appDetail.api_base_url}/conversations/{conversation_id}/variables/{variable_id}' \\---header 'Content-Type: application/json' \\---header 'Authorization: Bearer {api_key}' \\---data-raw '{- "value": {"product": "Widget", "quantity": 10, "price": 29.99},- "user": "abc-123"-}'`,- },- ]}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "id": "variable-uuid-1",- "name": "customer_name",- "value_type": "string",- "value": "Updated Value",- "description": "会話から抽出された顧客名",- "created_at": 1650000000000,- "updated_at": 1650000001000- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/audio-to-text'- method='POST'- title='音声からテキストへ'- name='#audio-to-text'-/>-<Row>- <Col>- このエンドポイントは multipart/form-data リクエストを必要とします。-- ### リクエストボディ-- <Properties>- <Property name='file' type='file' key='file'>- オーディオファイル。- サポートされている形式:`['mp3', 'mp4', 'mpeg', 'mpga', 'm4a', 'wav', 'webm']`- ファイルサイズ制限:15MB- </Property>- <Property name='user' type='string' key='user'>- ユーザー識別子、開発者のルールによって定義され、アプリケーション内で一意でなければなりません。- </Property>- </Properties>-- ### 応答- - `text` (string) 出力テキスト-- </Col>- <Col sticky>-- <CodeGroup- title="リクエスト"- tag="POST"- label="/audio-to-text"- targetCode={`curl -X POST '${props.appDetail.api_base_url}/audio-to-text' \\---header 'Authorization: Bearer {api_key}' \\---form 'file=@localfile;type=audio/[mp3|mp4|mpeg|mpga|m4a|wav|webm]'`}- />-- <CodeGroup title="応答">- ```json {{ title: '応答' }}- {- "text": ""- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/text-to-audio'- method='POST'- title='テキストから音声へ'- name='#text-to-audio'-/>-<Row>- <Col>- テキストを音声に変換します。-- ### リクエストボディ-- <Properties>- <Property name='message_id' type='str' key='message_id'>- Difyによって生成されたテキストメッセージの場合、生成されたメッセージIDを直接渡します。バックエンドはメッセージIDを使用して対応する内容を検索し、音声情報を直接合成します。message_idとtextが同時に提供される場合、message_idが優先されます。- </Property>- <Property name='text' type='str' key='text'>- 音声生成コンテンツ。- </Property>- <Property name='user' type='string' key='user'>- ユーザー識別子、開発者によって定義され、アプリ内で一意であることを保証しなければなりません。- </Property>- </Properties>- </Col>- <Col sticky>-- <CodeGroup- title="リクエスト"- tag="POST"- label="/text-to-audio"- targetCode={`curl -o text-to-audio.mp3 -X POST '${props.appDetail.api_base_url}/text-to-audio' \\---header 'Authorization: Bearer {api_key}' \\---header 'Content-Type: application/json' \\---data-raw '{- "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290",- "text": "Hello Dify",- "user": "abc-123",-}'`}- />-- <CodeGroup title="ヘッダー">- ```json {{ title: 'ヘッダー' }}- {- "Content-Type": "audio/wav"- }- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/info'- method='GET'- title='アプリケーションの基本情報を取得'- name='#info'-/>-<Row>- <Col>- このアプリケーションの基本情報を取得するために使用されます-- ### Response- - `name` (string) アプリケーションの名前- - `description` (string) アプリケーションの説明- - `tags` (array[string]) アプリケーションのタグ- - `mode` (string) アプリケーションのモード- - `author_name` (string) 作者の名前- </Col>- <Col>- <CodeGroup- title="リクエスト"- tag="GET"- label="/info"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/info' \\--H 'Authorization: Bearer {api_key}'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "name": "My App",- "description": "This is my app.",- "tags": [- "tag1",- "tag2"- ],- "mode": "advanced-chat",- "author_name": "Dify"- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/parameters'- method='GET'- title='アプリケーションのパラメータ情報を取得'- name='#parameters'-/>-<Row>- <Col>- ページに入る際に、機能、入力パラメータ名、タイプ、デフォルト値などの情報を取得するために使用されます。-- ### 応答- - `opening_statement` (string) 開始の挨拶- - `suggested_questions` (array[string]) 開始時の推奨質問のリスト- - `suggested_questions_after_answer` (object) 答えを有効にした後の質問を提案します。- - `enabled` (bool) 有効かどうか- - `speech_to_text` (object) 音声からテキストへ- - `enabled` (bool) 有効かどうか- - `text_to_speech` (object) テキストから音声へ- - `enabled` (bool) 有効かどうか- - `voice` (string) 音声タイプ- - `language` (string) 言語- - `autoPlay` (string) 自動再生- - `enabled` 有効- - `disabled` 無効- - `retriever_resource` (object) 引用と帰属- - `enabled` (bool) 有効かどうか- - `annotation_reply` (object) 注釈返信- - `enabled` (bool) 有効かどうか- - `user_input_form` (array[object]) ユーザー入力フォームの設定- - `text-input` (object) テキスト入力コントロール- - `label` (string) 変数表示ラベル名- - `variable` (string) 変数ID- - `required` (bool) 必須かどうか- - `default` (string) デフォルト値- - `paragraph` (object) 段落テキスト入力コントロール- - `label` (string) 変数表示ラベル名- - `variable` (string) 変数ID- - `required` (bool) 必須かどうか- - `default` (string) デフォルト値- - `select` (object) ドロップダウンコントロール- - `label` (string) 変数表示ラベル名- - `variable` (string) 変数ID- - `required` (bool) 必須かどうか- - `default` (string) デフォルト値- - `options` (array[string]) オプション値- - `file_upload` (object) ファイルアップロード設定- - `document` (object) ドキュメント設定- 現在サポートされているドキュメントタイプ:`txt`, `md`, `markdown`, `pdf`, `html`, `xlsx`, `xls`, `docx`, `csv`, `eml`, `msg`, `pptx`, `ppt`, `xml`, `epub`。- - `enabled` (bool) 有効かどうか- - `number_limits` (int) ドキュメント数の上限。デフォルトは 3- - `transfer_methods` (array[string]) 転送方法リスト:`remote_url`, `local_file`。いずれかを選択する必要があります。- - `image` (object) 画像設定- 現在サポートされている画像タイプ:`png`, `jpg`, `jpeg`, `webp`, `gif`。- - `enabled` (bool) 有効かどうか- - `number_limits` (int) 画像数の上限。デフォルトは 3- - `transfer_methods` (array[string]) 転送方法リスト:`remote_url`, `local_file`。いずれかを選択する必要があります。- - `audio` (object) オーディオ設定- 現在サポートされているオーディオタイプ:`mp3`, `m4a`, `wav`, `webm`, `amr`。- - `enabled` (bool) 有効かどうか- - `number_limits` (int) オーディオ数の上限。デフォルトは 3- - `transfer_methods` (array[string]) 転送方法リスト:`remote_url`, `local_file`。いずれかを選択する必要があります。- - `video` (object) ビデオ設定- 現在サポートされているビデオタイプ:`mp4`, `mov`, `mpeg`, `mpga`。- - `enabled` (bool) 有効かどうか- - `number_limits` (int) ビデオ数の上限。デフォルトは 3- - `transfer_methods` (array[string]) 転送方法リスト:`remote_url`, `local_file`。いずれかを選択する必要があります。- - `custom` (object) カスタム設定- - `enabled` (bool) 有効かどうか- - `number_limits` (int) カスタム数の上限。デフォルトは 3- - `transfer_methods` (array[string]) 転送方法リスト:`remote_url`, `local_file`。いずれかを選択する必要があります。- - `system_parameters` (object) システムパラメータ- - `file_size_limit` (int) ドキュメントアップロードサイズ制限(MB)- - `image_file_size_limit` (int) 画像ファイルアップロードサイズ制限(MB)- - `audio_file_size_limit` (int) オーディオファイルアップロードサイズ制限(MB)- - `video_file_size_limit` (int) ビデオファイルアップロードサイズ制限(MB)-- </Col>- <Col sticky>-- <CodeGroup- title="リクエスト"- tag="GET"- label="/parameters"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/parameters'`}- />-- <CodeGroup title="応答">- ```json {{ title: '応答' }}- {- "opening_statement": "こんにちは!",- "suggested_questions_after_answer": {- "enabled": true- },- "speech_to_text": {- "enabled": true- },- "text_to_speech": {- "enabled": true,- "voice": "sambert-zhinan-v1",- "language": "zh-Hans",- "autoPlay": "disabled"- },- "retriever_resource": {- "enabled": true- },- "annotation_reply": {- "enabled": true- },- "user_input_form": [- {- "paragraph": {- "label": "クエリ",- "variable": "query",- "required": true,- "default": ""- }- }- ],- "file_upload": {- "image": {- "enabled": false,- "number_limits": 3,- "detail": "high",- "transfer_methods": [- "remote_url",- "local_file"- ]- }- },- "system_parameters": {- "file_size_limit": 15,- "image_file_size_limit": 10,- "audio_file_size_limit": 50,- "video_file_size_limit": 100- }- }- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/meta'- method='GET'- title='アプリケーションのメタ情報を取得'- name='#meta'-/>-<Row>- <Col>- このアプリケーションのツールのアイコンを取得するために使用されます-- ### 応答- - `tool_icons`(object[string]) ツールアイコン- - `tool_name` (string)- - `icon` (object|string)- - (object) アイコンオブジェクト- - `background` (string) 背景色(16 進数形式)- - `content`(string) 絵文字- - (string) アイコンの URL- </Col>- <Col>-- <CodeGroup- title="リクエスト"- tag="GET"- label="/meta"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/meta' \\--H 'Authorization: Bearer {api_key}'`}- />-- <CodeGroup title="応答">- ```json {{ title: '応答' }}- {- "tool_icons": {- "dalle2": "https://cloud.dify.ai/console/api/workspaces/current/tool-provider/builtin/dalle/icon",- "api_tool": {- "background": "#252525",- "content": "\ud83d\ude01"- }- }- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/site'- method='GET'- title='アプリのWebApp設定を取得'- name='#site'-/>-<Row>- <Col>- アプリの WebApp 設定を取得するために使用します。- ### 応答- - `title` (string) WebApp 名- - `chat_color_theme` (string) チャットの色テーマ、16 進数形式- - `chat_color_theme_inverted` (bool) チャットの色テーマを反転するかどうか- - `icon_type` (string) アイコンタイプ、`emoji`-絵文字、`image`-画像- - `icon` (string) アイコン。`emoji`タイプの場合は絵文字、`image`タイプの場合は画像 URL- - `icon_background` (string) 16 進数形式の背景色- - `icon_url` (string) アイコンの URL- - `description` (string) 説明- - `copyright` (string) 著作権情報- - `privacy_policy` (string) プライバシーポリシーのリンク- - `custom_disclaimer` (string) カスタム免責事項- - `default_language` (string) デフォルト言語- - `show_workflow_steps` (bool) ワークフローの詳細を表示するかどうか- - `use_icon_as_answer_icon` (bool) WebApp のアイコンをチャット内の🤖に置き換えるかどうか- </Col>- <Col>- <CodeGroup- title="リクエスト"- tag="GET"- label="/site"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/site' \\--H 'Authorization: Bearer {api_key}'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "title": "My App",- "chat_color_theme": "#ff4a4a",- "chat_color_theme_inverted": false,- "icon_type": "emoji",- "icon": "😄",- "icon_background": "#FFEAD5",- "icon_url": null,- "description": "This is my app.",- "copyright": "all rights reserved",- "privacy_policy": "",- "custom_disclaimer": "All generated by AI",- "default_language": "en-US",- "show_workflow_steps": false,- "use_icon_as_answer_icon": false,- }- ```- </CodeGroup>- </Col>-</Row>-___diff --git a/web/app/components/develop/template/template_advanced_chat.zh.mdx b/web/app/components/develop/template/template_advanced_chat.zh.mdxdeleted file mode 100755index b37182435a9..00000000000--- a/web/app/components/develop/template/template_advanced_chat.zh.mdx+++ /dev/null@@ -1,2451 +0,0 @@-import { CodeGroup } from '../code.tsx'-import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx'-import { WorkflowVersionApiUpgradeNotice } from '../workflow-version-api-upgrade-notice.tsx'--# 工作流编排对话型应用 API--对话应用支持会话持久化,可将之前的聊天记录作为上下文进行回答,可适用于聊天/客服 AI 等。--<div>- ### 基础 URL- <CodeGroup title="Code" targetCode={props.appDetail.api_base_url} />-- ### 鉴权-- Service API 使用 `API-Key` 进行鉴权。- <i>**强烈建议开发者把 `API-Key` 放在后端存储,而非分享或者放在客户端存储,以免 `API-Key` 泄露,导致财产损失。**</i>- 所有 API 请求都应在 **`Authorization`** HTTP Header 中包含您的 `API-Key`,如下所示:-- <CodeGroup title="Code" targetCode='Authorization: Bearer {API_KEY}' />-</div>-------<Heading- url='/chat-messages'- method='POST'- title='发送对话消息'- name='#Create-Chat-Message'-/>-<Row>- <Col>- 创建会话消息。-- ### Request Body-- <Properties>- <Property name='query' type='string' key='query'>- 用户输入/提问内容。- </Property>- <Property name='inputs' type='object' key='inputs'>- 允许传入 App 定义的各变量值。- inputs 参数包含了多组键值对(Key/Value pairs),每组的键对应一个特定变量,每组的值则是该变量的具体值。- 如果变量是文件类型,请指定一个包含以下 `files` 中所述键的对象。- 默认 `{}`- </Property>- <Property name='response_mode' type='string' key='response_mode'>- - `streaming` 流式模式(推荐)。基于 SSE(**[Server-Sent Events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events)**)实现类似打字机输出方式的流式返回。- - `blocking` 阻塞模式,等待执行完毕后返回结果。(请求若流程较长可能会被中断)。- <i>由于 Cloudflare 限制,请求会在 100 秒超时无返回后中断。</i>- </Property>- <Property name='user' type='string' key='user'>- 用户标识,用于定义终端用户的身份,方便检索、统计。- 由开发者定义规则,需保证用户标识在应用内唯一。服务 API 不会共享 WebApp 创建的对话。- </Property>- <Property name='conversation_id' type='string' key='conversation_id'>- (选填)会话 ID,需要基于之前的聊天记录继续对话,必须传之前消息的 conversation_id。- </Property>- <Property name='files' type='array[object]' key='files'>- 文件列表,适用于传入文件结合文本理解并回答问题,仅当模型支持 Vision/Video 能力时可用。- - `type` (string) 支持类型:- - `document` 具体类型包含:'TXT', 'MD', 'MARKDOWN', 'MDX', 'PDF', 'HTML', 'XLSX', 'XLS', 'VTT', 'PROPERTIES', 'DOC', 'DOCX', 'CSV', 'EML', 'MSG', 'PPTX', 'PPT', 'XML', 'EPUB'- - `image` 具体类型包含:'JPG', 'JPEG', 'PNG', 'GIF', 'WEBP', 'SVG'- - `audio` 具体类型包含:'MP3', 'M4A', 'WAV', 'WEBM', 'MPGA'- - `video` 具体类型包含:'MP4', 'MOV', 'MPEG', 'WEBM'- - `custom` 具体类型包含:其他文件类型- - `transfer_method` (string) 传递方式:- - `remote_url`: 文件地址。- - `local_file`: 上传文件。- - `url` 文件地址。(仅当传递方式为 `remote_url` 时)。- - `upload_file_id` 上传文件 ID。(仅当传递方式为 `local_file `时)。- </Property>- <Property name='auto_generate_name' type='bool' key='auto_generate_name'>- (选填)自动生成标题,默认 `true`。 若设置为 `false`,则可通过调用会话重命名接口并设置 `auto_generate` 为 `true` 实现异步生成标题。- </Property>- <Property name='workflow_id' type='string' key='workflow_id' nameAction={<WorkflowVersionApiUpgradeNotice />}>- (选填)工作流ID,用于指定特定版本,如果不提供则使用默认的已发布版本。- </Property>- <Property name='trace_id' type='string' key='trace_id'>- (选填)链路追踪ID。适用于与业务系统已有的trace组件打通,实现端到端分布式追踪等场景。如果未指定,系统会自动生成<code>trace_id</code>。支持以下三种方式传递,具体优先级依次为:<br/>- - Header:通过 HTTP Header <code>X-Trace-Id</code> 传递,优先级最高。<br/>- - Query 参数:通过 URL 查询参数 <code>trace_id</code> 传递。<br/>- - Request Body:通过请求体字段 <code>trace_id</code> 传递(即本字段)。<br/>- </Property>- <Property name='trace_session_id' type='string' key='trace_session_id'>- (选填)用于可观测性分组的链路会话 ID。支持会话分组的追踪提供商可将该值用作导出的会话标识。它不会改变 conversation_id、workflow_run_id、trace_id 或 span 关系。支持以下三种方式传递,具体优先级依次为:<br/>- - Header:通过 HTTP Header <code>X-Trace-Session-Id</code> 传递,优先级最高。<br/>- - Query 参数:通过 URL 查询参数 <code>trace_session_id</code> 传递。<br/>- - Request Body:通过请求体字段 <code>trace_session_id</code> 传递(即本字段)。<br/>- </Property>- </Properties>-- ### Response- <Properties>- 当 `response_mode` 为 `blocking` 时,返回 ChatCompletionResponse object。- 当 `response_mode` 为 `streaming`时,返回 ChunkChatCompletionResponse object 流式序列。-- ### ChatCompletionResponse-- 返回完整的 App 结果,`Content-Type` 为 `application/json`。- - `event` (string) 事件类型,固定为 `message`- - `task_id` (string) 任务 ID,用于请求跟踪和下方的停止响应接口- - `id` (string) 唯一ID- - `message_id` (string) 消息唯一 ID- - `conversation_id` (string) 会话 ID- - `mode` (string) App 模式,固定为 chat- - `answer` (string) 完整回复内容- - `metadata` (object) 元数据- - `usage` (Usage) 模型用量信息- - `retriever_resources` (array[RetrieverResource]) 引用和归属分段列表- - `created_at` (int) 消息创建时间戳,如:1705395332-- ### ChunkChatCompletionResponse- 返回 App 输出的流式块,`Content-Type` 为 `text/event-stream`。- 每个流式块均为 data: 开头,块之间以 \n\n 即两个换行符分隔,如下所示:- <CodeGroup>- ```streaming {{ title: 'Response' }}- data: {"event": "message", "task_id": "900bbd43-dc0b-4383-a372-aa6e6c414227", "id": "663c5084-a254-4040-8ad3-51f2a3c1a77c", "answer": "Hi", "created_at": 1705398420}\n\n- ```- </CodeGroup>-- 流式块中根据 event 不同,结构也不同:- - `event: message` LLM 返回文本块事件,即:完整的文本以分块的方式输出。- - `task_id` (string) 任务 ID,用于请求跟踪和下方的停止响应接口- - `message_id` (string) 消息唯一 ID- - `conversation_id` (string) 会话 ID- - `answer` (string) LLM 返回文本块内容- - `created_at` (int) 创建时间戳,如:1705395332- - `event: message_file` 文件事件,表示有新文件需要展示- - `id` (string) 文件唯一ID- - `type` (string) 文件类型,目前仅为image- - `belongs_to` (string) 文件归属,user或assistant,该接口返回仅为 `assistant`- - `url` (string) 文件访问地址- - `conversation_id` (string) 会话ID- - `event: message_end` 消息结束事件,收到此事件则代表流式返回结束。- - `task_id` (string) 任务 ID,用于请求跟踪和下方的停止响应接口- - `message_id` (string) 消息唯一 ID- - `conversation_id` (string) 会话 ID- - `metadata` (object) 元数据- - `usage` (Usage) 模型用量信息- - `retriever_resources` (array[RetrieverResource]) 引用和归属分段列表- - `event: tts_message` TTS 音频流事件,即:语音合成输出。内容是Mp3格式的音频块,使用 base64 编码后的字符串,播放的时候直接解码即可。(开启自动播放才有此消息)- - `task_id` (string) 任务 ID,用于请求跟踪和下方的停止响应接口- - `message_id` (string) 消息唯一 ID- - `audio` (string) 语音合成之后的音频块使用 Base64 编码之后的文本内容,播放的时候直接 base64 解码送入播放器即可- - `created_at` (int) 创建时间戳,如:1705395332- - `event: tts_message_end` TTS 音频流结束事件,收到这个事件表示音频流返回结束。- - `task_id` (string) 任务 ID,用于请求跟踪和下方的停止响应接口- - `message_id` (string) 消息唯一 ID- - `audio` (string) 结束事件是没有音频的,所以这里是空字符串- - `created_at` (int) 创建时间戳,如:1705395332- - `event: message_replace` 消息内容替换事件。- 开启内容审查和审查输出内容时,若命中了审查条件,则会通过此事件替换消息内容为预设回复。- - `task_id` (string) 任务 ID,用于请求跟踪和下方的停止响应接口- - `message_id` (string) 消息唯一 ID- - `conversation_id` (string) 会话 ID- - `answer` (string) 替换内容(直接替换 LLM 所有回复文本)- - `created_at` (int) 创建时间戳,如:1705395332- - `event: workflow_started` workflow 开始执行- - `task_id` (string) 任务 ID,用于请求跟踪和下方的停止响应接口- - `workflow_run_id` (string) workflow 执行 ID- - `event` (string) 固定为 `workflow_started`- - `data` (object) 详细内容- - `id` (string) workflow 执行 ID- - `workflow_id` (string) 关联 Workflow ID- - `created_at` (timestamp) 开始时间- - `event: node_started` node 开始执行- - `task_id` (string) 任务 ID,用于请求跟踪和下方的停止响应接口- - `workflow_run_id` (string) workflow 执行 ID- - `event` (string) 固定为 `node_started`- - `data` (object) 详细内容- - `id` (string) workflow 执行 ID- - `node_id` (string) 节点 ID- - `node_type` (string) 节点类型- - `title` (string) 节点名称- - `index` (int) 执行序号,用于展示 Tracing Node 顺序- - `predecessor_node_id` (string) 前置节点 ID,用于画布展示执行路径- - `inputs` (object) 节点中所有使用到的前置节点变量内容- - `created_at` (timestamp) 开始时间- - `event: node_finished` node 执行结束,成功失败同一事件中不同状态- - `task_id` (string) 任务 ID,用于请求跟踪和下方的停止响应接口- - `workflow_run_id` (string) workflow 执行 ID- - `event` (string) 固定为 `node_finished`- - `data` (object) 详细内容- - `id` (string) node 执行 ID- - `node_id` (string) 节点 ID- - `index` (int) 执行序号,用于展示 Tracing Node 顺序- - `predecessor_node_id` (string) optional 前置节点 ID,用于画布展示执行路径- - `inputs` (object) 节点中所有使用到的前置节点变量内容- - `process_data` (json) Optional 节点过程数据- - `outputs` (json) Optional 输出内容- - `status` (string) 执行状态 `running` / `succeeded` / `failed` / `stopped`- - `error` (string) Optional 错误原因- - `elapsed_time` (float) Optional 耗时(s)- - `execution_metadata` (json) 元数据- - `total_tokens` (int) optional 总使用 tokens- - `total_price` (decimal) optional 总费用- - `currency` (string) optional 货币,如 `USD` / `RMB`- - `created_at` (timestamp) 开始时间- - `event: human_input_required` Workflow 已暂停,等待 Human-in-the-Loop 输入- - `task_id` (string) 任务 ID,用于请求跟踪- - `workflow_run_id` (string) workflow 执行 ID- - `event` (string) 固定为 `human_input_required`- - `data` (object) 详细内容- - `form_id` (string) 人工输入表单 ID- - `node_id` (string) Human Input 节点 ID- - `node_title` (string) Human Input 节点标题- - `form_content` (string) 渲染后的表单内容- - `inputs` (array[object]) 表单输入项定义- - `actions` (array[object]) 用户可选动作按钮- - `id` (string) 动作 ID- - `title` (string) 按钮文案- - `button_style` (string) 按钮样式- - `display_in_ui` (bool) 是否需要在 UI 展示该表单- - `form_token` (string) 用于 `/form/human_input/:form_token` 接口的令牌- - `resolved_default_values` (object) 运行时解析后的默认值- - `expiration_time` (timestamp) 表单过期时间(Unix 秒级时间戳)- - `event: workflow_finished` workflow 执行结束,成功失败同一事件中不同状态- - `task_id` (string) 任务 ID,用于请求跟踪和下方的停止响应接口- - `workflow_run_id` (string) workflow 执行 ID- - `event` (string) 固定为 `workflow_finished`- - `data` (object) 详细内容- - `id` (string) workflow 执行 ID- - `workflow_id` (string) 关联 Workflow ID- - `status` (string) 执行状态 `running` / `succeeded` / `failed` / `stopped`- - `outputs` (json) Optional 输出内容- - `error` (string) Optional 错误原因- - `elapsed_time` (float) Optional 耗时(s)- - `total_tokens` (int) Optional 总使用 tokens- - `total_steps` (int) 总步数(冗余),默认 0- - `created_at` (timestamp) 开始时间- - `finished_at` (timestamp) 结束时间- - `event: error`- 流式输出过程中出现的异常会以 stream event 形式输出,收到异常事件后即结束。- - `task_id` (string) 任务 ID,用于请求跟踪和下方的停止响应接口- - `message_id` (string) 消息唯一 ID- - `status` (int) HTTP 状态码- - `code` (string) 错误码- - `message` (string) 错误消息- - `event: ping` 每 10s 一次的 ping 事件,保持连接存活。-- ### Errors- - 404,对话不存在- - 400,`invalid_param`,传入参数异常- - 400,`app_unavailable`,App 配置不可用- - 400,`provider_not_initialize`,无可用模型凭据配置- - 400,`provider_quota_exceeded`,模型调用额度不足- - 400,`model_currently_not_support`,当前模型不可用- - 400,`workflow_not_found`,指定的工作流版本未找到- - 400,`draft_workflow_error`,无法使用草稿工作流版本- - 400,`workflow_id_format_error`,工作流ID格式错误,需要UUID格式- - 400,`completion_request_error`,文本生成失败- - 403,`workflow_version_execution_not_allowed`,当前套餐不支持执行工作流版本,请升级至付费套餐- - 500,服务内部异常-- </Properties>- </Col>- <Col sticky>-- <CodeGroup- title="Request"- tag="POST"- label="/chat-messages"- targetCode={`curl -X POST '${props.appDetail.api_base_url}/chat-messages' \\---header 'Authorization: Bearer {api_key}' \\---header 'Content-Type: application/json' \\---data-raw '{- "inputs": ${JSON.stringify(props.inputs)},- "query": "What are the specs of the iPhone 13 Pro Max?",- "response_mode": "streaming",- "conversation_id": "",- "user": "abc-123",- "files": [- {- "type": "image",- "transfer_method": "remote_url",- "url": "https://cloud.dify.ai/logo/logo-site.png"- }- ]-}'`}- />- ### 阻塞模式- 阻塞模式可能返回普通聊天响应,也可能返回暂停中的工作流响应。-- 当 Advanced Chat 因 Human-in-the-Loop 暂停时,`event` 会变为 `workflow_paused`。- 响应仍然包含 `message_id`、`conversation_id`、`answer` 和 `workflow_run_id`,并且 `data` 中会新增 `paused_nodes` 和 `reasons`。- 对于 `human_input_required`,每个 reason 都会包含 `form_id` 和 `expiration_time`。-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "event": "message",- "task_id": "c3800678-a077-43df-a102-53f23ed20b88",- "id": "9da23599-e713-473b-982c-4328d4f5c78a",- "message_id": "9da23599-e713-473b-982c-4328d4f5c78a",- "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2",- "mode": "chat",- "answer": "iPhone 13 Pro Max specs are listed here:...",- "metadata": {- "usage": {- "prompt_tokens": 1033,- "prompt_unit_price": "0.001",- "prompt_price_unit": "0.001",- "prompt_price": "0.0010330",- "completion_tokens": 128,- "completion_unit_price": "0.002",- "completion_price_unit": "0.001",- "completion_price": "0.0002560",- "total_tokens": 1161,- "total_price": "0.0012890",- "currency": "USD",- "latency": 0.7682376249867957- },- "retriever_resources": [- {- "position": 1,- "dataset_id": "101b4c97-fc2e-463c-90b1-5261a4cdcafb",- "dataset_name": "iPhone",- "document_id": "8dd1ad74-0b5f-4175-b735-7d98bbbb4e00",- "document_name": "iPhone List",- "segment_id": "ed599c7f-2766-4294-9d1d-e5235a61270a",- "score": 0.98457545,- "content": "\"Model\",\"Release Date\",\"Display Size\",\"Resolution\",\"Processor\",\"RAM\",\"Storage\",\"Camera\",\"Battery\",\"Operating System\"\n\"iPhone 13 Pro Max\",\"September 24, 2021\",\"6.7 inch\",\"1284 x 2778\",\"Hexa-core (2x3.23 GHz Avalanche + 4x1.82 GHz Blizzard)\",\"6 GB\",\"128, 256, 512 GB, 1TB\",\"12 MP\",\"4352 mAh\",\"iOS 15\""- }- ]- },- "created_at": 1705407629- }- ```- </CodeGroup>- <CodeGroup title="Paused Response Example">- ```json {{ title: 'Paused Response Example' }}- {- "event": "workflow_paused",- "task_id": "8a9cbfcf-e7e0-4b17-aeef-24de57a2659a",- "id": "31714374-88cb-485f-9fa4-e3ab2a9ed95e",- "message_id": "31714374-88cb-485f-9fa4-e3ab2a9ed95e",- "conversation_id": "098e19be-356a-435d-9ec3-a406f4f1a97a",- "mode": "advanced-chat",- "answer": "",- "metadata": {- "annotation_reply": null,- "retriever_resources": [],- "usage": null- },- "created_at": 1776074715,- "workflow_run_id": "7a4d6509-8a65-4c7d-a4fd-cf081dcf169f",- "data": {- "id": "31714374-88cb-485f-9fa4-e3ab2a9ed95e",- "mode": "advanced-chat",- "conversation_id": "098e19be-356a-435d-9ec3-a406f4f1a97a",- "message_id": "31714374-88cb-485f-9fa4-e3ab2a9ed95e",- "workflow_run_id": "7a4d6509-8a65-4c7d-a4fd-cf081dcf169f",- "answer": "",- "metadata": {- "annotation_reply": null,- "retriever_resources": [],- "usage": null- },- "created_at": 1776074715,- "paused_nodes": [- "1775724080699"- ],- "reasons": [- {- "form_id": "019d864d-6f55-752c-9f4c-feee67508d5b",- "form_content": "this is form 2:\n\n{{#$output.some_field_2#}}\n",- "inputs": [- {- "type": "paragraph",- "output_variable_name": "some_field_2",- "default": {- "type": "constant",- "selector": [],- "value": ""- }- }- ],- "actions": [- {- "id": "approve",- "title": "yes",- "button_style": "default"- },- {- "id": "reject",- "title": "no",- "button_style": "default"- }- ],- "display_in_ui": true,- "node_id": "1775724080699",- "node_title": "Human Input 2",- "resolved_default_values": {},- "form_token": "0dvwTdpTFXgCZmAo2FoiJ5",- "type": "human_input_required",- "expiration_time": 1776333914- }- ],- "status": "paused",- "elapsed_time": 0.034081,- "total_tokens": 0,- "total_steps": 2- }- }- ```- </CodeGroup>- ### 流式模式- <CodeGroup title="Response">- ```streaming {{ title: 'Response' }}- data: {"event": "workflow_started", "task_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "workflow_run_id": "5ad498-f0c7-4085-b384-88cbe6290", "data": {"id": "5ad498-f0c7-4085-b384-88cbe6290", "workflow_id": "dfjasklfjdslag", "created_at": 1679586595}}- data: {"event": "node_started", "task_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "workflow_run_id": "5ad498-f0c7-4085-b384-88cbe6290", "data": {"id": "5ad498-f0c7-4085-b384-88cbe6290", "node_id": "dfjasklfjdslag", "node_type": "start", "title": "Start", "index": 0, "predecessor_node_id": "fdljewklfklgejlglsd", "inputs": {}, "created_at": 1679586595}}- data: {"event": "node_finished", "task_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "workflow_run_id": "5ad498-f0c7-4085-b384-88cbe6290", "data": {"id": "5ad498-f0c7-4085-b384-88cbe6290", "node_id": "dfjasklfjdslag", "node_type": "start", "title": "Start", "index": 0, "predecessor_node_id": "fdljewklfklgejlglsd", "inputs": {}, "outputs": {}, "status": "succeeded", "elapsed_time": 0.324, "execution_metadata": {"total_tokens": 63127864, "total_price": 2.378, "currency": "USD"}, "created_at": 1679586595}}- data: {"event": "workflow_finished", "task_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "workflow_run_id": "5ad498-f0c7-4085-b384-88cbe6290", "data": {"id": "5ad498-f0c7-4085-b384-88cbe6290", "workflow_id": "dfjasklfjdslag", "outputs": {}, "status": "succeeded", "elapsed_time": 0.324, "total_tokens": 63127864, "total_steps": "1", "created_at": 1679586595, "finished_at": 1679976595}}- data: {"event": "message", "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " I", "created_at": 1679586595}- data: {"event": "message", "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": "'m", "created_at": 1679586595}- data: {"event": "message", "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " glad", "created_at": 1679586595}- data: {"event": "message", "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " to", "created_at": 1679586595}- data: {"event": "message", "message_id" : "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " meet", "created_at": 1679586595}- data: {"event": "message", "message_id" : "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " you", "created_at": 1679586595}- data: {"event": "message_end", "id": "5e52ce04-874b-4d27-9045-b3bc80def685", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "metadata": {"usage": {"prompt_tokens": 1033, "prompt_unit_price": "0.001", "prompt_price_unit": "0.001", "prompt_price": "0.0010330", "completion_tokens": 135, "completion_unit_price": "0.002", "completion_price_unit": "0.001", "completion_price": "0.0002700", "total_tokens": 1168, "total_price": "0.0013030", "currency": "USD", "latency": 1.381760165997548}, "retriever_resources": [{"position": 1, "dataset_id": "101b4c97-fc2e-463c-90b1-5261a4cdcafb", "dataset_name": "iPhone", "document_id": "8dd1ad74-0b5f-4175-b735-7d98bbbb4e00", "document_name": "iPhone List", "segment_id": "ed599c7f-2766-4294-9d1d-e5235a61270a", "score": 0.98457545, "content": "\"Model\",\"Release Date\",\"Display Size\",\"Resolution\",\"Processor\",\"RAM\",\"Storage\",\"Camera\",\"Battery\",\"Operating System\"\n\"iPhone 13 Pro Max\",\"September 24, 2021\",\"6.7 inch\",\"1284 x 2778\",\"Hexa-core (2x3.23 GHz Avalanche + 4x1.82 GHz Blizzard)\",\"6 GB\",\"128, 256, 512 GB, 1TB\",\"12 MP\",\"4352 mAh\",\"iOS 15\""}]}}- data: {"event": "tts_message", "conversation_id": "23dd85f3-1a41-4ea0-b7a9-062734ccfaf9", "message_id": "a8bdc41c-13b2-4c18-bfd9-054b9803038c", "created_at": 1721205487, "task_id": "3bf8a0bb-e73b-4690-9e66-4e429bad8ee7", "audio": "qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq"}- data: {"event": "tts_message_end", "conversation_id": "23dd85f3-1a41-4ea0-b7a9-062734ccfaf9", "message_id": "a8bdc41c-13b2-4c18-bfd9-054b9803038c", "created_at": 1721205487, "task_id": "3bf8a0bb-e73b-4690-9e66-4e429bad8ee7", "audio": ""}- ```- </CodeGroup>- 流式模式同样可能因为 Human-in-the-Loop 而暂停。此时 SSE 流会先返回 `human_input_required`,随后返回 `workflow_paused`。-- <CodeGroup title="Paused Streaming Response Example">- ```streaming {{ title: 'Paused Streaming Response Example' }}- event: ping-- data: {- "event": "workflow_started",- "workflow_run_id": "a4959eb4-c852-4e0c-ac7a-348233f7f345",- "task_id": "0399c5c2-181b-4493-a78e-1421914e8a25",- "data": {- "id": "a4959eb4-c852-4e0c-ac7a-348233f7f345",- "workflow_id": "e46514f1-c008-41ff-94b0-4f33d4b97d36",- "inputs": {- "sys.files": [],- "sys.user_id": "abc-123",- "sys.app_id": "d1074979-f67e-4114-8691-e35878df9a89",- "sys.workflow_id": "e46514f1-c008-41ff-94b0-4f33d4b97d36",- "sys.workflow_run_id": "a4959eb4-c852-4e0c-ac7a-348233f7f345"- },- "created_at": 1776129228,- "reason": "initial"- }- }-- data: {- "event": "node_started",- "workflow_run_id": "a4959eb4-c852-4e0c-ac7a-348233f7f345",- "task_id": "0399c5c2-181b-4493-a78e-1421914e8a25",- "data": {- "id": "7d9bb041-5ecb-497f-a674-d8706eed0ab1",- "node_id": "1775717266623",- "node_type": "start",- "title": "User Input",- "index": 1,- "predecessor_node_id": null,- "inputs": null,- "inputs_truncated": false,- "created_at": 1776129228,- "extras": {},- "iteration_id": null,- "loop_id": null,- "agent_strategy": null- }- }-- data: {- "event": "node_finished",- "workflow_run_id": "a4959eb4-c852-4e0c-ac7a-348233f7f345",- "task_id": "0399c5c2-181b-4493-a78e-1421914e8a25",- "data": {- "id": "7d9bb041-5ecb-497f-a674-d8706eed0ab1",- "node_id": "1775717266623",- "node_type": "start",- "title": "User Input",- "index": 1,- "predecessor_node_id": null,- "inputs": {- "sys.files": [],- "sys.user_id": "abc-123",- "sys.app_id": "d1074979-f67e-4114-8691-e35878df9a89",- "sys.workflow_id": "e46514f1-c008-41ff-94b0-4f33d4b97d36",- "sys.workflow_run_id": "a4959eb4-c852-4e0c-ac7a-348233f7f345",- "sys.timestamp": 1776129228- },- "inputs_truncated": false,- "process_data": {},- "process_data_truncated": false,- "outputs": {- "sys.files": [],- "sys.user_id": "abc-123",- "sys.app_id": "d1074979-f67e-4114-8691-e35878df9a89",- "sys.workflow_id": "e46514f1-c008-41ff-94b0-4f33d4b97d36",- "sys.workflow_run_id": "a4959eb4-c852-4e0c-ac7a-348233f7f345",- "sys.timestamp": 1776129228- },- "outputs_truncated": false,- "status": "succeeded",- "error": null,- "elapsed_time": 0.000097,- "execution_metadata": null,- "created_at": 1776129228,- "finished_at": 1776129228,- "files": [],- "iteration_id": null,- "loop_id": null- }- }-- data: {- "event": "node_started",- "workflow_run_id": "a4959eb4-c852-4e0c-ac7a-348233f7f345",- "task_id": "0399c5c2-181b-4493-a78e-1421914e8a25",- "data": {- "id": "c09ff568-1d55-4f0d-9a07-512bcbfeb289",- "node_id": "1775717346519",- "node_type": "human-input",- "title": "Human Input",- "index": 1,- "predecessor_node_id": null,- "inputs": null,- "inputs_truncated": false,- "created_at": 1776129228,- "extras": {},- "iteration_id": null,- "loop_id": null,- "agent_strategy": null- }- }-- data: {- "event": "human_input_required",- "workflow_run_id": "a4959eb4-c852-4e0c-ac7a-348233f7f345",- "task_id": "0399c5c2-181b-4493-a78e-1421914e8a25",- "data": {- "form_id": "019d898d-3d80-7105-b920-9899ead4ff3e",- "node_id": "1775717346519",- "node_title": "Human Input",- "form_content": "this is form 1:\n{{#$output.some_field#}}\n",- "inputs": [- {- "type": "paragraph",- "output_variable_name": "some_field",- "default": {- "type": "variable",- "selector": [- "sys",- "workflow_run_id"- ],- "value": ""- }- }- ],- "actions": [- {- "id": "approve",- "title": "YES",- "button_style": "default"- },- {- "id": "reject",- "title": "NO",- "button_style": "default"- }- ],- "display_in_ui": true,- "form_token": "0Tb1nXYe4hzQUD706nHB4y",- "resolved_default_values": {- "some_field": "a4959eb4-c852-4e0c-ac7a-348233f7f345"- },- "expiration_time": 1776388428- }- }-- data: {- "event": "workflow_paused",- "workflow_run_id": "a4959eb4-c852-4e0c-ac7a-348233f7f345",- "task_id": "0399c5c2-181b-4493-a78e-1421914e8a25",- "data": {- "workflow_run_id": "a4959eb4-c852-4e0c-ac7a-348233f7f345",- "paused_nodes": [- "1775717346519"- ],- "outputs": {},- "reasons": [- {- "form_id": "019d898d-3d80-7105-b920-9899ead4ff3e",- "form_content": "this is form 1:\n{{#$output.some_field#}}\n",- "inputs": [- {- "type": "paragraph",- "output_variable_name": "some_field",- "default": {- "type": "variable",- "selector": [- "sys",- "workflow_run_id"- ],- "value": ""- }- }- ],- "actions": [- {- "id": "approve",- "title": "YES",- "button_style": "default"- },- {- "id": "reject",- "title": "NO",- "button_style": "default"- }- ],- "display_in_ui": true,- "node_id": "1775717346519",- "node_title": "Human Input",- "resolved_default_values": {- "some_field": "a4959eb4-c852-4e0c-ac7a-348233f7f345"- },- "form_token": "0Tb1nXYe4hzQUD706nHB4y",- "type": "human_input_required",- "expiration_time": 1776388428- }- ],- "status": "paused",- "created_at": 1776129228,- "elapsed_time": 0.070478,- "total_tokens": 0,- "total_steps": 2- }- }- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/files/upload'- method='POST'- title='上传文件'- name='#files-upload'-/>-<Row>- <Col>- 上传文件并在发送消息时使用,可实现图文多模态理解。- 支持您的应用程序所支持的所有格式。- <i>上传的文件仅供当前终端用户使用。</i>-- ### Request Body- 该接口需使用 `multipart/form-data` 进行请求。- <Properties>- <Property name='file' type='file' key='file'>- 要上传的文件。- </Property>- <Property name='user' type='string' key='user'>- 用户标识,用于定义终端用户的身份,必须和发送消息接口传入 user 保持一致。- </Property>- </Properties>-- ### Response- 成功上传后,服务器会返回文件的 ID 和相关信息。- - `id` (uuid) ID- - `name` (string) 文件名- - `size` (int) 文件大小(byte)- - `extension` (string) 文件后缀- - `mime_type` (string) 文件 mime-type- - `created_by` (uuid) 上传人 ID- - `created_at` (timestamp) 上传时间-- ### Errors- - 400,`no_file_uploaded`,必须提供文件- - 400,`too_many_files`,目前只接受一个文件- - 400,`unsupported_preview`,该文件不支持预览- - 400,`unsupported_estimate`,该文件不支持估算- - 413,`file_too_large`,文件太大- - 415,`unsupported_file_type`,不支持的扩展名,当前只接受文档类文件- - 503,`s3_connection_failed`,无法连接到 S3 服务- - 503,`s3_permission_denied`,无权限上传文件到 S3- - 503,`s3_file_too_large`,文件超出 S3 大小限制- </Col>- <Col sticky>-- <CodeGroup- title="Request"- tag="POST"- label="/files/upload"- targetCode={`curl -X POST '${props.appDetail.api_base_url}/files/upload' \\---header 'Authorization: Bearer {api_key}' \\---form 'file=@localfile;type=image/[png|jpeg|jpg|webp|gif]' \\---form 'user=abc-123'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "id": "72fa9618-8f89-4a37-9b33-7e1178a24a67",- "name": "example.png",- "size": 1024,- "extension": "png",- "mime_type": "image/png",- "created_by": 123,- "created_at": 1577836800,- }- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/end-users/:end_user_id'- method='GET'- title='获取终端用户'- name='#end-user'-/>-<Row>- <Col>- 通过终端用户 ID 获取终端用户信息。-- 当其他 API 返回终端用户 ID(例如:上传文件接口返回的 `created_by`)时,可使用该接口查询对应的终端用户信息。-- ### 路径参数- - `end_user_id` (uuid) 必需- 终端用户 ID。-- ### Response- 返回 EndUser 对象。- - `id` (uuid) ID- - `tenant_id` (uuid) 工作空间(Tenant)ID- - `app_id` (uuid) 应用 ID- - `type` (string) 终端用户类型- - `external_user_id` (string) 外部用户 ID- - `name` (string) 名称- - `is_anonymous` (boolean) 是否匿名- - `session_id` (string) 会话 ID- - `created_at` (string) ISO 8601 时间- - `updated_at` (string) ISO 8601 时间-- ### Errors- - 404,`end_user_not_found`,终端用户不存在- - 500,内部服务器错误-- </Col>- <Col sticky>- <CodeGroup- title="Request"- tag="GET"- label="/end-users/:end_user_id"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/end-users/6ad1ab0a-73ff-4ac1-b9e4-cdb312f71f13' \\---header 'Authorization: Bearer {api_key}'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "id": "6ad1ab0a-73ff-4ac1-b9e4-cdb312f71f13",- "tenant_id": "8c0f3f3a-66b0-4b55-a0bf-8b8e0d6aee7d",- "app_id": "6c8c3f41-2c6f-4e1b-8f4f-7f11c8f2ad2a",- "type": "service_api",- "external_user_id": "abc-123",- "name": "Alice",- "is_anonymous": false,- "session_id": "abc-123",- "created_at": "2024-01-01T00:00:00Z",- "updated_at": "2024-01-01T00:00:00Z"- }- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/files/:file_id/preview'- method='GET'- title='文件预览'- name='#file-preview'-/>-<Row>- <Col>- 预览或下载已上传的文件。此端点允许您访问先前通过文件上传 API 上传的文件。-- <i>文件只能在属于请求应用程序的消息范围内访问。</i>-- ### 路径参数- - `file_id` (string) 必需- 要预览的文件的唯一标识符,从文件上传 API 响应中获得。-- ### 查询参数- - `as_attachment` (boolean) 可选- 是否强制将文件作为附件下载。默认为 `false`(在浏览器中预览)。-- ### 响应- 返回带有适当浏览器显示或下载标头的文件内容。- - `Content-Type` 根据文件 MIME 类型设置- - `Content-Length` 文件大小(以字节为单位,如果可用)- - `Content-Disposition` 如果 `as_attachment=true` 则设置为 "attachment"- - `Cache-Control` 用于性能的缓存标头- - `Accept-Ranges` 对于音频/视频文件设置为 "bytes"-- ### 错误- - 400, `invalid_param`, 参数输入异常- - 403, `file_access_denied`, 文件访问被拒绝或文件不属于当前应用程序- - 404, `file_not_found`, 文件未找到或已被删除- - 500, 服务内部错误-- </Col>- <Col sticky>- ### 请求示例- <CodeGroup- title="Request"- tag="GET"- label="/files/:file_id/preview"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/files/72fa9618-8f89-4a37-9b33-7e1178a24a67/preview' \\---header 'Authorization: Bearer {api_key}'`}- />-- ### 作为附件下载- <CodeGroup- title="Download Request"- tag="GET"- label="/files/:file_id/preview?as_attachment=true"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/files/72fa9618-8f89-4a37-9b33-7e1178a24a67/preview?as_attachment=true' \\---header 'Authorization: Bearer {api_key}' \\---output downloaded_file.png`}- />-- ### 响应标头示例- <CodeGroup title="Response Headers">- ```http {{ title: 'Headers - 图片预览' }}- Content-Type: image/png- Content-Length: 1024- Cache-Control: public, max-age=3600- ```- </CodeGroup>-- ### 文件下载响应标头- <CodeGroup title="Download Response Headers">- ```http {{ title: 'Headers - 文件下载' }}- Content-Type: image/png- Content-Length: 1024- Content-Disposition: attachment; filename*=UTF-8''example.png- Cache-Control: public, max-age=3600- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/chat-messages/:task_id/stop'- method='POST'- title='停止响应'- name='#Stop'-/>-<Row>- <Col>- 仅支持流式模式。- ### Path- - `task_id` (string) 任务 ID,可在流式返回 Chunk 中获取-- ### Request Body- - `user` (string) Required- 用户标识,用于定义终端用户的身份,必须和发送消息接口传入 user 保持一致。API 无法访问 WebApp 创建的会话。- ### Response- - `result` (string) 固定返回 success- </Col>- <Col sticky>- <CodeGroup- title="Request"- tag="POST"- label="/chat-messages/:task_id/stop"- targetCode={`curl -X POST '${props.appDetail.api_base_url}/chat-messages/:task_id/stop' \\--H 'Authorization: Bearer {api_key}' \\--H 'Content-Type: application/json' \\---data-raw '{- "user": "abc-123"-}'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "result": "success"- }- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/form/human_input/:form_token'- method='GET'- title='获取人工输入表单'- name='#get-human-input-form'-/>-<Row>- <Col>- 通过 `form_token` 获取待处理的 Human-in-the-Loop 表单。-- 当流式事件返回 `human_input_required`(包含 `form_token`)时,可调用此接口拉取表单详情。-- ### Path- - `form_token` (string) 必填,暂停事件返回的表单 token-- ### Response- - `form_content` (string) 已渲染的表单内容(markdown/plain text)- - `inputs` (array[object]) 表单输入项定义- - `resolved_default_values` (object) 已解析的默认值(字符串)- - `user_actions` (array[object]) 操作按钮列表- - `expiration_time` (timestamp) 表单过期时间(Unix 秒)-- ### Errors- - 404,表单不存在或不属于当前应用- - 412,`human_input_form_submitted`,表单已被提交- - 412,`human_input_form_expired`,表单已过期- </Col>- <Col sticky>- <CodeGroup- title="Request"- tag="GET"- label="/form/human_input/:form_token"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/form/human_input/{form_token}' \\---header 'Authorization: Bearer {api_key}'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "form_content": "请确认最终结果:{{#$output.answer#}}",- "inputs": [- {- "label": "答案",- "type": "text-input",- "required": true,- "output_variable_name": "answer"- }- ],- "resolved_default_values": {- "answer": "初始值"- },- "user_actions": [- { "id": "approve", "title": "通过", "button_style": "primary" },- { "id": "reject", "title": "拒绝", "button_style": "warning" }- ],- "expiration_time": 1735689600- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/form/human_input/:form_token'- method='POST'- title='提交人工输入表单'- name='#submit-human-input-form'-/>-<Row>- <Col>- 提交待处理的 Human-in-the-Loop 表单。-- ### Path- - `form_token` (string) 必填,暂停事件返回的表单 token-- ### Request Body- - `inputs` (object) 必填,表单字段的 key/value- - `action` (string) 必填,从 `user_actions` 中选择的动作 ID- - `user` (string) 必填,终端用户标识-- ### Response- 成功时返回空对象。-- ### Errors- - 400,`invalid_form_data`,提交数据与表单 schema 不匹配- - 404,表单不存在或不属于当前应用- - 412,`human_input_form_submitted`,表单已被提交- - 412,`human_input_form_expired`,表单已过期- </Col>- <Col sticky>- <CodeGroup- title="Request"- tag="POST"- label="/form/human_input/:form_token"- targetCode={`curl -X POST '${props.appDetail.api_base_url}/form/human_input/{form_token}' \\---header 'Authorization: Bearer {api_key}' \\---header 'Content-Type: application/json' \\---data-raw '{- "inputs": {"answer": "已确认答案"},- "action": "approve",- "user": "abc-123"-}'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {}- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/workflow/:task_id/events'- method='GET'- title='获取恢复后的 Workflow 事件流'- name='#get-workflow-resume-events'-/>-<Row>- <Col>- 在提交人工输入表单后,继续订阅工作流后续执行事件。-- 返回 `text/event-stream`,可持续接收直到工作流结束。-- ### Path- - `task_id` (string) 必填,workflow 运行 ID(`workflow_run_id`)-- ### Query- - `user` (string) 必填,终端用户标识- - `include_state_snapshot` (bool) 可选,设为 `true` 时会先回放持久化状态快照,再继续实时事件- - `continue_on_pause` (bool) 可选,设为 `true` 时,流会在 `workflow_paused` 事件之间保持连接,直到 `workflow_finished` 才结束-- ### Response- Server-Sent Events 流(`text/event-stream`)。- 常见事件包括 `workflow_paused`、`node_started`、`node_finished`、`human_input_form_filled`、`human_input_form_timeout`、`workflow_finished`。- 如果调用该接口时工作流已经结束,服务端会立即返回单个完成事件。- </Col>- <Col sticky>- <CodeGroup- title="Request"- tag="GET"- label="/workflow/:task_id/events"- targetCode={`curl -N -X GET '${props.appDetail.api_base_url}/workflow/{workflow_run_id}/events?user=abc-123&continue_on_pause=true' \\---header 'Authorization: Bearer {api_key}'`}- />-- <CodeGroup title="Response">- ```streaming {{ title: 'Response' }}- event: ping-- data: {"event":"workflow_started","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","data":{"id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","workflow_id":"e46514f1-c008-41ff-94b0-4f33d4b97d36","inputs":{"sys.files":[],"sys.user_id":"abc-123","sys.app_id":"d1074979-f67e-4114-8691-e35878df9a89","sys.workflow_id":"e46514f1-c008-41ff-94b0-4f33d4b97d36","sys.workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","sys.timestamp":1776087863},"created_at":1776087863,"reason":"initial"}}-- data: {"event":"node_started","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","data":{"id":"b552d685-1119-4e6a-9a81-e91a23e5324b","node_id":"1775717266623","node_type":"start","title":"User Input","index":1,"predecessor_node_id":null,"inputs":null,"created_at":1776087863,"extras":{},"iteration_id":null,"loop_id":null}}-- data: {"event":"node_finished","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","data":{"id":"b552d685-1119-4e6a-9a81-e91a23e5324b","node_id":"1775717266623","node_type":"start","title":"User Input","index":1,"predecessor_node_id":null,"inputs":null,"process_data":null,"outputs":null,"status":"succeeded","error":null,"elapsed_time":0.00032,"execution_metadata":null,"created_at":1776087863,"finished_at":1776087863,"files":[],"iteration_id":null,"loop_id":null}}-- data: {"event":"node_started","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","data":{"id":"8d7e8e01-5159-4089-a4b6-3aa394992cc2","node_id":"1775717346519","node_type":"human-input","title":"Human Input","index":2,"predecessor_node_id":null,"inputs":null,"created_at":1776087863,"extras":{},"iteration_id":null,"loop_id":null}}-- data: {"event":"node_finished","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","data":{"id":"8d7e8e01-5159-4089-a4b6-3aa394992cc2","node_id":"1775717346519","node_type":"human-input","title":"Human Input","index":2,"predecessor_node_id":null,"inputs":null,"process_data":null,"outputs":null,"status":"paused","error":null,"elapsed_time":0.007381,"execution_metadata":null,"created_at":1776087863,"finished_at":1776087863,"files":[],"iteration_id":null,"loop_id":null}}-- data: {"event":"workflow_paused","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","data":{"workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","paused_nodes":["1775717346519"],"outputs":{},"reasons":[{"form_id":"019d8716-0fde-75da-8207-1458ccde76e5","form_content":"this is form 1:\n{{#$output.some_field#}}\n","inputs":[{"type":"paragraph","output_variable_name":"some_field","default":{"type":"variable","selector":["sys","workflow_run_id"],"value":""}}],"actions":[{"id":"approve","title":"YES","button_style":"default"},{"id":"reject","title":"NO","button_style":"default"}],"display_in_ui":true,"node_id":"1775717346519","node_title":"Human Input","resolved_default_values":{"some_field":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c"},"form_token":"n7hFG4ZDYdGcgZ5VDc7EGM","type":"human_input_required"}],"status":"paused","created_at":1776087863,"elapsed_time":0.0,"total_tokens":0,"total_steps":2}}-- data: {"event":"workflow_started","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","data":{"id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","workflow_id":"e46514f1-c008-41ff-94b0-4f33d4b97d36","inputs":{"sys.files":[],"sys.user_id":"abc-123","sys.app_id":"d1074979-f67e-4114-8691-e35878df9a89","sys.workflow_id":"e46514f1-c008-41ff-94b0-4f33d4b97d36","sys.workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c"},"created_at":1776087877,"reason":"resumption"}}-- data: {"event":"node_started","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","data":{"id":"8d7e8e01-5159-4089-a4b6-3aa394992cc2","node_id":"1775717346519","node_type":"human-input","title":"Human Input","index":1,"predecessor_node_id":null,"inputs":null,"inputs_truncated":false,"created_at":1776087877,"extras":{},"iteration_id":null,"loop_id":null,"agent_strategy":null}}-- data: {"event":"human_input_form_filled","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","data":{"node_id":"1775717346519","node_title":"Human Input","rendered_content":"this is form 1:\nfield 1 filled!\n","action_id":"approve","action_text":"YES"}}-- data: {"event":"node_finished","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","data":{"id":"8d7e8e01-5159-4089-a4b6-3aa394992cc2","node_id":"1775717346519","node_type":"human-input","title":"Human Input","index":1,"predecessor_node_id":null,"inputs":{},"inputs_truncated":false,"process_data":{},"process_data_truncated":false,"outputs":{"some_field":"field 1 filled!","some_field_2":"from bruno with love","__action_id":"approve","__rendered_content":"this is form 1:\nfield 1 filled!\n"},"outputs_truncated":false,"status":"succeeded","error":null,"elapsed_time":0.004431,"execution_metadata":null,"created_at":1776087877,"finished_at":1776087877,"files":[],"iteration_id":null,"loop_id":null}}-- data: {"event":"node_started","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","data":{"id":"6d8fc3cb-19f7-440b-b83e-eed4e847a332","node_id":"1775717350710","node_type":"template-transform","title":"Template","index":1,"predecessor_node_id":null,"inputs":null,"inputs_truncated":false,"created_at":1776087877,"extras":{},"iteration_id":null,"loop_id":null,"agent_strategy":null}}-- data: {"event":"text_chunk","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","data":{"text":"field 1 filled!","from_variable_selector":["1775717350710","output"]}}-- data: {"event":"node_finished","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","data":{"id":"6d8fc3cb-19f7-440b-b83e-eed4e847a332","node_id":"1775717350710","node_type":"template-transform","title":"Template","index":1,"predecessor_node_id":null,"inputs":{"some_field":"field 1 filled!"},"inputs_truncated":false,"process_data":{},"process_data_truncated":false,"outputs":{"output":"field 1 filled!"},"outputs_truncated":false,"status":"succeeded","error":null,"elapsed_time":0.264614,"execution_metadata":null,"created_at":1776087877,"finished_at":1776087877,"files":[],"iteration_id":null,"loop_id":null}}-- data: {"event":"node_started","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","data":{"id":"e88dec7e-aa2c-41f7-8d73-032b749e23f5","node_id":"1775717354177","node_type":"end","title":"Output","index":1,"predecessor_node_id":null,"inputs":null,"inputs_truncated":false,"created_at":1776087877,"extras":{},"iteration_id":null,"loop_id":null,"agent_strategy":null}}-- data: {"event":"node_finished","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","data":{"id":"e88dec7e-aa2c-41f7-8d73-032b749e23f5","node_id":"1775717354177","node_type":"end","title":"Output","index":1,"predecessor_node_id":null,"inputs":{"output":"field 1 filled!"},"inputs_truncated":false,"process_data":{},"process_data_truncated":false,"outputs":{"output":"field 1 filled!"},"outputs_truncated":false,"status":"succeeded","error":null,"elapsed_time":0.00003,"execution_metadata":null,"created_at":1776087877,"finished_at":1776087877,"files":[],"iteration_id":null,"loop_id":null}}-- data: {"event":"workflow_finished","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","data":{"id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","workflow_id":"e46514f1-c008-41ff-94b0-4f33d4b97d36","status":"succeeded","outputs":{"output":"field 1 filled!"},"error":null,"elapsed_time":0.364935,"total_tokens":0,"total_steps":5,"created_by":{"id":"7932d34c-dcf4-4fba-b770-f2a9de88c0a0","user":"abc-123"},"created_at":1776087877,"finished_at":1776087877,"exceptions_count":0,"files":[]}}- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/messages/:message_id/feedbacks'- method='POST'- title='消息反馈(点赞)'- name='#feedbacks'-/>-<Row>- <Col>- 消息终端用户反馈、点赞,方便应用开发者优化输出预期。-- ### Path Params- <Properties>- <Property name='message_id' type='string' key='message_id'>- 消息 ID- </Property>- </Properties>-- ### Request Body-- <Properties>- <Property name='rating' type='string' key='rating'>- 点赞 like, 点踩 dislike, 撤销点赞 null- </Property>- <Property name='user' type='string' key='user'>- 用户标识,由开发者定义规则,需保证用户标识在应用内唯一。- </Property>- <Property name='content' type='string' key='content'>- 消息反馈的具体信息。- </Property>- </Properties>-- ### Response- - `result` (string) 固定返回 success- </Col>- <Col sticky>-- <CodeGroup- title="Request"- tag="POST"- label="/messages/:message_id/feedbacks"- targetCode={`curl -X POST '${props.appDetail.api_base_url}/messages/:message_id/feedbacks' \\---header 'Authorization: Bearer {api_key}' \\---header 'Content-Type: application/json' \\---data-raw '{- "rating": "like",- "user": "abc-123",- "content": "message feedback information"-}'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "result": "success"- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/app/feedbacks'- method='GET'- title='获取APP的消息点赞和反馈'- name='#app-feedbacks'-/>-<Row>- <Col>- 获取应用的终端用户反馈、点赞。-- ### Query- <Properties>- <Property name='page' type='string' key='page'>- (选填)分页,默认值:1- </Property>- </Properties>-- <Properties>- <Property name='limit' type='string' key='limit'>- (选填)每页数量,默认值:20- </Property>- </Properties>-- ### Response- - `data` (List) 返回该APP的点赞、反馈列表。- </Col>- <Col sticky>-- <CodeGroup- title="Request"- tag="GET"- label="/app/feedbacks"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/app/feedbacks?page=1&limit=20' \\---header 'Authorization: Bearer {api_key}' \\---header 'Content-Type: application/json'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "data": [- {- "id": "8c0fbed8-e2f9-49ff-9f0e-15a35bdd0e25",- "app_id": "f252d396-fe48-450e-94ec-e184218e7346",- "conversation_id": "2397604b-9deb-430e-b285-4726e51fd62d",- "message_id": "709c0b0f-0a96-4a4e-91a4-ec0889937b11",- "rating": "like",- "content": "message feedback information-3",- "from_source": "user",- "from_end_user_id": "74286412-9a1a-42c1-929c-01edb1d381d5",- "from_account_id": null,- "created_at": "2025-04-24T09:24:38",- "updated_at": "2025-04-24T09:24:38"- }- ]- }-- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/messages/{message_id}/suggested'- method='GET'- title='获取下一轮建议问题列表'- name='#suggested'-/>-<Row>- <Col>- 获取下一轮建议问题列表。-- ### Path Params-- <Properties>- <Property name='message_id' type='string' key='message_id'>- Message ID- </Property>- </Properties>-- ### Query- <Properties>- <Property name='user' type='string' key='user'>- 用户标识,由开发者定义规则,需保证用户标识在应用内唯一。- </Property>- </Properties>- </Col>- <Col sticky>-- <CodeGroup- title="Request"- tag="GET"- label="/messages/{message_id}/suggested"- targetCode={`curl --location --request GET '${props.appDetail.api_base_url}/messages/{message_id}/suggested?user=abc-123' \\---header 'Authorization: Bearer ENTER-YOUR-SECRET-KEY' \\---header 'Content-Type: application/json'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "result": "success",- "data": [- "a",- "b",- "c"- ]- }- ```- </CodeGroup>- </Col>-</Row>------------<Heading- url='/messages'- method='GET'- title='获取会话历史消息'- name='#messages'-/>-<Row>- <Col>- 滚动加载形式返回历史聊天记录,第一页返回最新 `limit` 条,即:倒序返回。-- ### Query-- <Properties>- <Property name='conversation_id' type='string' key='conversation_id'>- 会话 ID- </Property>- <Property name='user' type='string' key='user'>- 用户标识,由开发者定义规则,需保证用户标识在应用内唯一。- </Property>- <Property name='first_id' type='string' key='first_id'>- 当前页第一条聊天记录的 ID,默认 null- </Property>- <Property name='limit' type='int' key='limit'>- 一次请求返回多少条聊天记录,默认 20 条。- </Property>- </Properties>-- ### Response- - `data` (array[object]) 消息列表- - `id` (string) 消息 ID- - `conversation_id` (string) 会话 ID- - `inputs` (object) 用户输入参数。- - `query` (string) 用户输入 / 提问内容。- - `message_files` (array[object]) 消息文件- - `id` (string) ID- - `type` (string) 文件类型,image 图片- - `url` (string) 文件预览地址,使用文件预览 API (`/files/{file_id}/preview`) 访问文件- - `belongs_to` (string) 文件归属方,user 或 assistant- - `answer` (string) 回答消息内容- - `created_at` (timestamp) 创建时间- - `feedback` (object) 反馈信息- - `rating` (string) 点赞 like / 点踩 dislike- - `retriever_resources` (array[RetrieverResource]) 引用和归属分段列表- - `has_more` (bool) 是否存在下一页- - `limit` (int) 返回条数,若传入超过系统限制,返回系统限制数量- </Col>- <Col sticky>- ### Request Example- <CodeGroup- title="Request"- tag="GET"- label="/messages"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/messages?user=abc-123&conversation_id={conversation_id}'---header 'Authorization: Bearer {api_key}'`}- />-- ### Response Example- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "limit": 20,- "has_more": false,- "data": [- {- "id": "a076a87f-31e5-48dc-b452-0061adbbc922",- "conversation_id": "cd78daf6-f9e4-4463-9ff2-54257230a0ce",- "inputs": {- "name": "dify"- },- "query": "iphone 13 pro",- "answer": "The iPhone 13 Pro, released on September 24, 2021, features a 6.1-inch display with a resolution of 1170 x 2532. It is equipped with a Hexa-core (2x3.23 GHz Avalanche + 4x1.82 GHz Blizzard) processor, 6 GB of RAM, and offers storage options of 128 GB, 256 GB, 512 GB, and 1 TB. The camera is 12 MP, the battery capacity is 3095 mAh, and it runs on iOS 15.",- "message_files": [],- "feedback": null,- "retriever_resources": [- {- "position": 1,- "dataset_id": "101b4c97-fc2e-463c-90b1-5261a4cdcafb",- "dataset_name": "iPhone",- "document_id": "8dd1ad74-0b5f-4175-b735-7d98bbbb4e00",- "document_name": "iPhone List",- "segment_id": "ed599c7f-2766-4294-9d1d-e5235a61270a",- "score": 0.98457545,- "content": "\"Model\",\"Release Date\",\"Display Size\",\"Resolution\",\"Processor\",\"RAM\",\"Storage\",\"Camera\",\"Battery\",\"Operating System\"\n\"iPhone 13 Pro Max\",\"September 24, 2021\",\"6.7 inch\",\"1284 x 2778\",\"Hexa-core (2x3.23 GHz Avalanche + 4x1.82 GHz Blizzard)\",\"6 GB\",\"128, 256, 512 GB, 1TB\",\"12 MP\",\"4352 mAh\",\"iOS 15\""- }- ],- "created_at": 1705569239- }- ]- }- ```- </CodeGroup>-- ### Response Example(智能助手)- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "limit": 20,- "has_more": false,- "data": [- {- "id": "d35e006c-7c4d-458f-9142-be4930abdf94",- "conversation_id": "957c068b-f258-4f89-ba10-6e8a0361c457",- "inputs": {},- "query": "draw a cat",- "answer": "I have generated an image of a cat for you. Please check your messages to view the image.",- "message_files": [- {- "id": "976990d2-5294-47e6-8f14-7356ba9d2d76",- "type": "image",- "url": "http://127.0.0.1:5001/files/tools/976990d2-5294-47e6-8f14-7356ba9d2d76.png?timestamp=1705988524&nonce=55df3f9f7311a9acd91bf074cd524092&sign=z43nMSO1L2HBvoqADLkRxr7Biz0fkjeDstnJiCK1zh8=",- "belongs_to": "assistant"- }- ],- "feedback": null,- "retriever_resources": [],- "created_at": 1705988187- }- ]- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/conversations'- method='GET'- title='获取会话列表'- name='#conversations'-/>-<Row>- <Col>- 获取当前用户的会话列表,默认返回最近的 20 条。-- ### Query-- <Properties>- <Property name='user' type='string' key='user'>- 用户标识,由开发者定义规则,需保证用户标识在应用内唯一。- </Property>- <Property name='last_id' type='string' key='last_id'>- (选填)当前页最后面一条记录的 ID,默认 null- </Property>- <Property name='limit' type='int' key='limit'>- (选填)一次请求返回多少条记录,默认 20 条,最大 100 条,最小 1 条。- </Property>- <Property name='sort_by' type='string' key='sort_by'>- (选填)排序字段,默认 -updated_at(按更新时间倒序排列)- - 可选值:created_at, -created_at, updated_at, -updated_at- - 字段前面的符号代表顺序或倒序,-代表倒序- </Property>- </Properties>-- ### Response- - `data` (array[object]) 会话列表- - `id` (string) 会话 ID- - `name` (string) 会话名称,默认由大语言模型生成。- - `inputs` (object) 用户输入参数。- - `status` (string) 会话状态- - `introduction` (string) 开场白- - `created_at` (timestamp) 创建时间- - `updated_at` (timestamp) 更新时间- - `has_more` (bool)- - `limit` (int) 返回条数,若传入超过系统限制,返回系统限制数量-- </Col>- <Col sticky>-- <CodeGroup- title="Request"- tag="GET"- label="/conversations"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/conversations?user=abc-123&last_id=&limit=20' \\---header 'Authorization: Bearer {api_key}'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "limit": 20,- "has_more": false,- "data": [- {- "id": "10799fb8-64f7-4296-bbf7-b42bfbe0ae54",- "name": "New chat",- "inputs": {- "book": "book",- "myName": "Lucy"- },- "status": "normal",- "created_at": 1679667915,- "updated_at": 1679667915- },- {- "id": "hSIhXBhNe8X1d8Et"- // ...- }- ]- }- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/conversations/:conversation_id'- method='DELETE'- title='删除会话'- name='#delete'-/>-<Row>- <Col>- 删除会话。-- ### Path- - `conversation_id` (string) 会话 ID-- ### Request Body-- <Properties>- <Property name='user' type='string' key='user'>- 用户标识,由开发者定义规则,需保证用户标识在应用内唯一。- </Property>- </Properties>-- ### Response- - `result` (string) 固定返回 success- </Col>- <Col sticky>-- <CodeGroup- title="Request"- tag="DELETE"- label="/conversations/:conversation_id"- targetCode={`curl -X DELETE '${props.appDetail.api_base_url}/conversations/{conversation_id}' \\---header 'Content-Type: application/json' \\---header 'Accept: application/json' \\---header 'Authorization: Bearer {api_key}' \\---data '{- "user": "abc-123"-}'`}- />-- <CodeGroup title="Response">- ```text {{ title: 'Response' }}- 204 No Content- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/conversations/:conversation_id/name'- method='POST'- title='会话重命名'- name='#rename'-/>-<Row>- <Col>- 对会话进行重命名,会话名称用于显示在支持多会话的客户端上。-- ### Path- - `conversation_id` (string) 会话 ID-- ### Request Body-- <Properties>- <Property name='name' type='string' key='name'>- (选填)名称,若 `auto_generate` 为 `true` 时,该参数可不传。- </Property>- <Property name='auto_generate' type='bool' key='auto_generate'>- (选填)自动生成标题,默认 false。- </Property>- <Property name='user' type='string' key='user'>- 用户标识,由开发者定义规则,需保证用户标识在应用内唯一。- </Property>- </Properties>-- ### Response- - `id` (string) 会话 ID- - `name` (string) 会话名称- - `inputs` (object) 用户输入参数- - `status` (string) 会话状态- - `introduction` (string) 开场白- - `created_at` (timestamp) 创建时间- - `updated_at` (timestamp) 更新时间- </Col>- <Col sticky>-- <CodeGroup- title="Request"- tag="POST"- label="/conversations/:conversation_id/name"- targetCode={`curl -X POST '${props.appDetail.api_base_url}/conversations/{conversation_id}/name' \\---header 'Content-Type: application/json' \\---header 'Authorization: Bearer {api_key}' \\---data-raw '{- "name": "",- "auto_generate": true,- "user": "abc-123"-}'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "id": "34d511d5-56de-4f16-a997-57b379508443",- "name": "hello",- "inputs": {},- "status": "normal",- "introduction": "",- "created_at": 1732731141,- "updated_at": 1732734510- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/conversations/:conversation_id/variables'- method='GET'- title='获取对话变量'- name='#conversation-variables'-/>-<Row>- <Col>- 从特定对话中检索变量。此端点对于提取对话过程中捕获的结构化数据非常有用。-- ### 路径参数-- <Properties>- <Property name='conversation_id' type='string' key='conversation_id'>- 要从中检索变量的对话ID。- </Property>- </Properties>-- ### 查询参数-- <Properties>- <Property name='user' type='string' key='user'>- 用户标识符,由开发人员定义的规则,在应用程序内必须唯一。- </Property>- <Property name='last_id' type='string' key='last_id'>- (选填)当前页最后面一条记录的 ID,默认 null- </Property>- <Property name='limit' type='int' key='limit'>- (选填)一次请求返回多少条记录,默认 20 条,最大 100 条,最小 1 条。- </Property>- </Properties>-- ### 响应-- - `limit` (int) 每页项目数- - `has_more` (bool) 是否有更多项目- - `data` (array[object]) 变量列表- - `id` (string) 变量 ID- - `name` (string) 变量名称- - `value_type` (string) 变量类型(字符串、数字、布尔等)- - `value` (string) 变量值- - `description` (string) 变量描述- - `created_at` (int) 创建时间戳- - `updated_at` (int) 最后更新时间戳-- ### 错误- - 404, `conversation_not_exists`, 对话不存在-- </Col>- <Col sticky>-- <CodeGroup- title="Request"- tag="GET"- label="/conversations/:conversation_id/variables"- debug="true"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/conversations/{conversation_id}/variables?user=abc-123' \\---header 'Authorization: Bearer {api_key}'`} />-- <CodeGroup- title="带变量名过滤的请求"- language="bash"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/conversations/{conversation_id}/variables?user=abc-123&variable_name=customer_name' \\---header 'Authorization: Bearer {api_key}'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "limit": 100,- "has_more": false,- "data": [- {- "id": "variable-uuid-1",- "name": "customer_name",- "value_type": "string",- "value": "John Doe",- "description": "客户名称(从对话中提取)",- "created_at": 1650000000000,- "updated_at": 1650000000000- },- {- "id": "variable-uuid-2",- "name": "order_details",- "value_type": "json",- "value": "{\"product\":\"Widget\",\"quantity\":5,\"price\":19.99}",- "description": "客户的订单详情",- "created_at": 1650000000000,- "updated_at": 1650000000000- }- ]- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/conversations/:conversation_id/variables/:variable_id'- method='PUT'- title='更新对话变量'- name='#update-conversation-variable'-/>-<Row>- <Col>- 更新特定对话变量的值。此端点允许您修改在对话过程中捕获的变量值,同时保留其名称、类型和描述。-- ### 路径参数-- <Properties>- <Property name='conversation_id' type='string' key='conversation_id'>- 包含要更新变量的对话ID。- </Property>- <Property name='variable_id' type='string' key='variable_id'>- 要更新的变量ID。- </Property>- </Properties>-- ### 请求体-- <Properties>- <Property name='value' type='any' key='value'>- 变量的新值。必须匹配变量的预期类型(字符串、数字、对象等)。- </Property>- <Property name='user' type='string' key='user'>- 用户标识符,由开发人员定义的规则,在应用程序内必须唯一。- </Property>- </Properties>-- ### 响应-- 返回包含以下内容的更新变量对象:- - `id` (string) 变量ID- - `name` (string) 变量名称- - `value_type` (string) 变量类型(字符串、数字、对象等)- - `value` (any) 更新后的变量值- - `description` (string) 变量描述- - `created_at` (int) 创建时间戳- - `updated_at` (int) 最后更新时间戳-- ### 错误- - 400, `Type mismatch: variable expects {expected_type}, but got {actual_type} type`, 值类型与变量的预期类型不匹配- - 404, `conversation_not_exists`, 对话不存在- - 404, `conversation_variable_not_exists`, 变量不存在-- </Col>- <Col sticky>-- <CodeGroup- title="Request"- tag="PUT"- label="/conversations/:conversation_id/variables/:variable_id"- targetCode={`curl -X PUT '${props.appDetail.api_base_url}/conversations/{conversation_id}/variables/{variable_id}' \\---header 'Content-Type: application/json' \\---header 'Authorization: Bearer {api_key}' \\---data-raw '{- "value": "Updated Value",- "user": "abc-123"-}'`}- />-- <CodeGroup- title="使用不同值类型更新"- targetCode={[- {- title: '字符串值',- code: `curl -X PUT '${props.appDetail.api_base_url}/conversations/{conversation_id}/variables/{variable_id}' \\---header 'Content-Type: application/json' \\---header 'Authorization: Bearer {api_key}' \\---data-raw '{- "value": "新的字符串值",- "user": "abc-123"-}'`,- }, {- title: '数字值',- code: `curl -X PUT '${props.appDetail.api_base_url}/conversations/{conversation_id}/variables/{variable_id}' \\---header 'Content-Type: application/json' \\---header 'Authorization: Bearer {api_key}' \\---data-raw '{- "value": 42,- "user": "abc-123"-}'`,- }, {- title: '对象值',- code: `curl -X PUT '${props.appDetail.api_base_url}/conversations/{conversation_id}/variables/{variable_id}' \\---header 'Content-Type: application/json' \\---header 'Authorization: Bearer {api_key}' \\---data-raw '{- "value": {"product": "Widget", "quantity": 10, "price": 29.99},- "user": "abc-123"-}'`,- },- ]}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "id": "variable-uuid-1",- "name": "customer_name",- "value_type": "string",- "value": "Updated Value",- "description": "客户名称(从对话中提取)",- "created_at": 1650000000000,- "updated_at": 1650000001000- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/audio-to-text'- method='POST'- title='语音转文字'- name='#audio-to-text'-/>-<Row>- <Col>- ### Request Body- 该接口需使用 `multipart/form-data` 进行请求。- <Properties>- <Property name='file' type='file' key='file'>- 语音文件。- 支持格式:`['mp3', 'mp4', 'mpeg', 'mpga', 'm4a', 'wav', 'webm']`- 文件大小限制:15MB- </Property>- <Property name='user' type='string' key='user'>- 用户标识,由开发者定义规则,需保证用户标识在应用内唯一。- </Property>- </Properties>-- ### Response- - `text` (string) 输出文字- </Col>- <Col sticky>-- <CodeGroup- title="Request"- tag="POST"- label="/audio-to-text"- targetCode={`curl -X POST '${props.appDetail.api_base_url}/audio-to-text' \\---header 'Authorization: Bearer {api_key}' \\---form 'file=@localfile;type=audio/[mp3|mp4|mpeg|mpga|m4a|wav|webm]'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "text": "hello"- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/text-to-audio'- method='POST'- title='文字转语音'- name='#text-to-audio'-/>-<Row>- <Col>- 文字转语音。-- ### Request Body-- <Properties>- <Property name='message_id' type='str' key='message_id'>- Dify 生成的文本消息,那么直接传递生成的message-id 即可,后台会通过 message_id 查找相应的内容直接合成语音信息。如果同时传 message_id 和 text,优先使用 message_id。- </Property>- <Property name='text' type='str' key='text'>- 语音生成内容。如果没有传 message-id的话,则会使用这个字段的内容- </Property>- <Property name='user' type='string' key='user'>- 用户标识,由开发者定义规则,需保证用户标识在应用内唯一。- </Property>- </Properties>- </Col>- <Col sticky>-- <CodeGroup- title="Request"- tag="POST"- label="/text-to-audio"- targetCode={`curl -o text-to-audio.mp3 -X POST '${props.appDetail.api_base_url}/text-to-audio' \\---header 'Authorization: Bearer {api_key}' \\---header 'Content-Type: application/json' \\---data-raw '{- "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290",- "text": "Hello Dify",- "user": "abc-123",-}'`}- />-- <CodeGroup title="headers">- ```json {{ title: 'headers' }}- {- "Content-Type": "audio/wav"- }- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/info'- method='GET'- title='获取应用基本信息'- name='#info'-/>-<Row>- <Col>- 用于获取应用的基本信息- ### Response- - `name` (string) 应用名称- - `description` (string) 应用描述- - `tags` (array[string]) 应用标签- </Col>- <Col>- <CodeGroup- title="Request"- tag="GET"- label="/info"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/info' \\--H 'Authorization: Bearer {api_key}'`}- />- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "name": "My App",- "description": "This is my app.",- "tags": [- "tag1",- "tag2"- ],- "mode": "advanced-chat",- "author_name": "Dify"- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/parameters'- method='GET'- title='获取应用参数'- name='#parameters'-/>-<Row>- <Col>- 用于进入页面一开始,获取功能开关、输入参数名称、类型及默认值等使用。-- ### Response- - `opening_statement` (string) 开场白- - `suggested_questions` (array[string]) 开场推荐问题列表- - `suggested_questions_after_answer` (object) 启用回答后给出推荐问题。- - `enabled` (bool) 是否开启- - `speech_to_text` (object) 语音转文本- - `enabled` (bool) 是否开启- - `text_to_speech` (object) 文本转语音- - `enabled` (bool) 是否开启- - `voice` (string) 语音类型- - `language` (string) 语言- - `autoPlay` (string) 自动播放- - `enabled` 开启- - `disabled` 关闭- - `retriever_resource` (object) 引用和归属- - `enabled` (bool) 是否开启- - `annotation_reply` (object) 标记回复- - `enabled` (bool) 是否开启- - `user_input_form` (array[object]) 用户输入表单配置- - `text-input` (object) 文本输入控件- - `label` (string) 控件展示标签名- - `variable` (string) 控件 ID- - `required` (bool) 是否必填- - `default` (string) 默认值- - `paragraph` (object) 段落文本输入控件- - `label` (string) 控件展示标签名- - `variable` (string) 控件 ID- - `required` (bool) 是否必填- - `default` (string) 默认值- - `select` (object) 下拉控件- - `label` (string) 控件展示标签名- - `variable` (string) 控件 ID- - `required` (bool) 是否必填- - `default` (string) 默认值- - `options` (array[string]) 选项值- - `file_upload` (object) 文件上传配置- - `document` (object) 文档设置- 当前仅支持文档类型:`txt`, `md`, `markdown`, `pdf`, `html`, `xlsx`, `xls`, `docx`, `csv`, `eml`, `msg`, `pptx`, `ppt`, `xml`, `epub`。- - `enabled` (bool) 是否启用- - `number_limits` (int) 文档数量限制,默认为 3- - `transfer_methods` (array[string]) 传输方式列表:`remote_url`, `local_file`,必须选择一个。- - `image` (object) 图片设置- 当前仅支持图片类型:`png`, `jpg`, `jpeg`, `webp`, `gif`。- - `enabled` (bool) 是否启用- - `number_limits` (int) 图片数量限制,默认为 3- - `transfer_methods` (array[string]) 传输方式列表:`remote_url`, `local_file`,必须选择一个。- - `audio` (object) 音频设置- 当前仅支持音频类型:`mp3`, `m4a`, `wav`, `webm`, `amr`。- - `enabled` (bool) 是否启用- - `number_limits` (int) 音频数量限制,默认为 3- - `transfer_methods` (array[string]) 传输方式列表:`remote_url`, `local_file`,必须选择一个。- - `video` (object) 视频设置- 当前仅支持视频类型:`mp4`, `mov`, `mpeg`, `mpga`。- - `enabled` (bool) 是否启用- - `number_limits` (int) 视频数量限制,默认为 3- - `transfer_methods` (array[string]) 传输方式列表:`remote_url`, `local_file`,必须选择一个。- - `custom` (object) 自定义设置- - `enabled` (bool) 是否启用- - `number_limits` (int) 自定义数量限制,默认为 3- - `transfer_methods` (array[string]) 传输方式列表:`remote_url`, `local_file`,必须选择一个。- - `system_parameters` (object) 系统参数- - `file_size_limit` (int) Document upload size limit (MB)- - `image_file_size_limit` (int) Image file upload size limit (MB)- - `audio_file_size_limit` (int) Audio file upload size limit (MB)- - `video_file_size_limit` (int) Video file upload size limit (MB)- </Col>- <Col sticky>-- <CodeGroup- title="Request"- tag="GET"- label="/parameters"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/parameters'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "introduction": "nice to meet you",- "user_input_form": [- {- "text-input": {- "label": "a",- "variable": "a",- "required": true,- "max_length": 48,- "default": ""- }- },- {- // ...- }- ],- "file_upload": {- "image": {- "enabled": true,- "number_limits": 3,- "transfer_methods": [- "remote_url",- "local_file"- ]- }- },- "system_parameters": {- "file_size_limit": 15,- "image_file_size_limit": 10,- "audio_file_size_limit": 50,- "video_file_size_limit": 100- }- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/meta'- method='GET'- title='获取应用Meta信息'- name='#meta'-/>-<Row>- <Col>- 用于获取工具 icon- ### Response- - `tool_icons`(object[string]) 工具图标- - `工具名称` (string)- - `icon` (object|string)- - (object) 图标- - `background` (string) hex 格式的背景色- - `content`(string) emoji- - (string) 图标 URL- </Col>- <Col>- <CodeGroup- title="Request"- tag="GET"- label="/meta"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/meta' \\--H 'Authorization: Bearer {api_key}'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "tool_icons": {- "dalle2": "https://cloud.dify.ai/console/api/workspaces/current/tool-provider/builtin/dalle/icon",- "api_tool": {- "background": "#252525",- "content": "\ud83d\ude01"- }- }- }- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/site'- method='GET'- title='获取应用 WebApp 设置'- name='#site'-/>-<Row>- <Col>- 用于获取应用的 WebApp 设置- ### Response- - `title` (string) WebApp 名称- - `chat_color_theme` (string) 聊天颜色主题,hex 格式- - `chat_color_theme_inverted` (bool) 聊天颜色主题是否反转- - `icon_type` (string) 图标类型,`emoji`-表情,`image`-图片- - `icon` (string) 图标,如果是 `emoji` 类型,则是 emoji 表情符号,如果是 `image` 类型,则是图片 URL- - `icon_background` (string) hex 格式的背景色- - `icon_url` (string) 图标 URL- - `description` (string) 描述- - `copyright` (string) 版权信息- - `privacy_policy` (string) 隐私政策链接- - `custom_disclaimer` (string) 自定义免责声明- - `default_language` (string) 默认语言- - `show_workflow_steps` (bool) 是否显示工作流详情- - `use_icon_as_answer_icon` (bool) 是否使用 WebApp 图标替换聊天中的 🤖- </Col>- <Col>- <CodeGroup- title="Request"- tag="GET"- label="/site"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/site' \\--H 'Authorization: Bearer {api_key}'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "title": "My App",- "chat_color_theme": "#ff4a4a",- "chat_color_theme_inverted": false,- "icon_type": "emoji",- "icon": "😄",- "icon_background": "#FFEAD5",- "icon_url": null,- "description": "This is my app.",- "copyright": "all rights reserved",- "privacy_policy": "",- "custom_disclaimer": "All generated by AI",- "default_language": "en-US",- "show_workflow_steps": false,- "use_icon_as_answer_icon": false,- }- ```- </CodeGroup>- </Col>-</Row>-___--<Heading- url='/apps/annotations'- method='GET'- title='获取标注列表'- name='#annotation_list'-/>-<Row>- <Col>- ### Query- <Properties>- <Property name='page' type='string' key='page'>- 页码- </Property>- <Property name='limit' type='string' key='limit'>- 每页数量- </Property>- </Properties>- </Col>- <Col sticky>- <CodeGroup- title="Request"- tag="GET"- label="/apps/annotations"- targetCode={`curl --location --request GET '${props.appDetail.api_base_url}/apps/annotations?page=1&limit=20' \\---header 'Authorization: Bearer {api_key}'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "data": [- {- "id": "69d48372-ad81-4c75-9c46-2ce197b4d402",- "question": "What is your name?",- "answer": "I am Dify.",- "hit_count": 0,- "created_at": 1735625869- }- ],- "has_more": false,- "limit": 20,- "total": 1,- "page": 1- }- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/apps/annotations'- method='POST'- title='创建标注'- name='#create_annotation'-/>-<Row>- <Col>- ### Query- <Properties>- <Property name='question' type='string' key='question'>- 问题- </Property>- <Property name='answer' type='string' key='answer'>- 答案内容- </Property>- </Properties>- </Col>- <Col sticky>- <CodeGroup- title="Request"- tag="POST"- label="/apps/annotations"- targetCode={`curl --location --request POST '${props.appDetail.api_base_url}/apps/annotations' \\---header 'Authorization: Bearer {api_key}' \\---header 'Content-Type: application/json' \\---data-raw '{- "question": "What is your name?",- "answer": "I am Dify."-}'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "id": "69d48372-ad81-4c75-9c46-2ce197b4d402",- "question": "What is your name?",- "answer": "I am Dify.",- "hit_count": 0,- "created_at": 1735625869- }- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/apps/annotations/{annotation_id}'- method='PUT'- title='更新标注'- name='#update_annotation'-/>-<Row>- <Col>- ### Query- <Properties>- <Property name='annotation_id' type='string' key='annotation_id'>- 标注 ID- </Property>- <Property name='question' type='string' key='question'>- 问题- </Property>- <Property name='answer' type='string' key='answer'>- 答案内容- </Property>- </Properties>- </Col>- <Col sticky>- <CodeGroup- title="Request"- tag="PUT"- label="/apps/annotations/{annotation_id}"- targetCode={`curl --location --request PUT '${props.appDetail.api_base_url}/apps/annotations/{annotation_id}' \\---header 'Authorization: Bearer {api_key}' \\---header 'Content-Type: application/json' \\---data-raw '{- "question": "What is your name?",- "answer": "I am Dify."-}'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "id": "69d48372-ad81-4c75-9c46-2ce197b4d402",- "question": "What is your name?",- "answer": "I am Dify.",- "hit_count": 0,- "created_at": 1735625869- }- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/apps/annotations/{annotation_id}'- method='DELETE'- title='删除标注'- name='#delete_annotation'-/>-<Row>- <Col>- ### Query- <Properties>- <Property name='annotation_id' type='string' key='annotation_id'>- 标注 ID- </Property>- </Properties>- </Col>- <Col sticky>- <CodeGroup- title="Request"- tag="DELETE"- label="/apps/annotations/{annotation_id}"- targetCode={`curl --location --request DELETE '${props.appDetail.api_base_url}/apps/annotations/{annotation_id}' \\---header 'Authorization: Bearer {api_key}' \\---header 'Content-Type: application/json'`}- />-- <CodeGroup title="Response">- ```text {{ title: 'Response' }}- 204 No Content- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/apps/annotation-reply/{action}'- method='POST'- title='标注回复初始设置'- name='#initial_annotation_reply_settings'-/>-<Row>- <Col>- ### Query- <Properties>- <Property name='action' type='string' key='action'>- 动作,只能是 'enable' 或 'disable'- </Property>- <Property name='embedding_provider_name' type='string' key='embedding_provider_name'>- 指定的嵌入模型提供商,必须先在系统内设定好接入的模型,对应的是 provider 字段- </Property>- <Property name='embedding_model_name' type='string' key='embedding_model_name'>- 指定的嵌入模型,对应的是 model 字段- </Property>- <Property name='score_threshold' type='number' key='score_threshold'>- 相似度阈值,当相似度大于该阈值时,系统会自动回复,否则不回复- </Property>- </Properties>- </Col>- <Col sticky>- 嵌入模型的提供商和模型名称可以通过以下接口获取:v1/workspaces/current/models/model-types/text-embedding,具体见:通过 API 维护知识库。使用的 Authorization 是 Dataset 的 API Token。- <CodeGroup- title="Request"- tag="POST"- label="/apps/annotation-reply/{action}"- targetCode={`curl --location --request POST '${props.appDetail.api_base_url}/apps/annotation-reply/{action}' \\---header 'Authorization: Bearer {api_key}' \\---header 'Content-Type: application/json' \\---data-raw '{- "score_threshold": 0.9,- "embedding_provider_name": "zhipu",- "embedding_model_name": "embedding_3"-}'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "job_id": "b15c8f68-1cf4-4877-bf21-ed7cf2011802",- "job_status": "waiting"- }- ```- </CodeGroup>- 该接口是异步执行,所以会返回一个job_id,通过查询job状态接口可以获取到最终的执行结果。- </Col>-</Row>------<Heading- url='/apps/annotation-reply/{action}/status/{job_id}'- method='GET'- title='查询标注回复初始设置任务状态'- name='#initial_annotation_reply_settings_task_status'-/>-<Row>- <Col>- ### Query- <Properties>- <Property name='action' type='string' key='action'>- 动作,只能是 'enable' 或 'disable',并且必须和标注回复初始设置接口的动作一致- </Property>- <Property name='job_id' type='string' key='job_id'>- 任务 ID,从标注回复初始设置接口返回的 job_id- </Property>- </Properties>- </Col>- <Col sticky>- <CodeGroup- title="Request"- tag="GET"- label="/apps/annotations"- targetCode={`curl --location --request GET '${props.appDetail.api_base_url}/apps/annotation-reply/{action}/status/{job_id}' \\---header 'Authorization: Bearer {api_key}'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "job_id": "b15c8f68-1cf4-4877-bf21-ed7cf2011802",- "job_status": "waiting",- "error_msg": ""- }- ```- </CodeGroup>- </Col>-</Row>diff --git a/web/app/components/develop/template/template_chat.en.mdx b/web/app/components/develop/template/template_chat.en.mdxdeleted file mode 100644index a924670e52b..00000000000--- a/web/app/components/develop/template/template_chat.en.mdx+++ /dev/null@@ -1,1969 +0,0 @@-import { CodeGroup } from '../code.tsx'-import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx'--# Chat App API--Chat applications support session persistence, allowing previous chat history to be used as context for responses. This can be applicable for chatbot, customer service AI, etc.--<div>- ### Base URL- <CodeGroup title="Code" targetCode={props.appDetail.api_base_url} />-- ### Authentication-- The Service API uses `API-Key` authentication.- <i>**Strongly recommend storing your API Key on the server-side, not shared or stored on the client-side, to avoid possible API-Key leakage that can lead to serious consequences.**</i>-- For all API requests, include your API Key in the `Authorization`HTTP Header, as shown below:-- <CodeGroup title="Code" targetCode='Authorization: Bearer {API_KEY}' />-</div>-------<Heading- url='/chat-messages'- method='POST'- title='Send Chat Message'- name='#Send-Chat-Message'-/>-<Row>- <Col>- Send a request to the chat application.-- ### Request Body-- <Properties>- <Property name='query' type='string' key='query'>- User Input/Question content- </Property>- <Property name='inputs' type='object' key='inputs'>- Allows the entry of various variable values defined by the App.- The `inputs` parameter contains multiple key/value pairs, with each key corresponding to a specific variable and each value being the specific value for that variable. Default `{}`- </Property>- <Property name='response_mode' type='string' key='response_mode'>- The mode of response return, supporting:- - `streaming` Streaming mode (recommended), implements a typewriter-like output through SSE ([Server-Sent Events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events)).- - `blocking` Blocking mode, returns result after execution is complete. (Requests may be interrupted if the process is long)- Due to Cloudflare restrictions, the request will be interrupted without a return after 100 seconds.- <i>Note: blocking mode is not supported in Agent Assistant mode</i>- </Property>- <Property name='user' type='string' key='user'>- User identifier, used to define the identity of the end-user for retrieval and statistics.- Should be uniquely defined by the developer within the application.- </Property>- <Property name='conversation_id' type='string' key='conversation_id'>- Conversation ID, to continue the conversation based on previous chat records, it is necessary to pass the previous message's conversation_id.- </Property>- <Property name='files' type='array[object]' key='files'>- File list, suitable for inputting files combined with text understanding and answering questions, available only when the model supports Vision/Video capability.- - `type` (string) Supported type:- - `document` Supported types include: 'TXT', 'MD', 'MARKDOWN', 'MDX', 'PDF', 'HTML', 'XLSX', 'XLS', 'VTT', 'PROPERTIES', 'DOC', 'DOCX', 'CSV', 'EML', 'MSG', 'PPTX', 'PPT', 'XML', 'EPUB'- - `image` Supported types include: 'JPG', 'JPEG', 'PNG', 'GIF', 'WEBP', 'SVG'- - `audio` Supported types include: 'MP3', 'M4A', 'WAV', 'WEBM', 'MPGA'- - `video` Supported types include: 'MP4', 'MOV', 'MPEG', 'WEBM'- - `custom` Supported types include: other file types- - `transfer_method` (string) Transfer method:- - `remote_url`: File URL.- - `local_file`: Upload file.- - `url` File URL. (Only when transfer method is `remote_url`).- - `upload_file_id` Upload file ID. (Only when transfer method is `local_file`).- </Property>- <Property name='auto_generate_name' type='bool' key='auto_generate_name'>- Auto-generate title, default is `true`.- If set to `false`, can achieve async title generation by calling the conversation rename API and setting `auto_generate` to `true`.- </Property>- <Property name='workflow_id' type='string' key='workflow_id'>- (Optional) Workflow ID to specify a specific version, if not provided, uses the default published version.<br/>- How to obtain: In the version history interface, click the copy icon on the right side of each version entry to copy the complete workflow ID.- </Property>- <Property name='trace_id' type='string' key='trace_id'>- (Optional) Trace ID. Used for integration with existing business trace components to achieve end-to-end distributed tracing. If not provided, the system will automatically generate a trace_id. Supports the following three ways to pass, in order of priority:<br/>- - Header: via HTTP Header <code>X-Trace-Id</code>, highest priority.<br/>- - Query parameter: via URL query parameter <code>trace_id</code>.<br/>- - Request Body: via request body field <code>trace_id</code> (i.e., this field).<br/>- </Property>- <Property name='trace_session_id' type='string' key='trace_session_id'>- (Optional) Trace session ID for observability grouping. Tracing providers that support session grouping can use this value as the exported session identifier. It does not change conversation_id, workflow_run_id, trace_id, or span relationships. Supports the following three ways to pass, in order of priority:<br/>- - Header: via HTTP Header <code>X-Trace-Session-Id</code>, highest priority.<br/>- - Query parameter: via URL query parameter <code>trace_session_id</code>.<br/>- - Request Body: via request body field <code>trace_session_id</code> (i.e., this field).<br/>- </Property>- </Properties>-- ### Response- When response_mode is blocking, return a CompletionResponse object.- When response_mode is streaming, return a ChunkCompletionResponse stream.-- ### ChatCompletionResponse- Returns the complete App result, `Content-Type` is `application/json`.- - `event` (string) Event type, always `message` in blocking mode.- - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API- - `id` (string) Unique ID, same as `message_id`- - `message_id` (string) Unique message ID- - `conversation_id` (string) Conversation ID- - `mode` (string) App mode, fixed as `chat`- - `answer` (string) Complete response content- - `metadata` (object) Metadata- - `usage` (Usage) Model usage information- - `retriever_resources` (array[RetrieverResource]) Citation and Attribution List- - `created_at` (int) Message creation timestamp, e.g., 1705395332-- ### ChunkChatCompletionResponse- Returns the stream chunks outputted by the App, `Content-Type` is `text/event-stream`.- Each streaming chunk starts with `data:`, separated by two newline characters `\n\n`, as shown below:- <CodeGroup>- ```streaming {{ title: 'Response' }}- data: {"event": "message", "task_id": "900bbd43-dc0b-4383-a372-aa6e6c414227", "id": "663c5084-a254-4040-8ad3-51f2a3c1a77c", "answer": "Hi", "created_at": 1705398420}\n\n- ```- </CodeGroup>- The structure of the streaming chunks varies depending on the `event`:- - `event: message` LLM returns text chunk event, i.e., the complete text is output in a chunked fashion.- - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API- - `message_id` (string) Unique message ID- - `conversation_id` (string) Conversation ID- - `answer` (string) LLM returned text chunk content- - `created_at` (int) Creation timestamp, e.g., 1705395332- - `event: agent_message` LLM returns text chunk event, i.e., with Agent Assistant enabled, the complete text is output in a chunked fashion (Only supported in Agent mode)- - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API- - `message_id` (string) Unique message ID- - `conversation_id` (string) Conversation ID- - `answer` (string) LLM returned text chunk content- - `created_at` (int) Creation timestamp, e.g., 1705395332- - `event: tts_message` TTS audio stream event, that is, speech synthesis output. The content is an audio block in Mp3 format, encoded as a base64 string. When playing, simply decode the base64 and feed it into the player. (This message is available only when auto-play is enabled)- - `task_id` (string) Task ID, used for request tracking and the stop response interface below- - `message_id` (string) Unique message ID- - `audio` (string) The audio after speech synthesis, encoded in base64 text content, when playing, simply decode the base64 and feed it into the player- - `created_at` (int) Creation timestamp, e.g.: 1705395332- - `event: tts_message_end` TTS audio stream end event, receiving this event indicates the end of the audio stream.- - `task_id` (string) Task ID, used for request tracking and the stop response interface below- - `message_id` (string) Unique message ID- - `audio` (string) The end event has no audio, so this is an empty string- - `created_at` (int) Creation timestamp, e.g.: 1705395332- - `event: agent_thought` thought of Agent, contains the thought of LLM, input and output of tool calls (Only supported in Agent mode)- - `id` (string) Agent thought ID, every iteration has a unique agent thought ID- - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API- - `message_id` (string) Unique message ID- - `position` (int) Position of current agent thought, each message may have multiple thoughts in order.- - `thought` (string) What LLM is thinking about- - `observation` (string) Response from tool calls- - `tool` (string) A list of tools represents which tools are called,split by ;- - `tool_input` (string) Input of tools in JSON format. Like: `{"dalle3": {"prompt": "a cute cat"}}`.- - `created_at` (int) Creation timestamp, e.g., 1705395332- - `message_files` (array[string]) Refer to message_file event- - `file_id` (string) File ID- - `conversation_id` (string) Conversation ID- - `event: message_file` Message file event, a new file has created by tool- - `id` (string) File unique ID- - `type` (string) File type,only allow "image" currently- - `belongs_to` (string) Belongs to, it will only be an 'assistant' here- - `url` (string) Remote url of file- - `conversation_id` (string) Conversation ID- - `event: message_end` Message end event, receiving this event means streaming has ended.- - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API- - `message_id` (string) Unique message ID- - `conversation_id` (string) Conversation ID- - `metadata` (object) Metadata- - `usage` (Usage) Model usage information- - `retriever_resources` (array[RetrieverResource]) Citation and Attribution List- - `event: message_replace` Message content replacement event.- When output content moderation is enabled, if the content is flagged, then the message content will be replaced with a preset reply through this event.- - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API- - `message_id` (string) Unique message ID- - `conversation_id` (string) Conversation ID- - `answer` (string) Replacement content (directly replaces all LLM reply text)- - `created_at` (int) Creation timestamp, e.g., 1705395332- - `event: error`- Exceptions that occur during the streaming process will be output in the form of stream events, and reception of an error event will end the stream.- - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API- - `message_id` (string) Unique message ID- - `status` (int) HTTP status code- - `code` (string) Error code- - `message` (string) Error message- - `event: ping` Ping event every 10 seconds to keep the connection alive.-- ### Errors- - 404, Conversation does not exists- - 400, `invalid_param`, abnormal parameter input- - 400, `app_unavailable`, App configuration unavailable- - 400, `provider_not_initialize`, no available model credential configuration- - 400, `provider_quota_exceeded`, model invocation quota insufficient- - 400, `model_currently_not_support`, current model unavailable- - 400, `workflow_not_found`, specified workflow version not found- - 400, `draft_workflow_error`, cannot use draft workflow version- - 400, `workflow_id_format_error`, invalid workflow_id format, expected UUID format- - 400, `completion_request_error`, text generation failed- - 500, internal server error-- </Col>- <Col sticky>-- <CodeGroup- title="Request"- tag="POST"- label="/chat-messages"- targetCode={`curl -X POST '${props.appDetail.api_base_url}/chat-messages' \\---header 'Authorization: Bearer {api_key}' \\---header 'Content-Type: application/json' \\---data-raw '{- "inputs": ${JSON.stringify(props.inputs)},- "query": "What are the specs of the iPhone 13 Pro Max?",- "response_mode": "streaming",- "conversation_id": "",- "user": "abc-123",- "files": [- {- "type": "image",- "transfer_method": "remote_url",- "url": "https://cloud.dify.ai/logo/logo-site.png"- }- ]-}'`}- />- ### Blocking Mode- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "event": "message",- "task_id": "c3800678-a077-43df-a102-53f23ed20b88",- "id": "9da23599-e713-473b-982c-4328d4f5c78a",- "message_id": "9da23599-e713-473b-982c-4328d4f5c78a",- "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2",- "mode": "chat",- "answer": "iPhone 13 Pro Max specs are listed here:...",- "metadata": {- "usage": {- "prompt_tokens": 1033,- "prompt_unit_price": "0.001",- "prompt_price_unit": "0.001",- "prompt_price": "0.0010330",- "completion_tokens": 128,- "completion_unit_price": "0.002",- "completion_price_unit": "0.001",- "completion_price": "0.0002560",- "total_tokens": 1161,- "total_price": "0.0012890",- "currency": "USD",- "latency": 0.7682376249867957- },- "retriever_resources": [- {- "position": 1,- "dataset_id": "101b4c97-fc2e-463c-90b1-5261a4cdcafb",- "dataset_name": "iPhone",- "document_id": "8dd1ad74-0b5f-4175-b735-7d98bbbb4e00",- "document_name": "iPhone List",- "segment_id": "ed599c7f-2766-4294-9d1d-e5235a61270a",- "score": 0.98457545,- "content": "\"Model\",\"Release Date\",\"Display Size\",\"Resolution\",\"Processor\",\"RAM\",\"Storage\",\"Camera\",\"Battery\",\"Operating System\"\n\"iPhone 13 Pro Max\",\"September 24, 2021\",\"6.7 inch\",\"1284 x 2778\",\"Hexa-core (2x3.23 GHz Avalanche + 4x1.82 GHz Blizzard)\",\"6 GB\",\"128, 256, 512 GB, 1TB\",\"12 MP\",\"4352 mAh\",\"iOS 15\""- }- ]- },- "created_at": 1705407629- }- ```- </CodeGroup>- ### Streaming Mode ( Basic Assistant )- <CodeGroup title="Response">- ```streaming {{ title: 'Response' }}- data: {"event": "message", "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " I", "created_at": 1679586595}- data: {"event": "message", "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": "'m", "created_at": 1679586595}- data: {"event": "message", "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " glad", "created_at": 1679586595}- data: {"event": "message", "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " to", "created_at": 1679586595}- data: {"event": "message", "message_id" : "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " meet", "created_at": 1679586595}- data: {"event": "message", "message_id" : "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " you", "created_at": 1679586595}- data: {"event": "message_end", "id": "5e52ce04-874b-4d27-9045-b3bc80def685", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "metadata": {"usage": {"prompt_tokens": 1033, "prompt_unit_price": "0.001", "prompt_price_unit": "0.001", "prompt_price": "0.0010330", "completion_tokens": 135, "completion_unit_price": "0.002", "completion_price_unit": "0.001", "completion_price": "0.0002700", "total_tokens": 1168, "total_price": "0.0013030", "currency": "USD", "latency": 1.381760165997548}, "retriever_resources": [{"position": 1, "dataset_id": "101b4c97-fc2e-463c-90b1-5261a4cdcafb", "dataset_name": "iPhone", "document_id": "8dd1ad74-0b5f-4175-b735-7d98bbbb4e00", "document_name": "iPhone List", "segment_id": "ed599c7f-2766-4294-9d1d-e5235a61270a", "score": 0.98457545, "content": "\"Model\",\"Release Date\",\"Display Size\",\"Resolution\",\"Processor\",\"RAM\",\"Storage\",\"Camera\",\"Battery\",\"Operating System\"\n\"iPhone 13 Pro Max\",\"September 24, 2021\",\"6.7 inch\",\"1284 x 2778\",\"Hexa-core (2x3.23 GHz Avalanche + 4x1.82 GHz Blizzard)\",\"6 GB\",\"128, 256, 512 GB, 1TB\",\"12 MP\",\"4352 mAh\",\"iOS 15\""}]}}- data: {"event": "tts_message", "conversation_id": "23dd85f3-1a41-4ea0-b7a9-062734ccfaf9", "message_id": "a8bdc41c-13b2-4c18-bfd9-054b9803038c", "created_at": 1721205487, "task_id": "3bf8a0bb-e73b-4690-9e66-4e429bad8ee7", "audio": "qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq"}- data: {"event": "tts_message_end", "conversation_id": "23dd85f3-1a41-4ea0-b7a9-062734ccfaf9", "message_id": "a8bdc41c-13b2-4c18-bfd9-054b9803038c", "created_at": 1721205487, "task_id": "3bf8a0bb-e73b-4690-9e66-4e429bad8ee7", "audio": ""}- ```- </CodeGroup>- ### Response Example(Agent Assistant)- <CodeGroup title="Response">- ```streaming {{ title: 'Response' }}- data: {"event": "message", "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " I", "created_at": 1679586595}- data: {"event": "message", "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": "'m", "created_at": 1679586595}- data: {"event": "message", "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " glad", "created_at": 1679586595}- data: {"event": "message", "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " to", "created_at": 1679586595}- data: {"event": "message", "message_id" : "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " meet", "created_at": 1679586595}- data: {"event": "message", "message_id" : "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " you", "created_at": 1679586595}- data: {"event": "message_end", "id": "5e52ce04-874b-4d27-9045-b3bc80def685", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "metadata": {"usage": {"prompt_tokens": 1033, "prompt_unit_price": "0.001", "prompt_price_unit": "0.001", "prompt_price": "0.0010330", "completion_tokens": 135, "completion_unit_price": "0.002", "completion_price_unit": "0.001", "completion_price": "0.0002700", "total_tokens": 1168, "total_price": "0.0013030", "currency": "USD", "latency": 1.381760165997548}, "retriever_resources": [{"position": 1, "dataset_id": "101b4c97-fc2e-463c-90b1-5261a4cdcafb", "dataset_name": "iPhone", "document_id": "8dd1ad74-0b5f-4175-b735-7d98bbbb4e00", "document_name": "iPhone List", "segment_id": "ed599c7f-2766-4294-9d1d-e5235a61270a", "score": 0.98457545, "content": "\"Model\",\"Release Date\",\"Display Size\",\"Resolution\",\"Processor\",\"RAM\",\"Storage\",\"Camera\",\"Battery\",\"Operating System\"\n\"iPhone 13 Pro Max\",\"September 24, 2021\",\"6.7 inch\",\"1284 x 2778\",\"Hexa-core (2x3.23 GHz Avalanche + 4x1.82 GHz Blizzard)\",\"6 GB\",\"128, 256, 512 GB, 1TB\",\"12 MP\",\"4352 mAh\",\"iOS 15\""}]}}- data: {"event": "tts_message", "conversation_id": "23dd85f3-1a41-4ea0-b7a9-062734ccfaf9", "message_id": "a8bdc41c-13b2-4c18-bfd9-054b9803038c", "created_at": 1721205487, "task_id": "3bf8a0bb-e73b-4690-9e66-4e429bad8ee7", "audio": "qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq"}- data: {"event": "tts_message_end", "conversation_id": "23dd85f3-1a41-4ea0-b7a9-062734ccfaf9", "message_id": "a8bdc41c-13b2-4c18-bfd9-054b9803038c", "created_at": 1721205487, "task_id": "3bf8a0bb-e73b-4690-9e66-4e429bad8ee7", "audio": ""}- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/files/upload'- method='POST'- title='File Upload'- name='#file-upload'-/>-<Row>- <Col>- Upload a file (currently only images are supported) for use when sending messages, enabling multimodal understanding of images and text.- Supports png, jpg, jpeg, webp, gif formats.- Uploaded files are for use by the current end-user only.-- ### Request Body- This interface requires a `multipart/form-data` request.- - `file` (File) Required- The file to be uploaded.- - `user` (string) Required- User identifier, defined by the developer's rules, must be unique within the application. The Service API does not share conversations created by the WebApp.-- ### Response- After a successful upload, the server will return the file's ID and related information.- - `id` (uuid) ID- - `name` (string) File name- - `size` (int) File size (bytes)- - `extension` (string) File extension- - `mime_type` (string) File mime-type- - `created_by` (uuid) End-user ID- - `created_at` (timestamp) Creation timestamp, e.g., 1705395332-- ### Errors- - 400, `no_file_uploaded`, a file must be provided- - 400, `too_many_files`, currently only one file is accepted- - 400, `unsupported_preview`, the file does not support preview- - 400, `unsupported_estimate`, the file does not support estimation- - 413, `file_too_large`, the file is too large- - 415, `unsupported_file_type`, unsupported extension, currently only document files are accepted- - 503, `s3_connection_failed`, unable to connect to S3 service- - 503, `s3_permission_denied`, no permission to upload files to S3- - 503, `s3_file_too_large`, file exceeds S3 size limit- - 500, internal server error--- </Col>- <Col sticky>- ### Request Example- <CodeGroup- title="Request"- tag="POST"- label="/files/upload"- targetCode={`curl -X POST '${props.appDetail.api_base_url}/files/upload' \\---header 'Authorization: Bearer {api_key}' \\---form 'file=@localfile;type=image/[png|jpeg|jpg|webp|gif]' \\---form 'user=abc-123'`}- />-- ### Response Example- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "id": "72fa9618-8f89-4a37-9b33-7e1178a24a67",- "name": "example.png",- "size": 1024,- "extension": "png",- "mime_type": "image/png",- "created_by": "6ad1ab0a-73ff-4ac1-b9e4-cdb312f71f13",- "created_at": 1577836800,- }- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/end-users/:end_user_id'- method='GET'- title='Get End User'- name='#end-user'-/>-<Row>- <Col>- Retrieve an end user by ID.-- This is useful when other APIs return an end-user ID (e.g. `created_by` from File Upload).-- ### Path Parameters- - `end_user_id` (uuid) Required- End user ID.-- ### Response- Returns an EndUser object.- - `id` (uuid) ID- - `tenant_id` (uuid) Tenant ID- - `app_id` (uuid) App ID- - `type` (string) End user type- - `external_user_id` (string) External user ID- - `name` (string) Name- - `is_anonymous` (boolean) Whether anonymous- - `session_id` (string) Session ID- - `created_at` (string) ISO 8601 datetime- - `updated_at` (string) ISO 8601 datetime-- ### Errors- - 404, `end_user_not_found`, end user not found- - 500, internal server error-- </Col>- <Col sticky>- ### Request Example- <CodeGroup- title="Request"- tag="GET"- label="/end-users/:end_user_id"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/end-users/6ad1ab0a-73ff-4ac1-b9e4-cdb312f71f13' \\---header 'Authorization: Bearer {api_key}'`}- />-- ### Response Example- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "id": "6ad1ab0a-73ff-4ac1-b9e4-cdb312f71f13",- "tenant_id": "8c0f3f3a-66b0-4b55-a0bf-8b8e0d6aee7d",- "app_id": "6c8c3f41-2c6f-4e1b-8f4f-7f11c8f2ad2a",- "type": "service_api",- "external_user_id": "abc-123",- "name": "Alice",- "is_anonymous": false,- "session_id": "abc-123",- "created_at": "2024-01-01T00:00:00Z",- "updated_at": "2024-01-01T00:00:00Z"- }- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/files/:file_id/preview'- method='GET'- title='File Preview'- name='#file-preview'-/>-<Row>- <Col>- Preview or download uploaded files. This endpoint allows you to access files that have been previously uploaded via the File Upload API.-- <i>Files can only be accessed if they belong to messages within the requesting application.</i>-- ### Path Parameters- - `file_id` (string) Required- The unique identifier of the file to preview, obtained from the File Upload API response.-- ### Query Parameters- - `as_attachment` (boolean) Optional- Whether to force download the file as an attachment. Default is `false` (preview in browser).-- ### Response- Returns the file content with appropriate headers for browser display or download.- - `Content-Type` Set based on file mime type- - `Content-Length` File size in bytes (if available)- - `Content-Disposition` Set to "attachment" if `as_attachment=true`- - `Cache-Control` Caching headers for performance- - `Accept-Ranges` Set to "bytes" for audio/video files-- ### Errors- - 400, `invalid_param`, abnormal parameter input- - 403, `file_access_denied`, file access denied or file does not belong to current application- - 404, `file_not_found`, file not found or has been deleted- - 500, internal server error-- </Col>- <Col sticky>- ### Request Example- <CodeGroup- title="Request"- tag="GET"- label="/files/:file_id/preview"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/files/72fa9618-8f89-4a37-9b33-7e1178a24a67/preview' \\---header 'Authorization: Bearer {api_key}'`}- />-- ### Download as Attachment- <CodeGroup- title="Download Request"- tag="GET"- label="/files/:file_id/preview?as_attachment=true"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/files/72fa9618-8f89-4a37-9b33-7e1178a24a67/preview?as_attachment=true' \\---header 'Authorization: Bearer {api_key}' \\---output downloaded_file.png`}- />-- ### Response Headers Example- <CodeGroup title="Response Headers">- ```http {{ title: 'Headers - Image Preview' }}- Content-Type: image/png- Content-Length: 1024- Cache-Control: public, max-age=3600- ```- </CodeGroup>-- ### Download Response Headers- <CodeGroup title="Download Response Headers">- ```http {{ title: 'Headers - File Download' }}- Content-Type: image/png- Content-Length: 1024- Content-Disposition: attachment; filename*=UTF-8''example.png- Cache-Control: public, max-age=3600- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/chat-messages/:task_id/stop'- method='POST'- title='Stop Generate'- name='#stop-generatebacks'-/>-<Row>- <Col>- Only supported in streaming mode.- ### Path- - `task_id` (string) Task ID, can be obtained from the streaming chunk return- ### Request Body- - `user` (string) Required- User identifier, used to define the identity of the end-user, must be consistent with the user passed in the message sending interface. The Service API does not share conversations created by the WebApp.- ### Response- - `result` (string) Always returns "success"- </Col>- <Col sticky>- ### Request Example- <CodeGroup- title="Request"- tag="POST"- label="/chat-messages/:task_id/stop"- targetCode={`curl -X POST '${props.appDetail.api_base_url}/chat-messages/:task_id/stop' \\- -H 'Authorization: Bearer {api_key}' \\- -H 'Content-Type: application/json' \\- --data-raw '{"user": "abc-123"}'`}- />-- ### Response Example- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "result": "success"- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/messages/:message_id/feedbacks'- method='POST'- title='Message Feedback'- name='#feedbacks'-/>-<Row>- <Col>- End-users can provide feedback messages, facilitating application developers to optimize expected outputs.-- ### Path- <Properties>- <Property name='message_id' type='string' key='message_id'>- Message ID- </Property>- </Properties>-- ### Request Body-- <Properties>- <Property name='rating' type='string' key='rating'>- Upvote as `like`, downvote as `dislike`, revoke upvote as `null`- </Property>- <Property name='user' type='string' key='user'>- User identifier, defined by the developer's rules, must be unique within the application.- </Property>- <Property name='content' type='string' key='content'>- The specific content of message feedback.- </Property>- </Properties>-- ### Response- - `result` (string) Always returns "success"- </Col>- <Col sticky>-- <CodeGroup- title="Request"- tag="POST"- label="/messages/:message_id/feedbacks"- targetCode={`curl -X POST '${props.appDetail.api_base_url}/messages/:message_id/feedbacks \\---header 'Authorization: Bearer {api_key}' \\---header 'Content-Type: application/json' \\---data-raw '{- "rating": "like",- "user": "abc-123",- "content": "message feedback information"-}'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "result": "success"- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/app/feedbacks'- method='GET'- title='Get feedbacks of application'- name='#app-feedbacks'-/>-<Row>- <Col>- Get application's feedbacks.-- ### Query- <Properties>- <Property name='page' type='string' key='page'>- (optional)pagination,default:1- </Property>- </Properties>-- <Properties>- <Property name='limit' type='string' key='limit'>- (optional) records per page default:20- </Property>- </Properties>-- ### Response- - `data` (List) return apps feedback list.- </Col>- <Col sticky>-- <CodeGroup- title="Request"- tag="GET"- label="/app/feedbacks"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/app/feedbacks?page=1&limit=20'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "data": [- {- "id": "8c0fbed8-e2f9-49ff-9f0e-15a35bdd0e25",- "app_id": "f252d396-fe48-450e-94ec-e184218e7346",- "conversation_id": "2397604b-9deb-430e-b285-4726e51fd62d",- "message_id": "709c0b0f-0a96-4a4e-91a4-ec0889937b11",- "rating": "like",- "content": "message feedback information-3",- "from_source": "user",- "from_end_user_id": "74286412-9a1a-42c1-929c-01edb1d381d5",- "from_account_id": null,- "created_at": "2025-04-24T09:24:38",- "updated_at": "2025-04-24T09:24:38"- }- ]- }- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/messages/{message_id}/suggested'- method='GET'- title='Next Suggested Questions'- name='#suggested'-/>-<Row>- <Col>- Get next questions suggestions for the current message-- ### Path Params-- <Properties>- <Property name='message_id' type='string' key='message_id'>- Message ID- </Property>- </Properties>-- ### Query- <Properties>- <Property name='user' type='string' key='user'>- User identifier, used to define the identity of the end-user for retrieval and statistics.- Should be uniquely defined by the developer within the application.- </Property>- </Properties>- </Col>- <Col sticky>-- <CodeGroup- title="Request"- tag="GET"- label="/messages/{message_id}/suggested"- targetCode={`curl --location --request GET '${props.appDetail.api_base_url}/messages/{message_id}/suggested?user=abc-123& \\---header 'Authorization: Bearer ENTER-YOUR-SECRET-KEY' \\---header 'Content-Type: application/json'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "result": "success",- "data": [- "a",- "b",- "c"- ]- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/messages'- method='GET'- title='Get Conversation History Messages'- name='#messages'-/>-<Row>- <Col>- Returns historical chat records in a scrolling load format, with the first page returning the latest `{limit}` messages, i.e., in reverse order.-- ### Query-- <Properties>- <Property name='conversation_id' type='string' key='conversation_id'>- Conversation ID- </Property>- <Property name='user' type='string' key='user'>- User identifier, used to define the identity of the end-user for retrieval and statistics.- Should be uniquely defined by the developer within the application.- </Property>- <Property name='first_id' type='string' key='first_id'>- The ID of the first chat record on the current page, default is null.- </Property>- <Property name='limit' type='int' key='limit'>- How many chat history messages to return in one request, default is 20.- </Property>- </Properties>-- ### Response- - `data` (array[object]) Message list- - `id` (string) Message ID- - `conversation_id` (string) Conversation ID- - `inputs` (object) User input parameters.- - `query` (string) User input / question content.- - `message_files` (array[object]) Message files- - `id` (string) ID- - `type` (string) File type, image for images- - `url` (string) File preview URL, use the File Preview API (`/files/{file_id}/preview`) to access the file- - `belongs_to` (string) belongs to,user or assistant- - `agent_thoughts` (array[object]) Agent thought(Empty if it's a Basic Assistant)- - `id` (string) Agent thought ID, every iteration has a unique agent thought ID- - `message_id` (string) Unique message ID- - `position` (int) Position of current agent thought, each message may have multiple thoughts in order.- - `thought` (string) What LLM is thinking about- - `observation` (string) Response from tool calls- - `tool` (string) A list of tools represents which tools are called,split by ;- - `tool_input` (string) Input of tools in JSON format. Like: `{"dalle3": {"prompt": "a cute cat"}}`.- - `created_at` (int) Creation timestamp, e.g., 1705395332- - `message_files` (array[string]) Refer to message_file event- - `file_id` (string) File ID- - `answer` (string) Response message content- - `created_at` (timestamp) Creation timestamp, e.g., 1705395332- - `feedback` (object) Feedback information- - `rating` (string) Upvote as `like` / Downvote as `dislike`- - `retriever_resources` (array[RetrieverResource]) Citation and Attribution List- - `has_more` (bool) Whether there is a next page- - `limit` (int) Number of returned items, if input exceeds system limit, returns system limit amount-- </Col>- <Col sticky>-- <CodeGroup- title="Request"- tag="GET"- label="/messages"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/messages?user=abc-123&conversation_id='\\---header 'Authorization: Bearer {api_key}'`}- />-- ### Response Example (Basic Assistant)- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "limit": 20,- "has_more": false,- "data": [- {- "id": "a076a87f-31e5-48dc-b452-0061adbbc922",- "conversation_id": "cd78daf6-f9e4-4463-9ff2-54257230a0ce",- "inputs": {- "name": "dify"- },- "query": "iphone 13 pro",- "answer": "The iPhone 13 Pro, released on September 24, 2021, features a 6.1-inch display with a resolution of 1170 x 2532. It is equipped with a Hexa-core (2x3.23 GHz Avalanche + 4x1.82 GHz Blizzard) processor, 6 GB of RAM, and offers storage options of 128 GB, 256 GB, 512 GB, and 1 TB. The camera is 12 MP, the battery capacity is 3095 mAh, and it runs on iOS 15.",- "message_files": [],- "feedback": null,- "retriever_resources": [- {- "position": 1,- "dataset_id": "101b4c97-fc2e-463c-90b1-5261a4cdcafb",- "dataset_name": "iPhone",- "document_id": "8dd1ad74-0b5f-4175-b735-7d98bbbb4e00",- "document_name": "iPhone List",- "segment_id": "ed599c7f-2766-4294-9d1d-e5235a61270a",- "score": 0.98457545,- "content": "\"Model\",\"Release Date\",\"Display Size\",\"Resolution\",\"Processor\",\"RAM\",\"Storage\",\"Camera\",\"Battery\",\"Operating System\"\n\"iPhone 13 Pro Max\",\"September 24, 2021\",\"6.7 inch\",\"1284 x 2778\",\"Hexa-core (2x3.23 GHz Avalanche + 4x1.82 GHz Blizzard)\",\"6 GB\",\"128, 256, 512 GB, 1TB\",\"12 MP\",\"4352 mAh\",\"iOS 15\""- }- ],- "agent_thoughts": [],- "created_at": 1705569239,- }- ]- }- ```- </CodeGroup>-- ### Response Example (Agent Assistant)- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "limit": 20,- "has_more": false,- "data": [- {- "id": "d35e006c-7c4d-458f-9142-be4930abdf94",- "conversation_id": "957c068b-f258-4f89-ba10-6e8a0361c457",- "inputs": {},- "query": "draw a cat",- "answer": "I have generated an image of a cat for you. Please check your messages to view the image.",- "message_files": [- {- "id": "976990d2-5294-47e6-8f14-7356ba9d2d76",- "type": "image",- "url": "http://127.0.0.1:5001/files/tools/976990d2-5294-47e6-8f14-7356ba9d2d76.png?timestamp=1705988524&nonce=55df3f9f7311a9acd91bf074cd524092&sign=z43nMSO1L2HBvoqADLkRxr7Biz0fkjeDstnJiCK1zh8=",- "belongs_to": "assistant"- }- ],- "feedback": null,- "retriever_resources": [],- "created_at": 1705988187,- "agent_thoughts": [- {- "id": "592c84cf-07ee-441c-9dcc-ffc66c033469",- "chain_id": null,- "message_id": "d35e006c-7c4d-458f-9142-be4930abdf94",- "position": 1,- "thought": "",- "tool": "dalle2",- "tool_input": "{\"dalle2\": {\"prompt\": \"cat\"}}",- "created_at": 1705988186,- "observation": "image has been created and sent to user already, you should tell user to check it now.",- "files": [- "976990d2-5294-47e6-8f14-7356ba9d2d76"- ]- },- {- "id": "73ead60d-2370-4780-b5ed-532d2762b0e5",- "chain_id": null,- "message_id": "d35e006c-7c4d-458f-9142-be4930abdf94",- "position": 2,- "thought": "I have generated an image of a cat for you. Please check your messages to view the image.",- "tool": "",- "tool_input": "",- "created_at": 1705988199,- "observation": "",- "files": []- }- ]- }- ]- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/conversations'- method='GET'- title='Get Conversations'- name='#conversations'-/>-<Row>- <Col>- Retrieve the conversation list for the current user, defaulting to the most recent 20 entries.-- ### Query-- <Properties>- <Property name='user' type='string' key='user'>- User identifier, used to define the identity of the end-user for retrieval and statistics.- Should be uniquely defined by the developer within the application.- </Property>- <Property name='last_id' type='string' key='last_id'>- (Optional) The ID of the last record on the current page, default is null.- </Property>- <Property name='limit' type='int' key='limit'>- (Optional) How many records to return in one request, default is the most recent 20 entries. Maximum 100, minimum 1.- </Property>- <Property name='sort_by' type='string' key='sort_by'>- (Optional) Sorting Field, Default: -updated_at (sorted in descending order by update time)- - Available Values: created_at, -created_at, updated_at, -updated_at- - The symbol before the field represents the order or reverse, "-" represents reverse order.- </Property>- </Properties>-- ### Response- - `data` (array[object]) List of conversations- - `id` (string) Conversation ID- - `name` (string) Conversation name, by default, is a snippet of the first question asked by the user in the conversation.- - `inputs` (object) User input parameters.- - `status` (string) Conversation status- - `introduction` (string) Introduction- - `created_at` (timestamp) Creation timestamp, e.g., 1705395332- - `updated_at` (timestamp) Update timestamp, e.g., 1705395332- - `has_more` (bool)- - `limit` (int) Number of entries returned, if input exceeds system limit, system limit number is returned-- </Col>- <Col sticky>-- <CodeGroup- title="Request"- tag="GET"- label="/conversations"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/conversations?user=abc-123&last_id=&limit=20' \\---header 'Authorization: Bearer {api_key}'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "limit": 20,- "has_more": false,- "data": [- {- "id": "10799fb8-64f7-4296-bbf7-b42bfbe0ae54",- "name": "New chat",- "inputs": {- "book": "book",- "myName": "Lucy"- },- "status": "normal",- "created_at": 1679667915,- "updated_at": 1679667915- },- {- "id": "hSIhXBhNe8X1d8Et"- // ...- }- ]- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/conversations/:conversation_id'- method='DELETE'- title='Delete Conversation'- name='#delete'-/>-<Row>- <Col>- Delete a conversation.-- ### Path- - `conversation_id` (string) Conversation ID-- ### Request Body-- <Properties>- <Property name='user' type='string' key='user'>- The user identifier, defined by the developer, must ensure uniqueness within the application.- </Property>- </Properties>-- ### Response- - `result` (string) Always returns "success"- </Col>- <Col sticky>-- <CodeGroup- title="Request"- tag="DELETE"- label="/conversations/:conversation_id"- targetCode={`curl -X DELETE '${props.appDetail.api_base_url}/conversations/:conversation_id' \\---header 'Authorization: Bearer {api_key}' \\---header 'Content-Type: application/json' \\---data-raw '{- "user": "abc-123"-}'`}- />-- <CodeGroup title="Response">- ```text {{ title: 'Response' }}- 204 No Content- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/conversations/:conversation_id/name'- method='POST'- title='Conversation Rename'- name='#rename'-/>-<Row>- <Col>- ### Request Body- Rename the session, the session name is used for display on clients that support multiple sessions.-- ### Path- - `conversation_id` (string) Conversation ID-- <Properties>- <Property name='name' type='string' key='name'>- (Optional) The name of the conversation. This parameter can be omitted if `auto_generate` is set to `true`.- </Property>- <Property name='auto_generate' type='bool' key='auto_generate'>- (Optional) Automatically generate the title, default is `false`- </Property>- <Property name='user' type='string' key='user'>- The user identifier, defined by the developer, must ensure uniqueness within the application.- </Property>- </Properties>-- ### Response- - `id` (string) Conversation ID- - `name` (string) Conversation name- - `inputs` (object) User input parameters- - `status` (string) Conversation status- - `introduction` (string) Introduction- - `created_at` (timestamp) Creation timestamp, e.g., 1705395332- - `updated_at` (timestamp) Update timestamp, e.g., 1705395332- </Col>- <Col sticky>-- <CodeGroup- title="Request"- tag="POST"- label="/conversations/:conversation_id/name"- targetCode={`curl -X POST '${props.appDetail.api_base_url}/conversations/:conversation_id/name' \\---header 'Authorization: Bearer {api_key}' \\---header 'Content-Type: application/json' \\---data-raw '{- "name": "",- "auto_generate": true,- "user": "abc-123"-}'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "id": "cd78daf6-f9e4-4463-9ff2-54257230a0ce",- "name": "Chat vs AI",- "inputs": {},- "status": "normal",- "introduction": "",- "created_at": 1705569238,- "updated_at": 1705569238- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/conversations/:conversation_id/variables'- method='GET'- title='Get Conversation Variables'- name='#conversation-variables'-/>-<Row>- <Col>- Retrieve variables from a specific conversation. This endpoint is useful for extracting structured data that was captured during the conversation.-- ### Path Parameters-- <Properties>- <Property name='conversation_id' type='string' key='conversation_id'>- The ID of the conversation to retrieve variables from.- </Property>- </Properties>-- ### Query Parameters-- <Properties>- <Property name='user' type='string' key='user'>- The user identifier, defined by the developer, must ensure uniqueness within the application- </Property>- <Property name='last_id' type='string' key='last_id'>- (Optional) The ID of the last record on the current page, default is null.- </Property>- <Property name='limit' type='int' key='limit'>- (Optional) How many records to return in one request, default is the most recent 20 entries. Maximum 100, minimum 1.- </Property>- </Properties>-- ### Response-- - `limit` (int) Number of items per page- - `has_more` (bool) Whether there is a next page- - `data` (array[object]) List of variables- - `id` (string) Variable ID- - `name` (string) Variable name- - `value_type` (string) Variable type (string, number, object, etc.)- - `value` (string) Variable value- - `description` (string) Variable description- - `created_at` (int) Creation timestamp- - `updated_at` (int) Last update timestamp-- ### Errors- - 404, `conversation_not_exists`, Conversation not found-- </Col>- <Col sticky>-- <CodeGroup- title="Request"- tag="GET"- label="/conversations/:conversation_id/variables"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/conversations/{conversation_id}/variables?user=abc-123' \\---header 'Authorization: Bearer {api_key}'`}- />-- <CodeGroup title="Request with variable name filter">- ```bash {{ title: 'cURL' }}- curl -X GET '${props.appDetail.api_base_url}/conversations/{conversation_id}/variables?user=abc-123&variable_name=customer_name' \- --header 'Authorization: Bearer {api_key}'- ```- </CodeGroup>-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "limit": 100,- "has_more": false,- "data": [- {- "id": "variable-uuid-1",- "name": "customer_name",- "value_type": "string",- "value": "John Doe",- "description": "Customer name extracted from the conversation",- "created_at": 1650000000000,- "updated_at": 1650000000000- },- {- "id": "variable-uuid-2",- "name": "order_details",- "value_type": "json",- "value": "{\"product\":\"Widget\",\"quantity\":5,\"price\":19.99}",- "description": "Order details from the customer",- "created_at": 1650000000000,- "updated_at": 1650000000000- }- ]- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/conversations/:conversation_id/variables/:variable_id'- method='PUT'- title='Update Conversation Variable'- name='#update-conversation-variable'-/>-<Row>- <Col>- Update the value of a specific conversation variable. This endpoint allows you to modify the value of a variable that was captured during the conversation while preserving its name, type, and description.-- ### Path Parameters-- <Properties>- <Property name='conversation_id' type='string' key='conversation_id'>- The ID of the conversation containing the variable to update.- </Property>- <Property name='variable_id' type='string' key='variable_id'>- The ID of the variable to update.- </Property>- </Properties>-- ### Request Body-- <Properties>- <Property name='value' type='any' key='value'>- The new value for the variable. Must match the variable's expected type (string, number, object, etc.).- </Property>- <Property name='user' type='string' key='user'>- The user identifier, defined by the developer, must ensure uniqueness within the application.- </Property>- </Properties>-- ### Response-- Returns the updated variable object with:- - `id` (string) Variable ID- - `name` (string) Variable name- - `value_type` (string) Variable type (string, number, object, etc.)- - `value` (any) Updated variable value- - `description` (string) Variable description- - `created_at` (int) Creation timestamp- - `updated_at` (int) Last update timestamp-- ### Errors- - 400, `Type mismatch: variable expects {expected_type}, but got {actual_type} type`, Value type doesn't match variable's expected type- - 404, `conversation_not_exists`, Conversation not found- - 404, `conversation_variable_not_exists`, Variable not found-- </Col>- <Col sticky>-- <CodeGroup- title="Request"- tag="PUT"- label="/conversations/:conversation_id/variables/:variable_id"- targetCode={`curl -X PUT '${props.appDetail.api_base_url}/conversations/{conversation_id}/variables/{variable_id}' \\---header 'Authorization: Bearer {api_key}' \\---header 'Content-Type: application/json' \\---data-raw '{- "value": "Updated Value",- "user": "abc-123"-}'`}- />-- <CodeGroup title="Update with different value types">- ```bash {{ title: 'String Value' }}- curl -X PUT '${props.appDetail.api_base_url}/conversations/{conversation_id}/variables/{variable_id}' \- --header 'Content-Type: application/json' \- --header 'Authorization: Bearer {api_key}' \- --data-raw '{- "value": "New string value",- "user": "abc-123"- }'- ```-- ```bash {{ title: 'Number Value' }}- curl -X PUT '${props.appDetail.api_base_url}/conversations/{conversation_id}/variables/{variable_id}' \- --header 'Content-Type: application/json' \- --header 'Authorization: Bearer {api_key}' \- --data-raw '{- "value": 42,- "user": "abc-123"- }'- ```-- ```bash {{ title: 'Object Value' }}- curl -X PUT '${props.appDetail.api_base_url}/conversations/{conversation_id}/variables/{variable_id}' \- --header 'Content-Type: application/json' \- --header 'Authorization: Bearer {api_key}' \- --data-raw '{- "value": {"product": "Widget", "quantity": 10, "price": 29.99},- "user": "abc-123"- }'- ```- </CodeGroup>-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "id": "variable-uuid-1",- "name": "customer_name",- "value_type": "string",- "value": "Updated Value",- "description": "Customer name extracted from the conversation",- "created_at": 1650000000000,- "updated_at": 1650000001000- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/audio-to-text'- method='POST'- title='Speech to Text'- name='#audio-to-text'-/>-<Row>- <Col>- This endpoint requires a multipart/form-data request.-- ### Request Body-- <Properties>- <Property name='file' type='file' key='file'>- Audio file.- Supported formats: `['mp3', 'mp4', 'mpeg', 'mpga', 'm4a', 'wav', 'webm']`- File size limit: 15MB- </Property>- <Property name='user' type='string' key='user'>- User identifier, defined by the developer's rules, must be unique within the application.- </Property>- </Properties>-- ### Response- - `text` (string) Output text-- </Col>- <Col sticky>-- <CodeGroup- title="Request"- tag="POST"- label="/audio-to-text"- targetCode={`curl -X POST '${props.appDetail.api_base_url}/audio-to-text' \\---header 'Authorization: Bearer {api_key}' \\---form 'file=@localfile;type=audio/[mp3|mp4|mpeg|mpga|m4a|wav|webm]'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "text": ""- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/text-to-audio'- method='POST'- title='Text to Audio'- name='#text-to-audio'-/>-<Row>- <Col>- Text to speech.-- ### Request Body-- <Properties>- <Property name='message_id' type='str' key='message_id'>- For text messages generated by Dify, simply pass the generated message-id directly. The backend will use the message-id to look up the corresponding content and synthesize the voice information directly. If both message_id and text are provided simultaneously, the message_id is given priority.- </Property>- <Property name='text' type='str' key='text'>- Speech generated content。- </Property>- <Property name='user' type='string' key='user'>- The user identifier, defined by the developer, must ensure uniqueness within the app.- </Property>- </Properties>- </Col>- <Col sticky>-- <CodeGroup- title="Request"- tag="POST"- label="/text-to-audio"- targetCode={`curl --location --request POST '${props.appDetail.api_base_url}/text-to-audio' \\---header 'Authorization: Bearer ENTER-YOUR-SECRET-KEY' \\---form 'text=Hello Dify;user=abc-123;message_id=5ad4cb98-f0c7-4085-b384-88c403be6290`}- />-- <CodeGroup title="headers">- ```json {{ title: 'headers' }}- {- "Content-Type": "audio/wav"- }- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/info'- method='GET'- title='Get Application Basic Information'- name='#info'-/>-<Row>- <Col>- Used to get basic information about this application-- ### Response- - `name` (string) application name- - `description` (string) application description- - `tags` (array[string]) application tags- - `mode` (string) application mode- - `author_name` (string) application author name- </Col>- <Col>- <CodeGroup- title="Request"- tag="GET"- label="/info"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/info' \\--H 'Authorization: Bearer {api_key}'`}- />- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "name": "My App",- "description": "This is my app.",- "tags": [- "tag1",- "tag2"- ],- "mode": "advanced-chat",- "author_name": "Dify"- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/parameters'- method='GET'- title='Get Application Parameters Information'- name='#parameters'-/>-<Row>- <Col>- Used at the start of entering the page to obtain information such as features, input parameter names, types, and default values.-- ### Query-- <Properties>- <Property name='user' type='string' key='user'>- User identifier, defined by the developer's rules, must be unique within the application.- </Property>- </Properties>-- ### Response- - `opening_statement` (string) Opening statement- - `suggested_questions` (array[string]) List of suggested questions for the opening- - `suggested_questions_after_answer` (object) Suggest questions after enabling the answer.- - `enabled` (bool) Whether it is enabled- - `speech_to_text` (object) Speech to text- - `enabled` (bool) Whether it is enabled- - `text_to_speech` (object) Text to speech- - `enabled` (bool) Whether it is enabled- - `voice` (string) Voice type- - `language` (string) Language- - `autoPlay` (string) Auto play- - `enabled` Enabled- - `disabled` Disabled- - `retriever_resource` (object) Citation and Attribution- - `enabled` (bool) Whether it is enabled- - `annotation_reply` (object) Annotation reply- - `enabled` (bool) Whether it is enabled- - `user_input_form` (array[object]) User input form configuration- - `text-input` (object) Text input control- - `label` (string) Variable display label name- - `variable` (string) Variable ID- - `required` (bool) Whether it is required- - `default` (string) Default value- - `paragraph` (object) Paragraph text input control- - `label` (string) Variable display label name- - `variable` (string) Variable ID- - `required` (bool) Whether it is required- - `default` (string) Default value- - `select` (object) Dropdown control- - `label` (string) Variable display label name- - `variable` (string) Variable ID- - `required` (bool) Whether it is required- - `default` (string) Default value- - `options` (array[string]) Option values- - `file_upload` (object) File upload configuration- - `document` (object) Document settings- Currently only supports document types: `txt`, `md`, `markdown`, `pdf`, `html`, `xlsx`, `xls`, `docx`, `csv`, `eml`, `msg`, `pptx`, `ppt`, `xml`, `epub`.- - `enabled` (bool) Whether it is enabled- - `number_limits` (int) Document number limit, default is 3- - `transfer_methods` (array[string]) List of transfer methods: `remote_url`, `local_file`. Must choose one.- - `image` (object) Image settings- Currently only supports image types: `png`, `jpg`, `jpeg`, `webp`, `gif`.- - `enabled` (bool) Whether it is enabled- - `number_limits` (int) Image number limit, default is 3- - `transfer_methods` (array[string]) List of transfer methods: `remote_url`, `local_file`. Must choose one.- - `audio` (object) Audio settings- Currently only supports audio types: `mp3`, `m4a`, `wav`, `webm`, `amr`.- - `enabled` (bool) Whether it is enabled- - `number_limits` (int) Audio number limit, default is 3- - `transfer_methods` (array[string]) List of transfer methods: `remote_url`, `local_file`. Must choose one.- - `video` (object) Video settings- Currently only supports video types: `mp4`, `mov`, `mpeg`, `mpga`.- - `enabled` (bool) Whether it is enabled- - `number_limits` (int) Video number limit, default is 3- - `transfer_methods` (array[string]) List of transfer methods: `remote_url`, `local_file`. Must choose one.- - `custom` (object) Custom settings- - `enabled` (bool) Whether it is enabled- - `number_limits` (int) Custom number limit, default is 3- - `transfer_methods` (array[string]) List of transfer methods: `remote_url`, `local_file`. Must choose one.- - `system_parameters` (object) System parameters- - `file_size_limit` (int) Document upload size limit (MB)- - `image_file_size_limit` (int) Image file upload size limit (MB)- - `audio_file_size_limit` (int) Audio file upload size limit (MB)- - `video_file_size_limit` (int) Video file upload size limit (MB)-- </Col>- <Col sticky>-- <CodeGroup- title="Request"- tag="GET"- label="/parameters"- targetCode={` curl -X GET '${props.appDetail.api_base_url}/parameters'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "opening_statement": "Hello!",- "suggested_questions_after_answer": {- "enabled": true- },- "speech_to_text": {- "enabled": true- },- "text_to_speech": {- "enabled": true,- "voice": "sambert-zhinan-v1",- "language": "zh-Hans",- "autoPlay": "disabled"- },- "retriever_resource": {- "enabled": true- },- "annotation_reply": {- "enabled": true- },- "user_input_form": [- {- "paragraph": {- "label": "Query",- "variable": "query",- "required": true,- "default": ""- }- }- ],- "file_upload": {- "image": {- "enabled": false,- "number_limits": 3,- "detail": "high",- "transfer_methods": [- "remote_url",- "local_file"- ]- }- },- "system_parameters": {- "file_size_limit": 15,- "image_file_size_limit": 10,- "audio_file_size_limit": 50,- "video_file_size_limit": 100- }- }- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/meta'- method='GET'- title='Get Application Meta Information'- name='#meta'-/>-<Row>- <Col>- Used to get icons of tools in this application-- ### Response- - `tool_icons`(object[string]) tool icons- - `tool_name` (string)- - `icon` (object|string)- - (object) icon object- - `background` (string) background color in hex format- - `content`(string) emoji- - (string) url of icon- </Col>- <Col>- <CodeGroup- title="Request"- tag="GET"- label="/meta"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/meta' \\--H 'Authorization: Bearer {api_key}'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "tool_icons": {- "dalle2": "https://cloud.dify.ai/console/api/workspaces/current/tool-provider/builtin/dalle/icon",- "api_tool": {- "background": "#252525",- "content": "\ud83d\ude01"- }- }- }- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/site'- method='GET'- title='Get Application WebApp Settings'- name='#site'-/>-<Row>- <Col>- Used to get the WebApp settings of the application.- ### Response- - `title` (string) WebApp name- - `chat_color_theme` (string) Chat color theme, in hex format- - `chat_color_theme_inverted` (bool) Whether the chat color theme is inverted- - `icon_type` (string) Icon type, `emoji` - emoji, `image` - picture- - `icon` (string) Icon. If it's `emoji` type, it's an emoji symbol; if it's `image` type, it's an image URL- - `icon_background` (string) Background color in hex format- - `icon_url` (string) Icon URL- - `description` (string) Description- - `copyright` (string) Copyright information- - `privacy_policy` (string) Privacy policy link- - `custom_disclaimer` (string) Custom disclaimer- - `default_language` (string) Default language- - `show_workflow_steps` (bool) Whether to show workflow details- - `use_icon_as_answer_icon` (bool) Whether to replace 🤖 in chat with the WebApp icon- </Col>- <Col>- <CodeGroup- title="Request"- tag="GET"- label="/site"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/site' \\--H 'Authorization: Bearer {api_key}'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "title": "My App",- "chat_color_theme": "#ff4a4a",- "chat_color_theme_inverted": false,- "icon_type": "emoji",- "icon": "😄",- "icon_background": "#FFEAD5",- "icon_url": null,- "description": "This is my app.",- "copyright": "all rights reserved",- "privacy_policy": "",- "custom_disclaimer": "All generated by AI",- "default_language": "en-US",- "show_workflow_steps": false,- "use_icon_as_answer_icon": false,- }- ```- </CodeGroup>- </Col>-</Row>-___--<Heading- url='/apps/annotations'- method='GET'- title='Get Annotation List'- name='#annotation_list'-/>-<Row>- <Col>- ### Query- <Properties>- <Property name='page' type='string' key='page'>- Page number- </Property>- <Property name='limit' type='string' key='limit'>- Number of items returned, default 20, range 1-100- </Property>- </Properties>- </Col>- <Col sticky>- <CodeGroup- title="Request"- tag="GET"- label="/apps/annotations"- targetCode={`curl --location --request GET '${props.apiBaseUrl}/apps/annotations?page=1&limit=20' \\---header 'Authorization: Bearer {api_key}'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "data": [- {- "id": "69d48372-ad81-4c75-9c46-2ce197b4d402",- "question": "What is your name?",- "answer": "I am Dify.",- "hit_count": 0,- "created_at": 1735625869- }- ],- "has_more": false,- "limit": 20,- "total": 1,- "page": 1- }- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/apps/annotations'- method='POST'- title='Create Annotation'- name='#create_annotation'-/>-<Row>- <Col>- ### Query- <Properties>- <Property name='question' type='string' key='question'>- Question- </Property>- <Property name='answer' type='string' key='answer'>- Answer- </Property>- </Properties>- </Col>- <Col sticky>- <CodeGroup- title="Request"- tag="POST"- label="/apps/annotations"- targetCode={`curl --location --request POST '${props.apiBaseUrl}/apps/annotations' \\---header 'Authorization: Bearer {api_key}' \\---header 'Content-Type: application/json' \\---data-raw '{"question": "What is your name?","answer": "I am Dify."}'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- {- "id": "69d48372-ad81-4c75-9c46-2ce197b4d402",- "question": "What is your name?",- "answer": "I am Dify.",- "hit_count": 0,- "created_at": 1735625869- }- }- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/apps/annotations/{annotation_id}'- method='PUT'- title='Update Annotation'- name='#update_annotation'-/>-<Row>- <Col>- ### Query- <Properties>- <Property name='annotation_id' type='string' key='annotation_id'>- Annotation ID- </Property>- <Property name='question' type='string' key='question'>- Question- </Property>- <Property name='answer' type='string' key='answer'>- Answer- </Property>- </Properties>- </Col>- <Col sticky>- <CodeGroup- title="Request"- tag="PUT"- label="/apps/annotations/{annotation_id}"- targetCode={`curl --location --request POST '${props.apiBaseUrl}/apps/annotations/{annotation_id}' \\---header 'Authorization: Bearer {api_key}' \\---header 'Content-Type: application/json' \\---data-raw '{"question": "What is your name?","answer": "I am Dify."}'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- {- "id": "69d48372-ad81-4c75-9c46-2ce197b4d402",- "question": "What is your name?",- "answer": "I am Dify.",- "hit_count": 0,- "created_at": 1735625869- }- }- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/apps/annotations/{annotation_id}'- method='DELETE'- title='Delete Annotation'- name='#delete_annotation'-/>-<Row>- <Col>- ### Query- <Properties>- <Property name='annotation_id' type='string' key='annotation_id'>- Annotation ID- </Property>- </Properties>- </Col>- <Col sticky>- <CodeGroup- title="Request"- tag="PUT"- label="/apps/annotations/{annotation_id}"- targetCode={`curl --location --request DELETE '${props.apiBaseUrl}/apps/annotations/{annotation_id}' \\---header 'Authorization: Bearer {api_key}' \\---header 'Content-Type: application/json'`}- />-- <CodeGroup title="Response">- ```text {{ title: 'Response' }}- 204 No Content- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/apps/annotation-reply/{action}'- method='POST'- title='Initial Annotation Reply Settings'- name='#initial_annotation_reply_settings'-/>-<Row>- <Col>- ### Query- <Properties>- <Property name='action' type='string' key='action'>- Action, can only be 'enable' or 'disable'- </Property>- <Property name='embedding_model_provider' type='string' key='embedding_model_provider'>- Specified embedding model provider, must be set up in the system first, corresponding to the provider field(Optional)- </Property>- <Property name='embedding_model' type='string' key='embedding_model'>- Specified embedding model, corresponding to the model field(Optional)- </Property>- <Property name='score_threshold' type='number' key='score_threshold'>- The similarity threshold for matching annotated replies. Only annotations with scores above this threshold will be recalled.- </Property>- </Properties>- </Col>- <Col sticky>- The provider and model name of the embedding model can be obtained through the following interface: v1/workspaces/current/models/model-types/text-embedding. For specific instructions, see: Maintain Knowledge Base via API. The Authorization used is the Dataset API Token.- <CodeGroup- title="Request"- tag="POST"- label="/apps/annotation-reply/{action}"- targetCode={`curl --location --request POST '${props.apiBaseUrl}/apps/annotation-reply/{action}' \\---header 'Authorization: Bearer {api_key}' \\---header 'Content-Type: application/json' \\---data-raw '{"score_threshold": 0.9, "embedding_provider_name": "zhipu", "embedding_model_name": "embedding_3"}'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "job_id": "b15c8f68-1cf4-4877-bf21-ed7cf2011802",- "job_status": "waiting"- }- ```- </CodeGroup>- This interface is executed asynchronously, so it will return a job_id. You can get the final execution result by querying the job status interface.- </Col>-</Row>------<Heading- url='/apps/annotation-reply/{action}/status/{job_id}'- method='GET'- title='Query Initial Annotation Reply Settings Task Status'- name='#initial_annotation_reply_settings_task_status'-/>-<Row>- <Col>- ### Query- <Properties>- <Property name='action' type='string' key='action'>- Action, can only be 'enable' or 'disable', must be the same as the action in the initial annotation reply settings interface- </Property>- <Property name='job_id' type='string' key='job_id'>- Job ID,- </Property>- </Properties>- </Col>- <Col sticky>- <CodeGroup- title="Request"- tag="GET"- label="/apps/annotations"- targetCode={`curl --location --request GET '${props.apiBaseUrl}/apps/annotation-reply/{action}/status/{job_id}' \\---header 'Authorization: Bearer {api_key}'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "job_id": "b15c8f68-1cf4-4877-bf21-ed7cf2011802",- "job_status": "waiting",- "error_msg": ""- }- ```- </CodeGroup>- </Col>-</Row>diff --git a/web/app/components/develop/template/template_chat.ja.mdx b/web/app/components/develop/template/template_chat.ja.mdxdeleted file mode 100644index e418f1c8d78..00000000000--- a/web/app/components/develop/template/template_chat.ja.mdx+++ /dev/null@@ -1,1689 +0,0 @@-import { CodeGroup } from '../code.tsx'-import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx'--# チャットアプリ API--チャットアプリケーションはセッションの持続性をサポートしており、以前のチャット履歴を応答のコンテキストとして使用できます。これは、チャットボットやカスタマーサービス AI などに適用できます。--<div>- ### ベース URL- <CodeGroup title="コード" targetCode={props.appDetail.api_base_url} />-- ### 認証-- サービス API は `API-Key` 認証を使用します。- <i>**API キーの漏洩を防ぐため、API キーはクライアント側で共有または保存せず、サーバー側で保存することを強くお勧めします。**</i>-- すべての API リクエストにおいて、以下のように `Authorization`HTTP ヘッダーに API キーを含めてください:-- <CodeGroup title="コード" targetCode='Authorization: Bearer {API_KEY}' />-</div>-------<Heading- url='/chat-messages'- method='POST'- title='チャットメッセージを送信'- name='#Send-Chat-Message'-/>-<Row>- <Col>- チャットアプリケーションにリクエストを送信します。-- ### リクエストボディ-- <Properties>- <Property name='query' type='string' key='query'>- ユーザー入力/質問内容- </Property>- <Property name='inputs' type='object' key='inputs'>- アプリで定義されたさまざまな変数値の入力を許可します。- `inputs`パラメータには複数のキー/値ペアが含まれ、各キーは特定の変数に対応し、各値はその変数の特定の値です。デフォルトは`{}`- </Property>- <Property name='response_mode' type='string' key='response_mode'>- 応答の返却モードを指定します。サポートされているモード:- - `streaming` ストリーミングモード(推奨)、SSE([Server-Sent Events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events))を通じてタイプライターのような出力を実装します。- - `blocking` ブロッキングモード、実行完了後に結果を返します。(プロセスが長い場合、リクエストが中断される可能性があります)- Cloudflareの制限により、100秒後に応答がない場合、リクエストは中断されます。- <i>注:エージェントアシスタントモードではブロッキングモードはサポートされていません</i>- </Property>- <Property name='user' type='string' key='user'>- ユーザー識別子、エンドユーザーのアイデンティティを定義するために使用されます。- アプリケーション内で開発者によって一意に定義される必要があります。- </Property>- <Property name='conversation_id' type='string' key='conversation_id'>- 会話ID、以前のチャット記録に基づいて会話を続けるには、前のメッセージのconversation_idを渡す必要があります。- </Property>- <Property name='files' type='array[object]' key='files'>- ファイルリスト、モデルが Vision/Video 機能をサポートしている場合に限り、ファイルをテキスト理解および質問応答に組み合わせて入力するのに適しています。- - `type` (string) サポートされるタイプ:- - `document` サポートされるタイプには以下が含まれます:'TXT', 'MD', 'MARKDOWN', 'MDX', 'PDF', 'HTML', 'XLSX', 'XLS', 'VTT', 'PROPERTIES', 'DOC', 'DOCX', 'CSV', 'EML', 'MSG', 'PPTX', 'PPT', 'XML', 'EPUB'- - `image` サポートされるタイプには以下が含まれます:'JPG', 'JPEG', 'PNG', 'GIF', 'WEBP', 'SVG'- - `audio` サポートされるタイプには以下が含まれます:'MP3', 'M4A', 'WAV', 'WEBM', 'MPGA'- - `video` サポートされるタイプには以下が含まれます:'MP4', 'MOV', 'MPEG', 'WEBM'- - `custom` サポートされるタイプには以下が含まれます:その他のファイルタイプ- - `transfer_method` (string) 転送方法:- - `remote_url`: ファイルのURL。- - `local_file`: ファイルをアップロード。- - `url` ファイルのURL。(転送方法が `remote_url` の場合のみ)。- - `upload_file_id` アップロードされたファイルID。(転送方法が `local_file` の場合のみ)。- </Property>- <Property name='auto_generate_name' type='bool' key='auto_generate_name'>- タイトルを自動生成します。デフォルトは`true`です。- `false`に設定すると、会話のリネームAPIを呼び出し、`auto_generate`を`true`に設定することで非同期タイトル生成を実現できます。- </Property>- <Property name='workflow_id' type='string' key='workflow_id'>- (オプション)ワークフローID、特定のバージョンを指定するために使用、提供されない場合はデフォルトの公開バージョンを使用。<br/>- 取得方法:バージョン履歴インターフェースで、各バージョンエントリの右側にあるコピーアイコンをクリックすると、完全なワークフローIDをコピーできます。- </Property>- <Property name='trace_id' type='string' key='trace_id'>- (オプション)トレースID。既存の業務システムのトレースコンポーネントと連携し、エンドツーエンドの分散トレーシングを実現するために使用します。指定がない場合、システムが自動的に trace_id を生成します。以下の3つの方法で渡すことができ、優先順位は次のとおりです:<br/>- - Header:HTTPヘッダー <code>X-Trace-Id</code> で渡す(最優先)。<br/>- - クエリパラメータ:URLクエリパラメータ <code>trace_id</code> で渡す。<br/>- - リクエストボディ:リクエストボディの <code>trace_id</code> フィールドで渡す(本フィールド)。<br/>- </Property>- <Property name='trace_session_id' type='string' key='trace_session_id'>- (オプション)可観測性のグルーピングに使用するトレースセッションID。セッションのグルーピングに対応するトレースプロバイダーは、この値をエクスポートされるセッション識別子として使用できます。conversation_id、workflow_run_id、trace_id、または span の関係は変更しません。以下の3つの方法で渡すことができ、優先順位は次のとおりです:<br/>- - Header:HTTPヘッダー <code>X-Trace-Session-Id</code> で渡す(最優先)。<br/>- - クエリパラメータ:URLクエリパラメータ <code>trace_session_id</code> で渡す。<br/>- - リクエストボディ:リクエストボディの <code>trace_session_id</code> フィールドで渡す(本フィールド)。<br/>- </Property>- </Properties>-- ### 応答- response_modeがブロッキングの場合、CompletionResponseオブジェクトを返します。- response_modeがストリーミングの場合、ChunkCompletionResponseストリームを返します。-- ### ChatCompletionResponse- 完全なアプリ結果を返します。`Content-Type`は`application/json`です。- - `event` (string) イベントタイプ、固定で `message`- - `task_id` (string) タスクID、リクエスト追跡と以下のStop Generate APIに使用- - `id` (string) ユニークID- - `message_id` (string) 一意のメッセージID- - `conversation_id` (string) 会話ID- - `mode` (string) アプリモード、`chat`として固定- - `answer` (string) 完全な応答内容- - `metadata` (object) メタデータ- - `usage` (Usage) モデル使用情報- - `retriever_resources` (array[RetrieverResource]) 引用と帰属リスト- - `created_at` (int) メッセージ作成タイムスタンプ、例:1705395332-- ### ChunkChatCompletionResponse- アプリによって出力されたストリームチャンクを返します。`Content-Type`は`text/event-stream`です。- 各ストリーミングチャンクは`data:`で始まり、2つの改行文字`\n\n`で区切られます。以下のように表示されます:- <CodeGroup>- ```streaming {{ title: '応答' }}- data: {"event": "message", "task_id": "900bbd43-dc0b-4383-a372-aa6e6c414227", "id": "663c5084-a254-4040-8ad3-51f2a3c1a77c", "answer": "Hi", "created_at": 1705398420}\n\n- ```- </CodeGroup>- ストリーミングチャンクの構造は`event`に応じて異なります:- - `event: message` LLMはテキストチャンクイベントを返します。つまり、完全なテキストがチャンク形式で出力されます。- - `task_id` (string) タスクID、リクエスト追跡と以下のStop Generate APIに使用- - `message_id` (string) 一意のメッセージID- - `conversation_id` (string) 会話ID- - `answer` (string) LLMが返したテキストチャンク内容- - `created_at` (int) 作成タイムスタンプ、例:1705395332- - `event: agent_message` LLMはテキストチャンクイベントを返します。つまり、エージェントアシスタントが有効な場合、完全なテキストがチャンク形式で出力されます(エージェントモードでのみサポート)- - `task_id` (string) タスクID、リクエスト追跡と以下のStop Generate APIに使用- - `message_id` (string) 一意のメッセージID- - `conversation_id` (string) 会話ID- - `answer` (string) LLMが返したテキストチャンク内容- - `created_at` (int) 作成タイムスタンプ、例:1705395332- - `event: tts_message` TTSオーディオストリームイベント、つまり音声合成出力。内容はMp3形式のオーディオブロックで、base64文字列としてエンコードされています。再生時には、base64をデコードしてプレーヤーに入力するだけです。(このメッセージは自動再生が有効な場合にのみ利用可能)- - `task_id` (string) タスクID、リクエスト追跡と以下の停止応答インターフェースに使用- - `message_id` (string) 一意のメッセージID- - `audio` (string) 音声合成後のオーディオ、base64テキストコンテンツとしてエンコードされており、再生時にはbase64をデコードしてプレーヤーに入力するだけです- - `created_at` (int) 作成タイムスタンプ、例:1705395332- - `event: tts_message_end` TTSオーディオストリーム終了イベント。このイベントを受信すると、オーディオストリームの終了を示します。- - `task_id` (string) タスクID、リクエスト追跡と以下の停止応答インターフェースに使用- - `message_id` (string) 一意のメッセージID- - `audio` (string) 終了イベントにはオーディオがないため、これは空の文字列です- - `created_at` (int) 作成タイムスタンプ、例:1705395332- - `event: agent_thought` エージェントの思考、LLMの思考、ツール呼び出しの入力と出力を含みます(エージェントモードでのみサポート)- - `id` (string) エージェント思考ID、各反復には一意のエージェント思考IDがあります- - `task_id` (string) タスクID、リクエスト追跡と以下のStop Generate APIに使用- - `message_id` (string) 一意のメッセージID- - `position` (int) 現在のエージェント思考の位置、各メッセージには順番に複数の思考が含まれる場合があります。- - `thought` (string) LLMが考えていること- - `observation` (string) ツール呼び出しからの応答- - `tool` (string) 呼び出されたツールのリスト、;で区切られます- - `tool_input` (string) ツールの入力、JSON形式。例:`{"dalle3": {"prompt": "a cute cat"}}`。- - `created_at` (int) 作成タイムスタンプ、例:1705395332- - `message_files` (array[string]) message_fileイベントを参照- - `file_id` (string) ファイルID- - `conversation_id` (string) 会話ID- - `event: message_file` メッセージファイルイベント、ツールによって新しいファイルが作成されました- - `id` (string) ファイル一意ID- - `type` (string) ファイルタイプ、現在は"image"のみ許可- - `belongs_to` (string) 所属、ここでは'assistant'のみ- - `url` (string) ファイルのリモートURL- - `conversation_id` (string) 会話ID- - `event: message_end` メッセージ終了イベント、このイベントを受信するとストリーミングが終了したことを意味します。- - `task_id` (string) タスクID、リクエスト追跡と以下のStop Generate APIに使用- - `message_id` (string) 一意のメッセージID- - `conversation_id` (string) 会話ID- - `metadata` (object) メタデータ- - `usage` (Usage) モデル使用情報- - `retriever_resources` (array[RetrieverResource]) 引用と帰属リスト- - `event: message_replace` メッセージ内容置換イベント。- 出力内容のモデレーションが有効な場合、内容がフラグされると、このイベントを通じてメッセージ内容が事前設定された返信に置き換えられます。- - `task_id` (string) タスクID、リクエスト追跡と以下のStop Generate APIに使用- - `message_id` (string) 一意のメッセージID- - `conversation_id` (string) 会話ID- - `answer` (string) 置換内容(すべてのLLM返信テキストを直接置換)- - `created_at` (int) 作成タイムスタンプ、例:1705395332- - `event: error`- ストリーミングプロセス中に発生した例外はストリームイベントの形式で出力され、エラーイベントを受信するとストリームが終了します。- - `task_id` (string) タスクID、リクエスト追跡と以下のStop Generate APIに使用- - `message_id` (string) 一意のメッセージID- - `status` (int) HTTPステータスコード- - `code` (string) エラーコード- - `message` (string) エラーメッセージ- - `event: ping` 接続を維持するために10秒ごとにpingイベントが発生します。-- ### エラー- - 404, 会話が存在しません- - 400, `invalid_param`, 異常なパラメータ入力- - 400, `app_unavailable`, アプリ構成が利用できません- - 400, `provider_not_initialize`, 利用可能なモデル資格情報構成がありません- - 400, `provider_quota_exceeded`, モデル呼び出しクォータが不足しています- - 400, `model_currently_not_support`, 現在のモデルは利用できません- - 400, `workflow_not_found`, 指定されたワークフローバージョンが見つかりません- - 400, `draft_workflow_error`, ドラフトワークフローバージョンは使用できません- - 400, `workflow_id_format_error`, ワークフローID形式エラー、UUID形式が必要です- - 400, `completion_request_error`, テキスト生成に失敗しました- - 500, 内部サーバーエラー-- </Col>- <Col sticky>-- <CodeGroup- title="リクエスト"- tag="POST"- label="/chat-messages"- targetCode={`curl -X POST '${props.appDetail.api_base_url}/chat-messages' \\---header 'Authorization: Bearer {api_key}' \\---header 'Content-Type: application/json' \\---data-raw '{- "inputs": ${JSON.stringify(props.inputs)},- "query": "What are the specs of the iPhone 13 Pro Max?",- "response_mode": "streaming",- "conversation_id": "",- "user": "abc-123",- "files": [- {- "type": "image",- "transfer_method": "remote_url",- "url": "https://cloud.dify.ai/logo/logo-site.png"- }- ]-}'`}- />- ### ブロッキングモード- <CodeGroup title="応答">- ```json {{ title: '応答' }}- {- "event": "message",- "task_id": "c3800678-a077-43df-a102-53f23ed20b88",- "id": "9da23599-e713-473b-982c-4328d4f5c78a",- "message_id": "9da23599-e713-473b-982c-4328d4f5c78a",- "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2",- "mode": "chat",- "answer": "iPhone 13 Pro Maxの仕様は次のとおりです:...",- "metadata": {- "usage": {- "prompt_tokens": 1033,- "prompt_unit_price": "0.001",- "prompt_price_unit": "0.001",- "prompt_price": "0.0010330",- "completion_tokens": 128,- "completion_unit_price": "0.002",- "completion_price_unit": "0.001",- "completion_price": "0.0002560",- "total_tokens": 1161,- "total_price": "0.0012890",- "currency": "USD",- "latency": 0.7682376249867957- },- "retriever_resources": [- {- "position": 1,- "dataset_id": "101b4c97-fc2e-463c-90b1-5261a4cdcafb",- "dataset_name": "iPhone",- "document_id": "8dd1ad74-0b5f-4175-b735-7d98bbbb4e00",- "document_name": "iPhone List",- "segment_id": "ed599c7f-2766-4294-9d1d-e5235a61270a",- "score": 0.98457545,- "content": "\"Model\",\"Release Date\",\"Display Size\",\"Resolution\",\"Processor\",\"RAM\",\"Storage\",\"Camera\",\"Battery\",\"Operating System\"\n\"iPhone 13 Pro Max\",\"September 24, 2021\",\"6.7 inch\",\"1284 x 2778\",\"Hexa-core (2x3.23 GHz Avalanche + 4x1.82 GHz Blizzard)\",\"6 GB\",\"128, 256, 512 GB, 1TB\",\"12 MP\",\"4352 mAh\",\"iOS 15\""- }- ]- },- "created_at": 1705407629- }- ```- </CodeGroup>- ### ストリーミングモード(基本アシスタント)- <CodeGroup title="応答">- ```streaming {{ title: '応答' }}- data: {"event": "message", "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " I", "created_at": 1679586595}- data: {"event": "message", "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": "'m", "created_at": 1679586595}- data: {"event": "message", "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " glad", "created_at": 1679586595}- data: {"event": "message", "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " to", "created_at": 1679586595}- data: {"event": "message", "message_id" : "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " meet", "created_at": 1679586595}- data: {"event": "message", "message_id" : "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " you", "created_at": 1679586595}- data: {"event": "message_end", "id": "5e52ce04-874b-4d27-9045-b3bc80def685", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "metadata": {"usage": {"prompt_tokens": 1033, "prompt_unit_price": "0.001", "prompt_price_unit": "0.001", "prompt_price": "0.0010330", "completion_tokens": 135, "completion_unit_price": "0.002", "completion_price_unit": "0.001", "completion_price": "0.0002700", "total_tokens": 1168, "total_price": "0.0013030", "currency": "USD", "latency": 1.381760165997548}, "retriever_resources": [{"position": 1, "dataset_id": "101b4c97-fc2e-463c-90b1-5261a4cdcafb", "dataset_name": "iPhone", "document_id": "8dd1ad74-0b5f-4175-b735-7d98bbbb4e00", "document_name": "iPhone List", "segment_id": "ed599c7f-2766-4294-9d1d-e5235a61270a", "score": 0.98457545, "content": "\"Model\",\"Release Date\",\"Display Size\",\"Resolution\",\"Processor\",\"RAM\",\"Storage\",\"Camera\",\"Battery\",\"Operating System\"\n\"iPhone 13 Pro Max\",\"September 24, 2021\",\"6.7 inch\",\"1284 x 2778\",\"Hexa-core (2x3.23 GHz Avalanche + 4x1.82 GHz Blizzard)\",\"6 GB\",\"128, 256, 512 GB, 1TB\",\"12 MP\",\"4352 mAh\",\"iOS 15\""}]}}- data: {"event": "tts_message", "conversation_id": "23dd85f3-1a41-4ea0-b7a9-062734ccfaf9", "message_id": "a8bdc41c-13b2-4c18-bfd9-054b9803038c", "created_at": 1721205487, "task_id": "3bf8a0bb-e73b-4690-9e66-4e429bad8ee7", "audio": "qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq"}- data: {"event": "tts_message_end", "conversation_id": "23dd85f3-1a41-4ea0-b7a9-062734ccfaf9", "message_id": "a8bdc41c-13b2-4c18-bfd9-054b9803038c", "created_at": 1721205487, "task_id": "3bf8a0bb-e73b-4690-9e66-4e429bad8ee7", "audio": ""}- ```- </CodeGroup>- ### 応答例(エージェントアシスタント)- <CodeGroup title="応答">- ```streaming {{ title: '応答' }}- data: {"event": "message", "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " I", "created_at": 1679586595}- data: {"event": "message", "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": "'m", "created_at": 1679586595}- data: {"event": "message", "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " glad", "created_at": 1679586595}- data: {"event": "message", "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " to", "created_at": 1679586595}- data: {"event": "message", "message_id" : "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " meet", "created_at": 1679586595}- data: {"event": "message", "message_id" : "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " you", "created_at": 1679586595}- data: {"event": "message_end", "id": "5e52ce04-874b-4d27-9045-b3bc80def685", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "metadata": {"usage": {"prompt_tokens": 1033, "prompt_unit_price": "0.001", "prompt_price_unit": "0.001", "prompt_price": "0.0010330", "completion_tokens": 135, "completion_unit_price": "0.002", "completion_price_unit": "0.001", "completion_price": "0.0002700", "total_tokens": 1168, "total_price": "0.0013030", "currency": "USD", "latency": 1.381760165997548}, "retriever_resources": [{"position": 1, "dataset_id": "101b4c97-fc2e-463c-90b1-5261a4cdcafb", "dataset_name": "iPhone", "document_id": "8dd1ad74-0b5f-4175-b735-7d98bbbb4e00", "document_name": "iPhone List", "segment_id": "ed599c7f-2766-4294-9d1d-e5235a61270a", "score": 0.98457545, "content": "\"Model\",\"Release Date\",\"Display Size\",\"Resolution\",\"Processor\",\"RAM\",\"Storage\",\"Camera\",\"Battery\",\"Operating System\"\n\"iPhone 13 Pro Max\",\"September 24, 2021\",\"6.7 inch\",\"1284 x 2778\",\"Hexa-core (2x3.23 GHz Avalanche + 4x1.82 GHz Blizzard)\",\"6 GB\",\"128, 256, 512 GB, 1TB\",\"12 MP\",\"4352 mAh\",\"iOS 15\""}]}}- data: {"event": "tts_message", "conversation_id": "23dd85f3-1a41-4ea0-b7a9-062734ccfaf9", "message_id": "a8bdc41c-13b2-4c18-bfd9-054b9803038c", "created_at": 1721205487, "task_id": "3bf8a0bb-e73b-4690-9e66-4e429bad8ee7", "audio": "qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq"}- data: {"event": "tts_message_end", "conversation_id": "23dd85f3-1a41-4ea0-b7a9-062734ccfaf9", "message_id": "a8bdc41c-13b2-4c18-bfd9-054b9803038c", "created_at": 1721205487, "task_id": "3bf8a0bb-e73b-4690-9e66-4e429bad8ee7", "audio": ""}- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/files/upload'- method='POST'- title='ファイルアップロード'- name='#file-upload'-/>-<Row>- <Col>- メッセージ送信時に使用するためのファイルをアップロードします(現在は画像のみサポート)。画像とテキストのマルチモーダル理解を可能にします。- png、jpg、jpeg、webp、gif 形式をサポートしています。- アップロードされたファイルは現在のエンドユーザーのみが使用できます。-- ### リクエストボディ- このインターフェースは`multipart/form-data`リクエストを必要とします。- - `file` (File) 必須- アップロードするファイル。- - `user` (string) 必須- ユーザー識別子、開発者のルールで定義され、アプリケーション内で一意でなければなりません。サービス API は WebApp によって作成された会話を共有しません。-- ### 応答- アップロードが成功すると、サーバーはファイルの ID と関連情報を返します。- - `id` (uuid) ID- - `name` (string) ファイル名- - `size` (int) ファイルサイズ(バイト)- - `extension` (string) ファイル拡張子- - `mime_type` (string) ファイルの MIME タイプ- - `created_by` (uuid) エンドユーザーID- - `created_at` (timestamp) 作成タイムスタンプ、例:1705395332-- ### エラー- - 400, `no_file_uploaded`, ファイルが提供されなければなりません- - 400, `too_many_files`, 現在は 1 つのファイルのみ受け付けます- - 400, `unsupported_preview`, ファイルはプレビューをサポートしていません- - 400, `unsupported_estimate`, ファイルは推定をサポートしていません- - 413, `file_too_large`, ファイルが大きすぎます- - 415, `unsupported_file_type`, サポートされていない拡張子、現在はドキュメントファイルのみ受け付けます- - 503, `s3_connection_failed`, S3 サービスに接続できません- - 503, `s3_permission_denied`, S3 にファイルをアップロードする権限がありません- - 503, `s3_file_too_large`, ファイルが S3 のサイズ制限を超えています- - 500, 内部サーバーエラー--- </Col>- <Col sticky>- ### リクエスト例- <CodeGroup- title="リクエスト"- tag="POST"- label="/files/upload"- targetCode={`curl -X POST '${props.appDetail.api_base_url}/files/upload' \\---header 'Authorization: Bearer {api_key}' \\---form 'file=@localfile;type=image/[png|jpeg|jpg|webp|gif]' \\---form 'user=abc-123'`}- />-- ### 応答例- <CodeGroup title="応答">- ```json {{ title: '応答' }}- {- "id": "72fa9618-8f89-4a37-9b33-7e1178a24a67",- "name": "example.png",- "size": 1024,- "extension": "png",- "mime_type": "image/png",- "created_by": "6ad1ab0a-73ff-4ac1-b9e4-cdb312f71f13",- "created_at": 1577836800,- }- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/end-users/:end_user_id'- method='GET'- title='エンドユーザーを取得'- name='#end-user'-/>-<Row>- <Col>- エンドユーザー ID からエンドユーザー情報を取得します。-- 他の API がエンドユーザー ID(例:ファイルアップロードの `created_by`)を返す場合に利用できます。-- ### パスパラメータ- - `end_user_id` (uuid) 必須- エンドユーザー ID。-- ### レスポンス- EndUser オブジェクトを返します。- - `id` (uuid) ID- - `tenant_id` (uuid) テナント ID- - `app_id` (uuid) アプリ ID- - `type` (string) エンドユーザー種別- - `external_user_id` (string) 外部ユーザー ID- - `name` (string) 名前- - `is_anonymous` (boolean) 匿名ユーザーかどうか- - `session_id` (string) セッション ID- - `created_at` (string) ISO 8601 日時- - `updated_at` (string) ISO 8601 日時-- ### エラー- - 404, `end_user_not_found`, エンドユーザーが見つかりません- - 500, 内部サーバーエラー-- </Col>- <Col sticky>- ### リクエスト例- <CodeGroup- title="Request"- tag="GET"- label="/end-users/:end_user_id"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/end-users/6ad1ab0a-73ff-4ac1-b9e4-cdb312f71f13' \\---header 'Authorization: Bearer {api_key}'`}- />-- ### レスポンス例- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "id": "6ad1ab0a-73ff-4ac1-b9e4-cdb312f71f13",- "tenant_id": "8c0f3f3a-66b0-4b55-a0bf-8b8e0d6aee7d",- "app_id": "6c8c3f41-2c6f-4e1b-8f4f-7f11c8f2ad2a",- "type": "service_api",- "external_user_id": "abc-123",- "name": "Alice",- "is_anonymous": false,- "session_id": "abc-123",- "created_at": "2024-01-01T00:00:00Z",- "updated_at": "2024-01-01T00:00:00Z"- }- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/files/:file_id/preview'- method='GET'- title='ファイルプレビュー'- name='#file-preview'-/>-<Row>- <Col>- アップロードされたファイルをプレビューまたはダウンロードします。このエンドポイントを使用すると、以前にファイルアップロード API でアップロードされたファイルにアクセスできます。-- <i>ファイルは、リクエストしているアプリケーションのメッセージ範囲内にある場合のみアクセス可能です。</i>-- ### パスパラメータ- - `file_id` (string) 必須- プレビューするファイルの一意識別子。ファイルアップロード API レスポンスから取得します。-- ### クエリパラメータ- - `as_attachment` (boolean) オプション- ファイルを添付ファイルとして強制ダウンロードするかどうか。デフォルトは `false`(ブラウザでプレビュー)。-- ### レスポンス- ブラウザ表示またはダウンロード用の適切なヘッダー付きでファイル内容を返します。- - `Content-Type` ファイル MIME タイプに基づいて設定- - `Content-Length` ファイルサイズ(バイト、利用可能な場合)- - `Content-Disposition` `as_attachment=true` の場合は "attachment" に設定- - `Cache-Control` パフォーマンス向上のためのキャッシュヘッダー- - `Accept-Ranges` 音声/動画ファイルの場合は "bytes" に設定-- ### エラー- - 400, `invalid_param`, パラメータ入力異常- - 403, `file_access_denied`, ファイルアクセス拒否またはファイルが現在のアプリケーションに属していません- - 404, `file_not_found`, ファイルが見つからないか削除されています- - 500, サーバー内部エラー-- </Col>- <Col sticky>- ### リクエスト例- <CodeGroup- title="リクエスト"- tag="GET"- label="/files/:file_id/preview"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/files/72fa9618-8f89-4a37-9b33-7e1178a24a67/preview' \\---header 'Authorization: Bearer {api_key}'`}- />-- ### 添付ファイルとしてダウンロード- <CodeGroup- title="Download Request"- tag="GET"- label="/files/:file_id/preview?as_attachment=true"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/files/72fa9618-8f89-4a37-9b33-7e1178a24a67/preview?as_attachment=true' \\---header 'Authorization: Bearer {api_key}' \\---output downloaded_file.png`}- />-- ### レスポンスヘッダー例- <CodeGroup title="Response Headers">- ```http {{ title: 'Headers - 画像プレビュー' }}- Content-Type: image/png- Content-Length: 1024- Cache-Control: public, max-age=3600- ```- </CodeGroup>-- ### ダウンロードレスポンスヘッダー- <CodeGroup title="Download Response Headers">- ```http {{ title: 'Headers - ファイルダウンロード' }}- Content-Type: image/png- Content-Length: 1024- Content-Disposition: attachment; filename*=UTF-8''example.png- Cache-Control: public, max-age=3600- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/chat-messages/:task_id/stop'- method='POST'- title='生成停止'- name='#stop-generatebacks'-/>-<Row>- <Col>- ストリーミングモードでのみサポートされています。- ### パス- - `task_id` (string) タスク ID、ストリーミングチャンクの返り値から取得できます- ### リクエストボディ- - `user` (string) 必須- ユーザー識別子、エンドユーザーのアイデンティティを定義するために使用され、メッセージ送信インターフェースで渡されたユーザーと一致している必要があります。サービス API は WebApp によって作成された会話を共有しません。- ### 応答- - `result` (string) 常に"success"を返します- </Col>- <Col sticky>- ### リクエスト例- <CodeGroup- title="リクエスト"- tag="POST"- label="/chat-messages/:task_id/stop"- targetCode={`curl -X POST '${props.appDetail.api_base_url}/chat-messages/:task_id/stop' \\--H 'Authorization: Bearer {api_key}' \\--H 'Content-Type: application/json' \\---data-raw '{"user": "abc-123"}'`}- />-- ### 応答例- <CodeGroup title="応答">- ```json {{ title: '応答' }}- {- "result": "success"- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/messages/:message_id/feedbacks'- method='POST'- title='メッセージフィードバック'- name='#feedbacks'-/>-<Row>- <Col>- エンドユーザーはフィードバックメッセージを提供でき、アプリケーション開発者が期待される出力を最適化するのに役立ちます。-- ### パス- <Properties>- <Property name='message_id' type='string' key='message_id'>- メッセージID- </Property>- </Properties>-- ### リクエストボディ-- <Properties>- <Property name='rating' type='string' key='rating'>- アップボートは`like`、ダウンボートは`dislike`、アップボートの取り消しは`null`- </Property>- <Property name='user' type='string' key='user'>- ユーザー識別子、開発者のルールで定義され、アプリケーション内で一意でなければなりません。- </Property>- <Property name='content' type='string' key='content'>- メッセージのフィードバックです。- </Property>- </Properties>-- ### 応答- - `result` (string) 常に"success"を返します- </Col>- <Col sticky>-- <CodeGroup- title="リクエスト"- tag="POST"- label="/messages/:message_id/feedbacks"- targetCode={`curl -X POST '${props.appDetail.api_base_url}/messages/:message_id/feedbacks \\---header 'Authorization: Bearer {api_key}' \\---header 'Content-Type: application/json' \\---data-raw '{- "rating": "like",- "user": "abc-123",- "content": "message feedback information"-}'`}- />-- <CodeGroup title="応答">- ```json {{ title: '応答' }}- {- "result": "success"- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/app/feedbacks'- method='GET'- title='アプリのメッセージの「いいね」とフィードバックを取得'- name='#app-feedbacks'-/>-<Row>- <Col>- アプリのエンドユーザーからのフィードバックや「いいね」を取得します。-- ### クエリ- <Properties>- <Property name='page' type='string' key='page'>- (任意)ページ番号。デフォルト値:1- </Property>- </Properties>-- <Properties>- <Property name='limit' type='string' key='limit'>- (任意)1ページあたりの件数。デフォルト値:20- </Property>- </Properties>-- ### レスポンス- - `data` (リスト) このアプリの「いいね」とフィードバックの一覧を返します。- </Col>- <Col sticky>-- <CodeGroup- title="リクエスト"- tag="GET"- label="/app/feedbacks"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/app/feedbacks?page=1&limit=20'`}- />-- <CodeGroup title="応答">- ```json {{ title: 'Response' }}- {- "data": [- {- "id": "8c0fbed8-e2f9-49ff-9f0e-15a35bdd0e25",- "app_id": "f252d396-fe48-450e-94ec-e184218e7346",- "conversation_id": "2397604b-9deb-430e-b285-4726e51fd62d",- "message_id": "709c0b0f-0a96-4a4e-91a4-ec0889937b11",- "rating": "like",- "content": "message feedback information-3",- "from_source": "user",- "from_end_user_id": "74286412-9a1a-42c1-929c-01edb1d381d5",- "from_account_id": null,- "created_at": "2025-04-24T09:24:38",- "updated_at": "2025-04-24T09:24:38"- }- ]- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/messages/{message_id}/suggested'- method='GET'- title='次の推奨質問'- name='#suggested'-/>-<Row>- <Col>- 現在のメッセージに対する次の質問の提案を取得します-- ### パスパラメータ-- <Properties>- <Property name='message_id' type='string' key='message_id'>- メッセージID- </Property>- </Properties>-- ### クエリ- <Properties>- <Property name='user' type='string' key='user'>- ユーザー識別子、エンドユーザーのアイデンティティを定義するために使用され、統計のために使用されます。- アプリケーション内で開発者によって一意に定義される必要があります。- </Property>- </Properties>- </Col>- <Col sticky>-- <CodeGroup- title="リクエスト"- tag="GET"- label="/messages/{message_id}/suggested"- targetCode={`curl --location --request GET '${props.appDetail.api_base_url}/messages/{message_id}/suggested?user=abc-123& \\---header 'Authorization: Bearer ENTER-YOUR-SECRET-KEY' \\---header 'Content-Type: application/json'`}- />-- <CodeGroup title="応答">- ```json {{ title: '応答' }}- {- "result": "success",- "data": [- "a",- "b",- "c"- ]- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/messages'- method='GET'- title='会話履歴メッセージを取得'- name='#messages'-/>-<Row>- <Col>- スクロールロード形式で過去のチャット記録を返し、最初のページは最新の`{limit}`メッセージを返します。つまり、逆順です。-- ### クエリ-- <Properties>- <Property name='conversation_id' type='string' key='conversation_id'>- 会話ID- </Property>- <Property name='user' type='string' key='user'>- ユーザー識別子、エンドユーザーのアイデンティティを定義するために使用され、統計のために使用されます。- アプリケーション内で開発者によって一意に定義される必要があります。- </Property>- <Property name='first_id' type='string' key='first_id'>- 現在のページの最初のチャット記録のID、デフォルトはnullです。- </Property>- <Property name='limit' type='int' key='limit'>- 1回のリクエストで返すチャット履歴メッセージの数、デフォルトは20です。- </Property>- </Properties>-- ### 応答- - `data` (array[object]) メッセージリスト- - `id` (string) メッセージID- - `conversation_id` (string) 会話ID- - `inputs` (object) ユーザー入力パラメータ。- - `query` (string) ユーザー入力/質問内容。- - `message_files` (array[object]) メッセージファイル- - `id` (string) ID- - `type` (string) ファイルタイプ、画像の場合はimage- - `url` (string) ファイルプレビューURL、ファイルアクセスにはファイルプレビューAPI(`/files/{file_id}/preview`)を使用してください- - `belongs_to` (string) 所属、ユーザーまたはアシスタント- - `agent_thoughts` (array[object]) エージェントの思考(基本アシスタントの場合は空)- - `id` (string) エージェント思考ID、各反復には一意のエージェント思考IDがあります- - `message_id` (string) 一意のメッセージID- - `position` (int) 現在のエージェント思考の位置、各メッセージには順番に複数の思考が含まれる場合があります。- - `thought` (string) LLMが考えていること- - `observation` (string) ツール呼び出しからの応答- - `tool` (string) 呼び出されたツールのリスト、;で区切られます- - `tool_input` (string) ツールの入力、JSON形式。例:`{"dalle3": {"prompt": "a cute cat"}}`。- - `created_at` (int) 作成タイムスタンプ、例:1705395332- - `message_files` (array[string]) message_fileイベントを参照- - `file_id` (string) ファイルID- - `answer` (string) 応答メッセージ内容- - `created_at` (timestamp) 作成タイムスタンプ、例:1705395332- - `feedback` (object) フィードバック情報- - `rating` (string) アップボートは`like` / ダウンボートは`dislike`- - `retriever_resources` (array[RetrieverResource]) 引用と帰属リスト- - `has_more` (bool) 次のページがあるかどうか- - `limit` (int) 返されたアイテムの数、入力がシステム制限を超える場合、システム制限の数を返します-- </Col>- <Col sticky>-- <CodeGroup- title="リクエスト"- tag="GET"- label="/messages"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/messages?user=abc-123&conversation_id='\\---header 'Authorization: Bearer {api_key}'`}- />- ### 応答例(基本アシスタント)- <CodeGroup title="応答">- ```json {{ title: '応答' }}- {- "limit": 20,- "has_more": false,- "data": [- {- "id": "a076a87f-31e5-48dc-b452-0061adbbc922",- "conversation_id": "cd78daf6-f9e4-4463-9ff2-54257230a0ce",- "inputs": {- "name": "dify"- },- "query": "iphone 13 pro",- "answer": "iPhone 13 Proは2021年9月24日に発売され、6.1インチのディスプレイと1170 x 2532の解像度を備えています。Hexa-core (2x3.23 GHz Avalanche + 4x1.82 GHz Blizzard)プロセッサ、6 GBのRAMを搭載し、128 GB、256 GB、512 GB、1 TBのストレージオプションを提供します。カメラは12 MP、バッテリー容量は3095 mAhで、iOS 15を搭載しています。",- "message_files": [],- "feedback": null,- "retriever_resources": [- {- "position": 1,- "dataset_id": "101b4c97-fc2e-463c-90b1-5261a4cdcafb",- "dataset_name": "iPhone",- "document_id": "8dd1ad74-0b5f-4175-b735-7d98bbbb4e00",- "document_name": "iPhone List",- "segment_id": "ed599c7f-2766-4294-9d1d-e5235a61270a",- "score": 0.98457545,- "content": "\"Model\",\"Release Date\",\"Display Size\",\"Resolution\",\"Processor\",\"RAM\",\"Storage\",\"Camera\",\"Battery\",\"Operating System\"\n\"iPhone 13 Pro Max\",\"September 24, 2021\",\"6.7 inch\",\"1284 x 2778\",\"Hexa-core (2x3.23 GHz Avalanche + 4x1.82 GHz Blizzard)\",\"6 GB\",\"128, 256, 512 GB, 1TB\",\"12 MP\",\"4352 mAh\",\"iOS 15\""- }- ],- "agent_thoughts": [],- "created_at": 1705569239,- }- ]- }- ```- </CodeGroup>-- ### 応答例(エージェントアシスタント)- <CodeGroup title="応答">- ```json {{ title: '応答' }}- {- "limit": 20,- "has_more": false,- "data": [- {- "id": "d35e006c-7c4d-458f-9142-be4930abdf94",- "conversation_id": "957c068b-f258-4f89-ba10-6e8a0361c457",- "inputs": {},- "query": "draw a cat",- "answer": "猫の画像を生成しました。メッセージを確認して画像を表示してください。",- "message_files": [- {- "id": "976990d2-5294-47e6-8f14-7356ba9d2d76",- "type": "image",- "url": "http://127.0.0.1:5001/files/tools/976990d2-5294-47e6-8f14-7356ba9d2d76.png?timestamp=1705988524&nonce=55df3f9f7311a9acd91bf074cd524092&sign=z43nMSO1L2HBvoqADLkRxr7Biz0fkjeDstnJiCK1zh8=",- "belongs_to": "assistant"- }- ],- "feedback": null,- "retriever_resources": [],- "created_at": 1705988187,- "agent_thoughts": [- {- "id": "592c84cf-07ee-441c-9dcc-ffc66c033469",- "chain_id": null,- "message_id": "d35e006c-7c4d-458f-9142-be4930abdf94",- "position": 1,- "thought": "",- "tool": "dalle2",- "tool_input": "{\"dalle2\": {\"prompt\": \"cat\"}}",- "created_at": 1705988186,- "observation": "画像はすでに作成され、ユーザーに送信されました。今すぐユーザーに確認するように伝えてください。",- "files": [- "976990d2-5294-47e6-8f14-7356ba9d2d76"- ]- },- {- "id": "73ead60d-2370-4780-b5ed-532d2762b0e5",- "chain_id": null,- "message_id": "d35e006c-7c4d-458f-9142-be4930abdf94",- "position": 2,- "thought": "猫の画像を生成しました。メッセージを確認して画像を表示してください。",- "tool": "",- "tool_input": "",- "created_at": 1705988199,- "observation": "",- "files": []- }- ]- }- ]- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/conversations'- method='GET'- title='会話を取得'- name='#conversations'-/>-<Row>- <Col>- 現在のユーザーの会話リストを取得し、デフォルトで最新の 20 件を返します。-- ### クエリ-- <Properties>- <Property name='user' type='string' key='user'>- ユーザー識別子、エンドユーザーのアイデンティティを定義するために使用され、統計のために使用されます。- アプリケーション内で開発者によって一意に定義される必要があります。- </Property>- <Property name='last_id' type='string' key='last_id'>- (Optional)現在のページの最後のレコードのID、デフォルトはnullです。- </Property>- <Property name='limit' type='int' key='limit'>- (Optional)1回のリクエストで返すレコードの数、デフォルトは最新の20件です。最大100、最小1。- </Property>- <Property name='sort_by' type='string' key='sort_by'>- (Optional)ソートフィールド、デフォルト:-updated_at(更新時間で降順にソート)- - 利用可能な値:created_at, -created_at, updated_at, -updated_at- - フィールドの前の記号は順序または逆順を表し、"-"は逆順を表します。- </Property>- </Properties>-- ### 応答- - `data` (array[object]) 会話のリスト- - `id` (string) 会話ID- - `name` (string) 会話名、デフォルトでは、ユーザーが会話で最初に尋ねた質問のスニペットです。- - `inputs` (object) ユーザー入力パラメータ。- - `introduction` (string) 紹介- - `created_at` (timestamp) 作成タイムスタンプ、例:1705395332- - `updated_at` (timestamp) 更新タイムスタンプ、例:1705395332- - `has_more` (bool)- - `limit` (int) 返されたエントリの数、入力がシステム制限を超える場合、システム制限の数を返します-- </Col>- <Col sticky>-- <CodeGroup title="リクエスト" tag="GET" label="/conversations" targetCode={`curl -X GET '${props.appDetail.api_base_url}/conversations?user=abc-123&last_id=&limit=20' \\---header 'Authorization: Bearer {api_key}'`}- />-- <CodeGroup title="応答">- ```json {{ title: '応答' }}- {- "limit": 20,- "has_more": false,- "data": [- {- "id": "10799fb8-64f7-4296-bbf7-b42bfbe0ae54",- "name": "新しいチャット",- "inputs": {- "book": "book",- "myName": "Lucy"- },- "status": "normal",- "created_at": 1679667915,- "updated_at": 1679667915- },- {- "id": "hSIhXBhNe8X1d8Et"- // ...- }- ]- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/conversations/:conversation_id'- method='DELETE'- title='会話を削除'- name='#delete'-/>-<Row>- <Col>- 会話を削除します。-- ### パス- - `conversation_id` (string) 会話ID-- ### リクエストボディ-- <Properties>- <Property name='user' type='string' key='user'>- ユーザー識別子、開発者によって定義され、アプリケーション内で一意である必要があります。- </Property>- </Properties>-- ### 応答- - `result` (string) 常に"success"を返します- </Col>- <Col sticky>-- <CodeGroup- title="リクエスト"- tag="DELETE"- label="/conversations/:conversation_id"- targetCode={`curl -X DELETE '${props.appDetail.api_base_url}/conversations/:conversation_id' \\---header 'Authorization: Bearer {api_key}' \\---header 'Content-Type: application/json' \\---data-raw '{- "user": "abc-123"-}'`}- />-- <CodeGroup title="応答">- ```text {{ title: '応答' }}- 204 No Content- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/conversations/:conversation_id/name'- method='POST'- title='会話の名前を変更'- name='#rename'-/>-<Row>- <Col>- ### リクエストボディ- セッションの名前を変更します。セッション名は、複数のセッションをサポートするクライアントでの表示に使用されます。-- ### パス- - `conversation_id` (string) 会話ID-- <Properties>- <Property name='name' type='string' key='name'>- (Optional)会話の名前。このパラメータは、`auto_generate`が`true`に設定されている場合、省略できます。- </Property>- <Property name='auto_generate' type='bool' key='auto_generate'>- (Optional)タイトルを自動生成します。デフォルトは`false`です。- </Property>- <Property name='user' type='string' key='user'>- ユーザー識別子、開発者によって定義され、アプリケーション内で一意である必要があります。- </Property>- </Properties>-- ### 応答- - `id` (string) 会話ID- - `name` (string) 会話名- - `inputs` (object) ユーザー入力パラメータ- - `status` (string) 会話状態- - `introduction` (string) 紹介- - `created_at` (timestamp) 作成タイムスタンプ、例:1705395332- - `updated_at` (timestamp) 更新タイムスタンプ、例:1705395332- </Col>- <Col sticky>-- <CodeGroup- title="リクエスト"- tag="POST"- label="/conversations/:conversation_id/name"- targetCode={`curl -X POST '${props.appDetail.api_base_url}/conversations/:conversation_id/name' \\---header 'Authorization: Bearer {api_key}' \\---header 'Content-Type: application/json' \\---data-raw '{- "name": "",- "auto_generate": true,- "user": "abc-123"-}'`}- />-- <CodeGroup title="応答">- ```json {{ title: '応答' }}- {- "id": "cd78daf6-f9e4-4463-9ff2-54257230a0ce",- "name": "Chat vs AI",- "inputs": {},- "introduction": "",- "created_at": 1705569238,- "updated_at": 1705569238- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/conversations/:conversation_id/variables'- method='GET'- title='会話変数の取得'- name='#conversation-variables'-/>-<Row>- <Col>- 特定の会話から変数を取得します。このエンドポイントは、会話中に取得された構造化データを抽出するのに役立ちます。-- ### パスパラメータ-- <Properties>- <Property name='conversation_id' type='string' key='conversation_id'>- 変数を取得する会話のID。- </Property>- </Properties>-- ### クエリパラメータ-- <Properties>- <Property name='user' type='string' key='user'>- ユーザー識別子。開発者によって定義されたルールに従い、アプリケーション内で一意である必要があります。- </Property>- <Property name='last_id' type='string' key='last_id'>- (Optional)現在のページの最後のレコードのID、デフォルトはnullです。- </Property>- <Property name='limit' type='int' key='limit'>- (Optional)1回のリクエストで返すレコードの数、デフォルトは最新の20件です。最大100、最小1。- </Property>- </Properties>-- ### レスポンス-- - `limit` (int) ページごとのアイテム数- - `has_more` (bool) さらにアイテムがあるかどうか- - `data` (array[object]) 変数のリスト- - `id` (string) 変数 ID- - `name` (string) 変数名- - `value_type` (string) 変数タイプ(文字列、数値、真偽値など)- - `value` (string) 変数値- - `description` (string) 変数の説明- - `created_at` (int) 作成タイムスタンプ- - `updated_at` (int) 最終更新タイムスタンプ-- ### エラー- - 404, `conversation_not_exists`, 会話が見つかりません-- </Col>- <Col sticky>-- <CodeGroup- title="リクエスト"- tag="GET"- label="/conversations/:conversation_id/variables"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/conversations/{conversation_id}/variables?user=abc-123' \\---header 'Authorization: Bearer {api_key}'`}- />-- <CodeGroup title="Request with variable name filter">- ```bash {{ title: 'cURL' }}- curl -X GET '${props.appDetail.api_base_url}/conversations/{conversation_id}/variables?user=abc-123&variable_name=customer_name' \- --header 'Authorization: Bearer {api_key}'- ```- </CodeGroup>-- <CodeGroup title="応答">- ```json {{ title: 'Response' }}- {- "limit": 100,- "has_more": false,- "data": [- {- "id": "variable-uuid-1",- "name": "customer_name",- "value_type": "string",- "value": "John Doe",- "description": "会話から抽出された顧客名",- "created_at": 1650000000000,- "updated_at": 1650000000000- },- {- "id": "variable-uuid-2",- "name": "order_details",- "value_type": "json",- "value": "{\"product\":\"Widget\",\"quantity\":5,\"price\":19.99}",- "description": "顧客の注文詳細",- "created_at": 1650000000000,- "updated_at": 1650000000000- }- ]- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/conversations/:conversation_id/variables/:variable_id'- method='PUT'- title='会話変数の更新'- name='#update-conversation-variable'-/>-<Row>- <Col>- 特定の会話変数の値を更新します。このエンドポイントは、名前、型、説明を保持しながら、会話中にキャプチャされた変数の値を変更することを可能にします。-- ### パスパラメータ-- <Properties>- <Property name='conversation_id' type='string' key='conversation_id'>- 更新する変数を含む会話のID。- </Property>- <Property name='variable_id' type='string' key='variable_id'>- 更新する変数のID。- </Property>- </Properties>-- ### リクエストボディ-- <Properties>- <Property name='value' type='any' key='value'>- 変数の新しい値。変数の期待される型(文字列、数値、オブジェクトなど)と一致する必要があります。- </Property>- <Property name='user' type='string' key='user'>- ユーザー識別子。開発者によって定義されたルールに従い、アプリケーション内で一意である必要があります。- </Property>- </Properties>-- ### レスポンス-- 以下を含む更新された変数オブジェクトを返します:- - `id` (string) 変数ID- - `name` (string) 変数名- - `value_type` (string) 変数型(文字列、数値、オブジェクトなど)- - `value` (any) 更新された変数値- - `description` (string) 変数の説明- - `created_at` (int) 作成タイムスタンプ- - `updated_at` (int) 最終更新タイムスタンプ-- ### エラー- - 400, `Type mismatch: variable expects {expected_type}, but got {actual_type} type`, 値の型が変数の期待される型と一致しません- - 404, `conversation_not_exists`, 会話が見つかりません- - 404, `conversation_variable_not_exists`, 変数が見つかりません-- </Col>- <Col sticky>-- <CodeGroup- title="リクエスト"- tag="PUT"- label="/conversations/:conversation_id/variables/:variable_id"- targetCode={`curl -X PUT '${props.appDetail.api_base_url}/conversations/{conversation_id}/variables/{variable_id}' \\---header 'Authorization: Bearer {api_key}' \\---header 'Content-Type: application/json' \\---data-raw '{- "value": "Updated Value",- "user": "abc-123"-}'`}- />-- <CodeGroup title="異なる値型での更新">- ```bash {{ title: '文字列値' }}- curl -X PUT '${props.appDetail.api_base_url}/conversations/{conversation_id}/variables/{variable_id}' \- --header 'Content-Type: application/json' \- --header 'Authorization: Bearer {api_key}' \- --data-raw '{- "value": "新しい文字列値",- "user": "abc-123"- }'- ```-- ```bash {{ title: '数値' }}- curl -X PUT '${props.appDetail.api_base_url}/conversations/{conversation_id}/variables/{variable_id}' \- --header 'Content-Type: application/json' \- --header 'Authorization: Bearer {api_key}' \- --data-raw '{- "value": 42,- "user": "abc-123"- }'- ```-- ```bash {{ title: 'オブジェクト値' }}- curl -X PUT '${props.appDetail.api_base_url}/conversations/{conversation_id}/variables/{variable_id}' \- --header 'Content-Type: application/json' \- --header 'Authorization: Bearer {api_key}' \- --data-raw '{- "value": {"product": "Widget", "quantity": 10, "price": 29.99},- "user": "abc-123"- }'- ```- </CodeGroup>-- <CodeGroup title="応答">- ```json {{ title: 'Response' }}- {- "id": "variable-uuid-1",- "name": "customer_name",- "value_type": "string",- "value": "Updated Value",- "description": "会話から抽出された顧客名",- "created_at": 1650000000000,- "updated_at": 1650000001000- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/audio-to-text'- method='POST'- title='音声からテキストへ'- name='#audio-to-text'-/>-<Row>- <Col>- このエンドポイントは multipart/form-data リクエストを必要とします。-- ### リクエストボディ-- <Properties>- <Property name='file' type='file' key='file'>- オーディオファイル。- サポートされている形式:`['mp3', 'mp4', 'mpeg', 'mpga', 'm4a', 'wav', 'webm']`- ファイルサイズ制限:15MB- </Property>- <Property name='user' type='string' key='user'>- ユーザー識別子、開発者のルールで定義され、アプリケーション内で一意でなければなりません。- </Property>- </Properties>-- ### 応答- - `text` (string) 出力テキスト-- </Col>- <Col sticky>-- <CodeGroup- title="リクエスト"- tag="POST"- label="/audio-to-text"- targetCode={`curl -X POST '${props.appDetail.api_base_url}/audio-to-text' \\---header 'Authorization: Bearer {api_key}' \\---form 'file=@localfile;type=audio/[mp3|mp4|mpeg|mpga|m4a|wav|webm]'`}- />-- <CodeGroup title="応答">- ```json {{ title: '応答' }}- {- "text": ""- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/text-to-audio'- method='POST'- title='テキストから音声へ'- name='#text-to-audio'-/>-<Row>- <Col>- テキストを音声に変換します。-- ### リクエストボディ-- <Properties>- <Property name='message_id' type='str' key='message_id'>- Difyによって生成されたテキストメッセージの場合、生成されたメッセージIDを直接渡します。バックエンドはメッセージIDを使用して対応するコンテンツを検索し、音声情報を直接合成します。message_idとtextが同時に提供される場合、message_idが優先されます。- </Property>- <Property name='text' type='str' key='text'>- 音声生成コンテンツ。- </Property>- <Property name='user' type='string' key='user'>- ユーザー識別子、開発者によって定義され、アプリ内で一意である必要があります。- </Property>- </Properties>- </Col>- <Col sticky>-- <CodeGroup- title="リクエスト"- tag="POST"- label="/text-to-audio"- targetCode={`curl --location --request POST '${props.appDetail.api_base_url}/text-to-audio' \\---header 'Authorization: Bearer ENTER-YOUR-SECRET-KEY' \\---form 'text=Hello Dify;user=abc-123;message_id=5ad4cb98-f0c7-4085-b384-88c403be6290`}- />-- <CodeGroup title="ヘッダー">- ```json {{ title: 'ヘッダー' }}- {- "Content-Type": "audio/wav"- }- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/info'- method='GET'- title='アプリケーションの基本情報を取得'- name='#info'-/>-<Row>- <Col>- このアプリケーションの基本情報を取得するために使用されます-- ### Response- - `name` (string) アプリケーションの名前- - `description` (string) アプリケーションの説明- - `tags` (array[string]) アプリケーションのタグ- - `mode` (string) アプリケーションのモード- - `author_name` (string) 作者の名前- </Col>- <Col>- <CodeGroup- title="リクエスト"- tag="GET"- label="/info"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/info' \\--H 'Authorization: Bearer {api_key}'`}- />- <CodeGroup title="応答">- ```json {{ title: 'Response' }}- {- "name": "My App",- "description": "This is my app.",- "tags": [- "tag1",- "tag2"- ],- "mode": "chat",- "author_name": "Dify"- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/parameters'- method='GET'- title='アプリケーションのパラメータ情報を取得'- name='#parameters'-/>-<Row>- <Col>- ページに入る際に、機能、入力パラメータ名、タイプ、デフォルト値などの情報を取得するために使用されます。-- ### 応答- - `opening_statement` (string) 開始文- - `suggested_questions` (array[string]) 開始時の推奨質問のリスト- - `suggested_questions_after_answer` (object) 答えを有効にした後の質問を提案します。- - `enabled` (bool) 有効かどうか- - `speech_to_text` (object) 音声からテキストへ- - `enabled` (bool) 有効かどうか- - `text_to_speech` (object) テキストから音声へ- - `enabled` (bool) 有効かどうか- - `voice` (string) 音声タイプ- - `language` (string) 言語- - `autoPlay` (string) 自動再生- - `enabled` 有効- - `disabled` 無効- - `retriever_resource` (object) 引用と帰属- - `enabled` (bool) 有効かどうか- - `annotation_reply` (object) 注釈返信- - `enabled` (bool) 有効かどうか- - `user_input_form` (array[object]) ユーザー入力フォームの構成- - `text-input` (object) テキスト入力コントロール- - `label` (string) 変数表示ラベル名- - `variable` (string) 変数ID- - `required` (bool) 必須かどうか- - `default` (string) デフォルト値- - `paragraph` (object) 段落テキスト入力コントロール- - `label` (string) 変数表示ラベル名- - `variable` (string) 変数ID- - `required` (bool) 必須かどうか- - `default` (string) デフォルト値- - `select` (object) ドロップダウンコントロール- - `label` (string) 変数表示ラベル名- - `variable` (string) 変数ID- - `required` (bool) 必須かどうか- - `default` (string) デフォルト値- - `options` (array[string]) オプション値- - `file_upload` (object) ファイルアップロード設定- - `document` (object) ドキュメント設定- 現在サポートされているドキュメントタイプ:`txt`, `md`, `markdown`, `pdf`, `html`, `xlsx`, `xls`, `docx`, `csv`, `eml`, `msg`, `pptx`, `ppt`, `xml`, `epub`。- - `enabled` (bool) 有効かどうか- - `number_limits` (int) ドキュメント数の上限。デフォルトは 3- - `transfer_methods` (array[string]) 転送方法リスト:`remote_url`, `local_file`。いずれかを選択する必要があります。- - `image` (object) 画像設定- 現在サポートされている画像タイプ:`png`, `jpg`, `jpeg`, `webp`, `gif`。- - `enabled` (bool) 有効かどうか- - `number_limits` (int) 画像数の上限。デフォルトは 3- - `transfer_methods` (array[string]) 転送方法リスト:`remote_url`, `local_file`。いずれかを選択する必要があります。- - `audio` (object) オーディオ設定- 現在サポートされているオーディオタイプ:`mp3`, `m4a`, `wav`, `webm`, `amr`。- - `enabled` (bool) 有効かどうか- - `number_limits` (int) オーディオ数の上限。デフォルトは 3- - `transfer_methods` (array[string]) 転送方法リスト:`remote_url`, `local_file`。いずれかを選択する必要があります。- - `video` (object) ビデオ設定- 現在サポートされているビデオタイプ:`mp4`, `mov`, `mpeg`, `mpga`。- - `enabled` (bool) 有効かどうか- - `number_limits` (int) ビデオ数の上限。デフォルトは 3- - `transfer_methods` (array[string]) 転送方法リスト:`remote_url`, `local_file`。いずれかを選択する必要があります。- - `custom` (object) カスタム設定- - `enabled` (bool) 有効かどうか- - `number_limits` (int) カスタム数の上限。デフォルトは 3- - `transfer_methods` (array[string]) 転送方法リスト:`remote_url`, `local_file`。いずれかを選択する必要があります。- - `system_parameters` (object) システムパラメータ- - `file_size_limit` (int) ドキュメントアップロードサイズ制限(MB)- - `image_file_size_limit` (int) 画像ファイルアップロードサイズ制限(MB)- - `audio_file_size_limit` (int) オーディオファイルアップロードサイズ制限(MB)- - `video_file_size_limit` (int) ビデオファイルアップロードサイズ制限(MB)-- </Col>- <Col sticky>-- <CodeGroup- title="リクエスト"- tag="GET"- label="/parameters"- targetCode={` curl -X GET '${props.appDetail.api_base_url}/parameters'`}- />-- <CodeGroup title="応答">- ```json {{ title: '応答' }}- {- "opening_statement": "こんにちは!",- "suggested_questions_after_answer": {- "enabled": true- },- "speech_to_text": {- "enabled": true- },- "text_to_speech": {- "enabled": true,- "voice": "sambert-zhinan-v1",- "language": "zh-Hans",- "autoPlay": "disabled"- },- "retriever_resource": {- "enabled": true- },- "annotation_reply": {- "enabled": true- },- "user_input_form": [- {- "paragraph": {- "label": "クエリ",- "variable": "query",- "required": true,- "default": ""- }- }- ],- "file_upload": {- "image": {- "enabled": false,- "number_limits": 3,- "detail": "high",- "transfer_methods": [- "remote_url",- "local_file"- ]- }- },- "system_parameters": {- "file_size_limit": 15,- "image_file_size_limit": 10,- "audio_file_size_limit": 50,- "video_file_size_limit": 100- }- }- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/meta'- method='GET'- title='アプリケーションのメタ情報を取得'- name='#meta'-/>-<Row>- <Col>- このアプリケーションのツールのアイコンを取得するために使用されます-- ### 応答- - `tool_icons`(object[string]) ツールアイコン- - `tool_name` (string)- - `icon` (object|string)- - (object) アイコンオブジェクト- - `background` (string) 背景色(16 進数形式)- - `content`(string) 絵文字- - (string) アイコンの URL- </Col>- <Col>- <CodeGroup- title="リクエスト"- tag="GET"- label="/meta"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/meta' \\--H 'Authorization: Bearer {api_key}'`}- />-- <CodeGroup title="応答">- ```json {{ title: '応答' }}- {- "tool_icons": {- "dalle2": "https://cloud.dify.ai/console/api/workspaces/current/tool-provider/builtin/dalle/icon",- "api_tool": {- "background": "#252525",- "content": "\ud83d\ude01"- }- }- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/site'- method='GET'- title='アプリのWebApp設定を取得'- name='#site'-/>-<Row>- <Col>- アプリの WebApp 設定を取得するために使用します。- ### 応答- - `title` (string) WebApp 名- - `chat_color_theme` (string) チャットの色テーマ、16 進数形式- - `chat_color_theme_inverted` (bool) チャットの色テーマを反転するかどうか- - `icon_type` (string) アイコンタイプ、`emoji`-絵文字、`image`-画像- - `icon` (string) アイコン。`emoji`タイプの場合は絵文字、`image`タイプの場合は画像 URL- - `icon_background` (string) 16 進数形式の背景色- - `icon_url` (string) アイコンの URL- - `description` (string) 説明- - `copyright` (string) 著作権情報- - `privacy_policy` (string) プライバシーポリシーのリンク- - `custom_disclaimer` (string) カスタム免責事項- - `default_language` (string) デフォルト言語- - `show_workflow_steps` (bool) ワークフローの詳細を表示するかどうか- - `use_icon_as_answer_icon` (bool) WebApp のアイコンをチャット内の🤖に置き換えるかどうか- </Col>- <Col>- <CodeGroup- title="リクエスト"- tag="GET"- label="/site"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/site' \\--H 'Authorization: Bearer {api_key}'`}- />-- <CodeGroup title="応答">- ```json {{ title: 'Response' }}- {- "title": "My App",- "chat_color_theme": "#ff4a4a",- "chat_color_theme_inverted": false,- "icon_type": "emoji",- "icon": "😄",- "icon_background": "#FFEAD5",- "icon_url": null,- "description": "This is my app.",- "copyright": "all rights reserved",- "privacy_policy": "",- "custom_disclaimer": "All generated by AI",- "default_language": "en-US",- "show_workflow_steps": false,- "use_icon_as_answer_icon": false,- }- ```- </CodeGroup>- </Col>-</Row>-___diff --git a/web/app/components/develop/template/template_chat.zh.mdx b/web/app/components/develop/template/template_chat.zh.mdxdeleted file mode 100644index 1ba4f13a663..00000000000--- a/web/app/components/develop/template/template_chat.zh.mdx+++ /dev/null@@ -1,1680 +0,0 @@-import { CodeGroup } from '../code.tsx'-import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx'--# 对话型应用 API--对话应用支持会话持久化,可将之前的聊天记录作为上下文进行回答,可适用于聊天/客服 AI 等。--<div>- ### 基础 URL- <CodeGroup title="Code" targetCode={props.appDetail.api_base_url} />-- ### 鉴权-- Service API 使用 `API-Key` 进行鉴权。- <i>**强烈建议开发者把 `API-Key` 放在后端存储,而非分享或者放在客户端存储,以免 `API-Key` 泄露,导致财产损失。**</i>- 所有 API 请求都应在 **`Authorization`** HTTP Header 中包含您的 `API-Key`,如下所示:-- <CodeGroup title="Code" targetCode='Authorization: Bearer {API_KEY}' />-</div>-------<Heading- url='/chat-messages'- method='POST'- title='发送对话消息'- name='#Create-Chat-Message'-/>-<Row>- <Col>- 创建会话消息。-- ### Request Body-- <Properties>- <Property name='query' type='string' key='query'>- 用户输入/提问内容。- </Property>- <Property name='inputs' type='object' key='inputs'>- 允许传入 App 定义的各变量值。- inputs 参数包含了多组键值对(Key/Value pairs),每组的键对应一个特定变量,每组的值则是该变量的具体值。- 默认 `{}`- </Property>- <Property name='response_mode' type='string' key='response_mode'>- - `streaming` 流式模式(推荐)。基于 SSE(**[Server-Sent Events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events)**)实现类似打字机输出方式的流式返回。- - `blocking` 阻塞模式,等待执行完毕后返回结果。(请求若流程较长可能会被中断)。- <i>由于 Cloudflare 限制,请求会在 100 秒超时无返回后中断。</i>- 注:Agent模式下不允许blocking。- </Property>- <Property name='user' type='string' key='user'>- 用户标识,用于定义终端用户的身份,方便检索、统计。- 由开发者定义规则,需保证用户标识在应用内唯一。服务 API 不会共享 WebApp 创建的对话。- </Property>- <Property name='conversation_id' type='string' key='conversation_id'>- (选填)会话 ID,需要基于之前的聊天记录继续对话,必须传之前消息的 conversation_id。- </Property>- <Property name='files' type='array[object]' key='files'>- 文件列表,适用于传入文件结合文本理解并回答问题,仅当模型支持 Vision/Video 能力时可用。- - `type` (string) 支持类型:- - `document` 具体类型包含:'TXT', 'MD', 'MARKDOWN', 'MDX', 'PDF', 'HTML', 'XLSX', 'XLS', 'VTT', 'PROPERTIES', 'DOC', 'DOCX', 'CSV', 'EML', 'MSG', 'PPTX', 'PPT', 'XML', 'EPUB'- - `image` 具体类型包含:'JPG', 'JPEG', 'PNG', 'GIF', 'WEBP', 'SVG'- - `audio` 具体类型包含:'MP3', 'M4A', 'WAV', 'WEBM', 'MPGA'- - `video` 具体类型包含:'MP4', 'MOV', 'MPEG', 'WEBM'- - `custom` 具体类型包含:其他文件类型- - `transfer_method` (string) 传递方式:- - `remote_url`: 文件地址。- - `local_file`: 上传文件。- - `url` 文件地址。(仅当传递方式为 `remote_url` 时)。- - `upload_file_id` 上传文件 ID。(仅当传递方式为 `local_file `时)。- </Property>- <Property name='auto_generate_name' type='bool' key='auto_generate_name'>- (选填)自动生成标题,默认 `true`。 若设置为 `false`,则可通过调用会话重命名接口并设置 `auto_generate` 为 `true` 实现异步生成标题。- </Property>- <Property name='workflow_id' type='string' key='workflow_id'>- (选填)工作流ID,用于指定特定版本,如果不提供则使用默认的已发布版本。<br/>- 获取方式:在版本历史界面,点击每个版本条目右侧的复制图标即可复制完整的工作流 ID。- </Property>- <Property name='trace_id' type='string' key='trace_id'>- (选填)链路追踪ID。适用于与业务系统已有的trace组件打通,实现端到端分布式追踪等场景。如果未指定,系统会自动生成<code>trace_id</code>。支持以下三种方式传递,具体优先级依次为:<br/>- - Header:通过 HTTP Header <code>X-Trace-Id</code> 传递,优先级最高。<br/>- - Query 参数:通过 URL 查询参数 <code>trace_id</code> 传递。<br/>- - Request Body:通过请求体字段 <code>trace_id</code> 传递(即本字段)。<br/>- </Property>- <Property name='trace_session_id' type='string' key='trace_session_id'>- (选填)用于可观测性分组的链路会话 ID。支持会话分组的追踪提供商可将该值用作导出的会话标识。它不会改变 conversation_id、workflow_run_id、trace_id 或 span 关系。支持以下三种方式传递,具体优先级依次为:<br/>- - Header:通过 HTTP Header <code>X-Trace-Session-Id</code> 传递,优先级最高。<br/>- - Query 参数:通过 URL 查询参数 <code>trace_session_id</code> 传递。<br/>- - Request Body:通过请求体字段 <code>trace_session_id</code> 传递(即本字段)。<br/>- </Property>- </Properties>-- ### Response- <Properties>- 当 `response_mode` 为 `blocking` 时,返回 ChatCompletionResponse object。- 当 `response_mode` 为 `streaming`时,返回 ChunkChatCompletionResponse object 流式序列。-- ### ChatCompletionResponse-- 返回完整的 App 结果,`Content-Type` 为 `application/json`。- - `event` (string) 事件类型,固定为 `message`- - `task_id` (string) 任务 ID,用于请求跟踪和下方的停止响应接口- - `id` (string) 唯一ID- - `message_id` (string) 消息唯一 ID- - `conversation_id` (string) 会话 ID- - `mode` (string) App 模式,固定为 chat- - `answer` (string) 完整回复内容- - `metadata` (object) 元数据- - `usage` (Usage) 模型用量信息- - `retriever_resources` (array[RetrieverResource]) 引用和归属分段列表- - `created_at` (int) 消息创建时间戳,如:1705395332- ### ChunkChatCompletionResponse- 返回 App 输出的流式块,`Content-Type` 为 `text/event-stream`。- 每个流式块均为 data: 开头,块之间以 \n\n 即两个换行符分隔,如下所示:- <CodeGroup>- ```streaming {{ title: 'Response' }}- data: {"event": "message", "task_id": "900bbd43-dc0b-4383-a372-aa6e6c414227", "id": "663c5084-a254-4040-8ad3-51f2a3c1a77c", "answer": "Hi", "created_at": 1705398420}\n\n- ```- </CodeGroup>-- 流式块中根据 event 不同,结构也不同:- - `event: message` LLM 返回文本块事件,即:完整的文本以分块的方式输出。- - `task_id` (string) 任务 ID,用于请求跟踪和下方的停止响应接口- - `message_id` (string) 消息唯一 ID- - `conversation_id` (string) 会话 ID- - `answer` (string) LLM 返回文本块内容- - `created_at` (int) 创建时间戳,如:1705395332- - `event: agent_message` Agent模式下返回文本块事件,即:在Agent模式下,文章的文本以分块的方式输出(仅Agent模式下使用)- - `task_id` (string) 任务 ID,用于请求跟踪和下方的停止响应接口- - `message_id` (string) 消息唯一 ID- - `conversation_id` (string) 会话 ID- - `answer` (string) LLM 返回文本块内容- - `created_at` (int) 创建时间戳,如:1705395332- - `event: agent_thought` Agent模式下有关Agent思考步骤的相关内容,涉及到工具调用(仅Agent模式下使用)- - `id` (string) agent_thought ID,每一轮Agent迭代都会有一个唯一的id- - `task_id` (string) 任务ID,用于请求跟踪下方的停止响应接口- - `message_id` (string) 消息唯一ID- - `position` (int) agent_thought在消息中的位置,如第一轮迭代position为1- - `thought` (string) agent的思考内容- - `observation` (string) 工具调用的返回结果- - `tool` (string) 使用的工具列表,以 ; 分割多个工具- - `tool_input` (string) 工具的输入,JSON格式的字符串(object)。如:`{"dalle3": {"prompt": "a cute cat"}}`- - `created_at` (int) 创建时间戳,如:1705395332- - `message_files` (array[string]) 当前 `agent_thought` 关联的文件ID- - `file_id` (string) 文件ID- - `conversation_id` (string) 会话ID- - `event: message_file` 文件事件,表示有新文件需要展示- - `id` (string) 文件唯一ID- - `type` (string) 文件类型,目前仅为image- - `belongs_to` (string) 文件归属,user或assistant,该接口返回仅为 `assistant`- - `url` (string) 文件访问地址- - `conversation_id` (string) 会话ID- - `event: message_end` 消息结束事件,收到此事件则代表流式返回结束。- - `task_id` (string) 任务 ID,用于请求跟踪和下方的停止响应接口- - `message_id` (string) 消息唯一 ID- - `conversation_id` (string) 会话 ID- - `metadata` (object) 元数据- - `usage` (Usage) 模型用量信息- - `retriever_resources` (array[RetrieverResource]) 引用和归属分段列表- - `event: tts_message` TTS 音频流事件,即:语音合成输出。内容是Mp3格式的音频块,使用 base64 编码后的字符串,播放的时候直接解码即可。(开启自动播放才有此消息)- - `task_id` (string) 任务 ID,用于请求跟踪和下方的停止响应接口- - `message_id` (string) 消息唯一 ID- - `audio` (string) 语音合成之后的音频块使用 Base64 编码之后的文本内容,播放的时候直接 base64 解码送入播放器即可- - `created_at` (int) 创建时间戳,如:1705395332- - `event: tts_message_end` TTS 音频流结束事件,收到这个事件表示音频流返回结束。- - `task_id` (string) 任务 ID,用于请求跟踪和下方的停止响应接口- - `message_id` (string) 消息唯一 ID- - `audio` (string) 结束事件是没有音频的,所以这里是空字符串- - `created_at` (int) 创建时间戳,如:1705395332- - `event: message_replace` 消息内容替换事件。- 开启内容审查和审查输出内容时,若命中了审查条件,则会通过此事件替换消息内容为预设回复。- - `task_id` (string) 任务 ID,用于请求跟踪和下方的停止响应接口- - `message_id` (string) 消息唯一 ID- - `conversation_id` (string) 会话 ID- - `answer` (string) 替换内容(直接替换 LLM 所有回复文本)- - `created_at` (int) 创建时间戳,如:1705395332- - `event: error`- 流式输出过程中出现的异常会以 stream event 形式输出,收到异常事件后即结束。- - `task_id` (string) 任务 ID,用于请求跟踪和下方的停止响应接口- - `message_id` (string) 消息唯一 ID- - `status` (int) HTTP 状态码- - `code` (string) 错误码- - `message` (string) 错误消息- - `event: ping` 每 10s 一次的 ping 事件,保持连接存活。-- ### Errors- - 404,对话不存在- - 400,`invalid_param`,传入参数异常- - 400,`app_unavailable`,App 配置不可用- - 400,`provider_not_initialize`,无可用模型凭据配置- - 400,`provider_quota_exceeded`,模型调用额度不足- - 400,`model_currently_not_support`,当前模型不可用- - 400,`workflow_not_found`,指定的工作流版本未找到- - 400,`draft_workflow_error`,无法使用草稿工作流版本- - 400,`workflow_id_format_error`,工作流ID格式错误,需要UUID格式- - 400,`completion_request_error`,文本生成失败- - 500,服务内部异常-- </Properties>- </Col>- <Col sticky>-- <CodeGroup- title="Request"- tag="POST"- label="/chat-messages"- targetCode={`curl -X POST '${props.appDetail.api_base_url}/chat-messages' \\---header 'Authorization: Bearer {api_key}' \\---header 'Content-Type: application/json' \\---data-raw '{- "inputs": ${JSON.stringify(props.inputs)},- "query": "What are the specs of the iPhone 13 Pro Max?",- "response_mode": "streaming",- "conversation_id": "",- "user": "abc-123",- "files": [- {- "type": "image",- "transfer_method": "remote_url",- "url": "https://cloud.dify.ai/logo/logo-site.png"- }- ]-}'`}- />- ### 阻塞模式- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "event": "message",- "task_id": "c3800678-a077-43df-a102-53f23ed20b88",- "id": "9da23599-e713-473b-982c-4328d4f5c78a",- "message_id": "9da23599-e713-473b-982c-4328d4f5c78a",- "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2",- "mode": "chat",- "answer": "iPhone 13 Pro Max specs are listed here:...",- "metadata": {- "usage": {- "prompt_tokens": 1033,- "prompt_unit_price": "0.001",- "prompt_price_unit": "0.001",- "prompt_price": "0.0010330",- "completion_tokens": 128,- "completion_unit_price": "0.002",- "completion_price_unit": "0.001",- "completion_price": "0.0002560",- "total_tokens": 1161,- "total_price": "0.0012890",- "currency": "USD",- "latency": 0.7682376249867957- },- "retriever_resources": [- {- "position": 1,- "dataset_id": "101b4c97-fc2e-463c-90b1-5261a4cdcafb",- "dataset_name": "iPhone",- "document_id": "8dd1ad74-0b5f-4175-b735-7d98bbbb4e00",- "document_name": "iPhone List",- "segment_id": "ed599c7f-2766-4294-9d1d-e5235a61270a",- "score": 0.98457545,- "content": "\"Model\",\"Release Date\",\"Display Size\",\"Resolution\",\"Processor\",\"RAM\",\"Storage\",\"Camera\",\"Battery\",\"Operating System\"\n\"iPhone 13 Pro Max\",\"September 24, 2021\",\"6.7 inch\",\"1284 x 2778\",\"Hexa-core (2x3.23 GHz Avalanche + 4x1.82 GHz Blizzard)\",\"6 GB\",\"128, 256, 512 GB, 1TB\",\"12 MP\",\"4352 mAh\",\"iOS 15\""- }- ]- },- "created_at": 1705407629- }- ```- </CodeGroup>- ### 流式模式(基础助手)- <CodeGroup title="Response">- ```streaming {{ title: 'Response' }}- data: {"event": "message", "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " I", "created_at": 1679586595}- data: {"event": "message", "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": "'m", "created_at": 1679586595}- data: {"event": "message", "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " glad", "created_at": 1679586595}- data: {"event": "message", "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " to", "created_at": 1679586595}- data: {"event": "message", "message_id" : "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " meet", "created_at": 1679586595}- data: {"event": "message", "message_id" : "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " you", "created_at": 1679586595}- data: {"event": "message_end", "id": "5e52ce04-874b-4d27-9045-b3bc80def685", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "metadata": {"usage": {"prompt_tokens": 1033, "prompt_unit_price": "0.001", "prompt_price_unit": "0.001", "prompt_price": "0.0010330", "completion_tokens": 135, "completion_unit_price": "0.002", "completion_price_unit": "0.001", "completion_price": "0.0002700", "total_tokens": 1168, "total_price": "0.0013030", "currency": "USD", "latency": 1.381760165997548}, "retriever_resources": [{"position": 1, "dataset_id": "101b4c97-fc2e-463c-90b1-5261a4cdcafb", "dataset_name": "iPhone", "document_id": "8dd1ad74-0b5f-4175-b735-7d98bbbb4e00", "document_name": "iPhone List", "segment_id": "ed599c7f-2766-4294-9d1d-e5235a61270a", "score": 0.98457545, "content": "\"Model\",\"Release Date\",\"Display Size\",\"Resolution\",\"Processor\",\"RAM\",\"Storage\",\"Camera\",\"Battery\",\"Operating System\"\n\"iPhone 13 Pro Max\",\"September 24, 2021\",\"6.7 inch\",\"1284 x 2778\",\"Hexa-core (2x3.23 GHz Avalanche + 4x1.82 GHz Blizzard)\",\"6 GB\",\"128, 256, 512 GB, 1TB\",\"12 MP\",\"4352 mAh\",\"iOS 15\""}]}}- data: {"event": "tts_message", "conversation_id": "23dd85f3-1a41-4ea0-b7a9-062734ccfaf9", "message_id": "a8bdc41c-13b2-4c18-bfd9-054b9803038c", "created_at": 1721205487, "task_id": "3bf8a0bb-e73b-4690-9e66-4e429bad8ee7", "audio": "qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq"}- data: {"event": "tts_message_end", "conversation_id": "23dd85f3-1a41-4ea0-b7a9-062734ccfaf9", "message_id": "a8bdc41c-13b2-4c18-bfd9-054b9803038c", "created_at": 1721205487, "task_id": "3bf8a0bb-e73b-4690-9e66-4e429bad8ee7", "audio": ""}- ```- </CodeGroup>-- ### 流式模式(智能助手)- <CodeGroup title="Response">- ```streaming {{ title: 'Response' }}- data: {"event": "agent_thought", "id": "8dcf3648-fbad-407a-85dd-73a6f43aeb9f", "task_id": "9cf1ddd7-f94b-459b-b942-b77b26c59e9b", "message_id": "1fb10045-55fd-4040-99e6-d048d07cbad3", "position": 1, "thought": "", "observation": "", "tool": "", "tool_input": "", "created_at": 1705639511, "message_files": [], "conversation_id": "c216c595-2d89-438c-b33c-aae5ddddd142"}- data: {"event": "agent_thought", "id": "8dcf3648-fbad-407a-85dd-73a6f43aeb9f", "task_id": "9cf1ddd7-f94b-459b-b942-b77b26c59e9b", "message_id": "1fb10045-55fd-4040-99e6-d048d07cbad3", "position": 1, "thought": "", "observation": "", "tool": "dalle3", "tool_input": "{\"dalle3\": {\"prompt\": \"cute Japanese anime girl with white hair, blue eyes, bunny girl suit\"}}", "created_at": 1705639511, "message_files": [], "conversation_id": "c216c595-2d89-438c-b33c-aae5ddddd142"}- data: {"event": "message_file", "id": "d75b7a5c-ce5e-442e-ab1b-d6a5e5b557b0", "type": "image", "belongs_to": "assistant", "url": "http://127.0.0.1:5001/files/tools/d75b7a5c-ce5e-442e-ab1b-d6a5e5b557b0.png?timestamp=1705639526&nonce=70423256c60da73a9c96d1385ff78487&sign=7B5fKV9890YJuqchQvrABvW4AIupDvDvxGdu1EOJT94=", "conversation_id": "c216c595-2d89-438c-b33c-aae5ddddd142"}- data: {"event": "agent_thought", "id": "8dcf3648-fbad-407a-85dd-73a6f43aeb9f", "task_id": "9cf1ddd7-f94b-459b-b942-b77b26c59e9b", "message_id": "1fb10045-55fd-4040-99e6-d048d07cbad3", "position": 1, "thought": "", "observation": "image has been created and sent to user already, you should tell user to check it now.", "tool": "dalle3", "tool_input": "{\"dalle3\": {\"prompt\": \"cute Japanese anime girl with white hair, blue eyes, bunny girl suit\"}}", "created_at": 1705639511, "message_files": ["d75b7a5c-ce5e-442e-ab1b-d6a5e5b557b0"], "conversation_id": "c216c595-2d89-438c-b33c-aae5ddddd142"}- data: {"event": "agent_thought", "id": "67a99dc1-4f82-42d3-b354-18d4594840c8", "task_id": "9cf1ddd7-f94b-459b-b942-b77b26c59e9b", "message_id": "1fb10045-55fd-4040-99e6-d048d07cbad3", "position": 2, "thought": "", "observation": "", "tool": "", "tool_input": "", "created_at": 1705639511, "message_files": [], "conversation_id": "c216c595-2d89-438c-b33c-aae5ddddd142"}- data: {"event": "agent_message", "id": "1fb10045-55fd-4040-99e6-d048d07cbad3", "task_id": "9cf1ddd7-f94b-459b-b942-b77b26c59e9b", "message_id": "1fb10045-55fd-4040-99e6-d048d07cbad3", "answer": "I have created an image of a cute Japanese", "created_at": 1705639511, "conversation_id": "c216c595-2d89-438c-b33c-aae5ddddd142"}- data: {"event": "agent_message", "id": "1fb10045-55fd-4040-99e6-d048d07cbad3", "task_id": "9cf1ddd7-f94b-459b-b942-b77b26c59e9b", "message_id": "1fb10045-55fd-4040-99e6-d048d07cbad3", "answer": " anime girl with white hair and blue", "created_at": 1705639511, "conversation_id": "c216c595-2d89-438c-b33c-aae5ddddd142"}- data: {"event": "agent_message", "id": "1fb10045-55fd-4040-99e6-d048d07cbad3", "task_id": "9cf1ddd7-f94b-459b-b942-b77b26c59e9b", "message_id": "1fb10045-55fd-4040-99e6-d048d07cbad3", "answer": " eyes wearing a bunny girl" ,"created_at": 1705639511, "conversation_id": "c216c595-2d89-438c-b33c-aae5ddddd142"}- data: {"event": "agent_message", "id": "1fb10045-55fd-4040-99e6-d048d07cbad3", "task_id": "9cf1ddd7-f94b-459b-b942-b77b26c59e9b", "message_id": "1fb10045-55fd-4040-99e6-d048d07cbad3", "answer": " suit .", "created_at": 1705639511, "conversation_id": "c216c595-2d89-438c-b33c-aae5ddddd142"}- data: {"event": "agent_thought", "id": "67a99dc1-4f82-42d3-b354-18d4594840c8", "task_id": "9cf1ddd7-f94b-459b-b942-b77b26c59e9b", "message_id": "1fb10045-55fd-4040-99e6-d048d07cbad3", "position": 2, "thought": "I have created an image of a cute Japanese anime girl with white hair and blue eyes wearing a bunny girl suit.", "observation": "", "tool": "", "tool_input": "", "created_at": 1705639511, "message_files": [], "conversation_id": "c216c595-2d89-438c-b33c-aae5ddddd142"}- data: {"event": "message_end", "id": "5e52ce04-874b-4d27-9045-b3bc80def685", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "metadata": {"usage": {"prompt_tokens": 1033, "prompt_unit_price": "0.001", "prompt_price_unit": "0.001", "prompt_price": "0.0010330", "completion_tokens": 135, "completion_unit_price": "0.002", "completion_price_unit": "0.001", "completion_price": "0.0002700", "total_tokens": 1168, "total_price": "0.0013030", "currency": "USD", "latency": 1.381760165997548}, "retriever_resources": [{"position": 1, "dataset_id": "101b4c97-fc2e-463c-90b1-5261a4cdcafb", "dataset_name": "iPhone", "document_id": "8dd1ad74-0b5f-4175-b735-7d98bbbb4e00", "document_name": "iPhone List", "segment_id": "ed599c7f-2766-4294-9d1d-e5235a61270a", "score": 0.98457545, "content": "\"Model\",\"Release Date\",\"Display Size\",\"Resolution\",\"Processor\",\"RAM\",\"Storage\",\"Camera\",\"Battery\",\"Operating System\"\n\"iPhone 13 Pro Max\",\"September 24, 2021\",\"6.7 inch\",\"1284 x 2778\",\"Hexa-core (2x3.23 GHz Avalanche + 4x1.82 GHz Blizzard)\",\"6 GB\",\"128, 256, 512 GB, 1TB\",\"12 MP\",\"4352 mAh\",\"iOS 15\""}]}}- data: {"event": "tts_message", "conversation_id": "23dd85f3-1a41-4ea0-b7a9-062734ccfaf9", "message_id": "a8bdc41c-13b2-4c18-bfd9-054b9803038c", "created_at": 1721205487, "task_id": "3bf8a0bb-e73b-4690-9e66-4e429bad8ee7", "audio": "qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq"}- data: {"event": "tts_message_end", "conversation_id": "23dd85f3-1a41-4ea0-b7a9-062734ccfaf9", "message_id": "a8bdc41c-13b2-4c18-bfd9-054b9803038c", "created_at": 1721205487, "task_id": "3bf8a0bb-e73b-4690-9e66-4e429bad8ee7", "audio": ""}- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/files/upload'- method='POST'- title='上传文件'- name='#files-upload'-/>-<Row>- <Col>- 上传文件(目前仅支持图片)并在发送消息时使用,可实现图文多模态理解。- 支持 png, jpg, jpeg, webp, gif 格式。- <i>上传的文件仅供当前终端用户使用。</i>-- ### Request Body- 该接口需使用 `multipart/form-data` 进行请求。- <Properties>- <Property name='file' type='file' key='file'>- 要上传的文件。- </Property>- <Property name='user' type='string' key='user'>- 用户标识,用于定义终端用户的身份,必须和发送消息接口传入 user 保持一致。服务 API 不会共享 WebApp 创建的对话。- </Property>- </Properties>-- ### Response- 成功上传后,服务器会返回文件的 ID 和相关信息。- - `id` (uuid) ID- - `name` (string) 文件名- - `size` (int) 文件大小(byte)- - `extension` (string) 文件后缀- - `mime_type` (string) 文件 mime-type- - `created_by` (uuid) 上传人 ID- - `created_at` (timestamp) 上传时间-- ### Errors- - 400,`no_file_uploaded`,必须提供文件- - 400,`too_many_files`,目前只接受一个文件- - 400,`unsupported_preview`,该文件不支持预览- - 400,`unsupported_estimate`,该文件不支持估算- - 413,`file_too_large`,文件太大- - 415,`unsupported_file_type`,不支持的扩展名,当前只接受文档类文件- - 503,`s3_connection_failed`,无法连接到 S3 服务- - 503,`s3_permission_denied`,无权限上传文件到 S3- - 503,`s3_file_too_large`,文件超出 S3 大小限制- </Col>- <Col sticky>-- <CodeGroup- title="Request"- tag="POST"- label="/files/upload"- targetCode={`curl -X POST '${props.appDetail.api_base_url}/files/upload' \\---header 'Authorization: Bearer {api_key}' \\---form 'file=@localfile;type=image/[png|jpeg|jpg|webp|gif]' \\---form 'user=abc-123'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "id": "72fa9618-8f89-4a37-9b33-7e1178a24a67",- "name": "example.png",- "size": 1024,- "extension": "png",- "mime_type": "image/png",- "created_by": 123,- "created_at": 1577836800,- }- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/end-users/:end_user_id'- method='GET'- title='获取终端用户'- name='#end-user'-/>-<Row>- <Col>- 通过终端用户 ID 获取终端用户信息。-- 当其他 API 返回终端用户 ID(例如:上传文件接口返回的 `created_by`)时,可使用该接口查询对应的终端用户信息。-- ### 路径参数- - `end_user_id` (uuid) 必需- 终端用户 ID。-- ### Response- 返回 EndUser 对象。- - `id` (uuid) ID- - `tenant_id` (uuid) 工作空间(Tenant)ID- - `app_id` (uuid) 应用 ID- - `type` (string) 终端用户类型- - `external_user_id` (string) 外部用户 ID- - `name` (string) 名称- - `is_anonymous` (boolean) 是否匿名- - `session_id` (string) 会话 ID- - `created_at` (string) ISO 8601 时间- - `updated_at` (string) ISO 8601 时间-- ### Errors- - 404,`end_user_not_found`,终端用户不存在- - 500,内部服务器错误-- </Col>- <Col sticky>- <CodeGroup- title="Request"- tag="GET"- label="/end-users/:end_user_id"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/end-users/6ad1ab0a-73ff-4ac1-b9e4-cdb312f71f13' \\---header 'Authorization: Bearer {api_key}'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "id": "6ad1ab0a-73ff-4ac1-b9e4-cdb312f71f13",- "tenant_id": "8c0f3f3a-66b0-4b55-a0bf-8b8e0d6aee7d",- "app_id": "6c8c3f41-2c6f-4e1b-8f4f-7f11c8f2ad2a",- "type": "service_api",- "external_user_id": "abc-123",- "name": "Alice",- "is_anonymous": false,- "session_id": "abc-123",- "created_at": "2024-01-01T00:00:00Z",- "updated_at": "2024-01-01T00:00:00Z"- }- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/files/:file_id/preview'- method='GET'- title='文件预览'- name='#file-preview'-/>-<Row>- <Col>- 预览或下载已上传的文件。此端点允许您访问先前通过文件上传 API 上传的文件。-- <i>文件只能在属于请求应用程序的消息范围内访问。</i>-- ### 路径参数- - `file_id` (string) 必需- 要预览的文件的唯一标识符,从文件上传 API 响应中获得。-- ### 查询参数- - `as_attachment` (boolean) 可选- 是否强制将文件作为附件下载。默认为 `false`(在浏览器中预览)。-- ### 响应- 返回带有适当浏览器显示或下载标头的文件内容。- - `Content-Type` 根据文件 MIME 类型设置- - `Content-Length` 文件大小(以字节为单位,如果可用)- - `Content-Disposition` 如果 `as_attachment=true` 则设置为 "attachment"- - `Cache-Control` 用于性能的缓存标头- - `Accept-Ranges` 对于音频/视频文件设置为 "bytes"-- ### 错误- - 400, `invalid_param`, 参数输入异常- - 403, `file_access_denied`, 文件访问被拒绝或文件不属于当前应用程序- - 404, `file_not_found`, 文件未找到或已被删除- - 500, 服务内部错误-- </Col>- <Col sticky>- ### 请求示例- <CodeGroup- title="Request"- tag="GET"- label="/files/:file_id/preview"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/files/72fa9618-8f89-4a37-9b33-7e1178a24a67/preview' \\- --header 'Authorization: Bearer {api_key}'`}>-- ```bash {{ title: 'cURL' }}- curl -X GET '${props.appDetail.api_base_url}/files/72fa9618-8f89-4a37-9b33-7e1178a24a67/preview' \- --header 'Authorization: Bearer {api_key}'- ```-- </CodeGroup>-- ### 作为附件下载- <CodeGroup title="Request" tag="GET" label="/files/:file_id/preview?as_attachment=true" targetCode={`curl -X GET '${props.appDetail.api_base_url}/files/72fa9618-8f89-4a37-9b33-7e1178a24a67/preview?as_attachment=true' \\---header 'Authorization: Bearer {api_key}' \\---output downloaded_file.png`}- />-- ### 响应标头示例- <CodeGroup title="Response Headers">- ```http {{ title: 'Headers - 图片预览' }}- Content-Type: image/png- Content-Length: 1024- Cache-Control: public, max-age=3600- ```- </CodeGroup>-- ### 文件下载响应标头- <CodeGroup title="Download Response Headers">- ```http {{ title: 'Headers - 文件下载' }}- Content-Type: image/png- Content-Length: 1024- Content-Disposition: attachment; filename*=UTF-8''example.png- Cache-Control: public, max-age=3600- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/chat-messages/:task_id/stop'- method='POST'- title='停止响应'- name='#Stop'-/>-<Row>- <Col>- 仅支持流式模式。- ### Path- - `task_id` (string) 任务 ID,可在流式返回 Chunk 中获取-- ### Request Body- - `user` (string) Required- 用户标识,用于定义终端用户的身份,必须和发送消息接口传入 user 保持一致。API 无法访问 WebApp 创建的会话。- ### Response- - `result` (string) 固定返回 success- </Col>- <Col sticky>- <CodeGroup- title="Request"- tag="POST"- label="/chat-messages/:task_id/stop"- targetCode={`curl -X POST '${props.appDetail.api_base_url}/chat-messages/:task_id/stop' \\--H 'Authorization: Bearer {api_key}' \\--H 'Content-Type: application/json' \\---data-raw '{ "user": "abc-123"}'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "result": "success"- }- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/messages/:message_id/feedbacks'- method='POST'- title='消息反馈(点赞)'- name='#feedbacks'-/>-<Row>- <Col>- 消息终端用户反馈、点赞,方便应用开发者优化输出预期。-- ### Path Params- <Properties>- <Property name='message_id' type='string' key='message_id'>- 消息 ID- </Property>- </Properties>-- ### Request Body-- <Properties>- <Property name='rating' type='string' key='rating'>- 点赞 like, 点踩 dislike, 撤销点赞 null- </Property>- <Property name='user' type='string' key='user'>- 用户标识,由开发者定义规则,需保证用户标识在应用内唯一。服务 API 不会共享 WebApp 创建的对话。- </Property>- <Property name='content' type='string' key='content'>- 消息反馈的具体信息。- </Property>- </Properties>-- ### Response- - `result` (string) 固定返回 success- </Col>- <Col sticky>-- <CodeGroup- title="Request"- tag="POST"- label="/messages/:message_id/feedbacks"- targetCode={`curl -X POST '${props.appDetail.api_base_url}/messages/:message_id/feedbacks \\---header 'Authorization: Bearer {api_key}' \\---header 'Content-Type: application/json' \\---data-raw '{- "rating": "like",- "user": "abc-123",- "content": "message feedback information"-}'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "result": "success"- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/app/feedbacks'- method='GET'- title='获取APP的消息点赞和反馈'- name='#app-feedbacks'-/>-<Row>- <Col>- 获取应用的终端用户反馈、点赞。-- ### Query- <Properties>- <Property name='page' type='string' key='page'>- (选填)分页,默认值:1- </Property>- </Properties>-- <Properties>- <Property name='limit' type='string' key='limit'>- (选填)每页数量,默认值:20- </Property>- </Properties>-- ### Response- - `data` (List) 返回该APP的点赞、反馈列表。- </Col>- <Col sticky>-- <CodeGroup- title="Request"- tag="GET"- label="/app/feedbacks"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/app/feedbacks?page=1&limit=20'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "data": [- {- "id": "8c0fbed8-e2f9-49ff-9f0e-15a35bdd0e25",- "app_id": "f252d396-fe48-450e-94ec-e184218e7346",- "conversation_id": "2397604b-9deb-430e-b285-4726e51fd62d",- "message_id": "709c0b0f-0a96-4a4e-91a4-ec0889937b11",- "rating": "like",- "content": "message feedback information-3",- "from_source": "user",- "from_end_user_id": "74286412-9a1a-42c1-929c-01edb1d381d5",- "from_account_id": null,- "created_at": "2025-04-24T09:24:38",- "updated_at": "2025-04-24T09:24:38"- }- ]- }- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/messages/{message_id}/suggested'- method='GET'- title='获取下一轮建议问题列表'- name='#suggested'-/>-<Row>- <Col>- 获取下一轮建议问题列表。-- ### Path Params-- <Properties>- <Property name='message_id' type='string' key='message_id'>- Message ID- </Property>- </Properties>-- ### Query- <Properties>- <Property name='user' type='string' key='user'>- 用户标识,由开发者定义规则,需保证用户标识在应用内唯一。- </Property>- </Properties>- </Col>- <Col sticky>-- <CodeGroup- title="Request"- tag="GET"- label="/messages/{message_id}/suggested"- targetCode={`curl --location --request GET '${props.appDetail.api_base_url}/messages/{message_id}/suggested?user=abc-123 \\---header 'Authorization: Bearer ENTER-YOUR-SECRET-KEY' \\---header 'Content-Type: application/json'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "result": "success",- "data": [- "a",- "b",- "c"- ]- }- ```- </CodeGroup>- </Col>-</Row>------------<Heading- url='/messages'- method='GET'- title='获取会话历史消息'- name='#messages'-/>-<Row>- <Col>- 滚动加载形式返回历史聊天记录,第一页返回最新 `limit` 条,即:倒序返回。-- ### Query-- <Properties>- <Property name='conversation_id' type='string' key='conversation_id'>- 会话 ID- </Property>- <Property name='user' type='string' key='user'>- 用户标识,由开发者定义规则,需保证用户标识在应用内唯一。- </Property>- <Property name='first_id' type='string' key='first_id'>- 当前页第一条聊天记录的 ID,默认 null- </Property>- <Property name='limit' type='int' key='limit'>- 一次请求返回多少条聊天记录,默认 20 条。- </Property>- </Properties>-- ### Response- - `data` (array[object]) 消息列表- - `id` (string) 消息 ID- - `conversation_id` (string) 会话 ID- - `inputs` (object) 用户输入参数。- - `query` (string) 用户输入 / 提问内容。- - `message_files` (array[object]) 消息文件- - `id` (string) ID- - `type` (string) 文件类型,image 图片- - `url` (string) 文件预览地址,使用文件预览 API (`/files/{file_id}/preview`) 访问文件- - `belongs_to` (string) 文件归属方,user 或 assistant- - `agent_thoughts` (array[object]) Agent思考内容(仅Agent模式下不为空)- - `id` (string) agent_thought ID,每一轮Agent迭代都会有一个唯一的id- - `message_id` (string) 消息唯一ID- - `position` (int) agent_thought在消息中的位置,如第一轮迭代position为1- - `thought` (string) agent的思考内容- - `observation` (string) 工具调用的返回结果- - `tool` (string) 使用的工具列表,以 ; 分割多个工具- - `tool_input` (string) 工具的输入,JSON格式的字符串(object)。如:`{"dalle3": {"prompt": "a cute cat"}}`- - `created_at` (int) 创建时间戳,如:1705395332- - `message_files` (array[string]) 当前agent_thought 关联的文件ID- - `file_id` (string) 文件ID- - `conversation_id` (string) 会话ID- - `answer` (string) 回答消息内容- - `created_at` (timestamp) 创建时间- - `feedback` (object) 反馈信息- - `rating` (string) 点赞 like / 点踩 dislike- - `retriever_resources` (array[RetrieverResource]) 引用和归属分段列表- - `has_more` (bool) 是否存在下一页- - `limit` (int) 返回条数,若传入超过系统限制,返回系统限制数量- </Col>- <Col sticky>- ### Request Example- <CodeGroup- title="Request"- tag="GET"- label="/messages"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/messages?user=abc-123&conversation_id=' \\---header 'Authorization: Bearer {api_key}'`}- />-- ### Response Example(基础助手)- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "limit": 20,- "has_more": false,- "data": [- {- "id": "a076a87f-31e5-48dc-b452-0061adbbc922",- "conversation_id": "cd78daf6-f9e4-4463-9ff2-54257230a0ce",- "inputs": {- "name": "dify"- },- "query": "iphone 13 pro",- "answer": "The iPhone 13 Pro, released on September 24, 2021, features a 6.1-inch display with a resolution of 1170 x 2532. It is equipped with a Hexa-core (2x3.23 GHz Avalanche + 4x1.82 GHz Blizzard) processor, 6 GB of RAM, and offers storage options of 128 GB, 256 GB, 512 GB, and 1 TB. The camera is 12 MP, the battery capacity is 3095 mAh, and it runs on iOS 15.",- "message_files": [],- "feedback": null,- "retriever_resources": [- {- "position": 1,- "dataset_id": "101b4c97-fc2e-463c-90b1-5261a4cdcafb",- "dataset_name": "iPhone",- "document_id": "8dd1ad74-0b5f-4175-b735-7d98bbbb4e00",- "document_name": "iPhone List",- "segment_id": "ed599c7f-2766-4294-9d1d-e5235a61270a",- "score": 0.98457545,- "content": "\"Model\",\"Release Date\",\"Display Size\",\"Resolution\",\"Processor\",\"RAM\",\"Storage\",\"Camera\",\"Battery\",\"Operating System\"\n\"iPhone 13 Pro Max\",\"September 24, 2021\",\"6.7 inch\",\"1284 x 2778\",\"Hexa-core (2x3.23 GHz Avalanche + 4x1.82 GHz Blizzard)\",\"6 GB\",\"128, 256, 512 GB, 1TB\",\"12 MP\",\"4352 mAh\",\"iOS 15\""- }- ],- "agent_thoughts": [],- "created_at": 1705569239- }- ]- }- ```- </CodeGroup>-- ### Response Example(智能助手)- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "limit": 20,- "has_more": false,- "data": [- {- "id": "d35e006c-7c4d-458f-9142-be4930abdf94",- "conversation_id": "957c068b-f258-4f89-ba10-6e8a0361c457",- "inputs": {},- "query": "draw a cat",- "answer": "I have generated an image of a cat for you. Please check your messages to view the image.",- "message_files": [- {- "id": "976990d2-5294-47e6-8f14-7356ba9d2d76",- "type": "image",- "url": "http://127.0.0.1:5001/files/tools/976990d2-5294-47e6-8f14-7356ba9d2d76.png?timestamp=1705988524&nonce=55df3f9f7311a9acd91bf074cd524092&sign=z43nMSO1L2HBvoqADLkRxr7Biz0fkjeDstnJiCK1zh8=",- "belongs_to": "assistant"- }- ],- "feedback": null,- "retriever_resources": [],- "created_at": 1705988187,- "agent_thoughts": [- {- "id": "592c84cf-07ee-441c-9dcc-ffc66c033469",- "chain_id": null,- "message_id": "d35e006c-7c4d-458f-9142-be4930abdf94",- "position": 1,- "thought": "",- "tool": "dalle2",- "tool_input": "{\"dalle2\": {\"prompt\": \"cat\"}}",- "created_at": 1705988186,- "observation": "image has been created and sent to user already, you should tell user to check it now.",- "files": [- "976990d2-5294-47e6-8f14-7356ba9d2d76"- ]- },- {- "id": "73ead60d-2370-4780-b5ed-532d2762b0e5",- "chain_id": null,- "message_id": "d35e006c-7c4d-458f-9142-be4930abdf94",- "position": 2,- "thought": "I have generated an image of a cat for you. Please check your messages to view the image.",- "tool": "",- "tool_input": "",- "created_at": 1705988199,- "observation": "",- "files": []- }- ]- }- ]- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/conversations'- method='GET'- title='获取会话列表'- name='#conversations'-/>-<Row>- <Col>- 获取当前用户的会话列表,默认返回最近的 20 条。-- ### Query-- <Properties>- <Property name='user' type='string' key='user'>- 用户标识,由开发者定义规则,需保证用户标识在应用内唯一。- </Property>- <Property name='last_id' type='string' key='last_id'>- (选填)当前页最后面一条记录的 ID,默认 null- </Property>- <Property name='limit' type='int' key='limit'>- (选填)一次请求返回多少条记录,默认 20 条,最大 100 条,最小 1 条。- </Property>- <Property name='sort_by' type='string' key='sort_by'>- (选填)排序字段,默认 -updated_at(按更新时间倒序排列)- - 可选值:created_at, -created_at, updated_at, -updated_at- - 字段前面的符号代表顺序或倒序,-代表倒序- </Property>- </Properties>-- ### Response- - `data` (array[object]) 会话列表- - `id` (string) 会话 ID- - `name` (string) 会话名称,默认为会话中用户最开始问题的截取。- - `inputs` (object) 用户输入参数。- - `status` (string) 会话状态- - `introduction` (string) 开场白- - `created_at` (timestamp) 创建时间- - `updated_at` (timestamp) 更新时间- - `has_more` (bool)- - `limit` (int) 返回条数,若传入超过系统限制,返回系统限制数量-- </Col>- <Col sticky>-- <CodeGroup- title="Request"- tag="GET"- label="/conversations"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/conversations?user=abc-123&last_id=&limit=20'\\---header 'Authorization: Bearer {api_key}'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "limit": 20,- "has_more": false,- "data": [- {- "id": "10799fb8-64f7-4296-bbf7-b42bfbe0ae54",- "name": "New chat",- "inputs": {- "book": "book",- "myName": "Lucy"- },- "status": "normal",- "created_at": 1679667915,- "updated_at": 1679667915- },- {- "id": "hSIhXBhNe8X1d8Et"- // ...- }- ]- }- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/conversations/:conversation_id'- method='DELETE'- title='删除会话'- name='#delete'-/>-<Row>- <Col>- 删除会话。-- ### Path- - `conversation_id` (string) 会话 ID-- ### Request Body-- <Properties>- <Property name='user' type='string' key='user'>- 用户标识,由开发者定义规则,需保证用户标识在应用内唯一。- </Property>- </Properties>-- ### Response- - `result` (string) 固定返回 success- </Col>- <Col sticky>-- <CodeGroup- title="Request"- tag="DELETE"- label="/conversations/:conversation_id"- targetCode={`curl -X DELETE '${props.appDetail.api_base_url}/conversations/:conversation_id' \\---header 'Authorization: Bearer {api_key}' \\---header 'Content-Type: application/json' \\---data-raw '{- "user": "abc-123"-}'`}- />-- <CodeGroup title="Response">- ```text {{ title: 'Response' }}- 204 No Content- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/conversations/:conversation_id/name'- method='POST'- title='会话重命名'- name='#rename'-/>-<Row>- <Col>- 对会话进行重命名,会话名称用于显示在支持多会话的客户端上。-- ### Path- - `conversation_id` (string) 会话 ID-- ### Request Body-- <Properties>- <Property name='name' type='string' key='name'>- (选填)名称,若 `auto_generate` 为 `true` 时,该参数可不传。- </Property>- <Property name='auto_generate' type='bool' key='auto_generate'>- (选填)自动生成标题,默认 false。- </Property>- <Property name='user' type='string' key='user'>- 用户标识,由开发者定义规则,需保证用户标识在应用内唯一。- </Property>- </Properties>-- ### Response- - `id` (string) 会话 ID- - `name` (string) 会话名称- - `inputs` (object) 用户输入参数- - `status` (string) 会话状态- - `introduction` (string) 开场白- - `created_at` (timestamp) 创建时间- - `updated_at` (timestamp) 更新时间- </Col>- <Col sticky>-- <CodeGroup- title="Request"- tag="POST"- label="/conversations/:conversation_id/name"- targetCode={`curl -X POST '${props.appDetail.api_base_url}/conversations/:conversation_id/name' \\---header 'Authorization: Bearer {api_key}' \\---header 'Content-Type: application/json' \\---data-raw '{- "name": "",- "auto_generate": true,- "user": "abc-123"-}'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "id": "34d511d5-56de-4f16-a997-57b379508443",- "name": "hello",- "inputs": {},- "status": "normal",- "introduction": "",- "created_at": 1732731141,- "updated_at": 1732734510- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/conversations/:conversation_id/variables'- method='GET'- title='获取对话变量'- name='#conversation-variables'-/>-<Row>- <Col>- 从特定对话中检索变量。此端点对于提取对话过程中捕获的结构化数据非常有用。-- ### 路径参数-- <Properties>- <Property name='conversation_id' type='string' key='conversation_id'>- 要从中检索变量的对话ID。- </Property>- </Properties>-- ### 查询参数-- <Properties>- <Property name='user' type='string' key='user'>- 用户标识符,由开发人员定义的规则,在应用程序内必须唯一。- </Property>- <Property name='last_id' type='string' key='last_id'>- (选填)当前页最后面一条记录的 ID,默认 null- </Property>- <Property name='limit' type='int' key='limit'>- (选填)一次请求返回多少条记录,默认 20 条,最大 100 条,最小 1 条。- </Property>- </Properties>-- ### 响应-- - `limit` (int) 每页项目数- - `has_more` (bool) 是否有更多项目- - `data` (array[object]) 变量列表- - `id` (string) 变量 ID- - `name` (string) 变量名称- - `value_type` (string) 变量类型(字符串、数字、布尔等)- - `value` (string) 变量值- - `description` (string) 变量描述- - `created_at` (int) 创建时间戳- - `updated_at` (int) 最后更新时间戳-- ### 错误- - 404, `conversation_not_exists`, 对话不存在-- </Col>- <Col sticky>-- <CodeGroup- title="Request"- tag="GET"- label="/conversations/:conversation_id/variables"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/conversations/{conversation_id}/variables?user=abc-123' \\---header 'Authorization: Bearer {api_key}'`}- />-- <CodeGroup title="Request with variable name filter">- ```bash {{ title: 'cURL' }}- curl -X GET '${props.appDetail.api_base_url}/conversations/{conversation_id}/variables?user=abc-123&variable_name=customer_name' \- --header 'Authorization: Bearer {api_key}'- ```- </CodeGroup>-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "limit": 100,- "has_more": false,- "data": [- {- "id": "variable-uuid-1",- "name": "customer_name",- "value_type": "string",- "value": "John Doe",- "description": "客户名称(从对话中提取)",- "created_at": 1650000000000,- "updated_at": 1650000000000- },- {- "id": "variable-uuid-2",- "name": "order_details",- "value_type": "json",- "value": "{\"product\":\"Widget\",\"quantity\":5,\"price\":19.99}",- "description": "客户的订单详情",- "created_at": 1650000000000,- "updated_at": 1650000000000- }- ]- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/conversations/:conversation_id/variables/:variable_id'- method='PUT'- title='更新对话变量'- name='#update-conversation-variable'-/>-<Row>- <Col>- 更新特定对话变量的值。此端点允许您修改在对话过程中捕获的变量值,同时保留其名称、类型和描述。-- ### 路径参数-- <Properties>- <Property name='conversation_id' type='string' key='conversation_id'>- 包含要更新变量的对话ID。- </Property>- <Property name='variable_id' type='string' key='variable_id'>- 要更新的变量ID。- </Property>- </Properties>-- ### 请求体-- <Properties>- <Property name='value' type='any' key='value'>- 变量的新值。必须匹配变量的预期类型(字符串、数字、对象等)。- </Property>- <Property name='user' type='string' key='user'>- 用户标识符,由开发人员定义的规则,在应用程序内必须唯一。- </Property>- </Properties>-- ### 响应-- 返回包含以下内容的更新变量对象:- - `id` (string) 变量ID- - `name` (string) 变量名称- - `value_type` (string) 变量类型(字符串、数字、对象等)- - `value` (any) 更新后的变量值- - `description` (string) 变量描述- - `created_at` (int) 创建时间戳- - `updated_at` (int) 最后更新时间戳-- ### 错误- - 400, `Type mismatch: variable expects {expected_type}, but got {actual_type} type`, 值类型与变量的预期类型不匹配- - 404, `conversation_not_exists`, 对话不存在- - 404, `conversation_variable_not_exists`, 变量不存在-- </Col>- <Col sticky>-- <CodeGroup- title="Request"- tag="PUT"- label="/conversations/:conversation_id/variables/:variable_id"- targetCode={`curl -X PUT '${props.appDetail.api_base_url}/conversations/{conversation_id}/variables/{variable_id}' \\---header 'Authorization: Bearer {api_key}' \\---header 'Content-Type: application/json' \\---data-raw '{- "value": "Updated Value",- "user": "abc-123"-}'`}- />-- <CodeGroup title="使用不同值类型更新">- ```bash {{ title: '字符串值' }}- curl -X PUT '${props.appDetail.api_base_url}/conversations/{conversation_id}/variables/{variable_id}' \- --header 'Content-Type: application/json' \- --header 'Authorization: Bearer {api_key}' \- --data-raw '{- "value": "新的字符串值",- "user": "abc-123"- }'- ```-- ```bash {{ title: '数字值' }}- curl -X PUT '${props.appDetail.api_base_url}/conversations/{conversation_id}/variables/{variable_id}' \- --header 'Content-Type: application/json' \- --header 'Authorization: Bearer {api_key}' \- --data-raw '{- "value": 42,- "user": "abc-123"- }'- ```-- ```bash {{ title: '对象值' }}- curl -X PUT '${props.appDetail.api_base_url}/conversations/{conversation_id}/variables/{variable_id}' \- --header 'Content-Type: application/json' \- --header 'Authorization: Bearer {api_key}' \- --data-raw '{- "value": {"product": "Widget", "quantity": 10, "price": 29.99},- "user": "abc-123"- }'- ```- </CodeGroup>-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "id": "variable-uuid-1",- "name": "customer_name",- "value_type": "string",- "value": "Updated Value",- "description": "客户名称(从对话中提取)",- "created_at": 1650000000000,- "updated_at": 1650000001000- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/audio-to-text'- method='POST'- title='语音转文字'- name='#audio-to-text'-/>-<Row>- <Col>- ### Request Body- 该接口需使用 `multipart/form-data` 进行请求。- <Properties>- <Property name='file' type='file' key='file'>- 语音文件。- 支持格式:`['mp3', 'mp4', 'mpeg', 'mpga', 'm4a', 'wav', 'webm']`- 文件大小限制:15MB- </Property>- <Property name='user' type='string' key='user'>- 用户标识,由开发者定义规则,需保证用户标识在应用内唯一。- </Property>- </Properties>-- ### Response- - `text` (string) 输出文字- </Col>- <Col sticky>-- <CodeGroup- title="Request"- tag="POST"- label="/audio-to-text"- targetCode={`curl -X POST '${props.appDetail.api_base_url}/audio-to-text' \\---header 'Authorization: Bearer {api_key}' \\---form 'file=@localfile;type=audio/[mp3|mp4|mpeg|mpga|m4a|wav|webm]`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "text": "hello"- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/text-to-audio'- method='POST'- title='文字转语音'- name='#text-to-audio'-/>-<Row>- <Col>- 文字转语音。-- ### Request Body-- <Properties>- <Property name='message_id' type='str' key='message_id'>- Dify 生成的文本消息,那么直接传递生成的message-id 即可,后台会通过 message_id 查找相应的内容直接合成语音信息。如果同时传 message_id 和 text,优先使用 message_id。- </Property>- <Property name='text' type='str' key='text'>- 语音生成内容。如果没有传 message-id的话,则会使用这个字段的内容- </Property>- <Property name='user' type='string' key='user'>- 用户标识,由开发者定义规则,需保证用户标识在应用内唯一。- </Property>- </Properties>- </Col>- <Col sticky>-- <CodeGroup- title="Request"- tag="POST"- label="/text-to-audio"- targetCode={`curl --location --request POST '${props.appDetail.api_base_url}/text-to-audio' \\---header 'Authorization: Bearer ENTER-YOUR-SECRET-KEY' \\---form 'text=你好Dify;user=abc-123;message_id=5ad4cb98-f0c7-4085-b384-88c403be6290`}- />-- <CodeGroup title="headers">- ```json {{ title: 'headers' }}- {- "Content-Type": "audio/wav"- }- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/info'- method='GET'- title='获取应用基本信息'- name='#info'-/>-<Row>- <Col>- 用于获取应用的基本信息- ### Response- - `name` (string) 应用名称- - `description` (string) 应用描述- - `tags` (array[string]) 应用标签- - `mode` (string) 应用模式- - 'author_name' (string) 作者名称- </Col>- <Col>- <CodeGroup- title="Request"- tag="GET"- label="/info"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/info' \\--H 'Authorization: Bearer {api_key}'`}- />- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "name": "My App",- "description": "This is my app.",- "tags": [- "tag1",- "tag2"- ],- "mode": "chat",- "author_name": "Dify"- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/parameters'- method='GET'- title='获取应用参数'- name='#parameters'-/>-<Row>- <Col>- 用于进入页面一开始,获取功能开关、输入参数名称、类型及默认值等使用。-- ### Response- - `opening_statement` (string) 开场白- - `suggested_questions` (array[string]) 开场推荐问题列表- - `suggested_questions_after_answer` (object) 启用回答后给出推荐问题。- - `enabled` (bool) 是否开启- - `speech_to_text` (object) 语音转文本- - `enabled` (bool) 是否开启- - `text_to_speech` (object) 文本转语音- - `enabled` (bool) 是否开启- - `voice` (string) 语音类型- - `language` (string) 语言- - `autoPlay` (string) 自动播放- - `enabled` 开启- - `disabled` 关闭- - `retriever_resource` (object) 引用和归属- - `enabled` (bool) 是否开启- - `annotation_reply` (object) 标记回复- - `enabled` (bool) 是否开启- - `user_input_form` (array[object]) 用户输入表单配置- - `text-input` (object) 文本输入控件- - `label` (string) 控件展示标签名- - `variable` (string) 控件 ID- - `required` (bool) 是否必填- - `default` (string) 默认值- - `paragraph` (object) 段落文本输入控件- - `label` (string) 控件展示标签名- - `variable` (string) 控件 ID- - `required` (bool) 是否必填- - `default` (string) 默认值- - `select` (object) 下拉控件- - `label` (string) 控件展示标签名- - `variable` (string) 控件 ID- - `required` (bool) 是否必填- - `default` (string) 默认值- - `options` (array[string]) 选项值- - `file_upload` (object) 文件上传配置- - `document` (object) 文档设置- 当前仅支持文档类型:`txt`, `md`, `markdown`, `pdf`, `html`, `xlsx`, `xls`, `docx`, `csv`, `eml`, `msg`, `pptx`, `ppt`, `xml`, `epub`。- - `enabled` (bool) 是否启用- - `number_limits` (int) 文档数量限制,默认为 3- - `transfer_methods` (array[string]) 传输方式列表:`remote_url`, `local_file`,必须选择一个。- - `image` (object) 图片设置- 当前仅支持图片类型:`png`, `jpg`, `jpeg`, `webp`, `gif`。- - `enabled` (bool) 是否启用- - `number_limits` (int) 图片数量限制,默认为 3- - `transfer_methods` (array[string]) 传输方式列表:`remote_url`, `local_file`,必须选择一个。- - `audio` (object) 音频设置- 当前仅支持音频类型:`mp3`, `m4a`, `wav`, `webm`, `amr`。- - `enabled` (bool) 是否启用- - `number_limits` (int) 音频数量限制,默认为 3- - `transfer_methods` (array[string]) 传输方式列表:`remote_url`, `local_file`,必须选择一个。- - `video` (object) 视频设置- 当前仅支持视频类型:`mp4`, `mov`, `mpeg`, `mpga`。- - `enabled` (bool) 是否启用- - `number_limits` (int) 视频数量限制,默认为 3- - `transfer_methods` (array[string]) 传输方式列表:`remote_url`, `local_file`,必须选择一个。- - `custom` (object) 自定义设置- - `enabled` (bool) 是否启用- - `number_limits` (int) 自定义数量限制,默认为 3- - `transfer_methods` (array[string]) 传输方式列表:`remote_url`, `local_file`,必须选择一个。- - `system_parameters` (object) 系统参数- - `file_size_limit` (int) 文档上传大小限制 (MB)- - `image_file_size_limit` (int) 图片文件上传大小限制(MB)- - `audio_file_size_limit` (int) 音频文件上传大小限制 (MB)- - `video_file_size_limit` (int) 视频文件上传大小限制 (MB)- </Col>- <Col sticky>-- <CodeGroup- title="Request"- tag="GET"- label="/parameters"- targetCode={` curl -X GET '${props.appDetail.api_base_url}/parameters'\\---header 'Authorization: Bearer {api_key}'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "introduction": "nice to meet you",- "user_input_form": [- {- "text-input": {- "label": "a",- "variable": "a",- "required": true,- "max_length": 48,- "default": ""- }- },- {- // ...- }- ],- "file_upload": {- "image": {- "enabled": true,- "number_limits": 3,- "transfer_methods": [- "remote_url",- "local_file"- ]- }- },- "system_parameters": {- "file_size_limit": 15,- "image_file_size_limit": 10,- "audio_file_size_limit": 50,- "video_file_size_limit": 100- }- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/meta'- method='GET'- title='获取应用Meta信息'- name='#meta'-/>-<Row>- <Col>- 用于获取工具 icon- ### Response- - `tool_icons`(object[string]) 工具图标- - `工具名称` (string)- - `icon` (object|string)- - (object) 图标- - `background` (string) hex 格式的背景色- - `content`(string) emoji- - (string) 图标 URL- </Col>- <Col>- <CodeGroup- title="Request"- tag="POST"- label="/meta"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/meta' \\- -H 'Authorization: Bearer {api_key}'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "tool_icons": {- "dalle2": "https://cloud.dify.ai/console/api/workspaces/current/tool-provider/builtin/dalle/icon",- "api_tool": {- "background": "#252525",- "content": "\ud83d\ude01"- }- }- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/site'- method='GET'- title='获取应用 WebApp 设置'- name='#site'-/>-<Row>- <Col>- 用于获取应用的 WebApp 设置- ### Response- - `title` (string) WebApp 名称- - `chat_color_theme` (string) 聊天颜色主题,hex 格式- - `chat_color_theme_inverted` (bool) 聊天颜色主题是否反转- - `icon_type` (string) 图标类型,`emoji`-表情,`image`-图片- - `icon` (string) 图标,如果是 `emoji` 类型,则是 emoji 表情符号,如果是 `image` 类型,则是图片 URL- - `icon_background` (string) hex 格式的背景色- - `icon_url` (string) 图标 URL- - `description` (string) 描述- - `copyright` (string) 版权信息- - `privacy_policy` (string) 隐私政策链接- - `custom_disclaimer` (string) 自定义免责声明- - `default_language` (string) 默认语言- - `show_workflow_steps` (bool) 是否显示工作流详情- - `use_icon_as_answer_icon` (bool) 是否使用 WebApp 图标替换聊天中的 🤖- </Col>- <Col>- <CodeGroup- title="Request"- tag="GET"- label="/site"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/site' \\--H 'Authorization: Bearer {api_key}'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "title": "My App",- "chat_color_theme": "#ff4a4a",- "chat_color_theme_inverted": false,- "icon_type": "emoji",- "icon": "😄",- "icon_background": "#FFEAD5",- "icon_url": null,- "description": "This is my app.",- "copyright": "all rights reserved",- "privacy_policy": "",- "custom_disclaimer": "All generated by AI",- "default_language": "en-US",- "show_workflow_steps": false,- "use_icon_as_answer_icon": false,- }- ```- </CodeGroup>- </Col>-</Row>-___diff --git a/web/app/components/develop/template/template_workflow.en.mdx b/web/app/components/develop/template/template_workflow.en.mdxdeleted file mode 100644index dc56b1bee00..00000000000--- a/web/app/components/develop/template/template_workflow.en.mdx+++ /dev/null@@ -1,1644 +0,0 @@-import { CodeGroup } from '../code.tsx'-import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx'-import { WorkflowVersionApiContent, WorkflowVersionApiUpgradeNotice } from '../workflow-version-api-upgrade-notice.tsx'--# Workflow App API--Workflow applications offers non-session support and is ideal for translation, article writing, summarization AI, and more.--<div>- ### Base URL- <CodeGroup title="Code" targetCode={props.appDetail.api_base_url} />-- ### Authentication-- The Service API uses `API-Key` authentication.- <i>**Strongly recommend storing your API Key on the server-side, not shared or stored on the client-side, to avoid possible API-Key leakage that can lead to serious consequences.**</i>-- For all API requests, include your API Key in the `Authorization` HTTP Header, as shown below:-- <CodeGroup title="Code" targetCode='Authorization: Bearer {API_KEY}' />-</div>-------<Heading- url='/workflows/run'- method='POST'- title='Execute Workflow'- name='#Execute-Workflow'-/>-<Row>- <Col>- Execute workflow, cannot be executed without a published workflow.-- ### Request Body- - `inputs` (object) Required- Allows the entry of various variable values defined by the App.- The `inputs` parameter contains multiple key/value pairs, with each key corresponding to a specific variable and each value being the specific value for that variable.- The workflow application requires at least one key/value pair to be inputted. The variable can be of File Array type.- File Array type variable is suitable for inputting files combined with text understanding and answering questions, available only when the model supports file parsing and understanding capability.- If the variable is of File Array type, the corresponding value should be a list whose elements contain following attributions:- - `type` (string) Supported type:- - `document` Supported types include: 'TXT', 'MD', 'MARKDOWN', 'MDX', 'PDF', 'HTML', 'XLSX', 'XLS', 'VTT', 'PROPERTIES', 'DOC', 'DOCX', 'CSV', 'EML', 'MSG', 'PPTX', 'PPT', 'XML', 'EPUB'- - `image` Supported types include: 'JPG', 'JPEG', 'PNG', 'GIF', 'WEBP', 'SVG'- - `audio` Supported types include: 'MP3', 'M4A', 'WAV', 'WEBM', 'MPGA'- - `video` Supported types include: 'MP4', 'MOV', 'MPEG', 'WEBM'- - `custom` Supported types include: other file types- - `transfer_method` (string) Transfer method:- - `remote_url`: File URL.- - `local_file`: Upload file.- - `url` File URL. (Only when transfer method is `remote_url`).- - `upload_file_id` Upload file ID. (Only when transfer method is `local_file`).-- - `response_mode` (string) Required- The mode of response return, supporting:- - `streaming` Streaming mode (recommended), implements a typewriter-like output through SSE ([Server-Sent Events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events)).- - `blocking` Blocking mode, returns result after execution is complete. (Requests may be interrupted if the process is long)- <i>Due to Cloudflare restrictions, the request will be interrupted without a return after 100 seconds.</i>- - `user` (string) Required- User identifier, used to define the identity of the end-user for retrieval and statistics.- Should be uniquely defined by the developer within the application.- <br/>- <i>The user identifier should be consistent with the user passed in the message sending interface. The Service API does not share conversations created by the WebApp.</i>- - `files` (array[object]) Optional- - `trace_id` (string) Optional- Trace ID. Used for integration with existing business trace components to achieve end-to-end distributed tracing. If not provided, the system will automatically generate a trace_id. Supports the following three ways to pass, in order of priority:- 1. Header: via HTTP Header `X-Trace-Id`, highest priority.- 2. Query parameter: via URL query parameter `trace_id`.- 3. Request Body: via request body field `trace_id` (i.e., this field).- - `trace_session_id` (string) Optional- Trace session ID for observability grouping. Tracing providers that support session grouping can use this value as the exported session identifier. It does not change conversation_id, workflow_run_id, trace_id, or span relationships. Supports the following three ways to pass, in order of priority:- 1. Header: via HTTP Header `X-Trace-Session-Id`, highest priority.- 2. Query parameter: via URL query parameter `trace_session_id`.- 3. Request Body: via request body field `trace_session_id` (i.e., this field).-- ### Response- When `response_mode` is `blocking`, return a CompletionResponse object.- When `response_mode` is `streaming`, return a ChunkCompletionResponse stream.-- ### CompletionResponse- Returns the App result, `Content-Type` is `application/json`.- - `workflow_run_id` (string) Unique ID of workflow execution- - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API- - `data` (object) detail of result- - `id` (string) ID of workflow execution- - `workflow_id` (string) ID of related workflow- - `status` (string) status of execution, `running` / `succeeded` / `failed` / `stopped`- - `outputs` (json) Optional content of output- - `error` (string) Optional reason of error- - `elapsed_time` (float) Optional total seconds to be used- - `total_tokens` (int) Optional tokens to be used- - `total_steps` (int) default 0- - `created_at` (timestamp) start time- - `finished_at` (timestamp) end time-- ### ChunkCompletionResponse- Returns the stream chunks outputted by the App, `Content-Type` is `text/event-stream`.- Each streaming chunk starts with `data:`, separated by two newline characters `\n\n`, as shown below:- <CodeGroup>- ```streaming {{ title: 'Response' }}- data: {"event": "text_chunk", "workflow_run_id": "b85e5fc5-751b-454d-b14e-dc5f240b0a31", "task_id": "bd029338-b068-4d34-a331-fc85478922c2", "data": {"text": "\u4e3a\u4e86", "from_variable_selector": ["1745912968134", "text"]}}\n\n- ```- </CodeGroup>- The structure of the streaming chunks varies depending on the `event`:- - `event: workflow_started` workflow starts execution- - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API- - `workflow_run_id` (string) Unique ID of workflow execution- - `event` (string) fixed to `workflow_started`- - `data` (object) detail- - `id` (string) Unique ID of workflow execution- - `workflow_id` (string) ID of related workflow- - `created_at` (timestamp) Creation timestamp, e.g., 1705395332- - `event: node_started` node execution started- - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API- - `workflow_run_id` (string) Unique ID of workflow execution- - `event` (string) fixed to `node_started`- - `data` (object) detail- - `id` (string) Unique ID of workflow execution- - `node_id` (string) ID of node- - `node_type` (string) type of node- - `title` (string) name of node- - `index` (int) Execution sequence number, used to display Tracing Node sequence- - `predecessor_node_id` (string) optional Prefix node ID, used for canvas display execution path- - `inputs` (object) Contents of all preceding node variables used in the node- - `created_at` (timestamp) timestamp of start, e.g., 1705395332- - `event: text_chunk` Text fragment- - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API- - `workflow_run_id` (string) Unique ID of workflow execution- - `event` (string) fixed to `text_chunk`- - `data` (object) detail- - `text` (string) Text content- - `from_variable_selector` (array) Text source path, helping developers understand which node and variable generated the text- - `event: node_finished` node execution ends, success or failure in different states in the same event- - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API- - `workflow_run_id` (string) Unique ID of workflow execution- - `event` (string) fixed to `node_finished`- - `data` (object) detail- - `id` (string) Unique ID of workflow execution- - `node_id` (string) ID of node- - `node_type` (string) type of node- - `title` (string) name of node- - `index` (int) Execution sequence number, used to display Tracing Node sequence- - `predecessor_node_id` (string) optional Prefix node ID, used for canvas display execution path- - `inputs` (object) Contents of all preceding node variables used in the node- - `process_data` (json) Optional node process data- - `outputs` (json) Optional content of output- - `status` (string) status of execution, `running` / `succeeded` / `failed` / `stopped`- - `error` (string) Optional reason of error- - `elapsed_time` (float) Optional total seconds to be used- - `execution_metadata` (json) meta data- - `total_tokens` (int) optional tokens to be used- - `total_price` (decimal) optional Total cost- - `currency` (string) optional e.g. `USD` / `RMB`- - `created_at` (timestamp) timestamp of start, e.g., 1705395332- - `event: human_input_required` Workflow paused and requires Human-in-the-Loop input- - `task_id` (string) Task ID, used for request tracking- - `workflow_run_id` (string) Unique ID of workflow execution- - `event` (string) fixed to `human_input_required`- - `data` (object) detail- - `form_id` (string) Human input form ID- - `node_id` (string) Human input node ID- - `node_title` (string) Human input node title- - `form_content` (string) Rendered form content- - `inputs` (array[object]) Input field definitions- - `actions` (array[object]) User action buttons- - `id` (string) Action ID- - `title` (string) Button text- - `button_style` (string) Button style- - `display_in_ui` (bool) Whether this form should be shown in UI- - `form_token` (string) Token used by `/form/human_input/:form_token` APIs- - `resolved_default_values` (object) Runtime-resolved default values- - `expiration_time` (timestamp) Form expiration time (Unix seconds)- - `event: workflow_finished` workflow execution ends, success or failure in different states in the same event- - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API- - `workflow_run_id` (string) Unique ID of workflow execution- - `event` (string) fixed to `workflow_finished`- - `data` (object) detail- - `id` (string) ID of workflow execution- - `workflow_id` (string) ID of related workflow- - `status` (string) status of execution, `running` / `succeeded` / `failed` / `stopped`- - `outputs` (json) Optional content of output- - `error` (string) Optional reason of error- - `elapsed_time` (float) Optional total seconds to be used- - `total_tokens` (int) Optional tokens to be used- - `total_steps` (int) default 0- - `created_at` (timestamp) start time- - `finished_at` (timestamp) end time- - `event: tts_message` TTS audio stream event, that is, speech synthesis output. The content is an audio block in Mp3 format, encoded as a base64 string. When playing, simply decode the base64 and feed it into the player. (This message is available only when auto-play is enabled)- - `task_id` (string) Task ID, used for request tracking and the stop response interface below- - `message_id` (string) Unique message ID- - `audio` (string) The audio after speech synthesis, encoded in base64 text content, when playing, simply decode the base64 and feed it into the player- - `created_at` (int) Creation timestamp, e.g.: 1705395332- - `event: tts_message_end` TTS audio stream end event, receiving this event indicates the end of the audio stream.- - `task_id` (string) Task ID, used for request tracking and the stop response interface below- - `message_id` (string) Unique message ID- - `audio` (string) The end event has no audio, so this is an empty string- - `created_at` (int) Creation timestamp, e.g.: 1705395332- - `event: ping` Ping event every 10 seconds to keep the connection alive.-- ### Errors- - 400, `invalid_param`, abnormal parameter input- - 400, `app_unavailable`, App configuration unavailable- - 400, `provider_not_initialize`, no available model credential configuration- - 400, `provider_quota_exceeded`, model invocation quota insufficient- - 400, `model_currently_not_support`, current model unavailable- - 400, `workflow_request_error`, workflow execution failed- - 500, internal server error-- </Col>- <Col sticky>- <CodeGroup- title="Request"- tag="POST"- label="/workflows/run"- targetCode={`curl -X POST '${props.appDetail.api_base_url}/workflows/run' \\---header 'Authorization: Bearer {api_key}' \\---header 'Content-Type: application/json' \\---data-raw '{- "inputs": ${JSON.stringify(props.inputs)},- "response_mode": "streaming",- "user": "abc-123"-}'`}- />- <CodeGroup title="Example: file array as an input variable">- ```json {{ title: 'File variable example' }}- {- "inputs": {- "{variable_name}":- [- {- "transfer_method": "local_file",- "upload_file_id": "{upload_file_id}",- "type": "{document_type}"- }- ]- }- }- ```- </CodeGroup>- ### Blocking Mode- Blocking mode can return either a completed workflow result or a paused workflow result.-- When execution pauses for Human-in-the-Loop, the response still includes `workflow_run_id` and `task_id`, but `data.status` becomes `paused`.- The paused payload also includes `paused_nodes` and `reasons`. For `human_input_required`, each reason contains the `form_id` and its `expiration_time`.-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "workflow_run_id": "djflajgkldjgd",- "task_id": "9da23599-e713-473b-982c-4328d4f5c78a",- "data": {- "id": "fdlsjfjejkghjda",- "workflow_id": "fldjaslkfjlsda",- "status": "succeeded",- "outputs": {- "text": "Nice to meet you."- },- "error": null,- "elapsed_time": 0.875,- "total_tokens": 3562,- "total_steps": 8,- "created_at": 1705407629,- "finished_at": 1727807631- }- }- ```- </CodeGroup>- <CodeGroup title="Paused Response Example">- ```json {{ title: 'Paused Response Example' }}- {- "task_id": "3938b985-f4c6-4806-87b6-215e0aca9d81",- "workflow_run_id": "4a80f375-682b-49c5-b199-e950aac4968f",- "data": {- "id": "4a80f375-682b-49c5-b199-e950aac4968f",- "workflow_id": "e46514f1-c008-41ff-94b0-4f33d4b97d36",- "status": "paused",- "outputs": {},- "error": null,- "elapsed_time": 0.035667,- "total_tokens": 0,- "total_steps": 2,- "created_at": 1776074783,- "finished_at": null,- "paused_nodes": [- "1775717346519"- ],- "reasons": [- {- "form_id": "019d864e-7a36-74a2-b94e-e5660c47f5a7",- "form_content": "this is form 1:\n{{#$output.some_field#}}\n",- "inputs": [- {- "type": "paragraph",- "output_variable_name": "some_field",- "default": {- "type": "variable",- "selector": [- "sys",- "workflow_run_id"- ],- "value": ""- }- }- ],- "actions": [- {- "id": "approve",- "title": "YES",- "button_style": "default"- },- {- "id": "reject",- "title": "NO",- "button_style": "default"- }- ],- "display_in_ui": true,- "node_id": "1775717346519",- "node_title": "Human Input",- "resolved_default_values": {- "some_field": "4a80f375-682b-49c5-b199-e950aac4968f"- },- "form_token": "SZwvfmL47fTIsZynP2Jr9i",- "type": "human_input_required",- "expiration_time": 1776333983- }- ]- }- }- ```- </CodeGroup>- ### Streaming Mode- <CodeGroup title="Response">- ```streaming {{ title: 'Response' }}- data: {"event": "workflow_started", "task_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "workflow_run_id": "5ad498-f0c7-4085-b384-88cbe6290", "data": {"id": "5ad498-f0c7-4085-b384-88cbe6290", "workflow_id": "dfjasklfjdslag", "created_at": 1679586595}}- data: {"event": "node_started", "task_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "workflow_run_id": "5ad498-f0c7-4085-b384-88cbe6290", "data": {"id": "5ad498-f0c7-4085-b384-88cbe6290", "node_id": "dfjasklfjdslag", "node_type": "start", "title": "Start", "index": 0, "predecessor_node_id": "fdljewklfklgejlglsd", "inputs": {}, "created_at": 1679586595}}- data: {"event": "node_finished", "task_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "workflow_run_id": "5ad498-f0c7-4085-b384-88cbe6290", "data": {"id": "5ad498-f0c7-4085-b384-88cbe6290", "node_id": "dfjasklfjdslag", "node_type": "start", "title": "Start", "index": 0, "predecessor_node_id": "fdljewklfklgejlglsd", "inputs": {}, "outputs": {}, "status": "succeeded", "elapsed_time": 0.324, "execution_metadata": {"total_tokens": 63127864, "total_price": 2.378, "currency": "USD"}, "created_at": 1679586595}}- data: {"event": "workflow_finished", "task_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "workflow_run_id": "5ad498-f0c7-4085-b384-88cbe6290", "data": {"id": "5ad498-f0c7-4085-b384-88cbe6290", "workflow_id": "dfjasklfjdslag", "outputs": {}, "status": "succeeded", "elapsed_time": 0.324, "total_tokens": 63127864, "total_steps": "1", "created_at": 1679586595, "finished_at": 1679976595}}- data: {"event": "tts_message", "conversation_id": "23dd85f3-1a41-4ea0-b7a9-062734ccfaf9", "message_id": "a8bdc41c-13b2-4c18-bfd9-054b9803038c", "created_at": 1721205487, "task_id": "3bf8a0bb-e73b-4690-9e66-4e429bad8ee7", "audio": "qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq"}- data: {"event": "tts_message_end", "conversation_id": "23dd85f3-1a41-4ea0-b7a9-062734ccfaf9", "message_id": "a8bdc41c-13b2-4c18-bfd9-054b9803038c", "created_at": 1721205487, "task_id": "3bf8a0bb-e73b-4690-9e66-4e429bad8ee7", "audio": ""}- ```- </CodeGroup>- Streaming mode can also pause for Human-in-the-Loop. In that case, the SSE stream emits `human_input_required` first and then `workflow_paused`.-- <CodeGroup title="Paused Streaming Response Example">- ```streaming {{ title: 'Paused Streaming Response Example' }}- event: ping-- data: {- "event": "workflow_started",- "workflow_run_id": "a4959eb4-c852-4e0c-ac7a-348233f7f345",- "task_id": "0399c5c2-181b-4493-a78e-1421914e8a25",- "data": {- "id": "a4959eb4-c852-4e0c-ac7a-348233f7f345",- "workflow_id": "e46514f1-c008-41ff-94b0-4f33d4b97d36",- "inputs": {- "sys.files": [],- "sys.user_id": "abc-123",- "sys.app_id": "d1074979-f67e-4114-8691-e35878df9a89",- "sys.workflow_id": "e46514f1-c008-41ff-94b0-4f33d4b97d36",- "sys.workflow_run_id": "a4959eb4-c852-4e0c-ac7a-348233f7f345"- },- "created_at": 1776129228,- "reason": "initial"- }- }-- data: {- "event": "node_started",- "workflow_run_id": "a4959eb4-c852-4e0c-ac7a-348233f7f345",- "task_id": "0399c5c2-181b-4493-a78e-1421914e8a25",- "data": {- "id": "7d9bb041-5ecb-497f-a674-d8706eed0ab1",- "node_id": "1775717266623",- "node_type": "start",- "title": "User Input",- "index": 1,- "predecessor_node_id": null,- "inputs": null,- "inputs_truncated": false,- "created_at": 1776129228,- "extras": {},- "iteration_id": null,- "loop_id": null,- "agent_strategy": null- }- }-- data: {- "event": "node_finished",- "workflow_run_id": "a4959eb4-c852-4e0c-ac7a-348233f7f345",- "task_id": "0399c5c2-181b-4493-a78e-1421914e8a25",- "data": {- "id": "7d9bb041-5ecb-497f-a674-d8706eed0ab1",- "node_id": "1775717266623",- "node_type": "start",- "title": "User Input",- "index": 1,- "predecessor_node_id": null,- "inputs": {- "sys.files": [],- "sys.user_id": "abc-123",- "sys.app_id": "d1074979-f67e-4114-8691-e35878df9a89",- "sys.workflow_id": "e46514f1-c008-41ff-94b0-4f33d4b97d36",- "sys.workflow_run_id": "a4959eb4-c852-4e0c-ac7a-348233f7f345",- "sys.timestamp": 1776129228- },- "inputs_truncated": false,- "process_data": {},- "process_data_truncated": false,- "outputs": {- "sys.files": [],- "sys.user_id": "abc-123",- "sys.app_id": "d1074979-f67e-4114-8691-e35878df9a89",- "sys.workflow_id": "e46514f1-c008-41ff-94b0-4f33d4b97d36",- "sys.workflow_run_id": "a4959eb4-c852-4e0c-ac7a-348233f7f345",- "sys.timestamp": 1776129228- },- "outputs_truncated": false,- "status": "succeeded",- "error": null,- "elapsed_time": 0.000097,- "execution_metadata": null,- "created_at": 1776129228,- "finished_at": 1776129228,- "files": [],- "iteration_id": null,- "loop_id": null- }- }-- data: {- "event": "node_started",- "workflow_run_id": "a4959eb4-c852-4e0c-ac7a-348233f7f345",- "task_id": "0399c5c2-181b-4493-a78e-1421914e8a25",- "data": {- "id": "c09ff568-1d55-4f0d-9a07-512bcbfeb289",- "node_id": "1775717346519",- "node_type": "human-input",- "title": "Human Input",- "index": 1,- "predecessor_node_id": null,- "inputs": null,- "inputs_truncated": false,- "created_at": 1776129228,- "extras": {},- "iteration_id": null,- "loop_id": null,- "agent_strategy": null- }- }-- data: {- "event": "human_input_required",- "workflow_run_id": "a4959eb4-c852-4e0c-ac7a-348233f7f345",- "task_id": "0399c5c2-181b-4493-a78e-1421914e8a25",- "data": {- "form_id": "019d898d-3d80-7105-b920-9899ead4ff3e",- "node_id": "1775717346519",- "node_title": "Human Input",- "form_content": "this is form 1:\n{{#$output.some_field#}}\n",- "inputs": [- {- "type": "paragraph",- "output_variable_name": "some_field",- "default": {- "type": "variable",- "selector": [- "sys",- "workflow_run_id"- ],- "value": ""- }- }- ],- "actions": [- {- "id": "approve",- "title": "YES",- "button_style": "default"- },- {- "id": "reject",- "title": "NO",- "button_style": "default"- }- ],- "display_in_ui": true,- "form_token": "0Tb1nXYe4hzQUD706nHB4y",- "resolved_default_values": {- "some_field": "a4959eb4-c852-4e0c-ac7a-348233f7f345"- },- "expiration_time": 1776388428- }- }-- data: {- "event": "workflow_paused",- "workflow_run_id": "a4959eb4-c852-4e0c-ac7a-348233f7f345",- "task_id": "0399c5c2-181b-4493-a78e-1421914e8a25",- "data": {- "workflow_run_id": "a4959eb4-c852-4e0c-ac7a-348233f7f345",- "paused_nodes": [- "1775717346519"- ],- "outputs": {},- "reasons": [- {- "form_id": "019d898d-3d80-7105-b920-9899ead4ff3e",- "form_content": "this is form 1:\n{{#$output.some_field#}}\n",- "inputs": [- {- "type": "paragraph",- "output_variable_name": "some_field",- "default": {- "type": "variable",- "selector": [- "sys",- "workflow_run_id"- ],- "value": ""- }- }- ],- "actions": [- {- "id": "approve",- "title": "YES",- "button_style": "default"- },- {- "id": "reject",- "title": "NO",- "button_style": "default"- }- ],- "display_in_ui": true,- "node_id": "1775717346519",- "node_title": "Human Input",- "resolved_default_values": {- "some_field": "a4959eb4-c852-4e0c-ac7a-348233f7f345"- },- "form_token": "0Tb1nXYe4hzQUD706nHB4y",- "type": "human_input_required",- "expiration_time": 1776388428- }- ],- "status": "paused",- "created_at": 1776129228,- "elapsed_time": 0.070478,- "total_tokens": 0,- "total_steps": 2- }- }- ```- </CodeGroup>- <CodeGroup title="File upload sample code">- ```json {{ title: 'File upload sample code' }}- import requests- import json-- def upload_file(file_path, user):- upload_url = "https://api.dify.ai/v1/files/upload"- headers = {- "Authorization": "Bearer app-xxxxxxxx",- }-- try:- print("Upload file...")- with open(file_path, 'rb') as file:- files = {- 'file': (file_path, file, 'text/plain') # Make sure the file is uploaded with the appropriate MIME type- }- data = {- "user": user,- "type": "TXT" # Set the file type to TXT- }-- response = requests.post(upload_url, headers=headers, files=files, data=data)- if response.status_code == 201: # 201 means creation is successful- print("File uploaded successfully")- return response.json().get("id") # Get the uploaded file ID- else:- print(f"File upload failed, status code: {response.status_code}")- return None- except Exception as e:- print(f"Error occurred: {str(e)}")- return None-- def run_workflow(file_id, user, response_mode="blocking"):- workflow_url = "https://api.dify.ai/v1/workflows/run"- headers = {- "Authorization": "Bearer app-xxxxxxxxx",- "Content-Type": "application/json"- }-- data = {- "inputs": {- "orig_mail": [{- "transfer_method": "local_file",- "upload_file_id": file_id,- "type": "document"- }]- },- "response_mode": response_mode,- "user": user- }-- try:- print("Run Workflow...")- response = requests.post(workflow_url, headers=headers, json=data)- if response.status_code == 200:- print("Workflow execution successful")- return response.json()- else:- print(f"Workflow execution failed, status code: {response.status_code}")- return {"status": "error", "message": f"Failed to execute workflow, status code: {response.status_code}"}- except Exception as e:- print(f"Error occurred: {str(e)}")- return {"status": "error", "message": str(e)}-- # Usage Examples- file_path = "{your_file_path}"- user = "difyuser"-- # Upload files- file_id = upload_file(file_path, user)- if file_id:- # The file was uploaded successfully, and the workflow continues to run- result = run_workflow(file_id, user)- print(result)- else:- print("File upload failed and workflow cannot be executed")- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/workflows/:workflow_id/run'- method='POST'- title='Execute Specific Workflow'- name='#Execute-Specific-Workflow'- titleAction={<WorkflowVersionApiUpgradeNotice />}-/>-<WorkflowVersionApiContent>-<Row>- <Col>- Execute a specific version of workflow by specifying the workflow ID in the path parameter.-- ### Path- - `workflow_id` (string) Required Workflow ID to specify a specific version of workflow-- How to obtain: In the version history interface, click the copy icon on the right side of each version entry to copy the complete workflow ID. Each version entry contains a copyable ID field.-- ### Request Body- - `inputs` (object) Required- Allows the entry of various variable values defined by the App.- The `inputs` parameter contains multiple key/value pairs, with each key corresponding to a specific variable and each value being the specific value for that variable.- The workflow application requires at least one key/value pair to be inputted. The variable can be of File Array type.- File Array type variable is suitable for inputting files combined with text understanding and answering questions, available only when the model supports file parsing and understanding capability.- If the variable is of File Array type, the corresponding value should be a list whose elements contain following attributions:- - `type` (string) Supported type:- - `document` ('TXT', 'MD', 'MARKDOWN', 'PDF', 'HTML', 'XLSX', 'XLS', 'DOCX', 'CSV', 'EML', 'MSG', 'PPTX', 'PPT', 'XML', 'EPUB')- - `image` ('JPG', 'JPEG', 'PNG', 'GIF', 'WEBP', 'SVG')- - `audio` ('MP3', 'M4A', 'WAV', 'WEBM', 'AMR')- - `video` ('MP4', 'MOV', 'MPEG', 'MPGA')- - `custom` (Other file types)- - `transfer_method` (string) Transfer method, `remote_url` for image URL / `local_file` for file upload- - `url` (string) Image URL (when the transfer method is `remote_url`)- - `upload_file_id` (string) Uploaded file ID, which must be obtained by uploading through the File Upload API in advance (when the transfer method is `local_file`)-- - `response_mode` (string) Required- The mode of response return, supporting:- - `streaming` Streaming mode (recommended), implements a typewriter-like output through SSE ([Server-Sent Events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events)).- - `blocking` Blocking mode, returns result after execution is complete. (Requests may be interrupted if the process is long)- <i>Due to Cloudflare restrictions, the request will be interrupted without a return after 100 seconds.</i>- - `user` (string) Required- User identifier, used to define the identity of the end-user for retrieval and statistics.- Should be uniquely defined by the developer within the application.- <br/>- <i>The user identifier should be consistent with the user passed in the message sending interface. The Service API does not share conversations created by the WebApp.</i>- - `files` (array[object]) Optional- - `trace_id` (string) Optional- Trace ID. Used for integration with existing business trace components to achieve end-to-end distributed tracing. If not provided, the system will automatically generate a trace_id. Supports the following three ways to pass, in order of priority:- 1. Header: via HTTP Header `X-Trace-Id`, highest priority.- 2. Query parameter: via URL query parameter `trace_id`.- 3. Request Body: via request body field `trace_id` (i.e., this field).- - `trace_session_id` (string) Optional- Trace session ID for observability grouping. Tracing providers that support session grouping can use this value as the exported session identifier. It does not change conversation_id, workflow_run_id, trace_id, or span relationships. Supports the following three ways to pass, in order of priority:- 1. Header: via HTTP Header `X-Trace-Session-Id`, highest priority.- 2. Query parameter: via URL query parameter `trace_session_id`.- 3. Request Body: via request body field `trace_session_id` (i.e., this field).-- ### Response- When `response_mode` is `blocking`, return a CompletionResponse object.- When `response_mode` is `streaming`, return a ChunkCompletionResponse stream.-- ### CompletionResponse- Returns the App result, `Content-Type` is `application/json`.- - `workflow_run_id` (string) Unique ID of workflow execution- - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API- - `data` (object) detail of result- - `id` (string) ID of workflow execution- - `workflow_id` (string) ID of related workflow- - `status` (string) status of execution, `running` / `succeeded` / `failed` / `stopped`- - `outputs` (json) Optional content of output- - `error` (string) Optional reason of error- - `elapsed_time` (float) Optional total seconds to be used- - `total_tokens` (int) Optional tokens to be used- - `total_steps` (int) default 0- - `created_at` (timestamp) start time- - `finished_at` (timestamp) end time-- ### ChunkCompletionResponse- Returns the stream chunks outputted by the App, `Content-Type` is `text/event-stream`.- Each streaming chunk starts with `data:`, separated by two newline characters `\n\n`, as shown below:- <CodeGroup>- ```streaming {{ title: 'Response' }}- data: {"event": "text_chunk", "workflow_run_id": "b85e5fc5-751b-454d-b14e-dc5f240b0a31", "task_id": "bd029338-b068-4d34-a331-fc85478922c2", "data": {"text": "\u4e3a\u4e86", "from_variable_selector": ["1745912968134", "text"]}}\n\n- ```- </CodeGroup>- The structure of the streaming chunks varies depending on the `event`:- - `event: workflow_started` workflow starts execution- - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API- - `workflow_run_id` (string) Unique ID of workflow execution- - `event` (string) fixed to `workflow_started`- - `data` (object) detail- - `id` (string) Unique ID of workflow execution- - `workflow_id` (string) ID of related workflow- - `created_at` (timestamp) Creation timestamp, e.g., 1705395332- - `event: node_started` node execution started- - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API- - `workflow_run_id` (string) Unique ID of workflow execution- - `event` (string) fixed to `node_started`- - `data` (object) detail- - `id` (string) Unique ID of workflow execution- - `node_id` (string) ID of node- - `node_type` (string) type of node- - `title` (string) name of node- - `index` (int) Execution sequence number, used to display Tracing Node sequence- - `predecessor_node_id` (string) optional Prefix node ID, used for canvas display execution path- - `inputs` (object) Contents of all preceding node variables used in the node- - `created_at` (timestamp) timestamp of start, e.g., 1705395332- - `event: text_chunk` Text fragment- - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API- - `workflow_run_id` (string) Unique ID of workflow execution- - `event` (string) fixed to `text_chunk`- - `data` (object) detail- - `text` (string) Text content- - `from_variable_selector` (array) Text source path, helps developers understand which variable of which node the text is generated from- - `event: node_finished` node execution finished, success and failure are different states in the same event- - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API- - `workflow_run_id` (string) Unique ID of workflow execution- - `event` (string) fixed to `node_finished`- - `data` (object) detail- - `id` (string) Unique ID of node execution- - `node_id` (string) ID of node- - `index` (int) Execution sequence number, used to display Tracing Node sequence- - `predecessor_node_id` (string) optional Prefix node ID, used for canvas display execution path- - `inputs` (object) Contents of all preceding node variables used in the node- - `process_data` (json) Optional Process data of node- - `outputs` (json) Optional content of output- - `status` (string) status of execution `running` / `succeeded` / `failed` / `stopped`- - `error` (string) Optional reason of error- - `elapsed_time` (float) Optional total seconds to be used- - `execution_metadata` (json) metadata- - `total_tokens` (int) optional tokens to be used- - `total_price` (decimal) optional total cost- - `currency` (string) optional currency, such as `USD` / `RMB`- - `created_at` (timestamp) timestamp of start, e.g., 1705395332- - `event: human_input_required` Workflow paused and requires Human-in-the-Loop input- - `task_id` (string) Task ID, used for request tracking- - `workflow_run_id` (string) Unique ID of workflow execution- - `event` (string) fixed to `human_input_required`- - `data` (object) detail- - `form_id` (string) Human input form ID- - `node_id` (string) Human input node ID- - `node_title` (string) Human input node title- - `form_content` (string) Rendered form content- - `inputs` (array[object]) Input field definitions- - `actions` (array[object]) User action buttons- - `id` (string) Action ID- - `title` (string) Button text- - `button_style` (string) Button style- - `display_in_ui` (bool) Whether this form should be shown in UI- - `form_token` (string) Token used by `/form/human_input/:form_token` APIs- - `resolved_default_values` (object) Runtime-resolved default values- - `expiration_time` (timestamp) Form expiration time (Unix seconds)- - `event: workflow_finished` workflow execution finished, success and failure are different states in the same event- - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API- - `workflow_run_id` (string) Unique ID of workflow execution- - `event` (string) fixed to `workflow_finished`- - `data` (object) detail- - `id` (string) Unique ID of workflow execution- - `workflow_id` (string) ID of related workflow- - `status` (string) status of execution `running` / `succeeded` / `failed` / `stopped`- - `outputs` (json) Optional content of output- - `error` (string) Optional reason of error- - `elapsed_time` (float) Optional total seconds to be used- - `total_tokens` (int) Optional tokens to be used- - `total_steps` (int) default 0- - `created_at` (timestamp) start time- - `finished_at` (timestamp) end time- - `event: tts_message` TTS audio stream event, i.e., speech synthesis output. The content is an audio block in Mp3 format, encoded as a base64 string, which can be decoded directly when playing. (Only available when auto-play is enabled)- - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API- - `message_id` (string) Unique message ID- - `audio` (string) The audio block after speech synthesis is encoded as base64 text content, which can be directly base64 decoded and sent to the player when playing- - `created_at` (int) Creation timestamp, e.g., 1705395332- - `event: tts_message_end` TTS audio stream end event, receiving this event indicates the end of audio stream return.- - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API- - `message_id` (string) Unique message ID- - `audio` (string) The end event has no audio, so this is an empty string- - `created_at` (int) Creation timestamp, e.g., 1705395332- - `event: ping` Ping event every 10s to keep the connection alive.-- ### Errors- - 400, `invalid_param`, Invalid input parameters- - 400, `app_unavailable`, App configuration unavailable- - 400, `provider_not_initialize`, No available model credentials configured- - 400, `provider_quota_exceeded`, Insufficient model call quota- - 400, `model_currently_not_support`, Current model unavailable- - 400, `workflow_not_found`, Specified workflow version not found- - 400, `draft_workflow_error`, Cannot use draft workflow version- - 400, `workflow_id_format_error`, Workflow ID format error, UUID format required- - 400, `workflow_request_error`, Workflow execution failed- - 403, `workflow_version_execution_not_allowed`, Workflow version execution is not available on your current plan. Please upgrade to a paid plan.- - 500, Internal service error-- </Col>- <Col sticky>- <CodeGroup- title="Request"- tag="POST"- label="/workflows/:workflow_id/run"- targetCode={`curl -X POST '${props.appDetail.api_base_url}/workflows/{workflow_id}/run' \\---header 'Authorization: Bearer {api_key}' \\---header 'Content-Type: application/json' \\---data-raw '{- "inputs": ${JSON.stringify(props.inputs)},- "response_mode": "streaming",- "user": "abc-123"-}'`}- />- <CodeGroup title="Example: file array as an input variable">- ```json {{ title: 'File variable example' }}- {- "inputs": {- "{variable_name}":- [- {- "transfer_method": "local_file",- "upload_file_id": "{upload_file_id}",- "type": "{document_type}"- }- ]- }- }- ```- </CodeGroup>- ### Blocking Mode- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "workflow_run_id": "djflajgkldjgd",- "task_id": "9da23599-e713-473b-982c-4328d4f5c78a",- "data": {- "id": "fdlsjfjejkghjda",- "workflow_id": "fldjaslkfjlsda",- "status": "succeeded",- "outputs": {- "text": "Nice to meet you."- },- "error": null,- "elapsed_time": 0.875,- "total_tokens": 3562,- "total_steps": 8,- "created_at": 1705407629,- "finished_at": 1727807631- }- }- ```- </CodeGroup>- ### Streaming Mode- <CodeGroup title="Response">- ```streaming {{ title: 'Response' }}- data: {"event": "workflow_started", "task_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "workflow_run_id": "5ad498-f0c7-4085-b384-88cbe6290", "data": {"id": "5ad498-f0c7-4085-b384-88cbe6290", "workflow_id": "dfjasklfjdslag", "created_at": 1679586595}}- data: {"event": "node_started", "task_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "workflow_run_id": "5ad498-f0c7-4085-b384-88cbe6290", "data": {"id": "5ad498-f0c7-4085-b384-88cbe6290", "node_id": "dfjasklfjdslag", "node_type": "start", "title": "Start", "index": 0, "predecessor_node_id": "fdljewklfklgejlglsd", "inputs": {}, "created_at": 1679586595}}- data: {"event": "node_finished", "task_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "workflow_run_id": "5ad498-f0c7-4085-b384-88cbe6290", "data": {"id": "5ad498-f0c7-4085-b384-88cbe6290", "node_id": "dfjasklfjdslag", "node_type": "start", "title": "Start", "index": 0, "predecessor_node_id": "fdljewklfklgejlglsd", "inputs": {}, "outputs": {}, "status": "succeeded", "elapsed_time": 0.324, "execution_metadata": {"total_tokens": 63127864, "total_price": 2.378, "currency": "USD"}, "created_at": 1679586595}}- data: {"event": "workflow_finished", "task_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "workflow_run_id": "5ad498-f0c7-4085-b384-88cbe6290", "data": {"id": "5ad498-f0c7-4085-b384-88cbe6290", "workflow_id": "dfjasklfjdslag", "outputs": {}, "status": "succeeded", "elapsed_time": 0.324, "total_tokens": 63127864, "total_steps": "1", "created_at": 1679586595, "finished_at": 1679976595}}- data: {"event": "tts_message", "conversation_id": "23dd85f3-1a41-4ea0-b7a9-062734ccfaf9", "message_id": "a8bdc41c-13b2-4c18-bfd9-054b9803038c", "created_at": 1721205487, "task_id": "3bf8a0bb-e73b-4690-9e66-4e429bad8ee7", "audio": "qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq"}- data: {"event": "tts_message_end", "conversation_id": "23dd85f3-1a41-4ea0-b7a9-062734ccfaf9", "message_id": "a8bdc41c-13b2-4c18-bfd9-054b9803038c", "created_at": 1721205487, "task_id": "3bf8a0bb-e73b-4690-9e66-4e429bad8ee7", "audio": ""}- ```- </CodeGroup>- </Col>-</Row>-</WorkflowVersionApiContent>-------<Heading- url='/workflows/run/:workflow_run_id'- method='GET'- title='Get Workflow Run Detail'- name='#get-workflow-run-detail'-/>-<Row>- <Col>- Retrieve the current execution results of a workflow task based on the workflow execution ID.- ### Path- - `workflow_run_id` (string) Workflow run ID, can be obtained from the streaming chunk return- ### Response- - `id` (string) ID of workflow execution- - `workflow_id` (string) ID of related workflow- - `status` (string) status of execution, `running` / `succeeded` / `failed` / `stopped`- - `inputs` (json) content of input- - `outputs` (json) content of output- - `error` (string) reason of error- - `total_steps` (int) total steps of task- - `total_tokens` (int) total tokens to be used- - `created_at` (timestamp) start time- - `finished_at` (timestamp) end time- - `elapsed_time` (float) total seconds to be used- </Col>- <Col sticky>- ### Request Example- <CodeGroup- title="Request"- tag="GET"- label="/workflows/run/:workflow_run_id"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/workflows/run/:workflow_run_id' \\--H 'Authorization: Bearer {api_key}' \\--H 'Content-Type: application/json'`}- />-- ### Response Example- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "id": "b1ad3277-089e-42c6-9dff-6820d94fbc76",- "workflow_id": "19eff89f-ec03-4f75-b0fc-897e7effea02",- "status": "succeeded",- "inputs": "{\"sys.files\": [], \"sys.user_id\": \"abc-123\"}",- "outputs": null,- "error": null,- "total_steps": 3,- "total_tokens": 0,- "created_at": 1705407629,- "finished_at": 1727807631,- "elapsed_time": 30.098514399956912- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/workflows/tasks/:task_id/stop'- method='POST'- title='Stop Generate'- name='#stop-generatebacks'-/>-<Row>- <Col>- Only supported in streaming mode.- ### Path- - `task_id` (string) Task ID, can be obtained from the streaming chunk return- ### Request Body- - `user` (string) Required- User identifier, used to define the identity of the end-user, must be consistent with the user passed in the message sending interface. The Service API does not share conversations created by the WebApp.- ### Response- - `result` (string) Always returns "success"- </Col>- <Col sticky>- ### Request Example- <CodeGroup- title="Request"- tag="POST"- label="/workflows/tasks/:task_id/stop"- targetCode={`curl -X POST '${props.appDetail.api_base_url}/workflows/tasks/:task_id/stop' \\--H 'Authorization: Bearer {api_key}' \\--H 'Content-Type: application/json' \\---data-raw '{"user": "abc-123"}'`}- />-- ### Response Example- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "result": "success"- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/form/human_input/:form_token'- method='GET'- title='Get Human Input Form'- name='#get-human-input-form'-/>-<Row>- <Col>- Retrieve a pending Human-in-the-Loop form by `form_token`.-- Use this endpoint when a workflow pauses with `human_input_required` and returns a `form_token`.-- ### Path- - `form_token` (string) Required, token returned by the pause event.-- ### Response- - `form_content` (string) Rendered form content (markdown/plain text)- - `inputs` (array[object]) Form input definitions- - `resolved_default_values` (object) Default values resolved to strings- - `user_actions` (array[object]) Action buttons- - `expiration_time` (timestamp) Form expiration time (Unix seconds)-- ### Errors- - 404, form not found or does not belong to current app- - 412, `human_input_form_submitted`, form already submitted- - 412, `human_input_form_expired`, form expired- </Col>- <Col sticky>- <CodeGroup- title="Request"- tag="GET"- label="/form/human_input/:form_token"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/form/human_input/{form_token}' \\---header 'Authorization: Bearer {api_key}'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "form_content": "Please confirm the final answer: {{#$output.answer#}}",- "inputs": [- {- "label": "Answer",- "type": "text-input",- "required": true,- "output_variable_name": "answer"- }- ],- "resolved_default_values": {- "answer": "Initial value"- },- "user_actions": [- { "id": "approve", "title": "Approve", "button_style": "primary" },- { "id": "reject", "title": "Reject", "button_style": "warning" }- ],- "expiration_time": 1735689600- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/form/human_input/:form_token'- method='POST'- title='Submit Human Input Form'- name='#submit-human-input-form'-/>-<Row>- <Col>- Submit a pending Human-in-the-Loop form.-- ### Path- - `form_token` (string) Required, token returned by the pause event.-- ### Request Body- - `inputs` (object) Required, key/value pairs for form fields.- - `action` (string) Required, selected action ID from `user_actions`.- - `user` (string) Required, end-user identifier.-- ### Response- Returns an empty object on success.-- ### Errors- - 400, `invalid_form_data`, submitted data does not match the form schema- - 404, form not found or does not belong to current app- - 412, `human_input_form_submitted`, form already submitted- - 412, `human_input_form_expired`, form expired- </Col>- <Col sticky>- <CodeGroup- title="Request"- tag="POST"- label="/form/human_input/:form_token"- targetCode={`curl -X POST '${props.appDetail.api_base_url}/form/human_input/{form_token}' \\---header 'Authorization: Bearer {api_key}' \\---header 'Content-Type: application/json' \\---data-raw '{- "inputs": {"answer": "Approved answer"},- "action": "approve",- "user": "abc-123"-}'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {}- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/workflow/:task_id/events'- method='GET'- title='Get Workflow Resume Events'- name='#get-workflow-resume-events'-/>-<Row>- <Col>- Continue receiving workflow events after submitting a human input form.-- This endpoint returns `text/event-stream` and can be used to observe the resumed run until completion.-- ### Path- - `task_id` (string) Required, workflow run ID (`workflow_run_id`).-- ### Query- - `user` (string) Required, end-user identifier.- - `include_state_snapshot` (bool) Optional, set to `true` to replay from persisted state snapshot before continuing with live events.- - `continue_on_pause` (bool) Optional, set to `true` to keep the stream open across `workflow_paused` events until `workflow_finished`.-- ### Response- Server-Sent Events stream (`text/event-stream`).- Typical events include `workflow_paused`, `node_started`, `node_finished`, `human_input_form_filled`, `human_input_form_timeout`, and `workflow_finished`.- If the workflow has already finished when you call this endpoint, the server returns a single finished event immediately.- </Col>- <Col sticky>- <CodeGroup- title="Request"- tag="GET"- label="/workflow/:task_id/events"- targetCode={`curl -N -X GET '${props.appDetail.api_base_url}/workflow/{workflow_run_id}/events?user=abc-123&continue_on_pause=true' \\---header 'Authorization: Bearer {api_key}'`}- />-- <CodeGroup title="Response">- ```streaming {{ title: 'Response' }}- event: ping-- data: {"event":"workflow_started","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","data":{"id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","workflow_id":"e46514f1-c008-41ff-94b0-4f33d4b97d36","inputs":{"sys.files":[],"sys.user_id":"abc-123","sys.app_id":"d1074979-f67e-4114-8691-e35878df9a89","sys.workflow_id":"e46514f1-c008-41ff-94b0-4f33d4b97d36","sys.workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","sys.timestamp":1776087863},"created_at":1776087863,"reason":"initial"}}-- data: {"event":"node_started","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","data":{"id":"b552d685-1119-4e6a-9a81-e91a23e5324b","node_id":"1775717266623","node_type":"start","title":"User Input","index":1,"predecessor_node_id":null,"inputs":null,"created_at":1776087863,"extras":{},"iteration_id":null,"loop_id":null}}-- data: {"event":"node_finished","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","data":{"id":"b552d685-1119-4e6a-9a81-e91a23e5324b","node_id":"1775717266623","node_type":"start","title":"User Input","index":1,"predecessor_node_id":null,"inputs":null,"process_data":null,"outputs":null,"status":"succeeded","error":null,"elapsed_time":0.00032,"execution_metadata":null,"created_at":1776087863,"finished_at":1776087863,"files":[],"iteration_id":null,"loop_id":null}}-- data: {"event":"node_started","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","data":{"id":"8d7e8e01-5159-4089-a4b6-3aa394992cc2","node_id":"1775717346519","node_type":"human-input","title":"Human Input","index":2,"predecessor_node_id":null,"inputs":null,"created_at":1776087863,"extras":{},"iteration_id":null,"loop_id":null}}-- data: {"event":"node_finished","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","data":{"id":"8d7e8e01-5159-4089-a4b6-3aa394992cc2","node_id":"1775717346519","node_type":"human-input","title":"Human Input","index":2,"predecessor_node_id":null,"inputs":null,"process_data":null,"outputs":null,"status":"paused","error":null,"elapsed_time":0.007381,"execution_metadata":null,"created_at":1776087863,"finished_at":1776087863,"files":[],"iteration_id":null,"loop_id":null}}-- data: {"event":"workflow_paused","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","data":{"workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","paused_nodes":["1775717346519"],"outputs":{},"reasons":[{"form_id":"019d8716-0fde-75da-8207-1458ccde76e5","form_content":"this is form 1:\n{{#$output.some_field#}}\n","inputs":[{"type":"paragraph","output_variable_name":"some_field","default":{"type":"variable","selector":["sys","workflow_run_id"],"value":""}}],"actions":[{"id":"approve","title":"YES","button_style":"default"},{"id":"reject","title":"NO","button_style":"default"}],"display_in_ui":true,"node_id":"1775717346519","node_title":"Human Input","resolved_default_values":{"some_field":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c"},"form_token":"n7hFG4ZDYdGcgZ5VDc7EGM","type":"human_input_required"}],"status":"paused","created_at":1776087863,"elapsed_time":0.0,"total_tokens":0,"total_steps":2}}-- data: {"event":"workflow_started","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","data":{"id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","workflow_id":"e46514f1-c008-41ff-94b0-4f33d4b97d36","inputs":{"sys.files":[],"sys.user_id":"abc-123","sys.app_id":"d1074979-f67e-4114-8691-e35878df9a89","sys.workflow_id":"e46514f1-c008-41ff-94b0-4f33d4b97d36","sys.workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c"},"created_at":1776087877,"reason":"resumption"}}-- data: {"event":"node_started","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","data":{"id":"8d7e8e01-5159-4089-a4b6-3aa394992cc2","node_id":"1775717346519","node_type":"human-input","title":"Human Input","index":1,"predecessor_node_id":null,"inputs":null,"inputs_truncated":false,"created_at":1776087877,"extras":{},"iteration_id":null,"loop_id":null,"agent_strategy":null}}-- data: {"event":"human_input_form_filled","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","data":{"node_id":"1775717346519","node_title":"Human Input","rendered_content":"this is form 1:\nfield 1 filled!\n","action_id":"approve","action_text":"YES"}}-- data: {"event":"node_finished","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","data":{"id":"8d7e8e01-5159-4089-a4b6-3aa394992cc2","node_id":"1775717346519","node_type":"human-input","title":"Human Input","index":1,"predecessor_node_id":null,"inputs":{},"inputs_truncated":false,"process_data":{},"process_data_truncated":false,"outputs":{"some_field":"field 1 filled!","some_field_2":"from bruno with love","__action_id":"approve","__rendered_content":"this is form 1:\nfield 1 filled!\n"},"outputs_truncated":false,"status":"succeeded","error":null,"elapsed_time":0.004431,"execution_metadata":null,"created_at":1776087877,"finished_at":1776087877,"files":[],"iteration_id":null,"loop_id":null}}-- data: {"event":"node_started","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","data":{"id":"6d8fc3cb-19f7-440b-b83e-eed4e847a332","node_id":"1775717350710","node_type":"template-transform","title":"Template","index":1,"predecessor_node_id":null,"inputs":null,"inputs_truncated":false,"created_at":1776087877,"extras":{},"iteration_id":null,"loop_id":null,"agent_strategy":null}}-- data: {"event":"text_chunk","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","data":{"text":"field 1 filled!","from_variable_selector":["1775717350710","output"]}}-- data: {"event":"node_finished","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","data":{"id":"6d8fc3cb-19f7-440b-b83e-eed4e847a332","node_id":"1775717350710","node_type":"template-transform","title":"Template","index":1,"predecessor_node_id":null,"inputs":{"some_field":"field 1 filled!"},"inputs_truncated":false,"process_data":{},"process_data_truncated":false,"outputs":{"output":"field 1 filled!"},"outputs_truncated":false,"status":"succeeded","error":null,"elapsed_time":0.264614,"execution_metadata":null,"created_at":1776087877,"finished_at":1776087877,"files":[],"iteration_id":null,"loop_id":null}}-- data: {"event":"node_started","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","data":{"id":"e88dec7e-aa2c-41f7-8d73-032b749e23f5","node_id":"1775717354177","node_type":"end","title":"Output","index":1,"predecessor_node_id":null,"inputs":null,"inputs_truncated":false,"created_at":1776087877,"extras":{},"iteration_id":null,"loop_id":null,"agent_strategy":null}}-- data: {"event":"node_finished","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","data":{"id":"e88dec7e-aa2c-41f7-8d73-032b749e23f5","node_id":"1775717354177","node_type":"end","title":"Output","index":1,"predecessor_node_id":null,"inputs":{"output":"field 1 filled!"},"inputs_truncated":false,"process_data":{},"process_data_truncated":false,"outputs":{"output":"field 1 filled!"},"outputs_truncated":false,"status":"succeeded","error":null,"elapsed_time":0.00003,"execution_metadata":null,"created_at":1776087877,"finished_at":1776087877,"files":[],"iteration_id":null,"loop_id":null}}-- data: {"event":"workflow_finished","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","data":{"id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","workflow_id":"e46514f1-c008-41ff-94b0-4f33d4b97d36","status":"succeeded","outputs":{"output":"field 1 filled!"},"error":null,"elapsed_time":0.364935,"total_tokens":0,"total_steps":5,"created_by":{"id":"7932d34c-dcf4-4fba-b770-f2a9de88c0a0","user":"abc-123"},"created_at":1776087877,"finished_at":1776087877,"exceptions_count":0,"files":[]}}- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/files/upload'- method='POST'- title='File Upload'- name='#file-upload'-/>-<Row>- <Col>- Upload a file for use when sending messages, enabling multimodal understanding of images and text.- Supports any formats that are supported by your workflow.- Uploaded files are for use by the current end-user only.-- ### Request Body- This interface requires a `multipart/form-data` request.- - `file` (File) Required- The file to be uploaded.- - `user` (string) Required- User identifier, defined by the developer's rules, must be unique within the application. The Service API does not share conversations created by the WebApp.-- ### Response- After a successful upload, the server will return the file's ID and related information.- - `id` (uuid) ID- - `name` (string) File name- - `size` (int) File size (bytes)- - `extension` (string) File extension- - `mime_type` (string) File mime-type- - `created_by` (uuid) End-user ID- - `created_at` (timestamp) Creation timestamp, e.g., 1705395332-- ### Errors- - 400, `no_file_uploaded`, a file must be provided- - 400, `too_many_files`, currently only one file is accepted- - 400, `unsupported_preview`, the file does not support preview- - 400, `unsupported_estimate`, the file does not support estimation- - 413, `file_too_large`, the file is too large- - 415, `unsupported_file_type`, unsupported extension, currently only document files are accepted- - 503, `s3_connection_failed`, unable to connect to S3 service- - 503, `s3_permission_denied`, no permission to upload files to S3- - 503, `s3_file_too_large`, file exceeds S3 size limit- - 500, internal server error--- </Col>- <Col sticky>- ### Request Example- <CodeGroup- title="Request"- tag="POST"- label="/files/upload"- targetCode={`curl -X POST '${props.appDetail.api_base_url}/files/upload' \\---header 'Authorization: Bearer {api_key}' \\---form 'file=@localfile;type=image/[png|jpeg|jpg|webp|gif]' \\---form 'user=abc-123'`}- />-- ### Response Example- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "id": "72fa9618-8f89-4a37-9b33-7e1178a24a67",- "name": "example.png",- "size": 1024,- "extension": "png",- "mime_type": "image/png",- "created_by": "6ad1ab0a-73ff-4ac1-b9e4-cdb312f71f13",- "created_at": 1577836800,- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/end-users/:end_user_id'- method='GET'- title='Get End User'- name='#end-user'-/>-<Row>- <Col>- Retrieve an end user by ID.-- This is useful when other APIs return an end-user ID (e.g. `created_by` from File Upload).-- ### Path Parameters- - `end_user_id` (uuid) Required- End user ID.-- ### Response- Returns an EndUser object.- - `id` (uuid) ID- - `tenant_id` (uuid) Tenant ID- - `app_id` (uuid) App ID- - `type` (string) End user type- - `external_user_id` (string) External user ID- - `name` (string) Name- - `is_anonymous` (boolean) Whether anonymous- - `session_id` (string) Session ID- - `created_at` (string) ISO 8601 datetime- - `updated_at` (string) ISO 8601 datetime-- ### Errors- - 404, `end_user_not_found`, end user not found- - 500, internal server error-- </Col>- <Col sticky>- ### Request Example- <CodeGroup- title="Request"- tag="GET"- label="/end-users/:end_user_id"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/end-users/6ad1ab0a-73ff-4ac1-b9e4-cdb312f71f13' \\---header 'Authorization: Bearer {api_key}'`}- />-- ### Response Example- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "id": "6ad1ab0a-73ff-4ac1-b9e4-cdb312f71f13",- "tenant_id": "8c0f3f3a-66b0-4b55-a0bf-8b8e0d6aee7d",- "app_id": "6c8c3f41-2c6f-4e1b-8f4f-7f11c8f2ad2a",- "type": "service_api",- "external_user_id": "abc-123",- "name": "Alice",- "is_anonymous": false,- "session_id": "abc-123",- "created_at": "2024-01-01T00:00:00Z",- "updated_at": "2024-01-01T00:00:00Z"- }- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/workflows/logs'- method='GET'- title='Get Workflow Logs'- name='#Get-Workflow-Logs'-/>-<Row>- <Col>- Returns workflow logs, with the first page returning the latest `{limit}` messages, i.e., in reverse order.-- ### Query-- <Properties>- <Property name='keyword' type='string' key='keyword'>- Keyword to search- </Property>- <Property name='status' type='string' key='status'>- succeeded/failed/stopped- </Property>- <Property name='page' type='int' key='page'>- current page, default is 1.- </Property>- <Property name='limit' type='int' key='limit'>- How many chat history messages to return in one request, default is 20.- </Property>- <Property name='created_by_end_user_session_id' type='str' key='created_by_end_user_session_id'>- Created by which endUser, for example, `abc-123`.- </Property>- <Property name='created_by_account' type='str' key='created_by_account'>- Created by which email account, for example, [email protected].- </Property>- </Properties>-- ### Response- - `page` (int) Current page- - `limit` (int) Number of returned items, if input exceeds system limit, returns system limit amount- - `total` (int) Number of total items- - `has_more` (bool) Whether there is a next page- - `data` (array[object]) Log list- - `id` (string) ID- - `workflow_run` (object) Workflow run- - `id` (string) ID- - `version` (string) Version- - `status` (string) status of execution, `running` / `succeeded` / `failed` / `stopped`- - `error` (string) Optional reason of error- - `elapsed_time` (float) total seconds to be used- - `total_tokens` (int) tokens to be used- - `total_steps` (int) default 0- - `created_at` (timestamp) start time- - `finished_at` (timestamp) end time- - `created_from` (string) Created from- - `created_by_role` (string) Created by role- - `created_by_account` (string) Optional Created by account- - `created_by_end_user` (object) Created by end user- - `id` (string) ID- - `type` (string) Type- - `is_anonymous` (bool) Is anonymous- - `session_id` (string) Session ID- - `created_at` (timestamp) create time- </Col>- <Col sticky>-- <CodeGroup- title="Request"- tag="GET"- label="/workflows/logs"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/workflows/logs'\\---header 'Authorization: Bearer {api_key}'`}- />- ### Response Example- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "page": 1,- "limit": 1,- "total": 7,- "has_more": true,- "data": [- {- "id": "e41b93f1-7ca2-40fd-b3a8-999aeb499cc0",- "workflow_run": {- "id": "c0640fc8-03ef-4481-a96c-8a13b732a36e",- "version": "2024-08-01 12:17:09.771832",- "status": "succeeded",- "error": null,- "elapsed_time": 1.3588523610014818,- "total_tokens": 0,- "total_steps": 3,- "created_at": 1726139643,- "finished_at": 1726139644- },- "created_from": "service-api",- "created_by_role": "end_user",- "created_by_account": null,- "created_by_end_user": {- "id": "7f7d9117-dd9d-441d-8970-87e5e7e687a3",- "type": "service_api",- "is_anonymous": false,- "session_id": "abc-123"- },- "created_at": 1726139644- }- ]- }- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/info'- method='GET'- title='Get Application Basic Information'- name='#info'-/>-<Row>- <Col>- Used to get basic information about this application-- ### Response- - `name` (string) application name- - `description` (string) application description- - `tags` (array[string]) application tags- - `mode` (string) application mode- - `author_name` (string) application author name- </Col>- <Col>- <CodeGroup- title="Request"- tag="GET"- label="/info"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/info' \\--H 'Authorization: Bearer {api_key}'`}- />- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "name": "My App",- "description": "This is my app.",- "tags": [- "tag1",- "tag2"- ],- "mode": "workflow",- "author_name": "Dify"- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/parameters'- method='GET'- title='Get Application Parameters Information'- name='#parameters'-/>-<Row>- <Col>- Used at the start of entering the page to obtain information such as features, input parameter names, types, and default values.-- ### Response- - `user_input_form` (array[object]) User input form configuration- - `text-input` (object) Text input control- - `label` (string) Variable display label name- - `variable` (string) Variable ID- - `required` (bool) Whether it is required- - `default` (string) Default value- - `paragraph` (object) Paragraph text input control- - `label` (string) Variable display label name- - `variable` (string) Variable ID- - `required` (bool) Whether it is required- - `default` (string) Default value- - `select` (object) Dropdown control- - `label` (string) Variable display label name- - `variable` (string) Variable ID- - `required` (bool) Whether it is required- - `default` (string) Default value- - `options` (array[string]) Option values- - `file_upload` (object) File upload configuration- - `document` (object) Document settings- Currently only supports document types: `txt`, `md`, `markdown`, `pdf`, `html`, `xlsx`, `xls`, `docx`, `csv`, `eml`, `msg`, `pptx`, `ppt`, `xml`, `epub`.- - `enabled` (bool) Whether it is enabled- - `number_limits` (int) Document number limit, default is 3- - `transfer_methods` (array[string]) List of transfer methods: `remote_url`, `local_file`. Must choose one.- - `image` (object) Image settings- Currently only supports image types: `png`, `jpg`, `jpeg`, `webp`, `gif`.- - `enabled` (bool) Whether it is enabled- - `number_limits` (int) Image number limit, default is 3- - `transfer_methods` (array[string]) List of transfer methods: `remote_url`, `local_file`. Must choose one.- - `audio` (object) Audio settings- Currently only supports audio types: `mp3`, `m4a`, `wav`, `webm`, `amr`.- - `enabled` (bool) Whether it is enabled- - `number_limits` (int) Audio number limit, default is 3- - `transfer_methods` (array[string]) List of transfer methods: `remote_url`, `local_file`. Must choose one.- - `video` (object) Video settings- Currently only supports video types: `mp4`, `mov`, `mpeg`, `mpga`.- - `enabled` (bool) Whether it is enabled- - `number_limits` (int) Video number limit, default is 3- - `transfer_methods` (array[string]) List of transfer methods: `remote_url`, `local_file`. Must choose one.- - `custom` (object) Custom settings- - `enabled` (bool) Whether it is enabled- - `number_limits` (int) Custom number limit, default is 3- - `transfer_methods` (array[string]) List of transfer methods: `remote_url`, `local_file`. Must choose one.- - `system_parameters` (object) System parameters- - `file_size_limit` (int) Document upload size limit (MB)- - `image_file_size_limit` (int) Image file upload size limit (MB)- - `audio_file_size_limit` (int) Audio file upload size limit (MB)- - `video_file_size_limit` (int) Video file upload size limit (MB)-- </Col>- <Col sticky>-- <CodeGroup- title="Request"- tag="GET"- label="/parameters"- targetCode={` curl -X GET '${props.appDetail.api_base_url}/parameters'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "user_input_form": [- {- "paragraph": {- "label": "Query",- "variable": "query",- "required": true,- "default": ""- }- }- ],- "file_upload": {- "image": {- "enabled": false,- "number_limits": 3,- "detail": "high",- "transfer_methods": [- "remote_url",- "local_file"- ]- }- },- "system_parameters": {- "file_size_limit": 15,- "image_file_size_limit": 10,- "audio_file_size_limit": 50,- "video_file_size_limit": 100- }- }- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/site'- method='GET'- title='Get Application WebApp Settings'- name='#site'-/>-<Row>- <Col>- Used to get the WebApp settings of the application.- ### Response- - `title` (string) WebApp name- - `icon_type` (string) Icon type, `emoji` - emoji, `image` - picture- - `icon` (string) Icon. If it's `emoji` type, it's an emoji symbol; if it's `image` type, it's an image URL.- - `icon_background` (string) Background color in hex format- - `icon_url` (string) Icon URL- - `description` (string) Description- - `copyright` (string) Copyright information- - `privacy_policy` (string) Privacy policy link- - `custom_disclaimer` (string) Custom disclaimer- - `default_language` (string) Default language- - `show_workflow_steps` (bool) Whether to show workflow details- </Col>- <Col>- <CodeGroup- title="Request"- tag="GET"- label="/site"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/site' \\--H 'Authorization: Bearer {api_key}'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "title": "My App",- "icon_type": "emoji",- "icon": "😄",- "icon_background": "#FFEAD5",- "icon_url": null,- "description": "This is my app.",- "copyright": "all rights reserved",- "privacy_policy": "",- "custom_disclaimer": "All generated by AI",- "default_language": "en-US",- "show_workflow_steps": false,- }- ```- </CodeGroup>- </Col>-</Row>-___diff --git a/web/app/components/develop/template/template_workflow.ja.mdx b/web/app/components/develop/template/template_workflow.ja.mdxdeleted file mode 100644index 4b104aa862a..00000000000--- a/web/app/components/develop/template/template_workflow.ja.mdx+++ /dev/null@@ -1,1640 +0,0 @@-import { CodeGroup } from '../code.tsx'-import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx'-import { WorkflowVersionApiContent, WorkflowVersionApiUpgradeNotice } from '../workflow-version-api-upgrade-notice.tsx'--# ワークフローアプリ API--ワークフローアプリケーションは、セッションをサポートせず、翻訳、記事作成、要約 AI などに最適です。--<div>- ### ベース URL- <CodeGroup title="コード" targetCode={props.appDetail.api_base_url} />-- ### 認証-- サービス API は `API-Key` 認証を使用します。- <i>**API キーの漏洩を防ぐため、API キーはクライアント側で共有または保存せず、サーバー側で保存することを強くお勧めします。**</i>-- すべての API リクエストにおいて、以下のように `Authorization`HTTP ヘッダーに API キーを含めてください:-- <CodeGroup title="コード" targetCode='Authorization: Bearer {API_KEY}' />-</div>-------<Heading- url='/workflows/run'- method='POST'- title='ワークフローを実行'- name='#Execute-Workflow'-/>-<Row>- <Col>- ワークフローを実行します。公開されたワークフローがないと実行できません。-- ### リクエストボディ- - `inputs` (object) 必須- アプリで定義されたさまざまな変数値の入力を許可します。- `inputs`パラメータには複数のキー/値ペアが含まれ、各キーは特定の変数に対応し、各値はその変数の特定の値です。- ワークフローアプリケーションは少なくとも1つのキー/値ペアの入力を必要とします。値はファイルリストである場合もあります。- ファイルリストは、テキスト理解と質問への回答を組み合わせたファイルの入力に適しています。モデルがファイルの解析と理解機能をサポートしている場合にのみ使用できます。-- 変数がファイルリストの場合、リストの各要素は以下の属性を持つ必要があります。- - `type` (string) サポートされるタイプ:- - `document` サポートされるタイプには以下が含まれます:'TXT', 'MD', 'MARKDOWN', 'MDX', 'PDF', 'HTML', 'XLSX', 'XLS', 'VTT', 'PROPERTIES', 'DOC', 'DOCX', 'CSV', 'EML', 'MSG', 'PPTX', 'PPT', 'XML', 'EPUB'- - `image` サポートされるタイプには以下が含まれます:'JPG', 'JPEG', 'PNG', 'GIF', 'WEBP', 'SVG'- - `audio` サポートされるタイプには以下が含まれます:'MP3', 'M4A', 'WAV', 'WEBM', 'MPGA'- - `video` サポートされるタイプには以下が含まれます:'MP4', 'MOV', 'MPEG', 'WEBM'- - `custom` サポートされるタイプには以下が含まれます:その他のファイルタイプ- - `transfer_method` (string) 転送方法:- - `remote_url`: ファイルのURL。- - `local_file`: ファイルをアップロード。- - `url` ファイルのURL。(転送方法が `remote_url` の場合のみ)。- - `upload_file_id` アップロードされたファイルID。(転送方法が `local_file` の場合のみ)。-- - `response_mode` (string) 必須- 応答の返却モードを指定します。サポートされているモード:- - `streaming` ストリーミングモード(推奨)、SSE([Server-Sent Events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events))を通じてタイプライターのような出力を実装します。- - `blocking` ブロッキングモード、実行完了後に結果を返します。(プロセスが長い場合、リクエストが中断される可能性があります)- <i>Cloudflare の制限により、100 秒後に応答がない場合、リクエストは中断されます。</i>- - `user` (string) 必須- ユーザー識別子、エンドユーザーのアイデンティティを定義するために使用されます。- アプリケーション内で開発者によって一意に定義される必要があります。- - `files` (array[object]) オプション- - `trace_id` (string) オプション- トレースID。既存の業務システムのトレースコンポーネントと連携し、エンドツーエンドの分散トレーシングを実現するために使用します。指定がない場合、システムが自動的に trace_id を生成します。以下の3つの方法で渡すことができ、優先順位は次のとおりです:- 1. Header:HTTPヘッダー `X-Trace-Id` で渡す(最優先)。- 2. クエリパラメータ:URLクエリパラメータ `trace_id` で渡す。- 3. リクエストボディ:リクエストボディの `trace_id` フィールドで渡す(本フィールド)。- - `trace_session_id` (string) オプション- 可観測性のグルーピングに使用するトレースセッションID。セッションのグルーピングに対応するトレースプロバイダーは、この値をエクスポートされるセッション識別子として使用できます。conversation_id、workflow_run_id、trace_id、または span の関係は変更しません。以下の3つの方法で渡すことができ、優先順位は次のとおりです:- 1. ヘッダー:HTTP ヘッダー `X-Trace-Session-Id` で渡すことを推奨、最高優先度。- 2. クエリパラメータ:URL クエリパラメータ `trace_session_id` で渡す。- 3. リクエストボディ:リクエストボディフィールド `trace_session_id` で渡す(つまり、このフィールド)。--- ### 応答- `response_mode`が`blocking`の場合、CompletionResponse オブジェクトを返します。- `response_mode`が`streaming`の場合、ChunkCompletionResponse ストリームを返します。-- ### CompletionResponse- アプリの結果を返します。`Content-Type`は`application/json`です。- - `workflow_run_id` (string) ワークフロー実行の一意の ID- - `task_id` (string) タスク ID、リクエスト追跡と以下の Stop Generate API に使用- - `data` (object) 結果の詳細- - `id` (string) ワークフロー実行の ID- - `workflow_id` (string) 関連するワークフローの ID- - `status` (string) 実行のステータス、`running` / `succeeded` / `failed` / `stopped`- - `outputs` (json) オプションの出力内容- - `error` (string) オプションのエラー理由- - `elapsed_time` (float) オプションの使用時間(秒)- - `total_tokens` (int) オプションの使用トークン数- - `total_steps` (int) デフォルト 0- - `created_at` (timestamp) 開始時間- - `finished_at` (timestamp) 終了時間-- ### ChunkCompletionResponse- アプリによって出力されたストリームチャンクを返します。`Content-Type`は`text/event-stream`です。- 各ストリーミングチャンクは`data:`で始まり、2 つの改行文字`\n\n`で区切られます。以下のように表示されます:- <CodeGroup>- ```streaming {{ title: '応答' }}- data: {"event": "text_chunk", "workflow_run_id": "b85e5fc5-751b-454d-b14e-dc5f240b0a31", "task_id": "bd029338-b068-4d34-a331-fc85478922c2", "data": {"text": "\u4e3a\u4e86", "from_variable_selector": ["1745912968134", "text"]}}\n\n- ```- </CodeGroup>- ストリーミングチャンクの構造は`event`に応じて異なります:- - `event: workflow_started` ワークフローが実行を開始- - `task_id` (string) タスク ID、リクエスト追跡と以下の Stop Generate API に使用- - `workflow_run_id` (string) ワークフロー実行の一意の ID- - `event` (string) `workflow_started`に固定- - `data` (object) 詳細- - `id` (string) ワークフロー実行の一意の ID- - `workflow_id` (string) 関連するワークフローの ID- - `created_at` (timestamp) 作成タイムスタンプ、例:1705395332- - `event: node_started` ノード実行開始- - `task_id` (string) タスク ID、リクエスト追跡と以下の Stop Generate API に使用- - `workflow_run_id` (string) ワークフロー実行の一意の ID- - `event` (string) `node_started`に固定- - `data` (object) 詳細- - `id` (string) ワークフロー実行の一意の ID- - `node_id` (string) ノードの ID- - `node_type` (string) ノードのタイプ- - `title` (string) ノードの名前- - `index` (int) 実行シーケンス番号、トレースノードシーケンスを表示するために使用- - `predecessor_node_id` (string) オプションのプレフィックスノード ID、キャンバス表示実行パスに使用- - `inputs` (object) ノードで使用されるすべての前のノード変数の内容- - `created_at` (timestamp) 開始のタイムスタンプ、例:1705395332- - `event: text_chunk` テキストフラグメント- - `task_id` (string) タスク ID、リクエスト追跡と以下の Stop Generate API に使用- - `workflow_run_id` (string) ワークフロー実行の一意の ID- - `event` (string) `text_chunk`に固定- - `data` (object) 詳細- - `text` (string) テキスト内容- - `from_variable_selector` (array) テキスト生成元パス(開発者がどのノードのどの変数から生成されたかを理解するための情報)- - `event: node_finished` ノード実行終了、同じイベントで異なる状態で成功または失敗- - `task_id` (string) タスク ID、リクエスト追跡と以下の Stop Generate API に使用- - `workflow_run_id` (string) ワークフロー実行の一意の ID- - `event` (string) `node_finished`に固定- - `data` (object) 詳細- - `id` (string) ワークフロー実行の一意の ID- - `node_id` (string) ノードの ID- - `node_type` (string) ノードのタイプ- - `title` (string) ノードの名前- - `index` (int) 実行シーケンス番号、トレースノードシーケンスを表示するために使用- - `predecessor_node_id` (string) オプションのプレフィックスノード ID、キャンバス表示実行パスに使用- - `inputs` (object) ノードで使用されるすべての前のノード変数の内容- - `process_data` (json) オプションのノードプロセスデータ- - `outputs` (json) オプションの出力内容- - `status` (string) 実行のステータス、`running` / `succeeded` / `failed` / `stopped`- - `error` (string) オプションのエラー理由- - `elapsed_time` (float) オプションの使用時間(秒)- - `execution_metadata` (json) メタデータ- - `total_tokens` (int) オプションの使用トークン数- - `total_price` (decimal) オプションの総コスト- - `currency` (string) オプション 例:`USD` / `RMB`- - `created_at` (timestamp) 開始のタイムスタンプ、例:1705395332- - `event: human_input_required` ワークフローが一時停止し、Human-in-the-Loop 入力が必要- - `task_id` (string) タスク ID、リクエスト追跡に使用- - `workflow_run_id` (string) ワークフロー実行の一意の ID- - `event` (string) `human_input_required`に固定- - `data` (object) 詳細- - `form_id` (string) ヒューマン入力フォーム ID- - `node_id` (string) Human Input ノード ID- - `node_title` (string) Human Input ノードタイトル- - `form_content` (string) レンダリング済みフォーム内容- - `inputs` (array[object]) フォーム入力項目の定義- - `actions` (array[object]) ユーザーが選択できるアクションボタン- - `id` (string) アクション ID- - `title` (string) ボタンラベル- - `button_style` (string) ボタンスタイル- - `display_in_ui` (bool) UI にこのフォームを表示するかどうか- - `form_token` (string) `/form/human_input/:form_token` API で使用するトークン- - `resolved_default_values` (object) 実行時に解決されたデフォルト値- - `expiration_time` (timestamp) フォームの有効期限(Unix 秒)- - `event: workflow_finished` ワークフロー実行終了、同じイベントで異なる状態で成功または失敗- - `task_id` (string) タスク ID、リクエスト追跡と以下の Stop Generate API に使用- - `workflow_run_id` (string) ワークフロー実行の一意の ID- - `event` (string) `workflow_finished`に固定- - `data` (object) 詳細- - `id` (string) ワークフロー実行の ID- - `workflow_id` (string) 関連するワークフローの ID- - `status` (string) 実行のステータス、`running` / `succeeded` / `failed` / `stopped`- - `outputs` (json) オプションの出力内容- - `error` (string) オプションのエラー理由- - `elapsed_time` (float) オプションの使用時間(秒)- - `total_tokens` (int) オプションの使用トークン数- - `total_steps` (int) デフォルト 0- - `created_at` (timestamp) 開始時間- - `finished_at` (timestamp) 終了時間- - `event: tts_message` TTS オーディオストリームイベント、つまり音声合成出力。内容は Mp3 形式のオーディオブロックで、base64 文字列としてエンコードされています。再生時には、base64 をデコードしてプレーヤーに入力するだけです。(このメッセージは自動再生が有効な場合にのみ利用可能)- - `task_id` (string) タスク ID、リクエスト追跡と以下の停止応答インターフェースに使用- - `message_id` (string) 一意のメッセージ ID- - `audio` (string) 音声合成後のオーディオ、base64 テキストコンテンツとしてエンコードされており、再生時には base64 をデコードしてプレーヤーに入力するだけです- - `created_at` (int) 作成タイムスタンプ、例:1705395332- - `event: tts_message_end` TTS オーディオストリーム終了イベント。このイベントを受信すると、オーディオストリームの終了を示します。- - `task_id` (string) タスク ID、リクエスト追跡と以下の停止応答インターフェースに使用- - `message_id` (string) 一意のメッセージ ID- - `audio` (string) 終了イベントにはオーディオがないため、これは空の文字列です- - `created_at` (int) 作成タイムスタンプ、例:1705395332- - `event: ping` 接続を維持するために 10 秒ごとに送信される Ping イベント。-- ### エラー- - 400, `invalid_param`, 異常なパラメータ入力- - 400, `app_unavailable`, アプリの設定が利用できません- - 400, `provider_not_initialize`, 利用可能なモデル資格情報の設定がありません- - 400, `provider_quota_exceeded`, モデル呼び出しのクォータが不足しています- - 400, `model_currently_not_support`, 現在のモデルは利用できません- - 400, `workflow_request_error`, ワークフロー実行に失敗しました- - 500, 内部サーバーエラー-- </Col>- <Col sticky>- <CodeGroup- title="リクエスト"- tag="POST"- label="/workflows/run"- targetCode={`curl -X POST '${props.appDetail.api_base_url}/workflows/run' \\---header 'Authorization: Bearer {api_key}' \\---header 'Content-Type: application/json' \\---data-raw '{- "inputs": ${JSON.stringify(props.inputs)},- "response_mode": "streaming",- "user": "abc-123"-}'`}- />- <CodeGroup title="ファイル変数の例">- ```json {{ title: 'ファイル変数の例' }}- {- "inputs": {- "{variable_name}":- [- {- "transfer_method": "local_file",- "upload_file_id": "{upload_file_id}",- "type": "{document_type}"- }- ]- }- }- ```- </CodeGroup>- ### ブロッキングモード- ブロッキングモードでは、完了済みのワークフロー結果、または一時停止中のワークフロー結果のいずれかが返されます。-- Human-in-the-Loop で実行が一時停止した場合も、レスポンスには `workflow_run_id` と `task_id` が含まれますが、`data.status` は `paused` になります。- 一時停止レスポンスには `paused_nodes` と `reasons` も含まれます。`human_input_required` の各 reason には `form_id` と `expiration_time` が含まれます。-- <CodeGroup title="応答">- ```json {{ title: '応答' }}- {- "workflow_run_id": "djflajgkldjgd",- "task_id": "9da23599-e713-473b-982c-4328d4f5c78a",- "data": {- "id": "fdlsjfjejkghjda",- "workflow_id": "fldjaslkfjlsda",- "status": "succeeded",- "outputs": {- "text": "Nice to meet you."- },- "error": null,- "elapsed_time": 0.875,- "total_tokens": 3562,- "total_steps": 8,- "created_at": 1705407629,- "finished_at": 1727807631- }- }- ```- </CodeGroup>- <CodeGroup title="一時停止レスポンス例">- ```json {{ title: '一時停止レスポンス例' }}- {- "task_id": "3938b985-f4c6-4806-87b6-215e0aca9d81",- "workflow_run_id": "4a80f375-682b-49c5-b199-e950aac4968f",- "data": {- "id": "4a80f375-682b-49c5-b199-e950aac4968f",- "workflow_id": "e46514f1-c008-41ff-94b0-4f33d4b97d36",- "status": "paused",- "outputs": {},- "error": null,- "elapsed_time": 0.035667,- "total_tokens": 0,- "total_steps": 2,- "created_at": 1776074783,- "finished_at": null,- "paused_nodes": [- "1775717346519"- ],- "reasons": [- {- "form_id": "019d864e-7a36-74a2-b94e-e5660c47f5a7",- "form_content": "this is form 1:\n{{#$output.some_field#}}\n",- "inputs": [- {- "type": "paragraph",- "output_variable_name": "some_field",- "default": {- "type": "variable",- "selector": [- "sys",- "workflow_run_id"- ],- "value": ""- }- }- ],- "actions": [- {- "id": "approve",- "title": "YES",- "button_style": "default"- },- {- "id": "reject",- "title": "NO",- "button_style": "default"- }- ],- "display_in_ui": true,- "node_id": "1775717346519",- "node_title": "Human Input",- "resolved_default_values": {- "some_field": "4a80f375-682b-49c5-b199-e950aac4968f"- },- "form_token": "SZwvfmL47fTIsZynP2Jr9i",- "type": "human_input_required",- "expiration_time": 1776333983- }- ]- }- }- ```- </CodeGroup>- ### ストリーミングモード- <CodeGroup title="応答">- ```streaming {{ title: '応答' }}- data: {"event": "workflow_started", "task_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "workflow_run_id": "5ad498-f0c7-4085-b384-88cbe6290", "data": {"id": "5ad498-f0c7-4085-b384-88cbe6290", "workflow_id": "dfjasklfjdslag", "created_at": 1679586595}}- data: {"event": "node_started", "task_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "workflow_run_id": "5ad498-f0c7-4085-b384-88cbe6290", "data": {"id": "5ad498-f0c7-4085-b384-88cbe6290", "node_id": "dfjasklfjdslag", "node_type": "start", "title": "Start", "index": 0, "predecessor_node_id": "fdljewklfklgejlglsd", "inputs": {}, "created_at": 1679586595}}- data: {"event": "node_finished", "task_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "workflow_run_id": "5ad498-f0c7-4085-b384-88cbe6290", "data": {"id": "5ad498-f0c7-4085-b384-88cbe6290", "node_id": "dfjasklfjdslag", "node_type": "start", "title": "Start", "index": 0, "predecessor_node_id": "fdljewklfklgejlglsd", "inputs": {}, "outputs": {}, "status": "succeeded", "elapsed_time": 0.324, "execution_metadata": {"total_tokens": 63127864, "total_price": 2.378, "currency": "USD"}, "created_at": 1679586595}}- data: {"event": "workflow_finished", "task_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "workflow_run_id": "5ad498-f0c7-4085-b384-88cbe6290", "data": {"id": "5ad498-f0c7-4085-b384-88cbe6290", "workflow_id": "dfjasklfjdslag", "outputs": {}, "status": "succeeded", "elapsed_time": 0.324, "total_tokens": 63127864, "total_steps": "1", "created_at": 1679586595, "finished_at": 1679976595}}- data: {"event": "tts_message", "conversation_id": "23dd85f3-1a41-4ea0-b7a9-062734ccfaf9", "message_id": "a8bdc41c-13b2-4c18-bfd9-054b9803038c", "created_at": 1721205487, "task_id": "3bf8a0bb-e73b-4690-9e66-4e429bad8ee7", "audio": "qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq"}- data: {"event": "tts_message_end", "conversation_id": "23dd85f3-1a41-4ea0-b7a9-062734ccfaf9", "message_id": "a8bdc41c-13b2-4c18-bfd9-054b9803038c", "created_at": 1721205487, "task_id": "3bf8a0bb-e73b-4690-9e66-4e429bad8ee7", "audio": ""}- ```- </CodeGroup>- ストリーミングモードでも Human-in-the-Loop により一時停止する場合があります。その場合、SSE ストリームではまず `human_input_required` が送られ、その後に `workflow_paused` が送られます。-- <CodeGroup title="一時停止ストリーミングレスポンス例">- ```streaming {{ title: '一時停止ストリーミングレスポンス例' }}- event: ping-- data: {- "event": "workflow_started",- "workflow_run_id": "a4959eb4-c852-4e0c-ac7a-348233f7f345",- "task_id": "0399c5c2-181b-4493-a78e-1421914e8a25",- "data": {- "id": "a4959eb4-c852-4e0c-ac7a-348233f7f345",- "workflow_id": "e46514f1-c008-41ff-94b0-4f33d4b97d36",- "inputs": {- "sys.files": [],- "sys.user_id": "abc-123",- "sys.app_id": "d1074979-f67e-4114-8691-e35878df9a89",- "sys.workflow_id": "e46514f1-c008-41ff-94b0-4f33d4b97d36",- "sys.workflow_run_id": "a4959eb4-c852-4e0c-ac7a-348233f7f345"- },- "created_at": 1776129228,- "reason": "initial"- }- }-- data: {- "event": "node_started",- "workflow_run_id": "a4959eb4-c852-4e0c-ac7a-348233f7f345",- "task_id": "0399c5c2-181b-4493-a78e-1421914e8a25",- "data": {- "id": "7d9bb041-5ecb-497f-a674-d8706eed0ab1",- "node_id": "1775717266623",- "node_type": "start",- "title": "User Input",- "index": 1,- "predecessor_node_id": null,- "inputs": null,- "inputs_truncated": false,- "created_at": 1776129228,- "extras": {},- "iteration_id": null,- "loop_id": null,- "agent_strategy": null- }- }-- data: {- "event": "node_finished",- "workflow_run_id": "a4959eb4-c852-4e0c-ac7a-348233f7f345",- "task_id": "0399c5c2-181b-4493-a78e-1421914e8a25",- "data": {- "id": "7d9bb041-5ecb-497f-a674-d8706eed0ab1",- "node_id": "1775717266623",- "node_type": "start",- "title": "User Input",- "index": 1,- "predecessor_node_id": null,- "inputs": {- "sys.files": [],- "sys.user_id": "abc-123",- "sys.app_id": "d1074979-f67e-4114-8691-e35878df9a89",- "sys.workflow_id": "e46514f1-c008-41ff-94b0-4f33d4b97d36",- "sys.workflow_run_id": "a4959eb4-c852-4e0c-ac7a-348233f7f345",- "sys.timestamp": 1776129228- },- "inputs_truncated": false,- "process_data": {},- "process_data_truncated": false,- "outputs": {- "sys.files": [],- "sys.user_id": "abc-123",- "sys.app_id": "d1074979-f67e-4114-8691-e35878df9a89",- "sys.workflow_id": "e46514f1-c008-41ff-94b0-4f33d4b97d36",- "sys.workflow_run_id": "a4959eb4-c852-4e0c-ac7a-348233f7f345",- "sys.timestamp": 1776129228- },- "outputs_truncated": false,- "status": "succeeded",- "error": null,- "elapsed_time": 0.000097,- "execution_metadata": null,- "created_at": 1776129228,- "finished_at": 1776129228,- "files": [],- "iteration_id": null,- "loop_id": null- }- }-- data: {- "event": "node_started",- "workflow_run_id": "a4959eb4-c852-4e0c-ac7a-348233f7f345",- "task_id": "0399c5c2-181b-4493-a78e-1421914e8a25",- "data": {- "id": "c09ff568-1d55-4f0d-9a07-512bcbfeb289",- "node_id": "1775717346519",- "node_type": "human-input",- "title": "Human Input",- "index": 1,- "predecessor_node_id": null,- "inputs": null,- "inputs_truncated": false,- "created_at": 1776129228,- "extras": {},- "iteration_id": null,- "loop_id": null,- "agent_strategy": null- }- }-- data: {- "event": "human_input_required",- "workflow_run_id": "a4959eb4-c852-4e0c-ac7a-348233f7f345",- "task_id": "0399c5c2-181b-4493-a78e-1421914e8a25",- "data": {- "form_id": "019d898d-3d80-7105-b920-9899ead4ff3e",- "node_id": "1775717346519",- "node_title": "Human Input",- "form_content": "this is form 1:\n{{#$output.some_field#}}\n",- "inputs": [- {- "type": "paragraph",- "output_variable_name": "some_field",- "default": {- "type": "variable",- "selector": [- "sys",- "workflow_run_id"- ],- "value": ""- }- }- ],- "actions": [- {- "id": "approve",- "title": "YES",- "button_style": "default"- },- {- "id": "reject",- "title": "NO",- "button_style": "default"- }- ],- "display_in_ui": true,- "form_token": "0Tb1nXYe4hzQUD706nHB4y",- "resolved_default_values": {- "some_field": "a4959eb4-c852-4e0c-ac7a-348233f7f345"- },- "expiration_time": 1776388428- }- }-- data: {- "event": "workflow_paused",- "workflow_run_id": "a4959eb4-c852-4e0c-ac7a-348233f7f345",- "task_id": "0399c5c2-181b-4493-a78e-1421914e8a25",- "data": {- "workflow_run_id": "a4959eb4-c852-4e0c-ac7a-348233f7f345",- "paused_nodes": [- "1775717346519"- ],- "outputs": {},- "reasons": [- {- "form_id": "019d898d-3d80-7105-b920-9899ead4ff3e",- "form_content": "this is form 1:\n{{#$output.some_field#}}\n",- "inputs": [- {- "type": "paragraph",- "output_variable_name": "some_field",- "default": {- "type": "variable",- "selector": [- "sys",- "workflow_run_id"- ],- "value": ""- }- }- ],- "actions": [- {- "id": "approve",- "title": "YES",- "button_style": "default"- },- {- "id": "reject",- "title": "NO",- "button_style": "default"- }- ],- "display_in_ui": true,- "node_id": "1775717346519",- "node_title": "Human Input",- "resolved_default_values": {- "some_field": "a4959eb4-c852-4e0c-ac7a-348233f7f345"- },- "form_token": "0Tb1nXYe4hzQUD706nHB4y",- "type": "human_input_required",- "expiration_time": 1776388428- }- ],- "status": "paused",- "created_at": 1776129228,- "elapsed_time": 0.070478,- "total_tokens": 0,- "total_steps": 2- }- }- ```- </CodeGroup>- <CodeGroup title="ファイルアップロードのサンプルコード">- ```json {{ title: 'ファイルアップロードのサンプルコード' }}- import requests- import json-- def upload_file(file_path, user):- upload_url = "https://api.dify.ai/v1/files/upload"- headers = {- "Authorization": "Bearer app-xxxxxxxx",- }-- try:- print("ファイルをアップロードしています...")- with open(file_path, 'rb') as file:- files = {- 'file': (file_path, file, 'text/plain') # ファイルが適切な MIME タイプでアップロードされていることを確認してください- }- data = {- "user": user,- "type": "TXT" # ファイルタイプをTXTに設定します- }-- response = requests.post(upload_url, headers=headers, files=files, data=data)- if response.status_code == 201: # 201 は作成が成功したことを意味します- print("ファイルが正常にアップロードされました")- return response.json().get("id") # アップロードされたファイルIDを取得する- else:- print(f"ファイルのアップロードに失敗しました。ステータス コード: {response.status_code}")- return None- except Exception as e:- print(f"エラーが発生しました: {str(e)}")- return None-- def run_workflow(file_id, user, response_mode="blocking"):- workflow_url = "https://api.dify.ai/v1/workflows/run"- headers = {- "Authorization": "Bearer app-xxxxxxxxx",- "Content-Type": "application/json"- }-- data = {- "inputs": {- "orig_mail": [{- "transfer_method": "local_file",- "upload_file_id": file_id,- "type": "document"- }]- },- "response_mode": response_mode,- "user": user- }-- try:- print("ワークフローを実行...")- response = requests.post(workflow_url, headers=headers, json=data)- if response.status_code == 200:- print("ワークフローが正常に実行されました")- return response.json()- else:- print(f"ワークフローの実行がステータス コードで失敗しました: {response.status_code}")- return {"status": "error", "message": f"Failed to execute workflow, status code: {response.status_code}"}- except Exception as e:- print(f"エラーが発生しました: {str(e)}")- return {"status": "error", "message": str(e)}-- # 使用例- file_path = "{your_file_path}"- user = "difyuser"-- # ファイルをアップロードする- file_id = upload_file(file_path, user)- if file_id:- # ファイルは正常にアップロードされました。ワークフローの実行を続行します- result = run_workflow(file_id, user)- print(result)- else:- print("ファイルのアップロードに失敗し、ワークフローを実行できません")- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/workflows/:workflow_id/run'- method='POST'- title='特定バージョンのワークフローを実行'- name='#Execute-Specific-Workflow'- titleAction={<WorkflowVersionApiUpgradeNotice />}-/>-<WorkflowVersionApiContent>-<Row>- <Col>- パスパラメータでワークフローIDを指定して、特定バージョンのワークフローを実行します。-- ### パス- - `workflow_id` (string) 必須 特定バージョンのワークフローを指定するためのワークフローID-- 取得方法:バージョン履歴インターフェースで、各バージョンエントリの右側にあるコピーアイコンをクリックすると、完全なワークフローIDをコピーできます。-- ### リクエストボディ- - `inputs` (object) 必須- App で定義された各変数値を入力できます。- inputs パラメータには複数のキー/値ペアが含まれており、各キーは特定の変数に対応し、各値はその変数の具体的な値です。変数はファイルリスト型にすることができます。- ファイルリスト型変数は、ファイルをテキスト理解と組み合わせて質問に答えるために入力するのに適しており、モデルがファイル解析機能をサポートしている場合のみ使用できます。変数がファイルリスト型の場合、その変数に対応する値はリスト形式である必要があり、各要素には以下の内容が含まれます:- - `type` (string) サポートされるタイプ:- - `document` 具体的なタイプには以下が含まれます:'TXT', 'MD', 'MARKDOWN', 'PDF', 'HTML', 'XLSX', 'XLS', 'DOCX', 'CSV', 'EML', 'MSG', 'PPTX', 'PPT', 'XML', 'EPUB'- - `image` 具体的なタイプには以下が含まれます:'JPG', 'JPEG', 'PNG', 'GIF', 'WEBP', 'SVG'- - `audio` 具体的なタイプには以下が含まれます:'MP3', 'M4A', 'WAV', 'WEBM', 'AMR'- - `video` 具体的なタイプには以下が含まれます:'MP4', 'MOV', 'MPEG', 'MPGA'- - `custom` 具体的なタイプには以下が含まれます:その他のファイルタイプ- - `transfer_method` (string) 転送方法、`remote_url` 画像URL / `local_file` ファイルアップロード- - `url` (string) 画像URL(転送方法が `remote_url` の場合のみ)- - `upload_file_id` (string) アップロードされたファイルID(転送方法が `local_file` の場合のみ)- - `response_mode` (string) 必須- 応答返却モード、以下をサポート:- - `streaming` ストリーミングモード(推奨)。SSE(**[Server-Sent Events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events)**)をベースにタイプライター風の出力を実現。- - `blocking` ブロッキングモード、実行完了後に結果を返却。(プロセスが長い場合、リクエストが中断される可能性があります)。- <i>Cloudflare の制限により、100秒後に応答がない場合、リクエストは中断されます。</i>- - `user` (string) 必須- ユーザー識別子、エンドユーザーのアイデンティティを定義し、検索・統計を容易にするために使用されます。- 開発者が定義するルールで、アプリケーション内でユーザー識別子が一意である必要があります。API は WebApp で作成されたセッションにアクセスできません。- - `files` (array[object]) オプション- - `trace_id` (string) オプション- トレースID。既存のビジネスシステムのトレースコンポーネントと統合して、エンドツーエンドの分散トレーシングを実現するために使用されます。指定されていない場合、システムは自動的に `trace_id` を生成します。以下の3つの方法で渡すことができ、優先順位は以下の通りです:- 1. ヘッダー:HTTP ヘッダー `X-Trace-Id` で渡すことを推奨、最高優先度。- 2. クエリパラメータ:URL クエリパラメータ `trace_id` で渡す。- 3. リクエストボディ:リクエストボディフィールド `trace_id` で渡す(つまり、このフィールド)。- - `trace_session_id` (string) オプション- 可観測性のグルーピングに使用するトレースセッションID。セッションのグルーピングに対応するトレースプロバイダーは、この値をエクスポートされるセッション識別子として使用できます。conversation_id、workflow_run_id、trace_id、または span の関係は変更しません。以下の3つの方法で渡すことができ、優先順位は以下の通りです:- 1. ヘッダー:HTTP ヘッダー `X-Trace-Session-Id` で渡すことを推奨、最高優先度。- 2. クエリパラメータ:URL クエリパラメータ `trace_session_id` で渡す。- 3. リクエストボディ:リクエストボディフィールド `trace_session_id` で渡す(つまり、このフィールド)。-- ### 応答- `response_mode` が `blocking` の場合、CompletionResponse オブジェクトを返します。- `response_mode` が `streaming` の場合、ChunkCompletionResponse オブジェクトのストリーミングシーケンスを返します。-- ### CompletionResponse- 完全な App 結果を返し、`Content-Type` は `application/json` です。- - `workflow_run_id` (string) ワークフロー実行ID- - `task_id` (string) タスクID、リクエスト追跡と以下の停止応答インターフェースに使用- - `data` (object) 詳細内容- - `id` (string) ワークフロー実行ID- - `workflow_id` (string) 関連するワークフローID- - `status` (string) 実行ステータス、`running` / `succeeded` / `failed` / `stopped`- - `outputs` (json) オプション 出力内容- - `error` (string) オプション エラー理由- - `elapsed_time` (float) オプション 使用時間(s)- - `total_tokens` (int) オプション 使用されるトークンの総数- - `total_steps` (int) 総ステップ数(冗長)、デフォルト 0- - `created_at` (timestamp) 開始時間- - `finished_at` (timestamp) 終了時間-- ### ChunkCompletionResponse- App の出力ストリーミングチャンクを返し、`Content-Type` は `text/event-stream` です。- 各ストリーミングチャンクは `data:` で始まり、チャンク間は `\n\n` つまり2つの改行文字で区切られます。以下のようになります:- <CodeGroup>- ```streaming {{ title: '応答' }}- data: {"event": "text_chunk", "workflow_run_id": "b85e5fc5-751b-454d-b14e-dc5f240b0a31", "task_id": "bd029338-b068-4d34-a331-fc85478922c2", "data": {"text": "\u4e3a\u4e86", "from_variable_selector": ["1745912968134", "text"]}}\n\n- ```- </CodeGroup>- ストリーミングチャンクは `event` によって構造が異なり、以下のタイプが含まれます:- - `event: workflow_started` ワークフロー実行開始- - `task_id` (string) タスクID、リクエスト追跡と以下の停止応答インターフェースに使用- - `workflow_run_id` (string) ワークフロー実行ID- - `event` (string) `workflow_started` に固定- - `data` (object) 詳細内容- - `id` (string) ワークフロー実行ID- - `workflow_id` (string) 関連するワークフローID- - `created_at` (timestamp) 開始時間- - `event: node_started` ノード実行開始- - `task_id` (string) タスクID、リクエスト追跡と以下の停止応答インターフェースに使用- - `workflow_run_id` (string) ワークフロー実行ID- - `event` (string) `node_started` に固定- - `data` (object) 詳細内容- - `id` (string) ワークフロー実行ID- - `node_id` (string) ノードID- - `node_type` (string) ノードタイプ- - `title` (string) ノード名- - `index` (int) 実行シーケンス番号、Tracing Node シーケンスの表示に使用- - `predecessor_node_id` (string) 前置ノードID、キャンバス表示実行パスに使用- - `inputs` (object) ノードで使用されるすべての前置ノード変数の内容- - `created_at` (timestamp) 開始時間- - `event: text_chunk` テキストフラグメント- - `task_id` (string) タスクID、リクエスト追跡と以下の停止応答インターフェースに使用- - `workflow_run_id` (string) ワークフロー実行ID- - `event` (string) `text_chunk` に固定- - `data` (object) 詳細内容- - `text` (string) テキスト内容- - `from_variable_selector` (array) テキストソースパス、開発者がテキストがどのノードのどの変数から生成されたかを理解するのに役立ちます- - `event: node_finished` ノード実行終了、成功と失敗は同じイベント内の異なる状態- - `task_id` (string) タスクID、リクエスト追跡と以下の停止応答インターフェースに使用- - `workflow_run_id` (string) ワークフロー実行ID- - `event` (string) `node_finished` に固定- - `data` (object) 詳細内容- - `id` (string) ノード実行ID- - `node_id` (string) ノードID- - `index` (int) 実行シーケンス番号、Tracing Node シーケンスの表示に使用- - `predecessor_node_id` (string) オプション 前置ノードID、キャンバス表示実行パスに使用- - `inputs` (object) ノードで使用されるすべての前置ノード変数の内容- - `process_data` (json) オプション ノードプロセスデータ- - `outputs` (json) オプション 出力内容- - `status` (string) 実行ステータス `running` / `succeeded` / `failed` / `stopped`- - `error` (string) オプション エラー理由- - `elapsed_time` (float) オプション 使用時間(s)- - `execution_metadata` (json) メタデータ- - `total_tokens` (int) オプション 使用されるトークンの総数- - `total_price` (decimal) オプション 総費用- - `currency` (string) オプション 通貨、例:`USD` / `RMB`- - `created_at` (timestamp) 開始時間- - `event: human_input_required` ワークフローが一時停止し、Human-in-the-Loop 入力が必要- - `task_id` (string) タスク ID、リクエスト追跡に使用- - `workflow_run_id` (string) ワークフロー実行 ID- - `event` (string) `human_input_required` に固定- - `data` (object) 詳細内容- - `form_id` (string) ヒューマン入力フォーム ID- - `node_id` (string) Human Input ノード ID- - `node_title` (string) Human Input ノードタイトル- - `form_content` (string) レンダリング済みフォーム内容- - `inputs` (array[object]) フォーム入力項目の定義- - `actions` (array[object]) ユーザーが選択できるアクションボタン- - `id` (string) アクション ID- - `title` (string) ボタンラベル- - `button_style` (string) ボタンスタイル- - `display_in_ui` (bool) UI にこのフォームを表示するかどうか- - `form_token` (string) `/form/human_input/:form_token` API で使用するトークン- - `resolved_default_values` (object) 実行時に解決されたデフォルト値- - `expiration_time` (timestamp) フォームの有効期限(Unix 秒)- - `event: workflow_finished` ワークフロー実行終了、成功と失敗は同じイベント内の異なる状態- - `task_id` (string) タスクID、リクエスト追跡と以下の停止応答インターフェースに使用- - `workflow_run_id` (string) ワークフロー実行ID- - `event` (string) `workflow_finished` に固定- - `data` (object) 詳細内容- - `id` (string) ワークフロー実行ID- - `workflow_id` (string) 関連するワークフローID- - `status` (string) 実行ステータス `running` / `succeeded` / `failed` / `stopped`- - `outputs` (json) オプション 出力内容- - `error` (string) オプション エラー理由- - `elapsed_time` (float) オプション 使用時間(s)- - `total_tokens` (int) オプション 使用されるトークンの総数- - `total_steps` (int) 総ステップ数(冗長)、デフォルト 0- - `created_at` (timestamp) 開始時間- - `finished_at` (timestamp) 終了時間- - `event: tts_message` TTS オーディオストリームイベント、つまり:音声合成出力。内容はMp3形式のオーディオブロックで、base64エンコードされた文字列として、再生時に直接デコードできます。(自動再生が有効な場合のみこのメッセージがあります)- - `task_id` (string) タスクID、リクエスト追跡と以下の停止応答インターフェースに使用- - `message_id` (string) メッセージ一意ID- - `audio` (string) 音声合成後のオーディオブロックはbase64エンコードされたテキスト内容として、再生時に直接base64デコードしてプレーヤーに送信できます- - `created_at` (int) 作成タイムスタンプ、例:1705395332- - `event: tts_message_end` TTS オーディオストリーム終了イベント、このイベントを受信すると、オーディオストリームの返却が終了したことを示します。- - `task_id` (string) タスクID、リクエスト追跡と以下の停止応答インターフェースに使用- - `message_id` (string) メッセージ一意ID- - `audio` (string) 終了イベントにはオーディオがないため、ここは空文字列です- - `created_at` (int) 作成タイムスタンプ、例:1705395332- - `event: ping` 10秒ごとのpingイベント、接続を維持します。-- ### エラー- - 400,`invalid_param`,入力パラメータ異常- - 400,`app_unavailable`,App 設定が利用できません- - 400,`provider_not_initialize`,利用可能なモデル認証情報設定がありません- - 400,`provider_quota_exceeded`,モデル呼び出しクォータが不足しています- - 400,`model_currently_not_support`,現在のモデルが利用できません- - 400,`workflow_not_found`,指定されたワークフローバージョンが見つかりません- - 400,`draft_workflow_error`,ドラフトワークフローバージョンを使用できません- - 400,`workflow_id_format_error`,ワークフローID形式エラー、UUID形式が必要です- - 400,`workflow_request_error`,ワークフロー実行に失敗しました- - 403,`workflow_version_execution_not_allowed`,現在のプランではワークフローバージョンを実行できません。有料プランにアップグレードしてください- - 500,サービス内部異常-- </Col>- <Col sticky>- <CodeGroup- title="リクエスト"- tag="POST"- label="/workflows/:workflow_id/run"- targetCode={`curl -X POST '${props.appDetail.api_base_url}/workflows/{workflow_id}/run' \\---header 'Authorization: Bearer {api_key}' \\---header 'Content-Type: application/json' \\---data-raw '{- "inputs": ${JSON.stringify(props.inputs)},- "response_mode": "streaming",- "user": "abc-123"-}'`}- />- <CodeGroup title="例:入力変数としてのファイル配列">- ```json {{ title: 'ファイル変数の例' }}- {- "inputs": {- "{variable_name}":- [- {- "transfer_method": "local_file",- "upload_file_id": "{upload_file_id}",- "type": "{document_type}"- }- ]- }- }- ```- </CodeGroup>- ### ブロッキングモード- <CodeGroup title="応答">- ```json {{ title: '応答' }}- {- "workflow_run_id": "djflajgkldjgd",- "task_id": "9da23599-e713-473b-982c-4328d4f5c78a",- "data": {- "id": "fdlsjfjejkghjda",- "workflow_id": "fldjaslkfjlsda",- "status": "succeeded",- "outputs": {- "text": "Nice to meet you."- },- "error": null,- "elapsed_time": 0.875,- "total_tokens": 3562,- "total_steps": 8,- "created_at": 1705407629,- "finished_at": 1727807631- }- }- ```- </CodeGroup>- ### ストリーミングモード- <CodeGroup title="応答">- ```streaming {{ title: '応答' }}- data: {"event": "workflow_started", "task_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "workflow_run_id": "5ad498-f0c7-4085-b384-88cbe6290", "data": {"id": "5ad498-f0c7-4085-b384-88cbe6290", "workflow_id": "dfjasklfjdslag", "created_at": 1679586595}}- data: {"event": "node_started", "task_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "workflow_run_id": "5ad498-f0c7-4085-b384-88cbe6290", "data": {"id": "5ad498-f0c7-4085-b384-88cbe6290", "node_id": "dfjasklfjdslag", "node_type": "start", "title": "Start", "index": 0, "predecessor_node_id": "fdljewklfklgejlglsd", "inputs": {}, "created_at": 1679586595}}- data: {"event": "node_finished", "task_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "workflow_run_id": "5ad498-f0c7-4085-b384-88cbe6290", "data": {"id": "5ad498-f0c7-4085-b384-88cbe6290", "node_id": "dfjasklfjdslag", "node_type": "start", "title": "Start", "index": 0, "predecessor_node_id": "fdljewklfklgejlglsd", "inputs": {}, "outputs": {}, "status": "succeeded", "elapsed_time": 0.324, "execution_metadata": {"total_tokens": 63127864, "total_price": 2.378, "currency": "USD"}, "created_at": 1679586595}}- data: {"event": "workflow_finished", "task_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "workflow_run_id": "5ad498-f0c7-4085-b384-88cbe6290", "data": {"id": "5ad498-f0c7-4085-b384-88cbe6290", "workflow_id": "dfjasklfjdslag", "outputs": {}, "status": "succeeded", "elapsed_time": 0.324, "total_tokens": 63127864, "total_steps": "1", "created_at": 1679586595, "finished_at": 1679976595}}- data: {"event": "tts_message", "conversation_id": "23dd85f3-1a41-4ea0-b7a9-062734ccfaf9", "message_id": "a8bdc41c-13b2-4c18-bfd9-054b9803038c", "created_at": 1721205487, "task_id": "3bf8a0bb-e73b-4690-9e66-4e429bad8ee7", "audio": "qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq"}- data: {"event": "tts_message_end", "conversation_id": "23dd85f3-1a41-4ea0-b7a9-062734ccfaf9", "message_id": "a8bdc41c-13b2-4c18-bfd9-054b9803038c", "created_at": 1721205487, "task_id": "3bf8a0bb-e73b-4690-9e66-4e429bad8ee7", "audio": ""}- ```- </CodeGroup>- </Col>-</Row>-</WorkflowVersionApiContent>-------<Heading- url='/workflows/run/:workflow_run_id'- method='GET'- title='ワークフロー実行詳細を取得'- name='#get-workflow-run-detail'-/>-<Row>- <Col>- ワークフロー実行 ID に基づいて、ワークフロータスクの現在の実行結果を取得します。- ### パス- - `workflow_run_id` (string) ワークフロー実行ID、ストリーミングチャンクの返り値から取得可能- ### 応答- - `id` (string) ワークフロー実行の ID- - `workflow_id` (string) 関連するワークフローの ID- - `status` (string) 実行のステータス、`running` / `succeeded` / `failed` / `stopped`- - `inputs` (json) 入力内容- - `outputs` (json) 出力内容- - `error` (string) エラー理由- - `total_steps` (int) タスクの総ステップ数- - `total_tokens` (int) 使用されるトークンの総数- - `created_at` (timestamp) 開始時間- - `finished_at` (timestamp) 終了時間- - `elapsed_time` (float) 使用される総秒数- </Col>- <Col sticky>- ### リクエスト例- <CodeGroup- title="リクエスト"- tag="GET"- label="/workflows/run/:workflow_run_id"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/workflows/run/:workflow_run_id' \\--H 'Authorization: Bearer {api_key}' \\--H 'Content-Type: application/json'`}- />-- ### 応答例- <CodeGroup title="応答">- ```json {{ title: '応答' }}- {- "id": "b1ad3277-089e-42c6-9dff-6820d94fbc76",- "workflow_id": "19eff89f-ec03-4f75-b0fc-897e7effea02",- "status": "succeeded",- "inputs": "{\"sys.files\": [], \"sys.user_id\": \"abc-123\"}",- "outputs": null,- "error": null,- "total_steps": 3,- "total_tokens": 0,- "created_at": 1705407629,- "finished_at": 1727807631,- "elapsed_time": 30.098514399956912- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/workflows/tasks/:task_id/stop'- method='POST'- title='生成を停止'- name='#stop-generatebacks'-/>-<Row>- <Col>- ストリーミングモードでのみサポートされています。- ### パス- - `task_id` (string) タスク ID、ストリーミングチャンクの返り値から取得可能- ### リクエストボディ- - `user` (string) 必須- ユーザー識別子、エンドユーザーのアイデンティティを定義するために使用され、送信メッセージインターフェースで渡されたユーザーと一致している必要があります。サービス API は WebApp によって作成された会話を共有しません。- ### 応答- - `result` (string) 常に"success"を返します- </Col>- <Col sticky>- ### リクエスト例- <CodeGroup- title="リクエスト"- tag="POST"- label="/workflows/tasks/:task_id/stop"- targetCode={`curl -X POST '${props.appDetail.api_base_url}/workflows/tasks/:task_id/stop' \\--H 'Authorization: Bearer {api_key}' \\--H 'Content-Type: application/json' \\---data-raw '{"user": "abc-123"}'`}- />-- ### 応答例- <CodeGroup title="応答">- ```json {{ title: '応答' }}- {- "result": "success"- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/form/human_input/:form_token'- method='GET'- title='Human Input フォームを取得'- name='#get-human-input-form'-/>-<Row>- <Col>- `form_token` から保留中の Human-in-the-Loop フォームを取得します。-- Workflow が `human_input_required`(`form_token` を含む)で一時停止した際に使用します。-- ### パス- - `form_token` (string) 必須、一時停止イベントで返されたフォームトークン-- ### 応答- - `form_content` (string) レンダリング済みフォーム内容(markdown/plain text)- - `inputs` (array[object]) 入力項目定義- - `resolved_default_values` (object) 解決済みデフォルト値(文字列)- - `user_actions` (array[object]) アクションボタン一覧- - `expiration_time` (timestamp) フォーム有効期限(Unix 秒)-- ### エラー- - 404, フォームが存在しない、または現在のアプリに属していない- - 412, `human_input_form_submitted`, 既に送信済み- - 412, `human_input_form_expired`, 期限切れ- </Col>- <Col sticky>- <CodeGroup- title="リクエスト"- tag="GET"- label="/form/human_input/:form_token"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/form/human_input/{form_token}' \\---header 'Authorization: Bearer {api_key}'`}- />-- <CodeGroup title="応答">- ```json {{ title: '応答' }}- {- "form_content": "最終回答を確認してください: {{#$output.answer#}}",- "inputs": [- {- "label": "回答",- "type": "text-input",- "required": true,- "output_variable_name": "answer"- }- ],- "resolved_default_values": {- "answer": "初期値"- },- "user_actions": [- { "id": "approve", "title": "承認", "button_style": "primary" },- { "id": "reject", "title": "却下", "button_style": "warning" }- ],- "expiration_time": 1735689600- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/form/human_input/:form_token'- method='POST'- title='Human Input フォームを送信'- name='#submit-human-input-form'-/>-<Row>- <Col>- 保留中の Human-in-the-Loop フォームを送信します。-- ### パス- - `form_token` (string) 必須、一時停止イベントで返されたフォームトークン-- ### リクエストボディ- - `inputs` (object) 必須、フォーム項目の key/value- - `action` (string) 必須、`user_actions` から選択したアクション ID- - `user` (string) 必須、エンドユーザー識別子-- ### 応答- 成功時は空オブジェクトを返します。-- ### エラー- - 400, `invalid_form_data`, 送信データがフォームスキーマに一致しない- - 404, フォームが存在しない、または現在のアプリに属していない- - 412, `human_input_form_submitted`, 既に送信済み- - 412, `human_input_form_expired`, 期限切れ- </Col>- <Col sticky>- <CodeGroup- title="リクエスト"- tag="POST"- label="/form/human_input/:form_token"- targetCode={`curl -X POST '${props.appDetail.api_base_url}/form/human_input/{form_token}' \\---header 'Authorization: Bearer {api_key}' \\---header 'Content-Type: application/json' \\---data-raw '{- "inputs": {"answer": "承認済み回答"},- "action": "approve",- "user": "abc-123"-}'`}- />-- <CodeGroup title="応答">- ```json {{ title: '応答' }}- {}- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/workflow/:task_id/events'- method='GET'- title='再開後の Workflow イベントを取得'- name='#get-workflow-resume-events'-/>-<Row>- <Col>- Human Input フォーム送信後に、ワークフロー再開後のイベントを継続受信します。-- このエンドポイントは `text/event-stream` を返し、完了までイベントを購読できます。-- ### パス- - `task_id` (string) 必須、workflow 実行 ID(`workflow_run_id`)-- ### クエリ- - `user` (string) 必須、エンドユーザー識別子- - `include_state_snapshot` (bool) 任意、`true` の場合は永続化済み状態スナップショットを先に再生してからリアルタイムイベントへ移行- - `continue_on_pause` (bool) 任意、`true` にすると `workflow_paused` イベントをまたいでもストリームを維持し、`workflow_finished` で終了します-- ### 応答- Server-Sent Events ストリーム(`text/event-stream`)。- 主なイベントは `workflow_paused`、`node_started`、`node_finished`、`human_input_form_filled`、`human_input_form_timeout`、`workflow_finished` です。- 呼び出し時点でワークフローがすでに完了している場合、このエンドポイントは完了イベントを 1 件だけ即座に返します。- </Col>- <Col sticky>- <CodeGroup- title="リクエスト"- tag="GET"- label="/workflow/:task_id/events"- targetCode={`curl -N -X GET '${props.appDetail.api_base_url}/workflow/{workflow_run_id}/events?user=abc-123&continue_on_pause=true' \\---header 'Authorization: Bearer {api_key}'`}- />-- <CodeGroup title="応答">- ```streaming {{ title: '応答' }}- event: ping-- data: {"event":"workflow_started","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","data":{"id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","workflow_id":"e46514f1-c008-41ff-94b0-4f33d4b97d36","inputs":{"sys.files":[],"sys.user_id":"abc-123","sys.app_id":"d1074979-f67e-4114-8691-e35878df9a89","sys.workflow_id":"e46514f1-c008-41ff-94b0-4f33d4b97d36","sys.workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","sys.timestamp":1776087863},"created_at":1776087863,"reason":"initial"}}-- data: {"event":"node_started","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","data":{"id":"b552d685-1119-4e6a-9a81-e91a23e5324b","node_id":"1775717266623","node_type":"start","title":"User Input","index":1,"predecessor_node_id":null,"inputs":null,"created_at":1776087863,"extras":{},"iteration_id":null,"loop_id":null}}-- data: {"event":"node_finished","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","data":{"id":"b552d685-1119-4e6a-9a81-e91a23e5324b","node_id":"1775717266623","node_type":"start","title":"User Input","index":1,"predecessor_node_id":null,"inputs":null,"process_data":null,"outputs":null,"status":"succeeded","error":null,"elapsed_time":0.00032,"execution_metadata":null,"created_at":1776087863,"finished_at":1776087863,"files":[],"iteration_id":null,"loop_id":null}}-- data: {"event":"node_started","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","data":{"id":"8d7e8e01-5159-4089-a4b6-3aa394992cc2","node_id":"1775717346519","node_type":"human-input","title":"Human Input","index":2,"predecessor_node_id":null,"inputs":null,"created_at":1776087863,"extras":{},"iteration_id":null,"loop_id":null}}-- data: {"event":"node_finished","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","data":{"id":"8d7e8e01-5159-4089-a4b6-3aa394992cc2","node_id":"1775717346519","node_type":"human-input","title":"Human Input","index":2,"predecessor_node_id":null,"inputs":null,"process_data":null,"outputs":null,"status":"paused","error":null,"elapsed_time":0.007381,"execution_metadata":null,"created_at":1776087863,"finished_at":1776087863,"files":[],"iteration_id":null,"loop_id":null}}-- data: {"event":"workflow_paused","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","data":{"workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","paused_nodes":["1775717346519"],"outputs":{},"reasons":[{"form_id":"019d8716-0fde-75da-8207-1458ccde76e5","form_content":"this is form 1:\n{{#$output.some_field#}}\n","inputs":[{"type":"paragraph","output_variable_name":"some_field","default":{"type":"variable","selector":["sys","workflow_run_id"],"value":""}}],"actions":[{"id":"approve","title":"YES","button_style":"default"},{"id":"reject","title":"NO","button_style":"default"}],"display_in_ui":true,"node_id":"1775717346519","node_title":"Human Input","resolved_default_values":{"some_field":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c"},"form_token":"n7hFG4ZDYdGcgZ5VDc7EGM","type":"human_input_required"}],"status":"paused","created_at":1776087863,"elapsed_time":0.0,"total_tokens":0,"total_steps":2}}-- data: {"event":"workflow_started","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","data":{"id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","workflow_id":"e46514f1-c008-41ff-94b0-4f33d4b97d36","inputs":{"sys.files":[],"sys.user_id":"abc-123","sys.app_id":"d1074979-f67e-4114-8691-e35878df9a89","sys.workflow_id":"e46514f1-c008-41ff-94b0-4f33d4b97d36","sys.workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c"},"created_at":1776087877,"reason":"resumption"}}-- data: {"event":"node_started","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","data":{"id":"8d7e8e01-5159-4089-a4b6-3aa394992cc2","node_id":"1775717346519","node_type":"human-input","title":"Human Input","index":1,"predecessor_node_id":null,"inputs":null,"inputs_truncated":false,"created_at":1776087877,"extras":{},"iteration_id":null,"loop_id":null,"agent_strategy":null}}-- data: {"event":"human_input_form_filled","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","data":{"node_id":"1775717346519","node_title":"Human Input","rendered_content":"this is form 1:\nfield 1 filled!\n","action_id":"approve","action_text":"YES"}}-- data: {"event":"node_finished","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","data":{"id":"8d7e8e01-5159-4089-a4b6-3aa394992cc2","node_id":"1775717346519","node_type":"human-input","title":"Human Input","index":1,"predecessor_node_id":null,"inputs":{},"inputs_truncated":false,"process_data":{},"process_data_truncated":false,"outputs":{"some_field":"field 1 filled!","some_field_2":"from bruno with love","__action_id":"approve","__rendered_content":"this is form 1:\nfield 1 filled!\n"},"outputs_truncated":false,"status":"succeeded","error":null,"elapsed_time":0.004431,"execution_metadata":null,"created_at":1776087877,"finished_at":1776087877,"files":[],"iteration_id":null,"loop_id":null}}-- data: {"event":"node_started","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","data":{"id":"6d8fc3cb-19f7-440b-b83e-eed4e847a332","node_id":"1775717350710","node_type":"template-transform","title":"Template","index":1,"predecessor_node_id":null,"inputs":null,"inputs_truncated":false,"created_at":1776087877,"extras":{},"iteration_id":null,"loop_id":null,"agent_strategy":null}}-- data: {"event":"text_chunk","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","data":{"text":"field 1 filled!","from_variable_selector":["1775717350710","output"]}}-- data: {"event":"node_finished","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","data":{"id":"6d8fc3cb-19f7-440b-b83e-eed4e847a332","node_id":"1775717350710","node_type":"template-transform","title":"Template","index":1,"predecessor_node_id":null,"inputs":{"some_field":"field 1 filled!"},"inputs_truncated":false,"process_data":{},"process_data_truncated":false,"outputs":{"output":"field 1 filled!"},"outputs_truncated":false,"status":"succeeded","error":null,"elapsed_time":0.264614,"execution_metadata":null,"created_at":1776087877,"finished_at":1776087877,"files":[],"iteration_id":null,"loop_id":null}}-- data: {"event":"node_started","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","data":{"id":"e88dec7e-aa2c-41f7-8d73-032b749e23f5","node_id":"1775717354177","node_type":"end","title":"Output","index":1,"predecessor_node_id":null,"inputs":null,"inputs_truncated":false,"created_at":1776087877,"extras":{},"iteration_id":null,"loop_id":null,"agent_strategy":null}}-- data: {"event":"node_finished","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","data":{"id":"e88dec7e-aa2c-41f7-8d73-032b749e23f5","node_id":"1775717354177","node_type":"end","title":"Output","index":1,"predecessor_node_id":null,"inputs":{"output":"field 1 filled!"},"inputs_truncated":false,"process_data":{},"process_data_truncated":false,"outputs":{"output":"field 1 filled!"},"outputs_truncated":false,"status":"succeeded","error":null,"elapsed_time":0.00003,"execution_metadata":null,"created_at":1776087877,"finished_at":1776087877,"files":[],"iteration_id":null,"loop_id":null}}-- data: {"event":"workflow_finished","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","data":{"id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","workflow_id":"e46514f1-c008-41ff-94b0-4f33d4b97d36","status":"succeeded","outputs":{"output":"field 1 filled!"},"error":null,"elapsed_time":0.364935,"total_tokens":0,"total_steps":5,"created_by":{"id":"7932d34c-dcf4-4fba-b770-f2a9de88c0a0","user":"abc-123"},"created_at":1776087877,"finished_at":1776087877,"exceptions_count":0,"files":[]}}- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/files/upload'- method='POST'- title='ファイルアップロード'- name='#file-upload'-/>-<Row>- <Col>- メッセージ送信時に使用するためのファイルをアップロードし、画像とテキストのマルチモーダル理解を可能にします。- ワークフローでサポートされている任意の形式をサポートします。- アップロードされたファイルは、現在のエンドユーザーのみが使用できます。-- ### リクエストボディ- このインターフェースは`multipart/form-data`リクエストを必要とします。- - `file` (File) 必須- アップロードするファイル。- - `user` (string) 必須- ユーザー識別子、開発者のルールで定義され、アプリケーション内で一意でなければなりません。サービス API は WebApp によって作成された会話を共有しません。-- ### 応答- アップロードが成功すると、サーバーはファイルの ID と関連情報を返します。- - `id` (uuid) ID- - `name` (string) ファイル名- - `size` (int) ファイルサイズ(バイト)- - `extension` (string) ファイル拡張子- - `mime_type` (string) ファイルの MIME タイプ- - `created_by` (uuid) エンドユーザーID- - `created_at` (timestamp) 作成タイムスタンプ、例:1705395332-- ### エラー- - 400, `no_file_uploaded`, ファイルが提供されていません- - 400, `too_many_files`, 現在は 1 つのファイルのみ受け付けています- - 400, `unsupported_preview`, ファイルはプレビューをサポートしていません- - 400, `unsupported_estimate`, ファイルは推定をサポートしていません- - 413, `file_too_large`, ファイルが大きすぎます- - 415, `unsupported_file_type`, サポートされていない拡張子、現在はドキュメントファイルのみ受け付けています- - 503, `s3_connection_failed`, S3 サービスに接続できません- - 503, `s3_permission_denied`, S3 にファイルをアップロードする権限がありません- - 503, `s3_file_too_large`, ファイルが S3 のサイズ制限を超えています- - 500, 内部サーバーエラー--- </Col>- <Col sticky>- ### リクエスト例- <CodeGroup- title="リクエスト"- tag="POST"- label="/files/upload"- targetCode={`curl -X POST '${props.appDetail.api_base_url}/files/upload' \\---header 'Authorization: Bearer {api_key}' \\---form 'file=@localfile;type=image/[png|jpeg|jpg|webp|gif]' \\---form 'user=abc-123'`}- />--- ### 応答例- <CodeGroup title="応答">- ```json {{ title: '応答' }}- {- "id": "72fa9618-8f89-4a37-9b33-7e1178a24a67",- "name": "example.png",- "size": 1024,- "extension": "png",- "mime_type": "image/png",- "created_by": "6ad1ab0a-73ff-4ac1-b9e4-cdb312f71f13",- "created_at": 1577836800,- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/end-users/:end_user_id'- method='GET'- title='エンドユーザーを取得'- name='#end-user'-/>-<Row>- <Col>- エンドユーザー ID からエンドユーザー情報を取得します。-- 他の API がエンドユーザー ID(例:ファイルアップロードの `created_by`)を返す場合に利用できます。-- ### パスパラメータ- - `end_user_id` (uuid) 必須- エンドユーザー ID。-- ### レスポンス- EndUser オブジェクトを返します。- - `id` (uuid) ID- - `tenant_id` (uuid) テナント ID- - `app_id` (uuid) アプリ ID- - `type` (string) エンドユーザー種別- - `external_user_id` (string) 外部ユーザー ID- - `name` (string) 名前- - `is_anonymous` (boolean) 匿名ユーザーかどうか- - `session_id` (string) セッション ID- - `created_at` (string) ISO 8601 日時- - `updated_at` (string) ISO 8601 日時-- ### エラー- - 404, `end_user_not_found`, エンドユーザーが見つかりません- - 500, 内部サーバーエラー-- </Col>- <Col sticky>- ### リクエスト例- <CodeGroup- title="Request"- tag="GET"- label="/end-users/:end_user_id"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/end-users/6ad1ab0a-73ff-4ac1-b9e4-cdb312f71f13' \\---header 'Authorization: Bearer {api_key}'`}- />-- ### レスポンス例- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "id": "6ad1ab0a-73ff-4ac1-b9e4-cdb312f71f13",- "tenant_id": "8c0f3f3a-66b0-4b55-a0bf-8b8e0d6aee7d",- "app_id": "6c8c3f41-2c6f-4e1b-8f4f-7f11c8f2ad2a",- "type": "service_api",- "external_user_id": "abc-123",- "name": "Alice",- "is_anonymous": false,- "session_id": "abc-123",- "created_at": "2024-01-01T00:00:00Z",- "updated_at": "2024-01-01T00:00:00Z"- }- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/workflows/logs'- method='GET'- title='ワークフローログを取得'- name='#Get-Workflow-Logs'-/>-<Row>- <Col>- ワークフローログを返します。最初のページは最新の`{limit}`メッセージを返します。つまり、逆順です。-- ### クエリ-- <Properties>- <Property name='keyword' type='string' key='keyword'>- 検索するキーワード- </Property>- <Property name='status' type='string' key='status'>- succeeded/failed/stopped- </Property>- <Property name='page' type='int' key='page'>- 現在のページ、デフォルトは1。- </Property>- <Property name='limit' type='int' key='limit'>- 1回のリクエストで返すチャット履歴メッセージの数、デフォルトは20。- </Property>- <Property name='created_by_end_user_session_id' type='str' key='created_by_end_user_session_id'>- どのendUserによって作成されたか、例えば、`abc-123`。- </Property>- <Property name='created_by_account' type='str' key='created_by_account'>- どのメールアカウントによって作成されたか、例えば、[email protected]。- </Property>- </Properties>-- ### 応答- - `page` (int) 現在のページ- - `limit` (int) 返されたアイテムの数、入力がシステム制限を超える場合、システム制限量を返します- - `total` (int) 合計アイテム数- - `has_more` (bool) 次のページがあるかどうか- - `data` (array[object]) ログリスト- - `id` (string) ID- - `workflow_run` (object) ワークフロー実行- - `id` (string) ID- - `version` (string) バージョン- - `status` (string) 実行のステータス、`running` / `succeeded` / `failed` / `stopped`- - `error` (string) オプションのエラー理由- - `elapsed_time` (float) 使用される総秒数- - `total_tokens` (int) 使用されるトークン数- - `total_steps` (int) デフォルト 0- - `created_at` (timestamp) 開始時間- - `finished_at` (timestamp) 終了時間- - `created_from` (string) 作成元- - `created_by_role` (string) 作成者の役割- - `created_by_account` (string) オプションの作成者アカウント- - `created_by_end_user` (object) エンドユーザーによって作成- - `id` (string) ID- - `type` (string) タイプ- - `is_anonymous` (bool) 匿名かどうか- - `session_id` (string) セッション ID- - `created_at` (timestamp) 作成時間- </Col>- <Col sticky>-- <CodeGroup- title="リクエスト"- tag="GET"- label="/workflows/logs"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/workflows/logs'\\- --header 'Authorization: Bearer {api_key}'`}- />- ### 応答例- <CodeGroup title="応答">- ```json {{ title: '応答' }}- {- "page": 1,- "limit": 1,- "total": 7,- "has_more": true,- "data": [- {- "id": "e41b93f1-7ca2-40fd-b3a8-999aeb499cc0",- "workflow_run": {- "id": "c0640fc8-03ef-4481-a96c-8a13b732a36e",- "version": "2024-08-01 12:17:09.771832",- "status": "succeeded",- "error": null,- "elapsed_time": 1.3588523610014818,- "total_tokens": 0,- "total_steps": 3,- "created_at": 1726139643,- "finished_at": 1726139644- },- "created_from": "service-api",- "created_by_role": "end_user",- "created_by_account": null,- "created_by_end_user": {- "id": "7f7d9117-dd9d-441d-8970-87e5e7e687a3",- "type": "service_api",- "is_anonymous": false,- "session_id": "abc-123"- },- "created_at": 1726139644- }- ]- }- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/info'- method='GET'- title='アプリケーションの基本情報を取得'- name='#info'-/>-<Row>- <Col>- このアプリケーションの基本情報を取得するために使用されます-- ### Response- - `name` (string) アプリケーションの名前- - `description` (string) アプリケーションの説明- - `tags` (array[string]) アプリケーションのタグ- - `mode` (string) アプリケーションのモード- - `author_name` (string) 作者の名前- </Col>- <Col>- <CodeGroup- title="Request"- tag="GET"- label="/info"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/info' \\--H 'Authorization: Bearer {api_key}'`}- />- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "name": "My App",- "description": "This is my app.",- "tags": [- "tag1",- "tag2"- ],- "mode": "workflow",- "author_name": "Dify"- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/parameters'- method='GET'- title='アプリケーションのパラメータ情報を取得'- name='#parameters'-/>-<Row>- <Col>- ページに入る際に、機能、入力パラメータ名、タイプ、デフォルト値などの情報を取得するために使用されます。-- ### 応答- - `user_input_form` (array[object]) ユーザー入力フォームの設定- - `text-input` (object) テキスト入力コントロール- - `label` (string) 変数表示ラベル名- - `variable` (string) 変数ID- - `required` (bool) 必須かどうか- - `default` (string) デフォルト値- - `paragraph` (object) 段落テキスト入力コントロール- - `label` (string) 変数表示ラベル名- - `variable` (string) 変数ID- - `required` (bool) 必須かどうか- - `default` (string) デフォルト値- - `select` (object) ドロップダウンコントロール- - `label` (string) 変数表示ラベル名- - `variable` (string) 変数ID- - `required` (bool) 必須かどうか- - `default` (string) デフォルト値- - `options` (array[string]) オプション値- - `file_upload` (object) ファイルアップロード設定- - `document` (object) ドキュメント設定- 現在サポートされているドキュメントタイプ:`txt`, `md`, `markdown`, `pdf`, `html`, `xlsx`, `xls`, `docx`, `csv`, `eml`, `msg`, `pptx`, `ppt`, `xml`, `epub`。- - `enabled` (bool) 有効かどうか- - `number_limits` (int) ドキュメント数の上限。デフォルトは 3- - `transfer_methods` (array[string]) 転送方法リスト:`remote_url`, `local_file`。いずれかを選択する必要があります。- - `image` (object) 画像設定- 現在サポートされている画像タイプ:`png`, `jpg`, `jpeg`, `webp`, `gif`。- - `enabled` (bool) 有効かどうか- - `number_limits` (int) 画像数の上限。デフォルトは 3- - `transfer_methods` (array[string]) 転送方法リスト:`remote_url`, `local_file`。いずれかを選択する必要があります。- - `audio` (object) オーディオ設定- 現在サポートされているオーディオタイプ:`mp3`, `m4a`, `wav`, `webm`, `amr`。- - `enabled` (bool) 有効かどうか- - `number_limits` (int) オーディオ数の上限。デフォルトは 3- - `transfer_methods` (array[string]) 転送方法リスト:`remote_url`, `local_file`。いずれかを選択する必要があります。- - `video` (object) ビデオ設定- 現在サポートされているビデオタイプ:`mp4`, `mov`, `mpeg`, `mpga`。- - `enabled` (bool) 有効かどうか- - `number_limits` (int) ビデオ数の上限。デフォルトは 3- - `transfer_methods` (array[string]) 転送方法リスト:`remote_url`, `local_file`。いずれかを選択する必要があります。- - `custom` (object) カスタム設定- - `enabled` (bool) 有効かどうか- - `number_limits` (int) カスタム数の上限。デフォルトは 3- - `transfer_methods` (array[string]) 転送方法リスト:`remote_url`, `local_file`。いずれかを選択する必要があります。- - `system_parameters` (object) システムパラメータ- - `file_size_limit` (int) ドキュメントアップロードサイズ制限(MB)- - `image_file_size_limit` (int) 画像ファイルアップロードサイズ制限(MB)- - `audio_file_size_limit` (int) オーディオファイルアップロードサイズ制限(MB)- - `video_file_size_limit` (int) ビデオファイルアップロードサイズ制限(MB)-- </Col>- <Col sticky>-- <CodeGroup- title="リクエスト"- tag="GET"- label="/parameters"- targetCode={` curl -X GET '${props.appDetail.api_base_url}/parameters'`}- />-- <CodeGroup title="応答">- ```json {{ title: '応答' }}- {- "user_input_form": [- {- "paragraph": {- "label": "Query",- "variable": "query",- "required": true,- "default": ""- }- }- ],- "file_upload": {- "image": {- "enabled": false,- "number_limits": 3,- "detail": "high",- "transfer_methods": [- "remote_url",- "local_file"- ]- }- },- "system_parameters": {- "file_size_limit": 15,- "image_file_size_limit": 10,- "audio_file_size_limit": 50,- "video_file_size_limit": 100- }- }- ```- </CodeGroup>- </Col>-</Row>-———--<Heading- url='/site'- method='GET'- title='アプリのWebApp設定を取得'- name='#site'-/>-<Row>- <Col>- アプリの WebApp 設定を取得するために使用します。- ### 応答- - `title` (string) WebApp 名- - `icon_type` (string) アイコンタイプ、`emoji`-絵文字、`image`-画像- - `icon` (string) アイコン。`emoji`タイプの場合は絵文字、`image`タイプの場合は画像 URL- - `icon_background` (string) 16 進数形式の背景色- - `icon_url` (string) アイコンの URL- - `description` (string) 説明- - `copyright` (string) 著作権情報- - `privacy_policy` (string) プライバシーポリシーのリンク- - `custom_disclaimer` (string) カスタム免責事項- - `default_language` (string) デフォルト言語- - `show_workflow_steps` (bool) ワークフローの詳細を表示するかどうか- </Col>- <Col>- <CodeGroup- title="Request"- tag="GET"- label="/site"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/site' \\- -H 'Authorization: Bearer {api_key}'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "title": "My App",- "icon_type": "emoji",- "icon": "😄",- "icon_background": "#FFEAD5",- "icon_url": null,- "description": "This is my app.",- "copyright": "all rights reserved",- "privacy_policy": "",- "custom_disclaimer": "All generated by AI",- "default_language": "en-US",- "show_workflow_steps": false,- }- ```- </CodeGroup>- </Col>-</Row>-___diff --git a/web/app/components/develop/template/template_workflow.zh.mdx b/web/app/components/develop/template/template_workflow.zh.mdxdeleted file mode 100644index b637a5f4ba6..00000000000--- a/web/app/components/develop/template/template_workflow.zh.mdx+++ /dev/null@@ -1,1629 +0,0 @@-import { CodeGroup } from '../code.tsx'-import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx'-import { WorkflowVersionApiContent, WorkflowVersionApiUpgradeNotice } from '../workflow-version-api-upgrade-notice.tsx'--# Workflow 应用 API--Workflow 应用无会话支持,适合用于翻译/文章写作/总结 AI 等等。--<div>- ### Base URL- <CodeGroup title="Code" targetCode={props.appDetail.api_base_url} />-- ### Authentication-- Service API 使用 `API-Key` 进行鉴权。- <i>**强烈建议开发者把 `API-Key` 放在后端存储,而非分享或者放在客户端存储,以免 `API-Key` 泄露,导致财产损失。**</i>- 所有 API 请求都应在 **`Authorization`** HTTP Header 中包含您的 `API-Key`,如下所示:-- <CodeGroup title="Code" targetCode='Authorization: Bearer {API_KEY}' />-</div>-------<Heading- url='/workflows/run'- method='POST'- title='执行 Workflow'- name='#Execute-Workflow'-/>-<Row>- <Col>- 执行 workflow,没有已发布的 workflow,不可执行。-- ### Request Body- - `inputs` (object) Required- 允许传入 App 定义的各变量值。- inputs 参数包含了多组键值对(Key/Value pairs),每组的键对应一个特定变量,每组的值则是该变量的具体值。变量可以是文件列表类型。- 文件列表类型变量适用于传入文件结合文本理解并回答问题,仅当模型支持该类型文件解析能力时可用。如果该变量是文件列表类型,该变量对应的值应是列表格式,其中每个元素应包含以下内容:- - `type` (string) 支持类型:- - `document` 具体类型包含:'TXT', 'MD', 'MARKDOWN', 'PDF', 'HTML', 'XLSX', 'XLS', 'DOCX', 'CSV', 'EML', 'MSG', 'PPTX', 'PPT', 'XML', 'EPUB'- - `image` 具体类型包含:'JPG', 'JPEG', 'PNG', 'GIF', 'WEBP', 'SVG'- - `audio` 具体类型包含:'MP3', 'M4A', 'WAV', 'WEBM', 'AMR'- - `video` 具体类型包含:'MP4', 'MOV', 'MPEG', 'MPGA'- - `custom` 具体类型包含:其他文件类型- - `transfer_method` (string) 传递方式,`remote_url` 图片地址 / `local_file` 上传文件- - `url` (string) 图片地址(仅当传递方式为 `remote_url` 时)- - `upload_file_id` (string) 上传文件 ID(仅当传递方式为 `local_file` 时)- - `response_mode` (string) Required- 返回响应模式,支持:- - `streaming` 流式模式(推荐)。基于 SSE(**[Server-Sent Events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events)**)实现类似打字机输出方式的流式返回。- - `blocking` 阻塞模式,等待执行完毕后返回结果。(请求若流程较长可能会被中断)。- <i>由于 Cloudflare 限制,请求会在 100 秒超时无返回后中断。</i>- - `user` (string) Required- 用户标识,用于定义终端用户的身份,方便检索、统计。- 由开发者定义规则,需保证用户标识在应用内唯一。API 无法访问 WebApp 创建的会话。- - `files` (array[object]) 可选- - `trace_id` (string) Optional- 链路追踪ID。适用于与业务系统已有的trace组件打通,实现端到端分布式追踪等场景。如果未指定,系统将自动生成 `trace_id`。支持以下三种方式传递,具体优先级依次为:- 1. Header:推荐通过 HTTP Header `X-Trace-Id` 传递,优先级最高。- 2. Query 参数:通过 URL 查询参数 `trace_id` 传递。- 3. Request Body:通过请求体字段 `trace_id` 传递(即本字段)。- - `trace_session_id` (string) Optional- 用于可观测性分组的链路会话 ID。支持会话分组的追踪提供商可将该值用作导出的会话标识。它不会改变 conversation_id、workflow_run_id、trace_id 或 span 关系。支持以下三种方式传递,具体优先级依次为:- 1. Header:通过 HTTP Header `X-Trace-Session-Id` 传递,优先级最高。- 2. Query 参数:通过 URL 查询参数 `trace_session_id` 传递。- 3. Request Body:通过请求体字段 `trace_session_id` 传递(即本字段)。-- ### Response- 当 `response_mode` 为 `blocking` 时,返回 CompletionResponse object。- 当 `response_mode` 为 `streaming`时,返回 ChunkCompletionResponse object 流式序列。-- ### CompletionResponse- 返回完整的 App 结果,`Content-Type` 为 `application/json` 。- - `workflow_run_id` (string) workflow 执行 ID- - `task_id` (string) 任务 ID,用于请求跟踪和下方的停止响应接口- - `data` (object) 详细内容- - `id` (string) workflow 执行 ID- - `workflow_id` (string) 关联 Workflow ID- - `status` (string) 执行状态, `running` / `succeeded` / `failed` / `stopped`- - `outputs` (json) Optional 输出内容- - `error` (string) Optional 错误原因- - `elapsed_time` (float) Optional 耗时(s)- - `total_tokens` (int) Optional 总使用 tokens- - `total_steps` (int) 总步数(冗余),默认 0- - `created_at` (timestamp) 开始时间- - `finished_at` (timestamp) 结束时间-- ### ChunkCompletionResponse- 返回 App 输出的流式块,`Content-Type` 为 `text/event-stream`。- 每个流式块均为 data: 开头,块之间以 `\n\n` 即两个换行符分隔,如下所示:- <CodeGroup>- ```streaming {{ title: 'Response' }}- data: {"event": "text_chunk", "workflow_run_id": "b85e5fc5-751b-454d-b14e-dc5f240b0a31", "task_id": "bd029338-b068-4d34-a331-fc85478922c2", "data": {"text": "\u4e3a\u4e86", "from_variable_selector": ["1745912968134", "text"]}}\n\n- ```- </CodeGroup>- 流式块中根据 `event` 不同,结构也不同,包含以下类型:- - `event: workflow_started` workflow 开始执行- - `task_id` (string) 任务 ID,用于请求跟踪和下方的停止响应接口- - `workflow_run_id` (string) workflow 执行 ID- - `event` (string) 固定为 `workflow_started`- - `data` (object) 详细内容- - `id` (string) workflow 执行 ID- - `workflow_id` (string) 关联 Workflow ID- - `created_at` (timestamp) 开始时间- - `event: node_started` node 开始执行- - `task_id` (string) 任务 ID,用于请求跟踪和下方的停止响应接口- - `workflow_run_id` (string) workflow 执行 ID- - `event` (string) 固定为 `node_started`- - `data` (object) 详细内容- - `id` (string) workflow 执行 ID- - `node_id` (string) 节点 ID- - `node_type` (string) 节点类型- - `title` (string) 节点名称- - `index` (int) 执行序号,用于展示 Tracing Node 顺序- - `predecessor_node_id` (string) 前置节点 ID,用于画布展示执行路径- - `inputs` (object) 节点中所有使用到的前置节点变量内容- - `created_at` (timestamp) 开始时间- - `event: text_chunk` 文本片段- - `task_id` (string) 任务 ID,用于请求跟踪和下方的停止响应接口- - `workflow_run_id` (string) workflow 执行 ID- - `event` (string) 固定为 `text_chunk`- - `data` (object) 详细内容- - `text` (string) 文本内容- - `from_variable_selector` (array) 文本来源路径,帮助开发者了解文本是由哪个节点的哪个变量生成的- - `event: node_finished` node 执行结束,成功失败同一事件中不同状态- - `task_id` (string) 任务 ID,用于请求跟踪和下方的停止响应接口- - `workflow_run_id` (string) workflow 执行 ID- - `event` (string) 固定为 `node_finished`- - `data` (object) 详细内容- - `id` (string) node 执行 ID- - `node_id` (string) 节点 ID- - `index` (int) 执行序号,用于展示 Tracing Node 顺序- - `predecessor_node_id` (string) optional 前置节点 ID,用于画布展示执行路径- - `inputs` (object) 节点中所有使用到的前置节点变量内容- - `process_data` (json) Optional 节点过程数据- - `outputs` (json) Optional 输出内容- - `status` (string) 执行状态 `running` / `succeeded` / `failed` / `stopped`- - `error` (string) Optional 错误原因- - `elapsed_time` (float) Optional 耗时(s)- - `execution_metadata` (json) 元数据- - `total_tokens` (int) optional 总使用 tokens- - `total_price` (decimal) optional 总费用- - `currency` (string) optional 货币,如 `USD` / `RMB`- - `created_at` (timestamp) 开始时间- - `event: human_input_required` Workflow 已暂停,等待 Human-in-the-Loop 输入- - `task_id` (string) 任务 ID,用于请求跟踪- - `workflow_run_id` (string) workflow 执行 ID- - `event` (string) 固定为 `human_input_required`- - `data` (object) 详细内容- - `form_id` (string) 人工输入表单 ID- - `node_id` (string) Human Input 节点 ID- - `node_title` (string) Human Input 节点标题- - `form_content` (string) 渲染后的表单内容- - `inputs` (array[object]) 表单输入项定义- - `actions` (array[object]) 用户可选动作按钮- - `id` (string) 动作 ID- - `title` (string) 按钮文案- - `button_style` (string) 按钮样式- - `display_in_ui` (bool) 是否需要在 UI 展示该表单- - `form_token` (string) 用于 `/form/human_input/:form_token` 接口的令牌- - `resolved_default_values` (object) 运行时解析后的默认值- - `expiration_time` (timestamp) 表单过期时间(Unix 秒级时间戳)- - `event: workflow_finished` workflow 执行结束,成功失败同一事件中不同状态- - `task_id` (string) 任务 ID,用于请求跟踪和下方的停止响应接口- - `workflow_run_id` (string) workflow 执行 ID- - `event` (string) 固定为 `workflow_finished`- - `data` (object) 详细内容- - `id` (string) workflow 执行 ID- - `workflow_id` (string) 关联 Workflow ID- - `status` (string) 执行状态 `running` / `succeeded` / `failed` / `stopped`- - `outputs` (json) Optional 输出内容- - `error` (string) Optional 错误原因- - `elapsed_time` (float) Optional 耗时(s)- - `total_tokens` (int) Optional 总使用 tokens- - `total_steps` (int) 总步数(冗余),默认 0- - `created_at` (timestamp) 开始时间- - `finished_at` (timestamp) 结束时间- - `event: tts_message` TTS 音频流事件,即:语音合成输出。内容是Mp3格式的音频块,使用 base64 编码后的字符串,播放的时候直接解码即可。(开启自动播放才有此消息)- - `task_id` (string) 任务 ID,用于请求跟踪和下方的停止响应接口- - `message_id` (string) 消息唯一 ID- - `audio` (string) 语音合成之后的音频块使用 Base64 编码之后的文本内容,播放的时候直接 base64 解码送入播放器即可- - `created_at` (int) 创建时间戳,如:1705395332- - `event: tts_message_end` TTS 音频流结束事件,收到这个事件表示音频流返回结束。- - `task_id` (string) 任务 ID,用于请求跟踪和下方的停止响应接口- - `message_id` (string) 消息唯一 ID- - `audio` (string) 结束事件是没有音频的,所以这里是空字符串- - `created_at` (int) 创建时间戳,如:1705395332- - `event: ping` 每 10s 一次的 ping 事件,保持连接存活。-- ### Errors- - 400,`invalid_param`,传入参数异常- - 400,`app_unavailable`,App 配置不可用- - 400,`provider_not_initialize`,无可用模型凭据配置- - 400,`provider_quota_exceeded`,模型调用额度不足- - 400,`model_currently_not_support`,当前模型不可用- - 400,`workflow_request_error`,workflow 执行失败- - 500,服务内部异常-- </Col>- <Col sticky>- <CodeGroup- title="Request"- tag="POST"- label="/workflows/run"- targetCode={`curl -X POST '${props.appDetail.api_base_url}/workflows/run' \\---header 'Authorization: Bearer {api_key}' \\---header 'Content-Type: application/json' \\---data-raw '{- "inputs": ${JSON.stringify(props.inputs)},- "response_mode": "streaming",- "user": "abc-123"-}'`}- />- <CodeGroup title="Example: file array as an input variable">- ```json {{ title: 'File variable example' }}- {- "inputs": {- "{variable_name}":- [- {- "transfer_method": "local_file",- "upload_file_id": "{upload_file_id}",- "type": "{document_type}"- }- ]- }- }- ```- </CodeGroup>- ### Blocking Mode- 阻塞模式可能返回已完成的工作流结果,也可能返回暂停中的工作流结果。-- 当执行因 Human-in-the-Loop 暂停时,响应仍然会包含 `workflow_run_id` 和 `task_id`,但 `data.status` 会变为 `paused`。- 暂停响应还会包含 `paused_nodes` 和 `reasons`。对于 `human_input_required`,每个 reason 都会包含 `form_id` 和 `expiration_time`。-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "workflow_run_id": "djflajgkldjgd",- "task_id": "9da23599-e713-473b-982c-4328d4f5c78a",- "data": {- "id": "fdlsjfjejkghjda",- "workflow_id": "fldjaslkfjlsda",- "status": "succeeded",- "outputs": {- "text": "Nice to meet you."- },- "error": null,- "elapsed_time": 0.875,- "total_tokens": 3562,- "total_steps": 8,- "created_at": 1705407629,- "finished_at": 1727807631- }- }- ```- </CodeGroup>- <CodeGroup title="Paused Response Example">- ```json {{ title: 'Paused Response Example' }}- {- "task_id": "3938b985-f4c6-4806-87b6-215e0aca9d81",- "workflow_run_id": "4a80f375-682b-49c5-b199-e950aac4968f",- "data": {- "id": "4a80f375-682b-49c5-b199-e950aac4968f",- "workflow_id": "e46514f1-c008-41ff-94b0-4f33d4b97d36",- "status": "paused",- "outputs": {},- "error": null,- "elapsed_time": 0.035667,- "total_tokens": 0,- "total_steps": 2,- "created_at": 1776074783,- "finished_at": null,- "paused_nodes": [- "1775717346519"- ],- "reasons": [- {- "form_id": "019d864e-7a36-74a2-b94e-e5660c47f5a7",- "form_content": "this is form 1:\n{{#$output.some_field#}}\n",- "inputs": [- {- "type": "paragraph",- "output_variable_name": "some_field",- "default": {- "type": "variable",- "selector": [- "sys",- "workflow_run_id"- ],- "value": ""- }- }- ],- "actions": [- {- "id": "approve",- "title": "YES",- "button_style": "default"- },- {- "id": "reject",- "title": "NO",- "button_style": "default"- }- ],- "display_in_ui": true,- "node_id": "1775717346519",- "node_title": "Human Input",- "resolved_default_values": {- "some_field": "4a80f375-682b-49c5-b199-e950aac4968f"- },- "form_token": "SZwvfmL47fTIsZynP2Jr9i",- "type": "human_input_required",- "expiration_time": 1776333983- }- ]- }- }- ```- </CodeGroup>- ### Streaming Mode- <CodeGroup title="Response">- ```streaming {{ title: 'Response' }}- data: {"event": "workflow_started", "task_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "workflow_run_id": "5ad498-f0c7-4085-b384-88cbe6290", "data": {"id": "5ad498-f0c7-4085-b384-88cbe6290", "workflow_id": "dfjasklfjdslag", "created_at": 1679586595}}- data: {"event": "node_started", "task_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "workflow_run_id": "5ad498-f0c7-4085-b384-88cbe6290", "data": {"id": "5ad498-f0c7-4085-b384-88cbe6290", "node_id": "dfjasklfjdslag", "node_type": "start", "title": "Start", "index": 0, "predecessor_node_id": "fdljewklfklgejlglsd", "inputs": {}, "created_at": 1679586595}}- data: {"event": "node_finished", "task_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "workflow_run_id": "5ad498-f0c7-4085-b384-88cbe6290", "data": {"id": "5ad498-f0c7-4085-b384-88cbe6290", "node_id": "dfjasklfjdslag", "node_type": "start", "title": "Start", "index": 0, "predecessor_node_id": "fdljewklfklgejlglsd", "inputs": {}, "outputs": {}, "status": "succeeded", "elapsed_time": 0.324, "execution_metadata": {"total_tokens": 63127864, "total_price": 2.378, "currency": "USD"}, "created_at": 1679586595}}- data: {"event": "workflow_finished", "task_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "workflow_run_id": "5ad498-f0c7-4085-b384-88cbe6290", "data": {"id": "5ad498-f0c7-4085-b384-88cbe6290", "workflow_id": "dfjasklfjdslag", "outputs": {}, "status": "succeeded", "elapsed_time": 0.324, "total_tokens": 63127864, "total_steps": "1", "created_at": 1679586595, "finished_at": 1679976595}}- data: {"event": "tts_message", "conversation_id": "23dd85f3-1a41-4ea0-b7a9-062734ccfaf9", "message_id": "a8bdc41c-13b2-4c18-bfd9-054b9803038c", "created_at": 1721205487, "task_id": "3bf8a0bb-e73b-4690-9e66-4e429bad8ee7", "audio": "qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq"}- data: {"event": "tts_message_end", "conversation_id": "23dd85f3-1a41-4ea0-b7a9-062734ccfaf9", "message_id": "a8bdc41c-13b2-4c18-bfd9-054b9803038c", "created_at": 1721205487, "task_id": "3bf8a0bb-e73b-4690-9e66-4e429bad8ee7", "audio": ""}- ```- </CodeGroup>- 流式模式同样可能因为 Human-in-the-Loop 而暂停。此时 SSE 流会先返回 `human_input_required`,随后返回 `workflow_paused`。-- <CodeGroup title="Paused Streaming Response Example">- ```streaming {{ title: 'Paused Streaming Response Example' }}- event: ping-- data: {- "event": "workflow_started",- "workflow_run_id": "a4959eb4-c852-4e0c-ac7a-348233f7f345",- "task_id": "0399c5c2-181b-4493-a78e-1421914e8a25",- "data": {- "id": "a4959eb4-c852-4e0c-ac7a-348233f7f345",- "workflow_id": "e46514f1-c008-41ff-94b0-4f33d4b97d36",- "inputs": {- "sys.files": [],- "sys.user_id": "abc-123",- "sys.app_id": "d1074979-f67e-4114-8691-e35878df9a89",- "sys.workflow_id": "e46514f1-c008-41ff-94b0-4f33d4b97d36",- "sys.workflow_run_id": "a4959eb4-c852-4e0c-ac7a-348233f7f345"- },- "created_at": 1776129228,- "reason": "initial"- }- }-- data: {- "event": "node_started",- "workflow_run_id": "a4959eb4-c852-4e0c-ac7a-348233f7f345",- "task_id": "0399c5c2-181b-4493-a78e-1421914e8a25",- "data": {- "id": "7d9bb041-5ecb-497f-a674-d8706eed0ab1",- "node_id": "1775717266623",- "node_type": "start",- "title": "User Input",- "index": 1,- "predecessor_node_id": null,- "inputs": null,- "inputs_truncated": false,- "created_at": 1776129228,- "extras": {},- "iteration_id": null,- "loop_id": null,- "agent_strategy": null- }- }-- data: {- "event": "node_finished",- "workflow_run_id": "a4959eb4-c852-4e0c-ac7a-348233f7f345",- "task_id": "0399c5c2-181b-4493-a78e-1421914e8a25",- "data": {- "id": "7d9bb041-5ecb-497f-a674-d8706eed0ab1",- "node_id": "1775717266623",- "node_type": "start",- "title": "User Input",- "index": 1,- "predecessor_node_id": null,- "inputs": {- "sys.files": [],- "sys.user_id": "abc-123",- "sys.app_id": "d1074979-f67e-4114-8691-e35878df9a89",- "sys.workflow_id": "e46514f1-c008-41ff-94b0-4f33d4b97d36",- "sys.workflow_run_id": "a4959eb4-c852-4e0c-ac7a-348233f7f345",- "sys.timestamp": 1776129228- },- "inputs_truncated": false,- "process_data": {},- "process_data_truncated": false,- "outputs": {- "sys.files": [],- "sys.user_id": "abc-123",- "sys.app_id": "d1074979-f67e-4114-8691-e35878df9a89",- "sys.workflow_id": "e46514f1-c008-41ff-94b0-4f33d4b97d36",- "sys.workflow_run_id": "a4959eb4-c852-4e0c-ac7a-348233f7f345",- "sys.timestamp": 1776129228- },- "outputs_truncated": false,- "status": "succeeded",- "error": null,- "elapsed_time": 0.000097,- "execution_metadata": null,- "created_at": 1776129228,- "finished_at": 1776129228,- "files": [],- "iteration_id": null,- "loop_id": null- }- }-- data: {- "event": "node_started",- "workflow_run_id": "a4959eb4-c852-4e0c-ac7a-348233f7f345",- "task_id": "0399c5c2-181b-4493-a78e-1421914e8a25",- "data": {- "id": "c09ff568-1d55-4f0d-9a07-512bcbfeb289",- "node_id": "1775717346519",- "node_type": "human-input",- "title": "Human Input",- "index": 1,- "predecessor_node_id": null,- "inputs": null,- "inputs_truncated": false,- "created_at": 1776129228,- "extras": {},- "iteration_id": null,- "loop_id": null,- "agent_strategy": null- }- }-- data: {- "event": "human_input_required",- "workflow_run_id": "a4959eb4-c852-4e0c-ac7a-348233f7f345",- "task_id": "0399c5c2-181b-4493-a78e-1421914e8a25",- "data": {- "form_id": "019d898d-3d80-7105-b920-9899ead4ff3e",- "node_id": "1775717346519",- "node_title": "Human Input",- "form_content": "this is form 1:\n{{#$output.some_field#}}\n",- "inputs": [- {- "type": "paragraph",- "output_variable_name": "some_field",- "default": {- "type": "variable",- "selector": [- "sys",- "workflow_run_id"- ],- "value": ""- }- }- ],- "actions": [- {- "id": "approve",- "title": "YES",- "button_style": "default"- },- {- "id": "reject",- "title": "NO",- "button_style": "default"- }- ],- "display_in_ui": true,- "form_token": "0Tb1nXYe4hzQUD706nHB4y",- "resolved_default_values": {- "some_field": "a4959eb4-c852-4e0c-ac7a-348233f7f345"- },- "expiration_time": 1776388428- }- }-- data: {- "event": "workflow_paused",- "workflow_run_id": "a4959eb4-c852-4e0c-ac7a-348233f7f345",- "task_id": "0399c5c2-181b-4493-a78e-1421914e8a25",- "data": {- "workflow_run_id": "a4959eb4-c852-4e0c-ac7a-348233f7f345",- "paused_nodes": [- "1775717346519"- ],- "outputs": {},- "reasons": [- {- "form_id": "019d898d-3d80-7105-b920-9899ead4ff3e",- "form_content": "this is form 1:\n{{#$output.some_field#}}\n",- "inputs": [- {- "type": "paragraph",- "output_variable_name": "some_field",- "default": {- "type": "variable",- "selector": [- "sys",- "workflow_run_id"- ],- "value": ""- }- }- ],- "actions": [- {- "id": "approve",- "title": "YES",- "button_style": "default"- },- {- "id": "reject",- "title": "NO",- "button_style": "default"- }- ],- "display_in_ui": true,- "node_id": "1775717346519",- "node_title": "Human Input",- "resolved_default_values": {- "some_field": "a4959eb4-c852-4e0c-ac7a-348233f7f345"- },- "form_token": "0Tb1nXYe4hzQUD706nHB4y",- "type": "human_input_required",- "expiration_time": 1776388428- }- ],- "status": "paused",- "created_at": 1776129228,- "elapsed_time": 0.070478,- "total_tokens": 0,- "total_steps": 2- }- }- ```- </CodeGroup>- <CodeGroup title="File upload sample code">- ```json {{ title: 'File upload sample code' }}- import requests- import json-- def upload_file(file_path, user):- upload_url = "https://api.dify.ai/v1/files/upload"- headers = {- "Authorization": "Bearer app-xxxxxxxx",- }-- try:- print("上传文件中...")- with open(file_path, 'rb') as file:- files = {- 'file': (file_path, file, 'text/plain') # 确保文件以适当的MIME类型上传- }- data = {- "user": user,- "type": "TXT" # 设置文件类型为TXT- }-- response = requests.post(upload_url, headers=headers, files=files, data=data)- if response.status_code == 201: # 201 表示创建成功- print("文件上传成功")- return response.json().get("id") # 获取上传的文件 ID- else:- print(f"文件上传失败,状态码: {response.status_code}")- return None- except Exception as e:- print(f"发生错误: {str(e)}")- return None-- def run_workflow(file_id, user, response_mode="blocking"):- workflow_url = "https://api.dify.ai/v1/workflows/run"- headers = {- "Authorization": "Bearer app-xxxxxxxxx",- "Content-Type": "application/json"- }-- data = {- "inputs": {- "orig_mail": [{- "transfer_method": "local_file",- "upload_file_id": file_id,- "type": "document"- }]- },- "response_mode": response_mode,- "user": user- }-- try:- print("运行工作流...")- response = requests.post(workflow_url, headers=headers, json=data)- if response.status_code == 200:- print("工作流执行成功")- return response.json()- else:- print(f"工作流执行失败,状态码: {response.status_code}")- return {"status": "error", "message": f"Failed to execute workflow, status code: {response.status_code}"}- except Exception as e:- print(f"发生错误: {str(e)}")- return {"status": "error", "message": str(e)}-- # 使用示例- file_path = "{your_file_path}"- user = "difyuser"-- # 上传文件- file_id = upload_file(file_path, user)- if file_id:- # 文件上传成功,继续运行工作流- result = run_workflow(file_id, user)- print(result)- else:- print("文件上传失败,无法执行工作流")- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/workflows/:workflow_id/run'- method='POST'- title='执行指定版本 Workflow'- name='#Execute-Specific-Workflow'- titleAction={<WorkflowVersionApiUpgradeNotice />}-/>-<WorkflowVersionApiContent>-<Row>- <Col>- 执行指定版本的工作流,通过路径参数指定工作流ID。-- ### Path- - `workflow_id` (string) Required 工作流ID,用于指定特定版本的工作流-- 获取方式:在版本历史界面,点击每个版本条目右侧的复制图标即可复制完整的工作流 ID。-- ### Request Body- - `inputs` (object) Required- 允许传入 App 定义的各变量值。- inputs 参数包含了多组键值对(Key/Value pairs),每组的键对应一个特定变量,每组的值则是该变量的具体值。变量可以是文件列表类型。- 文件列表类型变量适用于传入文件结合文本理解并回答问题,仅当模型支持该类型文件解析能力时可用。如果该变量是文件列表类型,该变量对应的值应是列表格式,其中每个元素应包含以下内容:- - `type` (string) 支持类型:- - `document` 具体类型包含:'TXT', 'MD', 'MARKDOWN', 'MDX', 'PDF', 'HTML', 'XLSX', 'XLS', 'VTT', 'PROPERTIES', 'DOC', 'DOCX', 'CSV', 'EML', 'MSG', 'PPTX', 'PPT', 'XML', 'EPUB'- - `image` 具体类型包含:'JPG', 'JPEG', 'PNG', 'GIF', 'WEBP', 'SVG'- - `audio` 具体类型包含:'MP3', 'M4A', 'WAV', 'WEBM', 'MPGA'- - `video` 具体类型包含:'MP4', 'MOV', 'MPEG', 'WEBM'- - `custom` 具体类型包含:其他文件类型- - `transfer_method` (string) 传递方式:- - `remote_url`: 文件地址。- - `local_file`: 上传文件。- - `url` 文件地址。(仅当传递方式为 `remote_url` 时)。- - `upload_file_id` 上传文件 ID。(仅当传递方式为 `local_file `时)。-- - `response_mode` (string) Required- 返回响应模式,支持:- - `streaming` 流式模式(推荐)。基于 SSE(**[Server-Sent Events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events)**)实现类似打字机输出方式的流式返回。- - `blocking` 阻塞模式,等待执行完毕后返回结果。(请求若流程较长可能会被中断)。- <i>由于 Cloudflare 限制,请求会在 100 秒超时无返回后中断。</i>- - `user` (string) Required- 用户标识,用于定义终端用户的身份,方便检索、统计。- 由开发者定义规则,需保证用户标识在应用内唯一。API 无法访问 WebApp 创建的会话。- - `files` (array[object]) 可选- - `trace_id` (string) Optional- 链路追踪ID。适用于与业务系统已有的trace组件打通,实现端到端分布式追踪等场景。如果未指定,系统将自动生成 `trace_id`。支持以下三种方式传递,具体优先级依次为:- 1. Header:推荐通过 HTTP Header `X-Trace-Id` 传递,优先级最高。- 2. Query 参数:通过 URL 查询参数 `trace_id` 传递。- 3. Request Body:通过请求体字段 `trace_id` 传递(即本字段)。- - `trace_session_id` (string) Optional- 用于可观测性分组的链路会话 ID。支持会话分组的追踪提供商可将该值用作导出的会话标识。它不会改变 conversation_id、workflow_run_id、trace_id 或 span 关系。支持以下三种方式传递,具体优先级依次为:- 1. Header:通过 HTTP Header `X-Trace-Session-Id` 传递,优先级最高。- 2. Query 参数:通过 URL 查询参数 `trace_session_id` 传递。- 3. Request Body:通过请求体字段 `trace_session_id` 传递(即本字段)。-- ### Response- 当 `response_mode` 为 `blocking` 时,返回 CompletionResponse object。- 当 `response_mode` 为 `streaming`时,返回 ChunkCompletionResponse object 流式序列。-- ### CompletionResponse- 返回完整的 App 结果,`Content-Type` 为 `application/json` 。- - `workflow_run_id` (string) workflow 执行 ID- - `task_id` (string) 任务 ID,用于请求跟踪和下方的停止响应接口- - `data` (object) 详细内容- - `id` (string) workflow 执行 ID- - `workflow_id` (string) 关联 Workflow ID- - `status` (string) 执行状态, `running` / `succeeded` / `failed` / `stopped`- - `outputs` (json) Optional 输出内容- - `error` (string) Optional 错误原因- - `elapsed_time` (float) Optional 耗时(s)- - `total_tokens` (int) Optional 总使用 tokens- - `total_steps` (int) 总步数(冗余),默认 0- - `created_at` (timestamp) 开始时间- - `finished_at` (timestamp) 结束时间-- ### ChunkCompletionResponse- 返回 App 输出的流式块,`Content-Type` 为 `text/event-stream`。- 每个流式块均为 data: 开头,块之间以 `\n\n` 即两个换行符分隔,如下所示:- <CodeGroup>- ```streaming {{ title: 'Response' }}- data: {"event": "text_chunk", "workflow_run_id": "b85e5fc5-751b-454d-b14e-dc5f240b0a31", "task_id": "bd029338-b068-4d34-a331-fc85478922c2", "data": {"text": "\u4e3a\u4e86", "from_variable_selector": ["1745912968134", "text"]}}\n\n- ```- </CodeGroup>- 流式块中根据 `event` 不同,结构也不同,包含以下类型:- - `event: workflow_started` workflow 开始执行- - `task_id` (string) 任务 ID,用于请求跟踪和下方的停止响应接口- - `workflow_run_id` (string) workflow 执行 ID- - `event` (string) 固定为 `workflow_started`- - `data` (object) 详细内容- - `id` (string) workflow 执行 ID- - `workflow_id` (string) 关联 Workflow ID- - `created_at` (timestamp) 开始时间- - `event: node_started` node 开始执行- - `task_id` (string) 任务 ID,用于请求跟踪和下方的停止响应接口- - `workflow_run_id` (string) workflow 执行 ID- - `event` (string) 固定为 `node_started`- - `data` (object) 详细内容- - `id` (string) workflow 执行 ID- - `node_id` (string) 节点 ID- - `node_type` (string) 节点类型- - `title` (string) 节点名称- - `index` (int) 执行序号,用于展示 Tracing Node 顺序- - `predecessor_node_id` (string) 前置节点 ID,用于画布展示执行路径- - `inputs` (object) 节点中所有使用到的前置节点变量内容- - `created_at` (timestamp) 开始时间- - `event: text_chunk` 文本片段- - `task_id` (string) 任务 ID,用于请求跟踪和下方的停止响应接口- - `workflow_run_id` (string) workflow 执行 ID- - `event` (string) 固定为 `text_chunk`- - `data` (object) 详细内容- - `text` (string) 文本内容- - `from_variable_selector` (array) 文本来源路径,帮助开发者了解文本是由哪个节点的哪个变量生成的- - `event: node_finished` node 执行结束,成功失败同一事件中不同状态- - `task_id` (string) 任务 ID,用于请求跟踪和下方的停止响应接口- - `workflow_run_id` (string) workflow 执行 ID- - `event` (string) 固定为 `node_finished`- - `data` (object) 详细内容- - `id` (string) node 执行 ID- - `node_id` (string) 节点 ID- - `index` (int) 执行序号,用于展示 Tracing Node 顺序- - `predecessor_node_id` (string) optional 前置节点 ID,用于画布展示执行路径- - `inputs` (object) 节点中所有使用到的前置节点变量内容- - `process_data` (json) Optional 节点过程数据- - `outputs` (json) Optional 输出内容- - `status` (string) 执行状态 `running` / `succeeded` / `failed` / `stopped`- - `error` (string) Optional 错误原因- - `elapsed_time` (float) Optional 耗时(s)- - `execution_metadata` (json) 元数据- - `total_tokens` (int) optional 总使用 tokens- - `total_price` (decimal) optional 总费用- - `currency` (string) optional 货币,如 `USD` / `RMB`- - `created_at` (timestamp) 开始时间- - `event: human_input_required` Workflow 已暂停,等待 Human-in-the-Loop 输入- - `task_id` (string) 任务 ID,用于请求跟踪- - `workflow_run_id` (string) workflow 执行 ID- - `event` (string) 固定为 `human_input_required`- - `data` (object) 详细内容- - `form_id` (string) 人工输入表单 ID- - `node_id` (string) Human Input 节点 ID- - `node_title` (string) Human Input 节点标题- - `form_content` (string) 渲染后的表单内容- - `inputs` (array[object]) 表单输入项定义- - `actions` (array[object]) 用户可选动作按钮- - `id` (string) 动作 ID- - `title` (string) 按钮文案- - `button_style` (string) 按钮样式- - `display_in_ui` (bool) 是否需要在 UI 展示该表单- - `form_token` (string) 用于 `/form/human_input/:form_token` 接口的令牌- - `resolved_default_values` (object) 运行时解析后的默认值- - `expiration_time` (timestamp) 表单过期时间(Unix 秒级时间戳)- - `event: workflow_finished` workflow 执行结束,成功失败同一事件中不同状态- - `task_id` (string) 任务 ID,用于请求跟踪和下方的停止响应接口- - `workflow_run_id` (string) workflow 执行 ID- - `event` (string) 固定为 `workflow_finished`- - `data` (object) 详细内容- - `id` (string) workflow 执行 ID- - `workflow_id` (string) 关联 Workflow ID- - `status` (string) 执行状态 `running` / `succeeded` / `failed` / `stopped`- - `outputs` (json) Optional 输出内容- - `error` (string) Optional 错误原因- - `elapsed_time` (float) Optional 耗时(s)- - `total_tokens` (int) Optional 总使用 tokens- - `total_steps` (int) 总步数(冗余),默认 0- - `created_at` (timestamp) 开始时间- - `finished_at` (timestamp) 结束时间- - `event: tts_message` TTS 音频流事件,即:语音合成输出。内容是Mp3格式的音频块,使用 base64 编码后的字符串,播放的时候直接解码即可。(开启自动播放才有此消息)- - `task_id` (string) 任务 ID,用于请求跟踪和下方的停止响应接口- - `message_id` (string) 消息唯一 ID- - `audio` (string) 语音合成之后的音频块使用 Base64 编码之后的文本内容,播放的时候直接 base64 解码送入播放器即可- - `created_at` (int) 创建时间戳,如:1705395332- - `event: tts_message_end` TTS 音频流结束事件,收到这个事件表示音频流返回结束。- - `task_id` (string) 任务 ID,用于请求跟踪和下方的停止响应接口- - `message_id` (string) 消息唯一 ID- - `audio` (string) 结束事件是没有音频的,所以这里是空字符串- - `created_at` (int) 创建时间戳,如:1705395332- - `event: ping` 每 10s 一次的 ping 事件,保持连接存活。-- ### Errors- - 400,`invalid_param`,传入参数异常- - 400,`app_unavailable`,App 配置不可用- - 400,`provider_not_initialize`,无可用模型凭据配置- - 400,`provider_quota_exceeded`,模型调用额度不足- - 400,`model_currently_not_support`,当前模型不可用- - 400,`workflow_not_found`,指定的工作流版本未找到- - 400,`draft_workflow_error`,无法使用草稿工作流版本- - 400,`workflow_id_format_error`,工作流ID格式错误,需要UUID格式- - 400,`workflow_request_error`,workflow 执行失败- - 403,`workflow_version_execution_not_allowed`,当前套餐不支持执行工作流版本,请升级至付费套餐- - 500,服务内部异常-- </Col>- <Col sticky>- <CodeGroup- title="Request"- tag="POST"- label="/workflows/:workflow_id/run"- targetCode={`curl -X POST '${props.appDetail.api_base_url}/workflows/{workflow_id}/run' \\---header 'Authorization: Bearer {api_key}' \\---header 'Content-Type: application/json' \\---data-raw '{- "inputs": ${JSON.stringify(props.inputs)},- "response_mode": "streaming",- "user": "abc-123"-}'`}- />- <CodeGroup title="Example: file array as an input variable">- ```json {{ title: 'File variable example' }}- {- "inputs": {- "{variable_name}":- [- {- "transfer_method": "local_file",- "upload_file_id": "{upload_file_id}",- "type": "{document_type}"- }- ]- }- }- ```- </CodeGroup>- ### Blocking Mode- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "workflow_run_id": "djflajgkldjgd",- "task_id": "9da23599-e713-473b-982c-4328d4f5c78a",- "data": {- "id": "fdlsjfjejkghjda",- "workflow_id": "fldjaslkfjlsda",- "status": "succeeded",- "outputs": {- "text": "Nice to meet you."- },- "error": null,- "elapsed_time": 0.875,- "total_tokens": 3562,- "total_steps": 8,- "created_at": 1705407629,- "finished_at": 1727807631- }- }- ```- </CodeGroup>- ### Streaming Mode- <CodeGroup title="Response">- ```streaming {{ title: 'Response' }}- data: {"event": "workflow_started", "task_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "workflow_run_id": "5ad498-f0c7-4085-b384-88cbe6290", "data": {"id": "5ad498-f0c7-4085-b384-88cbe6290", "workflow_id": "dfjasklfjdslag", "created_at": 1679586595}}- data: {"event": "node_started", "task_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "workflow_run_id": "5ad498-f0c7-4085-b384-88cbe6290", "data": {"id": "5ad498-f0c7-4085-b384-88cbe6290", "node_id": "dfjasklfjdslag", "node_type": "start", "title": "Start", "index": 0, "predecessor_node_id": "fdljewklfklgejlglsd", "inputs": {}, "created_at": 1679586595}}- data: {"event": "node_finished", "task_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "workflow_run_id": "5ad498-f0c7-4085-b384-88cbe6290", "data": {"id": "5ad498-f0c7-4085-b384-88cbe6290", "node_id": "dfjasklfjdslag", "node_type": "start", "title": "Start", "index": 0, "predecessor_node_id": "fdljewklfklgejlglsd", "inputs": {}, "outputs": {}, "status": "succeeded", "elapsed_time": 0.324, "execution_metadata": {"total_tokens": 63127864, "total_price": 2.378, "currency": "USD"}, "created_at": 1679586595}}- data: {"event": "workflow_finished", "task_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "workflow_run_id": "5ad498-f0c7-4085-b384-88cbe6290", "data": {"id": "5ad498-f0c7-4085-b384-88cbe6290", "workflow_id": "dfjasklfjdslag", "outputs": {}, "status": "succeeded", "elapsed_time": 0.324, "total_tokens": 63127864, "total_steps": "1", "created_at": 1679586595, "finished_at": 1679976595}}- data: {"event": "tts_message", "conversation_id": "23dd85f3-1a41-4ea0-b7a9-062734ccfaf9", "message_id": "a8bdc41c-13b2-4c18-bfd9-054b9803038c", "created_at": 1721205487, "task_id": "3bf8a0bb-e73b-4690-9e66-4e429bad8ee7", "audio": "qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq"}- data: {"event": "tts_message_end", "conversation_id": "23dd85f3-1a41-4ea0-b7a9-062734ccfaf9", "message_id": "a8bdc41c-13b2-4c18-bfd9-054b9803038c", "created_at": 1721205487, "task_id": "3bf8a0bb-e73b-4690-9e66-4e429bad8ee7", "audio": ""}- ```- </CodeGroup>- </Col>-</Row>-</WorkflowVersionApiContent>-------<Heading- url='/workflows/run/:workflow_run_id'- method='GET'- title='获取 Workflow 执行情况'- name='#get-workflow-run-detail'-/>-<Row>- <Col>- 根据 workflow 执行 ID 获取 workflow 任务当前执行结果- ### Path- - `workflow_run_id` (string) workflow 执行 ID,可在流式返回 Chunk 中获取- ### Response- - `id` (string) workflow 执行 ID- - `workflow_id` (string) 关联的 Workflow ID- - `status` (string) 执行状态 `running` / `succeeded` / `failed` / `stopped`- - `inputs` (json) 任务输入内容- - `outputs` (json) 任务输出内容- - `error` (string) 错误原因- - `total_steps` (int) 任务执行总步数- - `total_tokens` (int) 任务执行总 tokens- - `created_at` (timestamp) 任务开始时间- - `finished_at` (timestamp) 任务结束时间- - `elapsed_time` (float) 耗时 (s)- </Col>- <Col sticky>- ### Request Example- <CodeGroup- title="Request"- tag="GET"- label="/workflows/run/:workflow_run_id"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/workflows/run/:workflow_run_id' \\--H 'Authorization: Bearer {api_key}' \\--H 'Content-Type: application/json'`}- />-- ### Response Example- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "id": "b1ad3277-089e-42c6-9dff-6820d94fbc76",- "workflow_id": "19eff89f-ec03-4f75-b0fc-897e7effea02",- "status": "succeeded",- "inputs": "{\"sys.files\": [], \"sys.user_id\": \"abc-123\"}",- "outputs": null,- "error": null,- "total_steps": 3,- "total_tokens": 0,- "created_at": 1705407629,- "finished_at": 1727807631,- "elapsed_time": 30.098514399956912- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/workflows/tasks/:task_id/stop'- method='POST'- title='停止响应'- name='#stop-generatebacks'-/>-<Row>- <Col>- 仅支持流式模式。- ### Path- - `task_id` (string) 任务 ID,可在流式返回 Chunk 中获取- ### Request Body- - `user` (string) Required- 用户标识,用于定义终端用户的身份,必须和发送消息接口传入 user 保持一致。API 无法访问 WebApp 创建的会话。- ### Response- - `result` (string) 固定返回 "success"- </Col>- <Col sticky>- ### Request Example- <CodeGroup- title="Request"- tag="POST"- label="/workflows/tasks/:task_id/stop"- targetCode={`curl -X POST '${props.appDetail.api_base_url}/workflows/tasks/:task_id/stop' \\--H 'Authorization: Bearer {api_key}' \\--H 'Content-Type: application/json' \\---data-raw '{"user": "abc-123"}'`}- />-- ### Response Example- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "result": "success"- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/form/human_input/:form_token'- method='GET'- title='获取人工输入表单'- name='#get-human-input-form'-/>-<Row>- <Col>- 通过 `form_token` 获取待处理的 Human-in-the-Loop 表单。-- 当 Workflow 在流式事件中返回 `human_input_required`(包含 `form_token`)时,可调用此接口拉取表单详情。-- ### Path- - `form_token` (string) 必填,暂停事件返回的表单 token-- ### Response- - `form_content` (string) 已渲染的表单内容(markdown/plain text)- - `inputs` (array[object]) 表单输入项定义- - `resolved_default_values` (object) 已解析的默认值(字符串)- - `user_actions` (array[object]) 操作按钮列表- - `expiration_time` (timestamp) 表单过期时间(Unix 秒)-- ### Errors- - 404,表单不存在或不属于当前应用- - 412,`human_input_form_submitted`,表单已被提交- - 412,`human_input_form_expired`,表单已过期- </Col>- <Col sticky>- <CodeGroup- title="Request"- tag="GET"- label="/form/human_input/:form_token"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/form/human_input/{form_token}' \\---header 'Authorization: Bearer {api_key}'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "form_content": "请确认最终结果:{{#$output.answer#}}",- "inputs": [- {- "label": "答案",- "type": "text-input",- "required": true,- "output_variable_name": "answer"- }- ],- "resolved_default_values": {- "answer": "初始值"- },- "user_actions": [- { "id": "approve", "title": "通过", "button_style": "primary" },- { "id": "reject", "title": "拒绝", "button_style": "warning" }- ],- "expiration_time": 1735689600- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/form/human_input/:form_token'- method='POST'- title='提交人工输入表单'- name='#submit-human-input-form'-/>-<Row>- <Col>- 提交待处理的 Human-in-the-Loop 表单。-- ### Path- - `form_token` (string) 必填,暂停事件返回的表单 token-- ### Request Body- - `inputs` (object) 必填,表单字段的 key/value- - `action` (string) 必填,从 `user_actions` 中选择的动作 ID- - `user` (string) 必填,终端用户标识-- ### Response- 成功时返回空对象。-- ### Errors- - 400,`invalid_form_data`,提交数据与表单 schema 不匹配- - 404,表单不存在或不属于当前应用- - 412,`human_input_form_submitted`,表单已被提交- - 412,`human_input_form_expired`,表单已过期- </Col>- <Col sticky>- <CodeGroup- title="Request"- tag="POST"- label="/form/human_input/:form_token"- targetCode={`curl -X POST '${props.appDetail.api_base_url}/form/human_input/{form_token}' \\---header 'Authorization: Bearer {api_key}' \\---header 'Content-Type: application/json' \\---data-raw '{- "inputs": {"answer": "已确认答案"},- "action": "approve",- "user": "abc-123"-}'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {}- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/workflow/:task_id/events'- method='GET'- title='获取恢复后的 Workflow 事件流'- name='#get-workflow-resume-events'-/>-<Row>- <Col>- 在提交人工输入表单后,继续订阅工作流后续执行事件。-- 返回 `text/event-stream`,可持续接收直到工作流结束。-- ### Path- - `task_id` (string) 必填,workflow 运行 ID(`workflow_run_id`)-- ### Query- - `user` (string) 必填,终端用户标识- - `include_state_snapshot` (bool) 可选,设为 `true` 时会先回放持久化状态快照,再继续实时事件- - `continue_on_pause` (bool) 可选,设为 `true` 时,流会在 `workflow_paused` 事件之间保持连接,直到 `workflow_finished` 才结束-- ### Response- Server-Sent Events 流(`text/event-stream`)。- 常见事件包括 `workflow_paused`、`node_started`、`node_finished`、`human_input_form_filled`、`human_input_form_timeout`、`workflow_finished`。- 如果调用该接口时工作流已经结束,服务端会立即返回单个完成事件。- </Col>- <Col sticky>- <CodeGroup- title="Request"- tag="GET"- label="/workflow/:task_id/events"- targetCode={`curl -N -X GET '${props.appDetail.api_base_url}/workflow/{workflow_run_id}/events?user=abc-123&continue_on_pause=true' \\---header 'Authorization: Bearer {api_key}'`}- />-- <CodeGroup title="Response">- ```streaming {{ title: 'Response' }}- event: ping-- data: {"event":"workflow_started","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","data":{"id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","workflow_id":"e46514f1-c008-41ff-94b0-4f33d4b97d36","inputs":{"sys.files":[],"sys.user_id":"abc-123","sys.app_id":"d1074979-f67e-4114-8691-e35878df9a89","sys.workflow_id":"e46514f1-c008-41ff-94b0-4f33d4b97d36","sys.workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","sys.timestamp":1776087863},"created_at":1776087863,"reason":"initial"}}-- data: {"event":"node_started","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","data":{"id":"b552d685-1119-4e6a-9a81-e91a23e5324b","node_id":"1775717266623","node_type":"start","title":"User Input","index":1,"predecessor_node_id":null,"inputs":null,"created_at":1776087863,"extras":{},"iteration_id":null,"loop_id":null}}-- data: {"event":"node_finished","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","data":{"id":"b552d685-1119-4e6a-9a81-e91a23e5324b","node_id":"1775717266623","node_type":"start","title":"User Input","index":1,"predecessor_node_id":null,"inputs":null,"process_data":null,"outputs":null,"status":"succeeded","error":null,"elapsed_time":0.00032,"execution_metadata":null,"created_at":1776087863,"finished_at":1776087863,"files":[],"iteration_id":null,"loop_id":null}}-- data: {"event":"node_started","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","data":{"id":"8d7e8e01-5159-4089-a4b6-3aa394992cc2","node_id":"1775717346519","node_type":"human-input","title":"Human Input","index":2,"predecessor_node_id":null,"inputs":null,"created_at":1776087863,"extras":{},"iteration_id":null,"loop_id":null}}-- data: {"event":"node_finished","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","data":{"id":"8d7e8e01-5159-4089-a4b6-3aa394992cc2","node_id":"1775717346519","node_type":"human-input","title":"Human Input","index":2,"predecessor_node_id":null,"inputs":null,"process_data":null,"outputs":null,"status":"paused","error":null,"elapsed_time":0.007381,"execution_metadata":null,"created_at":1776087863,"finished_at":1776087863,"files":[],"iteration_id":null,"loop_id":null}}-- data: {"event":"workflow_paused","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","data":{"workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","paused_nodes":["1775717346519"],"outputs":{},"reasons":[{"form_id":"019d8716-0fde-75da-8207-1458ccde76e5","form_content":"this is form 1:\n{{#$output.some_field#}}\n","inputs":[{"type":"paragraph","output_variable_name":"some_field","default":{"type":"variable","selector":["sys","workflow_run_id"],"value":""}}],"actions":[{"id":"approve","title":"YES","button_style":"default"},{"id":"reject","title":"NO","button_style":"default"}],"display_in_ui":true,"node_id":"1775717346519","node_title":"Human Input","resolved_default_values":{"some_field":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c"},"form_token":"n7hFG4ZDYdGcgZ5VDc7EGM","type":"human_input_required"}],"status":"paused","created_at":1776087863,"elapsed_time":0.0,"total_tokens":0,"total_steps":2}}-- data: {"event":"workflow_started","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","data":{"id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","workflow_id":"e46514f1-c008-41ff-94b0-4f33d4b97d36","inputs":{"sys.files":[],"sys.user_id":"abc-123","sys.app_id":"d1074979-f67e-4114-8691-e35878df9a89","sys.workflow_id":"e46514f1-c008-41ff-94b0-4f33d4b97d36","sys.workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c"},"created_at":1776087877,"reason":"resumption"}}-- data: {"event":"node_started","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","data":{"id":"8d7e8e01-5159-4089-a4b6-3aa394992cc2","node_id":"1775717346519","node_type":"human-input","title":"Human Input","index":1,"predecessor_node_id":null,"inputs":null,"inputs_truncated":false,"created_at":1776087877,"extras":{},"iteration_id":null,"loop_id":null,"agent_strategy":null}}-- data: {"event":"human_input_form_filled","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","data":{"node_id":"1775717346519","node_title":"Human Input","rendered_content":"this is form 1:\nfield 1 filled!\n","action_id":"approve","action_text":"YES"}}-- data: {"event":"node_finished","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","data":{"id":"8d7e8e01-5159-4089-a4b6-3aa394992cc2","node_id":"1775717346519","node_type":"human-input","title":"Human Input","index":1,"predecessor_node_id":null,"inputs":{},"inputs_truncated":false,"process_data":{},"process_data_truncated":false,"outputs":{"some_field":"field 1 filled!","some_field_2":"from bruno with love","__action_id":"approve","__rendered_content":"this is form 1:\nfield 1 filled!\n"},"outputs_truncated":false,"status":"succeeded","error":null,"elapsed_time":0.004431,"execution_metadata":null,"created_at":1776087877,"finished_at":1776087877,"files":[],"iteration_id":null,"loop_id":null}}-- data: {"event":"node_started","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","data":{"id":"6d8fc3cb-19f7-440b-b83e-eed4e847a332","node_id":"1775717350710","node_type":"template-transform","title":"Template","index":1,"predecessor_node_id":null,"inputs":null,"inputs_truncated":false,"created_at":1776087877,"extras":{},"iteration_id":null,"loop_id":null,"agent_strategy":null}}-- data: {"event":"text_chunk","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","data":{"text":"field 1 filled!","from_variable_selector":["1775717350710","output"]}}-- data: {"event":"node_finished","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","data":{"id":"6d8fc3cb-19f7-440b-b83e-eed4e847a332","node_id":"1775717350710","node_type":"template-transform","title":"Template","index":1,"predecessor_node_id":null,"inputs":{"some_field":"field 1 filled!"},"inputs_truncated":false,"process_data":{},"process_data_truncated":false,"outputs":{"output":"field 1 filled!"},"outputs_truncated":false,"status":"succeeded","error":null,"elapsed_time":0.264614,"execution_metadata":null,"created_at":1776087877,"finished_at":1776087877,"files":[],"iteration_id":null,"loop_id":null}}-- data: {"event":"node_started","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","data":{"id":"e88dec7e-aa2c-41f7-8d73-032b749e23f5","node_id":"1775717354177","node_type":"end","title":"Output","index":1,"predecessor_node_id":null,"inputs":null,"inputs_truncated":false,"created_at":1776087877,"extras":{},"iteration_id":null,"loop_id":null,"agent_strategy":null}}-- data: {"event":"node_finished","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","data":{"id":"e88dec7e-aa2c-41f7-8d73-032b749e23f5","node_id":"1775717354177","node_type":"end","title":"Output","index":1,"predecessor_node_id":null,"inputs":{"output":"field 1 filled!"},"inputs_truncated":false,"process_data":{},"process_data_truncated":false,"outputs":{"output":"field 1 filled!"},"outputs_truncated":false,"status":"succeeded","error":null,"elapsed_time":0.00003,"execution_metadata":null,"created_at":1776087877,"finished_at":1776087877,"files":[],"iteration_id":null,"loop_id":null}}-- data: {"event":"workflow_finished","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","data":{"id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","workflow_id":"e46514f1-c008-41ff-94b0-4f33d4b97d36","status":"succeeded","outputs":{"output":"field 1 filled!"},"error":null,"elapsed_time":0.364935,"total_tokens":0,"total_steps":5,"created_by":{"id":"7932d34c-dcf4-4fba-b770-f2a9de88c0a0","user":"abc-123"},"created_at":1776087877,"finished_at":1776087877,"exceptions_count":0,"files":[]}}- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/files/upload'- method='POST'- title='上传文件'- name='#files-upload'-/>-<Row>- <Col>- 上传文件并在发送消息时使用,可实现图文多模态理解。- 支持您的工作流程所支持的任何格式。- <i>上传的文件仅供当前终端用户使用。</i>-- ### Request Body- 该接口需使用 `multipart/form-data` 进行请求。- <Properties>- <Property name='file' type='file' key='file'>- 要上传的文件。- </Property>- <Property name='user' type='string' key='user'>- 用户标识,用于定义终端用户的身份,必须和发送消息接口传入 user 保持一致。服务 API 不会共享 WebApp 创建的对话。- </Property>- </Properties>-- ### Response- 成功上传后,服务器会返回文件的 ID 和相关信息。- - `id` (uuid) ID- - `name` (string) 文件名- - `size` (int) 文件大小(byte)- - `extension` (string) 文件后缀- - `mime_type` (string) 文件 mime-type- - `created_by` (uuid) 上传人 ID- - `created_at` (timestamp) 上传时间-- ### Errors- - 400,`no_file_uploaded`,必须提供文件- - 400,`too_many_files`,目前只接受一个文件- - 400,`unsupported_preview`,该文件不支持预览- - 400,`unsupported_estimate`,该文件不支持估算- - 413,`file_too_large`,文件太大- - 415,`unsupported_file_type`,不支持的扩展名,当前只接受文档类文件- - 503,`s3_connection_failed`,无法连接到 S3 服务- - 503,`s3_permission_denied`,无权限上传文件到 S3- - 503,`s3_file_too_large`,文件超出 S3 大小限制- </Col>- <Col sticky>-- <CodeGroup- title="Request"- tag="POST"- label="/files/upload"- targetCode={`curl -X POST '${props.appDetail.api_base_url}/files/upload' \\---header 'Authorization: Bearer {api_key}' \\---form 'file=@localfile;type=image/[png|jpeg|jpg|webp|gif]' \\---form 'user=abc-123'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "id": "72fa9618-8f89-4a37-9b33-7e1178a24a67",- "name": "example.png",- "size": 1024,- "extension": "png",- "mime_type": "image/png",- "created_by": 123,- "created_at": 1577836800,- }- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/end-users/:end_user_id'- method='GET'- title='获取终端用户'- name='#end-user'-/>-<Row>- <Col>- 通过终端用户 ID 获取终端用户信息。-- 当其他 API 返回终端用户 ID(例如:上传文件接口返回的 `created_by`)时,可使用该接口查询对应的终端用户信息。-- ### 路径参数- - `end_user_id` (uuid) 必需- 终端用户 ID。-- ### Response- 返回 EndUser 对象。- - `id` (uuid) ID- - `tenant_id` (uuid) 工作空间(Tenant)ID- - `app_id` (uuid) 应用 ID- - `type` (string) 终端用户类型- - `external_user_id` (string) 外部用户 ID- - `name` (string) 名称- - `is_anonymous` (boolean) 是否匿名- - `session_id` (string) 会话 ID- - `created_at` (string) ISO 8601 时间- - `updated_at` (string) ISO 8601 时间-- ### Errors- - 404,`end_user_not_found`,终端用户不存在- - 500,内部服务器错误-- </Col>- <Col sticky>- <CodeGroup- title="Request"- tag="GET"- label="/end-users/:end_user_id"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/end-users/6ad1ab0a-73ff-4ac1-b9e4-cdb312f71f13' \\---header 'Authorization: Bearer {api_key}'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "id": "6ad1ab0a-73ff-4ac1-b9e4-cdb312f71f13",- "tenant_id": "8c0f3f3a-66b0-4b55-a0bf-8b8e0d6aee7d",- "app_id": "6c8c3f41-2c6f-4e1b-8f4f-7f11c8f2ad2a",- "type": "service_api",- "external_user_id": "abc-123",- "name": "Alice",- "is_anonymous": false,- "session_id": "abc-123",- "created_at": "2024-01-01T00:00:00Z",- "updated_at": "2024-01-01T00:00:00Z"- }- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/workflows/logs'- method='GET'- title='获取 Workflow 日志'- name='#Get-Workflow-Logs'-/>-<Row>- <Col>- 倒序返回 workflow 日志-- ### Query-- <Properties>- <Property name='keyword' type='string' key='keyword'>- 关键字- </Property>- <Property name='status' type='string' key='status'>- 执行状态 succeeded/failed/stopped- </Property>- <Property name='page' type='int' key='page'>- 当前页码, 默认1.- </Property>- <Property name='limit' type='int' key='limit'>- 每页条数, 默认20.- </Property>- <Property name='created_by_end_user_session_id' type='str' key='created_by_end_user_session_id'>- 由哪个endUser创建,例如,`abc-123`.- </Property>- <Property name='created_by_account' type='str' key='created_by_account'>- 由哪个邮箱账户创建,例如,[email protected].- </Property>- </Properties>-- ### Response- - `page` (int) 当前页码- - `limit` (int) 每页条数- - `total` (int) 总条数- - `has_more` (bool) 是否还有更多数据- - `data` (array[object]) 当前页码的数据- - `id` (string) 标识- - `workflow_run` (object) Workflow 执行日志- - `id` (string) 标识- - `version` (string) 版本- - `status` (string) 执行状态,`running` / `succeeded` / `failed` / `stopped`- - `error` (string) (可选) 错误- - `elapsed_time` (float) 耗时,单位秒- - `total_tokens` (int) 消耗的 token 数量- - `total_steps` (int) 执行步骤长度- - `created_at` (timestamp) 开始时间- - `finished_at` (timestamp) 结束时间- - `created_from` (string) 来源- - `created_by_role` (string) 角色- - `created_by_account` (string) (可选) 帐号- - `created_by_end_user` (object) 用户- - `id` (string) 标识- - `type` (string) 类型- - `is_anonymous` (bool) 是否匿名- - `session_id` (string) 会话标识- - `created_at` (timestamp) 创建时间- </Col>- <Col sticky>-- <CodeGroup- title="Request"- tag="GET"- label="/workflows/logs"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/workflows/logs'\\---header 'Authorization: Bearer {api_key}'`}- />- ### Response Example- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "page": 1,- "limit": 1,- "total": 7,- "has_more": true,- "data": [- {- "id": "e41b93f1-7ca2-40fd-b3a8-999aeb499cc0",- "workflow_run": {- "id": "c0640fc8-03ef-4481-a96c-8a13b732a36e",- "version": "2024-08-01 12:17:09.771832",- "status": "succeeded",- "error": null,- "elapsed_time": 1.3588523610014818,- "total_tokens": 0,- "total_steps": 3,- "created_at": 1726139643,- "finished_at": 1726139644- },- "created_from": "service-api",- "created_by_role": "end_user",- "created_by_account": null,- "created_by_end_user": {- "id": "7f7d9117-dd9d-441d-8970-87e5e7e687a3",- "type": "service_api",- "is_anonymous": false,- "session_id": "abc-123"- },- "created_at": 1726139644- }- ]- }- ```- </CodeGroup>- </Col>-</Row>------<Heading- url='/info'- method='GET'- title='获取应用基本信息'- name='#info'-/>-<Row>- <Col>- 用于获取应用的基本信息- ### Response- - `name` (string) 应用名称- - `description` (string) 应用描述- - `tags` (array[string]) 应用标签- - `mode` (string) 应用模式- - 'author_name' (string) 作者名称- </Col>- <Col>- <CodeGroup- title="Request"- tag="GET"- label="/info"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/info' \\--H 'Authorization: Bearer {api_key}'`}- />- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "name": "My App",- "description": "This is my app.",- "tags": [- "tag1",- "tag2"- ],- "mode": "workflow",- "author_name": "Dify"- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/parameters'- method='GET'- title='获取应用参数'- name='#parameters'-/>-<Row>- <Col>- 用于进入页面一开始,获取功能开关、输入参数名称、类型及默认值等使用。-- ### Response- - `user_input_form` (array[object]) 用户输入表单配置- - `text-input` (object) 文本输入控件- - `label` (string) 控件展示标签名- - `variable` (string) 控件 ID- - `required` (bool) 是否必填- - `default` (string) 默认值- - `paragraph` (object) 段落文本输入控件- - `label` (string) 控件展示标签名- - `variable` (string) 控件 ID- - `required` (bool) 是否必填- - `default` (string) 默认值- - `select` (object) 下拉控件- - `label` (string) 控件展示标签名- - `variable` (string) 控件 ID- - `required` (bool) 是否必填- - `default` (string) 默认值- - `options` (array[string]) 选项值- - `file_upload` (object) 文件上传配置- - `document` (object) 文档设置- 当前仅支持文档类型:`txt`, `md`, `markdown`, `pdf`, `html`, `xlsx`, `xls`, `docx`, `csv`, `eml`, `msg`, `pptx`, `ppt`, `xml`, `epub`。- - `enabled` (bool) 是否启用- - `number_limits` (int) 文档数量限制,默认为 3- - `transfer_methods` (array[string]) 传输方式列表:`remote_url`, `local_file`,必须选择一个。- - `image` (object) 图片设置- 当前仅支持图片类型:`png`, `jpg`, `jpeg`, `webp`, `gif`。- - `enabled` (bool) 是否启用- - `number_limits` (int) 图片数量限制,默认为 3- - `transfer_methods` (array[string]) 传输方式列表:`remote_url`, `local_file`,必须选择一个。- - `audio` (object) 音频设置- 当前仅支持音频类型:`mp3`, `m4a`, `wav`, `webm`, `amr`。- - `enabled` (bool) 是否启用- - `number_limits` (int) 音频数量限制,默认为 3- - `transfer_methods` (array[string]) 传输方式列表:`remote_url`, `local_file`,必须选择一个。- - `video` (object) 视频设置- 当前仅支持视频类型:`mp4`, `mov`, `mpeg`, `mpga`。- - `enabled` (bool) 是否启用- - `number_limits` (int) 视频数量限制,默认为 3- - `transfer_methods` (array[string]) 传输方式列表:`remote_url`, `local_file`,必须选择一个。- - `custom` (object) 自定义设置- - `enabled` (bool) 是否启用- - `number_limits` (int) 自定义数量限制,默认为 3- - `transfer_methods` (array[string]) 传输方式列表:`remote_url`, `local_file`,必须选择一个。- - `system_parameters` (object) 系统参数- - `file_size_limit` (int) 文档上传大小限制 (MB)- - `image_file_size_limit` (int) 图片文件上传大小限制(MB)- - `audio_file_size_limit` (int) 音频文件上传大小限制 (MB)- - `video_file_size_limit` (int) 视频文件上传大小限制 (MB)-- </Col>- <Col sticky>-- <CodeGroup- title="Request"- tag="GET"- label="/parameters"- targetCode={` curl -X GET '${props.appDetail.api_base_url}/parameters'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "user_input_form": [- {- "paragraph": {- "label": "Query",- "variable": "query",- "required": true,- "default": ""- }- }- ],- "file_upload": {- "image": {- "enabled": false,- "number_limits": 3,- "detail": "high",- "transfer_methods": [- "remote_url",- "local_file"- ]- }- },- "system_parameters": {- "file_size_limit": 15,- "image_file_size_limit": 10,- "audio_file_size_limit": 50,- "video_file_size_limit": 100- }- }- ```- </CodeGroup>- </Col>-</Row>-------<Heading- url='/site'- method='GET'- title='获取应用 WebApp 设置'- name='#site'-/>-<Row>- <Col>- 用于获取应用的 WebApp 设置- ### Response- - `title` (string) WebApp 名称- - `icon_type` (string) 图标类型,`emoji`-表情,`image`-图片- - `icon` (string) 图标,如果是 `emoji` 类型,则是 emoji 表情符号,如果是 `image` 类型,则是图片 URL- - `icon_background` (string) hex 格式的背景色- - `icon_url` (string) 图标 URL- - `description` (string) 描述- - `copyright` (string) 版权信息- - `privacy_policy` (string) 隐私政策链接- - `custom_disclaimer` (string) 自定义免责声明- - `default_language` (string) 默认语言- - `show_workflow_steps` (bool) 是否显示工作流详情- </Col>- <Col>- <CodeGroup- title="Request"- tag="GET"- label="/site"- targetCode={`curl -X GET '${props.appDetail.api_base_url}/site' \\--H 'Authorization: Bearer {api_key}'`}- />-- <CodeGroup title="Response">- ```json {{ title: 'Response' }}- {- "title": "My App",- "icon_type": "emoji",- "icon": "😄",- "icon_background": "#FFEAD5",- "icon_url": null,- "description": "This is my app.",- "copyright": "all rights reserved",- "privacy_policy": "",- "custom_disclaimer": "All generated by AI",- "default_language": "en-US",- "show_workflow_steps": false,- }- ```- </CodeGroup>- </Col>-</Row>-___diff --git a/web/app/components/develop/toc-panel.tsx b/web/app/components/develop/toc-panel.tsxdeleted file mode 100644index 9fe94473244..00000000000--- a/web/app/components/develop/toc-panel.tsx+++ /dev/null@@ -1,92 +0,0 @@-'use client'-import type { TocItem } from './hooks/use-doc-toc'-import { cn } from '@langgenius/dify-ui/cn'-import { useTranslation } from 'react-i18next'--type TocPanelProps = {- toc: TocItem[]- activeSection: string- isTocExpanded: boolean- onToggle: (expanded: boolean) => void- onItemClick: (e: React.MouseEvent<HTMLAnchorElement>, item: TocItem) => void-}--const TocPanel = ({ toc, activeSection, isTocExpanded, onToggle, onItemClick }: TocPanelProps) => {- const { t } = useTranslation()-- if (!isTocExpanded) {- return (- <button- type="button"- onClick={() => onToggle(true)}- className="group flex h-11 w-11 items-center justify-center rounded-full border-[0.5px] border-components-panel-border bg-components-panel-bg shadow-lg transition-all duration-150 hover:bg-background-default-hover hover:shadow-xl"- aria-label="Open table of contents"- >- <span className="i-ri-list-unordered size-5 text-text-tertiary transition-colors group-hover:text-text-secondary" />- </button>- )- }-- return (- <nav className="toc flex max-h-[calc(100vh-150px)] w-full flex-col overflow-hidden rounded-xl border-[0.5px] border-components-panel-border bg-background-default-hover shadow-xl">- <div className="relative z-10 flex items-center justify-between border-b border-components-panel-border-subtle bg-background-default-hover px-4 py-2.5">- <span className="text-xs font-medium tracking-wide text-text-tertiary uppercase">- {t(($) => $['develop.toc'], { ns: 'appApi' })}- </span>- <button- type="button"- onClick={() => onToggle(false)}- className="group flex size-6 items-center justify-center rounded-md transition-colors hover:bg-state-base-hover"- aria-label="Close"- >- <span className="i-ri-close-line size-3 text-text-quaternary transition-colors group-hover:text-text-secondary" />- </button>- </div>-- <div className="pointer-events-none absolute top-10.25 right-0 left-0 z-10 h-2 bg-linear-to-b from-components-panel-border-subtle/20 to-transparent"></div>- <div className="pointer-events-none absolute top-10.75 right-0 left-0 z-10 h-3 bg-linear-to-b from-background-default-hover to-transparent"></div>-- <div className="relative flex-1 overflow-y-auto p-3 pt-1">- {toc.length === 0 ? (- <div className="px-2 py-8 text-center text-xs text-text-quaternary">- {t(($) => $['develop.noContent'], { ns: 'appApi' })}- </div>- ) : (- <ul className="space-y-0.5">- {toc.map((item) => {- const isActive = activeSection === item.href.replace('#', '')- return (- <li key={item.href}>- <a- href={item.href}- onClick={(e) => onItemClick(e, item)}- className={cn(- 'group relative flex items-center rounded-md px-3 py-2 text-[13px] transition-all duration-200',- isActive- ? 'bg-state-base-hover font-medium text-text-primary'- : 'text-text-tertiary hover:bg-state-base-hover hover:text-text-secondary',- )}- >- <span- className={cn(- 'mr-2 size-1.5 rounded-full transition-all duration-200',- isActive- ? 'scale-100 bg-text-accent'- : 'scale-75 bg-components-panel-border',- )}- />- <span className="flex-1 truncate">{item.text}</span>- </a>- </li>- )- })}- </ul>- )}- </div>-- <div className="pointer-events-none absolute inset-x-0 bottom-0 z-10 h-4 rounded-b-xl bg-linear-to-t from-background-default-hover to-transparent"></div>- </nav>- )-}--export default TocPaneldiff --git a/web/app/components/develop/workflow-version-api-upgrade-notice.tsx b/web/app/components/develop/workflow-version-api-upgrade-notice.tsxdeleted file mode 100644index 9791a4aeb00..00000000000--- a/web/app/components/develop/workflow-version-api-upgrade-notice.tsx+++ /dev/null@@ -1,49 +0,0 @@-'use client'--import type { PropsWithChildren } from 'react'-import { useState } from 'react'-import { useTranslation } from 'react-i18next'-import { PlanUpgradeModal } from '@/app/components/billing/plan-upgrade-modal'-import UpgradeBtn from '@/app/components/billing/upgrade-btn'-import { useProviderContext } from '@/context/provider-context'--export const WorkflowVersionApiContent = ({ children }: PropsWithChildren) => {- const { plan, enableBilling, isFetchedPlan } = useProviderContext()-- if (enableBilling && (!isFetchedPlan || plan.type === 'sandbox')) return <div aria-hidden />-- return children-}--export const WorkflowVersionApiUpgradeNotice = () => {- const { t } = useTranslation('billing')- const { plan, enableBilling, isFetchedPlan } = useProviderContext()- const [isPlanUpgradeModalOpen, setIsPlanUpgradeModalOpen] = useState(false)-- if (!isFetchedPlan || !enableBilling || plan.type !== 'sandbox') return null-- const title = t(($) => $['upgrade.workflowVersionRun.title'])- const description = t(($) => $['upgrade.workflowVersionRun.description'])-- return (- <>- <span className="inline-flex">- <UpgradeBtn- isShort- size="custom"- loc="workflow-version-api-docs"- className="h-5! rounded-md! px-1!"- onClick={() => setIsPlanUpgradeModalOpen(true)}- />- </span>- {isPlanUpgradeModalOpen && (- <PlanUpgradeModal- show- onClose={() => setIsPlanUpgradeModalOpen(false)}- title={title}- description={description}- />- )}- </>- )-}diff --git a/web/app/components/goto-anything/actions/__tests__/app.spec.ts b/web/app/components/goto-anything/actions/__tests__/app.spec.tsindex f8fe65f1e62..49faf5e66a5 100644--- a/web/app/components/goto-anything/actions/__tests__/app.spec.ts+++ b/web/app/components/goto-anything/actions/__tests__/app.spec.ts@@ -69,7 +69,6 @@ describe('app search query', () => {'app-1:configuration','app-1:overview','app-1:logs',- 'app-1:develop',])expect(workflowOptions.select!(response([app({ id: 'wf-1', mode: 'workflow' })])).map(diff --git a/web/app/components/goto-anything/actions/app.tsx b/web/app/components/goto-anything/actions/app.tsxindex d4953e652b0..edacdf6d824 100644--- a/web/app/components/goto-anything/actions/app.tsx+++ b/web/app/components/goto-anything/actions/app.tsx@@ -72,12 +72,6 @@ const getAppSections = (app: AppPartial): AppSection[] => {path: `${base}/logs`,iconClassName: 'i-ri-file-list-line size-4 text-text-tertiary',},- {- id: 'develop',- label: 'Develop',- path: `${base}/develop`,- iconClassName: 'i-ri-terminal-box-line size-4 text-text-tertiary',- },]}diff --git a/web/app/components/workflow-app/hooks/__tests__/use-workflow-run-callbacks.spec.ts b/web/app/components/workflow-app/hooks/__tests__/use-workflow-run-callbacks.spec.tsindex c87c9a403d7..6b1368e6d5e 100644--- a/web/app/components/workflow-app/hooks/__tests__/use-workflow-run-callbacks.spec.ts+++ b/web/app/components/workflow-app/hooks/__tests__/use-workflow-run-callbacks.spec.ts@@ -1,4 +1,4 @@-import type AudioPlayer from '@/app/components/base/audio-btn/audio'+import type { AudioPlayer } from '@/app/components/base/audio-btn/audio'import {createBaseWorkflowRunCallbacks,createFinalWorkflowRunCallbacks,diff --git a/web/app/components/workflow-app/hooks/use-workflow-run-callbacks.ts b/web/app/components/workflow-app/hooks/use-workflow-run-callbacks.tsindex 01259976324..15109c4cbd8 100644--- a/web/app/components/workflow-app/hooks/use-workflow-run-callbacks.ts+++ b/web/app/components/workflow-app/hooks/use-workflow-run-callbacks.ts@@ -1,4 +1,4 @@-import type AudioPlayer from '@/app/components/base/audio-btn/audio'+import type { AudioPlayer } from '@/app/components/base/audio-btn/audio'import type { IOtherOptions } from '@/service/base'import { AudioPlayerManager } from '@/app/components/base/audio-btn/audio.player.manager'import { sseGet } from '@/service/base'diff --git a/web/app/components/workflow-app/hooks/use-workflow-run.ts b/web/app/components/workflow-app/hooks/use-workflow-run.tsindex 30626962983..f4cecec43ff 100644--- a/web/app/components/workflow-app/hooks/use-workflow-run.ts+++ b/web/app/components/workflow-app/hooks/use-workflow-run.ts@@ -1,5 +1,5 @@import type { HandleRunOptions } from './use-workflow-run-utils'-import type AudioPlayer from '@/app/components/base/audio-btn/audio'+import type { AudioPlayer } from '@/app/components/base/audio-btn/audio'import type { Node } from '@/app/components/workflow/types'import type { IOtherOptions } from '@/service/base'import type { VersionHistory } from '@/types/workflow'diff --git a/web/app/components/workflow/run/status-container.tsx b/web/app/components/workflow/run/status-container.tsxindex 8a7038d4870..b03b927ad7b 100644--- a/web/app/components/workflow/run/status-container.tsx+++ b/web/app/components/workflow/run/status-container.tsx@@ -1,7 +1,7 @@'use client'import type { FC } from 'react'import { cn } from '@langgenius/dify-ui/cn'-import CopyFeedback from '@/app/components/base/copy-feedback'+import { CopyFeedback } from '@/app/components/base/copy-feedback'import useTheme from '@/hooks/use-theme'import { Theme } from '@/types/app'diff --git a/web/app/components/workflow/variable-inspect/right.tsx b/web/app/components/workflow/variable-inspect/right.tsxindex 2a25a104131..7d4d3410984 100644--- a/web/app/components/workflow/variable-inspect/right.tsx+++ b/web/app/components/workflow/variable-inspect/right.tsx@@ -10,7 +10,7 @@ import { useCallback, useMemo } from 'react'import { useTranslation } from 'react-i18next'import GetAutomaticResModal from '@/app/components/app/configuration/config/automatic/get-automatic-res'import Badge from '@/app/components/base/badge'-import CopyFeedback from '@/app/components/base/copy-feedback'+import { CopyFeedback } from '@/app/components/base/copy-feedback'import Loading from '@/app/components/base/loading'import BlockIcon from '@/app/components/workflow/block-icon'import { VariableIconWithColor } from '@/app/components/workflow/nodes/_base/components/variable/variable-label'diff --git a/web/app/styles/plugins/typography-config.js b/web/app/styles/plugins/typography-config.jsdeleted file mode 100644index 2b8fe52c2a5..00000000000--- a/web/app/styles/plugins/typography-config.js+++ /dev/null@@ -1,357 +0,0 @@-export default ({ theme }) => ({- DEFAULT: {- css: {- '--tw-prose-body': theme('colors.zinc.700'),- '--tw-prose-headings': theme('colors.zinc.900'),- '--tw-prose-links': theme('colors.emerald.500'),- '--tw-prose-links-hover': theme('colors.emerald.600'),- '--tw-prose-links-underline': theme('colors.emerald.500 / 0.3'),- '--tw-prose-bold': theme('colors.zinc.900'),- '--tw-prose-counters': theme('colors.zinc.500'),- '--tw-prose-bullets': theme('colors.zinc.300'),- '--tw-prose-hr': theme('colors.zinc.900 / 0.05'),- '--tw-prose-quotes': theme('colors.zinc.900'),- '--tw-prose-quote-borders': theme('colors.zinc.200'),- '--tw-prose-captions': theme('colors.zinc.500'),- '--tw-prose-code': theme('colors.zinc.900'),- '--tw-prose-code-bg': theme('colors.zinc.100'),- '--tw-prose-code-ring': theme('colors.zinc.300'),- '--tw-prose-th-borders': theme('colors.zinc.300'),- '--tw-prose-td-borders': theme('colors.zinc.200'),-- '--tw-prose-invert-body': theme('colors.zinc.400'),- '--tw-prose-invert-headings': theme('colors.white'),- '--tw-prose-invert-links': theme('colors.emerald.400'),- '--tw-prose-invert-links-hover': theme('colors.emerald.500'),- '--tw-prose-invert-links-underline': theme('colors.emerald.500 / 0.3'),- '--tw-prose-invert-bold': theme('colors.white'),- '--tw-prose-invert-counters': theme('colors.zinc.400'),- '--tw-prose-invert-bullets': theme('colors.zinc.600'),- '--tw-prose-invert-hr': theme('colors.white / 0.05'),- '--tw-prose-invert-quotes': theme('colors.zinc.100'),- '--tw-prose-invert-quote-borders': theme('colors.zinc.700'),- '--tw-prose-invert-captions': theme('colors.zinc.400'),- '--tw-prose-invert-code': theme('colors.white'),- '--tw-prose-invert-code-bg': theme('colors.zinc.700 / 0.15'),- '--tw-prose-invert-code-ring': theme('colors.white / 0.1'),- '--tw-prose-invert-th-borders': theme('colors.zinc.600'),- '--tw-prose-invert-td-borders': theme('colors.zinc.700'),-- // Base- color: 'var(--tw-prose-body)',- fontSize: theme('fontSize.sm')[0],- lineHeight: theme('lineHeight.7'),-- // Layout- '> *': {- maxWidth: theme('maxWidth.2xl'),- marginLeft: 'auto',- marginRight: 'auto',- '@media (min-width: 1024px)': {- maxWidth: theme('maxWidth.3xl'),- marginLeft: `calc(50% - min(50%, ${theme('maxWidth.lg')}))`,- marginRight: `calc(50% - min(50%, ${theme('maxWidth.lg')}))`,- },- },-- // Text- p: {- marginTop: theme('spacing.6'),- marginBottom: theme('spacing.6'),- },- '[class~="lead"]': {- fontSize: theme('fontSize.base')[0],- ...theme('fontSize.base')[1],- },-- // Lists- ol: {- listStyleType: 'decimal',- marginTop: theme('spacing.5'),- marginBottom: theme('spacing.5'),- paddingLeft: '1.625rem',- },- 'ol[type="A"]': {- listStyleType: 'upper-alpha',- },- 'ol[type="a"]': {- listStyleType: 'lower-alpha',- },- 'ol[type="A" s]': {- listStyleType: 'upper-alpha',- },- 'ol[type="a" s]': {- listStyleType: 'lower-alpha',- },- 'ol[type="I"]': {- listStyleType: 'upper-roman',- },- 'ol[type="i"]': {- listStyleType: 'lower-roman',- },- 'ol[type="I" s]': {- listStyleType: 'upper-roman',- },- 'ol[type="i" s]': {- listStyleType: 'lower-roman',- },- 'ol[type="1"]': {- listStyleType: 'decimal',- },- ul: {- listStyleType: 'disc',- marginTop: theme('spacing.5'),- marginBottom: theme('spacing.5'),- paddingLeft: '1.625rem',- },- li: {- marginTop: theme('spacing.2'),- marginBottom: theme('spacing.2'),- },- ':is(ol, ul) > li': {- paddingLeft: theme('spacing[1.5]'),- },- 'ol > li::marker': {- fontWeight: '400',- color: 'var(--tw-prose-counters)',- },- 'ul > li::marker': {- color: 'var(--tw-prose-bullets)',- },- '> ul > li p': {- marginTop: theme('spacing.3'),- marginBottom: theme('spacing.3'),- },- '> ul > li > *:first-child': {- marginTop: theme('spacing.5'),- },- '> ul > li > *:last-child': {- marginBottom: theme('spacing.5'),- },- '> ol > li > *:first-child': {- marginTop: theme('spacing.5'),- },- '> ol > li > *:last-child': {- marginBottom: theme('spacing.5'),- },- 'ul ul, ul ol, ol ul, ol ol': {- marginTop: theme('spacing.3'),- marginBottom: theme('spacing.3'),- },-- // Horizontal rules- hr: {- borderColor: 'var(--tw-prose-hr)',- borderTopWidth: 1,- marginTop: theme('spacing.16'),- marginBottom: theme('spacing.16'),- maxWidth: 'none',- marginLeft: `calc(-1 * ${theme('spacing.4')})`,- marginRight: `calc(-1 * ${theme('spacing.4')})`,- '@media (min-width: 640px)': {- marginLeft: `calc(-1 * ${theme('spacing.6')})`,- marginRight: `calc(-1 * ${theme('spacing.6')})`,- },- '@media (min-width: 1024px)': {- marginLeft: `calc(-1 * ${theme('spacing.8')})`,- marginRight: `calc(-1 * ${theme('spacing.8')})`,- },- },-- // Quotes- blockquote: {- fontWeight: '500',- fontStyle: 'italic',- color: 'var(--tw-prose-quotes)',- borderLeftWidth: '0.25rem',- borderLeftColor: 'var(--tw-prose-quote-borders)',- quotes: '"\\201C""\\201D""\\2018""\\2019"',- marginTop: theme('spacing.8'),- marginBottom: theme('spacing.8'),- paddingLeft: theme('spacing.5'),- },- 'blockquote p:first-of-type::before': {- content: 'open-quote',- },- 'blockquote p:last-of-type::after': {- content: 'close-quote',- },-- // Headings- h1: {- color: 'var(--tw-prose-headings)',- fontWeight: '700',- fontSize: theme('fontSize.2xl')[0],- ...theme('fontSize.2xl')[1],- marginBottom: theme('spacing.2'),- },- h2: {- color: 'var(--tw-prose-headings)',- fontWeight: '600',- fontSize: theme('fontSize.lg')[0],- ...theme('fontSize.lg')[1],- marginTop: theme('spacing.16'),- marginBottom: theme('spacing.2'),- },- h3: {- color: 'var(--tw-prose-headings)',- fontSize: theme('fontSize.base')[0],- ...theme('fontSize.base')[1],- fontWeight: '600',- marginTop: theme('spacing.10'),- marginBottom: theme('spacing.2'),- },-- // Media- 'img, video, figure': {- marginTop: theme('spacing.8'),- marginBottom: theme('spacing.8'),- },- 'figure > *': {- marginTop: '0',- marginBottom: '0',- },- figcaption: {- color: 'var(--tw-prose-captions)',- fontSize: theme('fontSize.xs')[0],- ...theme('fontSize.xs')[1],- marginTop: theme('spacing.2'),- },-- // Tables- table: {- width: '100%',- tableLayout: 'auto',- textAlign: 'left',- marginTop: theme('spacing.8'),- marginBottom: theme('spacing.8'),- lineHeight: theme('lineHeight.6'),- },- thead: {- borderBottomWidth: '1px',- borderBottomColor: 'var(--tw-prose-th-borders)',- },- 'thead th': {- color: 'var(--tw-prose-headings)',- fontWeight: '600',- verticalAlign: 'bottom',- paddingRight: theme('spacing.2'),- paddingBottom: theme('spacing.2'),- paddingLeft: theme('spacing.2'),- },- 'thead th:first-child': {- paddingLeft: '0',- },- 'thead th:last-child': {- paddingRight: '0',- },- 'tbody tr': {- borderBottomWidth: '1px',- borderBottomColor: 'var(--tw-prose-td-borders)',- },- 'tbody tr:last-child': {- borderBottomWidth: '0',- },- 'tbody td': {- verticalAlign: 'baseline',- },- tfoot: {- borderTopWidth: '1px',- borderTopColor: 'var(--tw-prose-th-borders)',- },- 'tfoot td': {- verticalAlign: 'top',- },- ':is(tbody, tfoot) td': {- paddingTop: theme('spacing.2'),- paddingRight: theme('spacing.2'),- paddingBottom: theme('spacing.2'),- paddingLeft: theme('spacing.2'),- },- ':is(tbody, tfoot) td:first-child': {- paddingLeft: '0',- },- ':is(tbody, tfoot) td:last-child': {- paddingRight: '0',- },-- // Inline elements- a: {- color: 'var(--tw-prose-links)',- textDecoration: 'underline transparent',- fontWeight: '500',- transitionProperty: 'color, text-decoration-color',- transitionDuration: theme('transitionDuration.DEFAULT'),- transitionTimingFunction: theme('transitionTimingFunction.DEFAULT'),- '&:hover': {- color: 'var(--tw-prose-links-hover)',- textDecorationColor: 'var(--tw-prose-links-underline)',- },- },- ':is(h1, h2, h3) a': {- fontWeight: 'inherit',- },- strong: {- color: 'var(--tw-prose-bold)',- fontWeight: '600',- },- ':is(a, blockquote, thead th) strong': {- color: 'inherit',- },- code: {- color: 'var(--tw-prose-code)',- borderRadius: theme('borderRadius.lg'),- paddingTop: theme('padding.1'),- paddingRight: theme('padding[1.5]'),- paddingBottom: theme('padding.1'),- paddingLeft: theme('padding[1.5]'),- boxShadow: 'inset 0 0 0 1px var(--tw-prose-code-ring)',- backgroundColor: 'var(--tw-prose-code-bg)',- fontSize: theme('fontSize.2xs'),- },- ':is(a, h1, h2, h3, blockquote, thead th) code': {- color: 'inherit',- },- 'h2 code': {- fontSize: theme('fontSize.base')[0],- fontWeight: 'inherit',- },- 'h3 code': {- fontSize: theme('fontSize.sm')[0],- fontWeight: 'inherit',- },-- // Overrides- ':is(h1, h2, h3) + *': {- marginTop: '0',- },- '> :first-child': {- marginTop: '0 !important',- },- '> :last-child': {- marginBottom: '0 !important',- },- },- },- invert: {- css: {- '--tw-prose-body': 'var(--tw-prose-invert-body)',- '--tw-prose-headings': 'var(--tw-prose-invert-headings)',- '--tw-prose-links': 'var(--tw-prose-invert-links)',- '--tw-prose-links-hover': 'var(--tw-prose-invert-links-hover)',- '--tw-prose-links-underline': 'var(--tw-prose-invert-links-underline)',- '--tw-prose-bold': 'var(--tw-prose-invert-bold)',- '--tw-prose-counters': 'var(--tw-prose-invert-counters)',- '--tw-prose-bullets': 'var(--tw-prose-invert-bullets)',- '--tw-prose-hr': 'var(--tw-prose-invert-hr)',- '--tw-prose-quotes': 'var(--tw-prose-invert-quotes)',- '--tw-prose-quote-borders': 'var(--tw-prose-invert-quote-borders)',- '--tw-prose-captions': 'var(--tw-prose-invert-captions)',- '--tw-prose-code': 'var(--tw-prose-invert-code)',- '--tw-prose-code-bg': 'var(--tw-prose-invert-code-bg)',- '--tw-prose-code-ring': 'var(--tw-prose-invert-code-ring)',- '--tw-prose-th-borders': 'var(--tw-prose-invert-th-borders)',- '--tw-prose-td-borders': 'var(--tw-prose-invert-td-borders)',- },- },-})diff --git a/web/app/styles/plugins/typography.ts b/web/app/styles/plugins/typography.tsdeleted file mode 100644index 9ebb015c994..00000000000--- a/web/app/styles/plugins/typography.ts+++ /dev/null@@ -1,17 +0,0 @@-/*- * `@tailwindcss/typography` configured with Dify's prose color tokens.- * Injects `theme.typography` for v4 CSS-first via plugin `config` merge.- */-import typographyPlugin from '@tailwindcss/typography'-import typographyConfig from './typography-config.js'--const created = typographyPlugin()--export default {- handler: created.handler,- config: {- theme: {- typography: typographyConfig,- },- },-}diff --git a/web/app/styles/tailwind-core.css b/web/app/styles/tailwind-core.cssindex be22aa7fb74..810b2950046 100644--- a/web/app/styles/tailwind-core.css+++ b/web/app/styles/tailwind-core.css@@ -31,7 +31,6 @@/* ---------- JS plugins ------------------------------------------------ */@plugin './plugins/icons.ts';-@plugin './plugins/typography.ts';/* ---------- Project-only theme tokens --------------------------------- */@theme {diff --git a/web/features/agent-v2/agent-detail/access/components/agent-api-key-modal.tsx b/web/features/agent-v2/agent-detail/access/components/agent-api-key-modal.tsxindex b6bd1dd34b3..2c1b2ccfdfa 100644--- a/web/features/agent-v2/agent-detail/access/components/agent-api-key-modal.tsx+++ b/web/features/agent-v2/agent-detail/access/components/agent-api-key-modal.tsx@@ -22,7 +22,7 @@ import { toast } from '@langgenius/dify-ui/toast'import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'import { useState } from 'react'import { useTranslation } from 'react-i18next'-import CopyFeedback from '@/app/components/base/copy-feedback'+import { CopyFeedback } from '@/app/components/base/copy-feedback'import useTimestamp from '@/hooks/use-timestamp'import { consoleQuery } from '@/service/client'diff --git a/web/features/new-rag/__tests__/new-knowledge-list.spec.tsx b/web/features/new-rag/__tests__/new-knowledge-list.spec.tsxindex 1b98fbf24d6..c3b008a063c 100644--- a/web/features/new-rag/__tests__/new-knowledge-list.spec.tsx+++ b/web/features/new-rag/__tests__/new-knowledge-list.spec.tsx@@ -47,7 +47,7 @@ vi.mock('@/service/knowledge/use-dataset', () => ({}))vi.mock('@/app/components/datasets/extra-info/service-api', () => ({- default: () => <button type="button">dataset.serviceApi.title</button>,+ ServiceApi: () => <button type="button">dataset.serviceApi.title</button>,}))vi.mock('@/app/components/datasets/external-api/external-api-panel', () => ({diff --git a/web/features/new-rag/new-knowledge-list.tsx b/web/features/new-rag/new-knowledge-list.tsxindex ae804c2505a..cb50a0ca925 100644--- a/web/features/new-rag/new-knowledge-list.tsx+++ b/web/features/new-rag/new-knowledge-list.tsx@@ -8,7 +8,7 @@ import { useState } from 'react'import { useTranslation } from 'react-i18next'import { SearchInput } from '@/app/components/base/search-input'import ExternalAPIPanel from '@/app/components/datasets/external-api/external-api-panel'-import ServiceApi from '@/app/components/datasets/extra-info/service-api'+import { ServiceApi } from '@/app/components/datasets/extra-info/service-api'import { workspacePermissionKeysAtom } from '@/context/permission-state'import Link from '@/next/link'import { consoleQuery } from '@/service/client'diff --git a/web/global.d.ts b/web/global.d.tsindex 4d53414edda..5a68838920c 100644--- a/web/global.d.ts+++ b/web/global.d.ts@@ -1,6 +1,5 @@import './types/i18n'import './types/jsx'-import './types/mdx'import './types/assets'declare global {diff --git a/web/i18n/ar-TN/billing.json b/web/i18n/ar-TN/billing.jsonindex e69f3e455dc..74cebe97daa 100644--- a/web/i18n/ar-TN/billing.json+++ b/web/i18n/ar-TN/billing.json@@ -167,8 +167,6 @@"upgrade.uploadMultiplePages.title": "قم بالترقية لتحميل عدة مستندات دفعة واحدة","upgrade.workflowRestore.description": "استعادة إصدارات سير العمل غير متاحة في خطتك الحالية.","upgrade.workflowRestore.title": "قم بالترقية لاستعادة إصدارات سير العمل",- "upgrade.workflowVersionRun.description": "تشغيل إصدار محدد من سير العمل باستخدام معرّف سير العمل غير متاح في خطتك الحالية.",- "upgrade.workflowVersionRun.title": "قم بالترقية لتشغيل إصدارات محددة من سير العمل","upgradeBtn.encourage": "الترقية الآن","upgradeBtn.encourageShort": "ترقية","upgradeBtn.plain": "عرض الخطة",diff --git a/web/i18n/de-DE/billing.json b/web/i18n/de-DE/billing.jsonindex 0679e969d43..3b238ecf2fa 100644--- a/web/i18n/de-DE/billing.json+++ b/web/i18n/de-DE/billing.json@@ -167,8 +167,6 @@"upgrade.uploadMultiplePages.title": "Upgrade, um mehrere Dokumente gleichzeitig hochzuladen","upgrade.workflowRestore.description": "Die Wiederherstellung von Workflow-Versionen ist in Ihrem aktuellen Tarif nicht verfügbar.","upgrade.workflowRestore.title": "Upgraden, um Workflow-Versionen wiederherzustellen",- "upgrade.workflowVersionRun.description": "Das Ausführen einer bestimmten Workflow-Version über die Workflow-ID ist in Ihrem aktuellen Tarif nicht verfügbar.",- "upgrade.workflowVersionRun.title": "Upgraden, um bestimmte Workflow-Versionen auszuführen","upgradeBtn.encourage": "Jetzt Upgraden","upgradeBtn.encourageShort": "Upgraden","upgradeBtn.plain": "Tarif Upgraden",diff --git a/web/i18n/en-US/billing.json b/web/i18n/en-US/billing.jsonindex f17e2a18e8c..77a7ad17dee 100644--- a/web/i18n/en-US/billing.json+++ b/web/i18n/en-US/billing.json@@ -167,8 +167,6 @@"upgrade.uploadMultiplePages.title": "Upgrade to upload multiple documents at once","upgrade.workflowRestore.description": "Workflow version restoration is not available on your current plan.","upgrade.workflowRestore.title": "Upgrade to restore workflow versions",- "upgrade.workflowVersionRun.description": "Running a specific workflow version by workflow ID is not available on your current plan.",- "upgrade.workflowVersionRun.title": "Upgrade to run specific workflow versions","upgradeBtn.encourage": "Upgrade Now","upgradeBtn.encourageShort": "Upgrade","upgradeBtn.plain": "View Plan",diff --git a/web/i18n/es-ES/billing.json b/web/i18n/es-ES/billing.jsonindex 926cf25f0a5..a55b9306151 100644--- a/web/i18n/es-ES/billing.json+++ b/web/i18n/es-ES/billing.json@@ -167,8 +167,6 @@"upgrade.uploadMultiplePages.title": "Actualiza para subir varios documentos a la vez","upgrade.workflowRestore.description": "La restauración de versiones del flujo de trabajo no está disponible en tu plan actual.","upgrade.workflowRestore.title": "Actualiza para restaurar versiones del flujo de trabajo",- "upgrade.workflowVersionRun.description": "Ejecutar una versión específica del flujo de trabajo mediante su ID no está disponible en tu plan actual.",- "upgrade.workflowVersionRun.title": "Actualiza para ejecutar versiones específicas del flujo de trabajo","upgradeBtn.encourage": "Actualizar Ahora","upgradeBtn.encourageShort": "Actualizar","upgradeBtn.plain": "Actualizar Plan",diff --git a/web/i18n/fa-IR/billing.json b/web/i18n/fa-IR/billing.jsonindex 086250af5c6..3dc7c8a722e 100644--- a/web/i18n/fa-IR/billing.json+++ b/web/i18n/fa-IR/billing.json@@ -167,8 +167,6 @@"upgrade.uploadMultiplePages.title": "ارتقا برای آپلود همزمان چندین سند","upgrade.workflowRestore.description": "بازیابی نسخههای گردشکار در طرح فعلی شما در دسترس نیست.","upgrade.workflowRestore.title": "برای بازیابی نسخههای گردشکار ارتقا دهید",- "upgrade.workflowVersionRun.description": "اجرای نسخهای خاص از گردشکار با شناسه گردشکار در طرح فعلی شما در دسترس نیست.",- "upgrade.workflowVersionRun.title": "برای اجرای نسخههای خاص گردشکار ارتقا دهید","upgradeBtn.encourage": "هم اکنون ارتقاء دهید","upgradeBtn.encourageShort": "ارتقاء دهید","upgradeBtn.plain": "ارتقاء طرح",diff --git a/web/i18n/fr-FR/billing.json b/web/i18n/fr-FR/billing.jsonindex 68b9f2fdfe5..c5be49c5e2a 100644--- a/web/i18n/fr-FR/billing.json+++ b/web/i18n/fr-FR/billing.json@@ -167,8 +167,6 @@"upgrade.uploadMultiplePages.title": "Passez à la version supérieure pour télécharger plusieurs documents à la fois","upgrade.workflowRestore.description": "La restauration des versions du workflow n'est pas disponible avec votre plan actuel.","upgrade.workflowRestore.title": "Mettez à niveau pour restaurer les versions du workflow",- "upgrade.workflowVersionRun.description": "L’exécution d’une version spécifique du workflow via son ID n’est pas disponible avec votre plan actuel.",- "upgrade.workflowVersionRun.title": "Mettez à niveau pour exécuter des versions spécifiques du workflow","upgradeBtn.encourage": "Mettre à niveau maintenant","upgradeBtn.encourageShort": "Mise à niveau","upgradeBtn.plain": "Mettre à jour le plan",diff --git a/web/i18n/hi-IN/billing.json b/web/i18n/hi-IN/billing.jsonindex 261cae2e376..329b002f221 100644--- a/web/i18n/hi-IN/billing.json+++ b/web/i18n/hi-IN/billing.json@@ -167,8 +167,6 @@"upgrade.uploadMultiplePages.title": "एक बार में कई दस्तावेज़ अपलोड करने के लिए अपग्रेड करें","upgrade.workflowRestore.description": "आपकी वर्तमान योजना में वर्कफ़्लो संस्करण पुनर्स्थापना उपलब्ध नहीं है।","upgrade.workflowRestore.title": "वर्कफ़्लो संस्करणों को पुनर्स्थापित करने के लिए अपग्रेड करें",- "upgrade.workflowVersionRun.description": "वर्कफ़्लो ID के ज़रिए किसी विशिष्ट वर्कफ़्लो संस्करण को चलाना आपकी वर्तमान योजना में उपलब्ध नहीं है।",- "upgrade.workflowVersionRun.title": "विशिष्ट वर्कफ़्लो संस्करण चलाने के लिए अपग्रेड करें","upgradeBtn.encourage": "अभी अपग्रेड करें","upgradeBtn.encourageShort": "अपग्रेड करें","upgradeBtn.plain": "योजना अपग्रेड करें",diff --git a/web/i18n/id-ID/billing.json b/web/i18n/id-ID/billing.jsonindex 208e4935703..fb2e853802f 100644--- a/web/i18n/id-ID/billing.json+++ b/web/i18n/id-ID/billing.json@@ -167,8 +167,6 @@"upgrade.uploadMultiplePages.title": "Tingkatkan untuk mengunggah beberapa dokumen sekaligus","upgrade.workflowRestore.description": "Pemulihan versi workflow tidak tersedia di paket Anda saat ini.","upgrade.workflowRestore.title": "Tingkatkan untuk memulihkan versi workflow",- "upgrade.workflowVersionRun.description": "Menjalankan versi workflow tertentu berdasarkan ID workflow tidak tersedia di paket Anda saat ini.",- "upgrade.workflowVersionRun.title": "Tingkatkan untuk menjalankan versi workflow tertentu","upgradeBtn.encourage": "Tingkatkan Sekarang","upgradeBtn.encourageShort": "Upgrade","upgradeBtn.plain": "Lihat Paket",diff --git a/web/i18n/it-IT/billing.json b/web/i18n/it-IT/billing.jsonindex fadc2fa849a..170bcf086b0 100644--- a/web/i18n/it-IT/billing.json+++ b/web/i18n/it-IT/billing.json@@ -167,8 +167,6 @@"upgrade.uploadMultiplePages.title": "Aggiorna per caricare più documenti contemporaneamente","upgrade.workflowRestore.description": "Il ripristino delle versioni del workflow non è disponibile nel tuo piano attuale.","upgrade.workflowRestore.title": "Esegui l'upgrade per ripristinare le versioni del workflow",- "upgrade.workflowVersionRun.description": "L’esecuzione di una versione specifica del workflow tramite il relativo ID non è disponibile nel tuo piano attuale.",- "upgrade.workflowVersionRun.title": "Esegui l’upgrade per avviare versioni specifiche del workflow","upgradeBtn.encourage": "Aggiorna Ora","upgradeBtn.encourageShort": "Aggiorna","upgradeBtn.plain": "Aggiorna Piano",diff --git a/web/i18n/ja-JP/billing.json b/web/i18n/ja-JP/billing.jsonindex 0d72e5c46b5..f6685df7c17 100644--- a/web/i18n/ja-JP/billing.json+++ b/web/i18n/ja-JP/billing.json@@ -167,8 +167,6 @@"upgrade.uploadMultiplePages.title": "複数ドキュメントを一度にアップロードするにはアップグレード","upgrade.workflowRestore.description": "現在のプランでは、ワークフローバージョンの復元は利用できません。","upgrade.workflowRestore.title": "アップグレードしてワークフローバージョンを復元",- "upgrade.workflowVersionRun.description": "現在のプランでは、ワークフロー ID を指定した特定バージョンの実行は利用できません。",- "upgrade.workflowVersionRun.title": "アップグレードして特定のワークフローバージョンを実行","upgradeBtn.encourage": "今すぐアップグレード","upgradeBtn.encourageShort": "アップグレード","upgradeBtn.plain": "プランを見る",diff --git a/web/i18n/ko-KR/billing.json b/web/i18n/ko-KR/billing.jsonindex a0836737444..f03a0eb5766 100644--- a/web/i18n/ko-KR/billing.json+++ b/web/i18n/ko-KR/billing.json@@ -167,8 +167,6 @@"upgrade.uploadMultiplePages.title": "한 번에 여러 문서를 업로드하려면 업그레이드하세요","upgrade.workflowRestore.description": "현재 플랜에서는 워크플로 버전 복원을 사용할 수 없습니다.","upgrade.workflowRestore.title": "워크플로 버전을 복원하려면 업그레이드하세요",- "upgrade.workflowVersionRun.description": "현재 플랜에서는 워크플로 ID로 특정 워크플로 버전을 실행할 수 없습니다.",- "upgrade.workflowVersionRun.title": "특정 워크플로 버전을 실행하려면 업그레이드하세요","upgradeBtn.encourage": "지금 업그레이드","upgradeBtn.encourageShort": "업그레이드","upgradeBtn.plain": "요금제 업그레이드",diff --git a/web/i18n/lo-LA/billing.json b/web/i18n/lo-LA/billing.jsonindex cf497b30187..40a6d41a72d 100644--- a/web/i18n/lo-LA/billing.json+++ b/web/i18n/lo-LA/billing.json@@ -167,8 +167,6 @@"upgrade.uploadMultiplePages.title": "ອັບເກຣດເພື່ອອັບໂຫລດຫຼາຍເອກະສານພ້ອມກັນ","upgrade.workflowRestore.description": "ການກູ້ຄືນເວີຊັນ Workflow ບໍ່ສາມາດໃຊ້ງານໄດ້ໃນແພັກເກດປັດຈຸບັນຂອງທ່ານ.","upgrade.workflowRestore.title": "ອັບເກຣດເພື່ອກູ້ຄືນເວີຊັນ Workflow",- "upgrade.workflowVersionRun.description": "ການສັ່ງລັນ Workflow ເວີຊັນສະເພາະດ້ວຍ ID ບໍ່ສາມາດໃຊ້ງານໄດ້ໃນແພັກເກດປັດຈຸບັນຂອງທ່ານ.",- "upgrade.workflowVersionRun.title": "ອັບເກຣດເພື່ອສັ່ງລັນ Workflow ເວີຊັນສະເພາະ","upgradeBtn.encourage": "ອັບເກຣດຕອນນີ້","upgradeBtn.encourageShort": "ອັບເກຣດ","upgradeBtn.plain": "ເບິ່ງແພັກເກດ",diff --git a/web/i18n/nl-NL/billing.json b/web/i18n/nl-NL/billing.jsonindex d0d5734e80a..86afcd5fdc2 100644--- a/web/i18n/nl-NL/billing.json+++ b/web/i18n/nl-NL/billing.json@@ -167,8 +167,6 @@"upgrade.uploadMultiplePages.title": "Upgrade to upload multiple documents at once","upgrade.workflowRestore.description": "Het herstellen van workflowversies is niet beschikbaar in je huidige abonnement.","upgrade.workflowRestore.title": "Upgrade om workflowversies te herstellen",- "upgrade.workflowVersionRun.description": "Een specifieke workflowversie uitvoeren via de workflow-ID is niet beschikbaar in je huidige abonnement.",- "upgrade.workflowVersionRun.title": "Upgrade om specifieke workflowversies uit te voeren","upgradeBtn.encourage": "Upgrade Now","upgradeBtn.encourageShort": "Upgrade","upgradeBtn.plain": "View Plan",diff --git a/web/i18n/pl-PL/billing.json b/web/i18n/pl-PL/billing.jsonindex 0e739d12809..3d1b3f49849 100644--- a/web/i18n/pl-PL/billing.json+++ b/web/i18n/pl-PL/billing.json@@ -167,8 +167,6 @@"upgrade.uploadMultiplePages.title": "Przejdź na wyższą wersję, aby przesyłać wiele dokumentów jednocześnie","upgrade.workflowRestore.description": "Przywracanie wersji przepływu pracy nie jest dostępne w obecnym planie.","upgrade.workflowRestore.title": "Ulepsz plan, aby przywracać wersje przepływu pracy",- "upgrade.workflowVersionRun.description": "Uruchamianie określonej wersji przepływu pracy za pomocą identyfikatora nie jest dostępne w obecnym planie.",- "upgrade.workflowVersionRun.title": "Ulepsz plan, aby uruchamiać określone wersje przepływu pracy","upgradeBtn.encourage": "Ulepsz teraz","upgradeBtn.encourageShort": "Ulepsz","upgradeBtn.plain": "Ulepsz plan",diff --git a/web/i18n/pt-BR/billing.json b/web/i18n/pt-BR/billing.jsonindex f2165017bc3..2e086067099 100644--- a/web/i18n/pt-BR/billing.json+++ b/web/i18n/pt-BR/billing.json@@ -167,8 +167,6 @@"upgrade.uploadMultiplePages.title": "Atualize para enviar vários documentos de uma vez","upgrade.workflowRestore.description": "A restauração de versões do fluxo de trabalho não está disponível no seu plano atual.","upgrade.workflowRestore.title": "Faça upgrade para restaurar versões do fluxo de trabalho",- "upgrade.workflowVersionRun.description": "Executar uma versão específica do fluxo de trabalho pelo ID não está disponível no seu plano atual.",- "upgrade.workflowVersionRun.title": "Faça upgrade para executar versões específicas do fluxo de trabalho","upgradeBtn.encourage": "Fazer Upgrade Agora","upgradeBtn.encourageShort": "Upgrade","upgradeBtn.plain": "Fazer Upgrade do Plano",diff --git a/web/i18n/ro-RO/billing.json b/web/i18n/ro-RO/billing.jsonindex 7f8c0f523d7..4fe771fe6fc 100644--- a/web/i18n/ro-RO/billing.json+++ b/web/i18n/ro-RO/billing.json@@ -167,8 +167,6 @@"upgrade.uploadMultiplePages.title": "Actualizează pentru a încărca mai multe documente odată","upgrade.workflowRestore.description": "Restaurarea versiunilor fluxului de lucru nu este disponibilă în planul tău actual.","upgrade.workflowRestore.title": "Fă upgrade pentru a restaura versiunile fluxului de lucru",- "upgrade.workflowVersionRun.description": "Rularea unei versiuni specifice a fluxului de lucru prin ID nu este disponibilă în planul tău actual.",- "upgrade.workflowVersionRun.title": "Fă upgrade pentru a rula versiuni specifice ale fluxului de lucru","upgradeBtn.encourage": "Actualizează acum","upgradeBtn.encourageShort": "Actualizează","upgradeBtn.plain": "Actualizează planul",diff --git a/web/i18n/ru-RU/billing.json b/web/i18n/ru-RU/billing.jsonindex 3f3707ed763..311fa1131e0 100644--- a/web/i18n/ru-RU/billing.json+++ b/web/i18n/ru-RU/billing.json@@ -167,8 +167,6 @@"upgrade.uploadMultiplePages.title": "Обновите версию, чтобы загружать несколько документов одновременно","upgrade.workflowRestore.description": "Восстановление версий рабочего процесса недоступно в вашем текущем плане.","upgrade.workflowRestore.title": "Обновите план, чтобы восстанавливать версии рабочего процесса",- "upgrade.workflowVersionRun.description": "Запуск определённой версии рабочего процесса по его идентификатору недоступен в вашем текущем плане.",- "upgrade.workflowVersionRun.title": "Обновите план, чтобы запускать определённые версии рабочего процесса","upgradeBtn.encourage": "Обновить сейчас","upgradeBtn.encourageShort": "Обновить","upgradeBtn.plain": "Обновить тарифный план",diff --git a/web/i18n/sl-SI/billing.json b/web/i18n/sl-SI/billing.jsonindex db1742c3fbd..79918ec47e2 100644--- a/web/i18n/sl-SI/billing.json+++ b/web/i18n/sl-SI/billing.json@@ -167,8 +167,6 @@"upgrade.uploadMultiplePages.title": "Nadgradite za nalaganje več dokumentov hkrati","upgrade.workflowRestore.description": "Obnovitev različic poteka dela v vašem trenutnem paketu ni na voljo.","upgrade.workflowRestore.title": "Nadgradite za obnovitev različic poteka dela",- "upgrade.workflowVersionRun.description": "Zagon določene različice poteka dela prek njegovega ID-ja v vašem trenutnem paketu ni na voljo.",- "upgrade.workflowVersionRun.title": "Nadgradite za zagon določenih različic poteka dela","upgradeBtn.encourage": "Nadgradi zdaj","upgradeBtn.encourageShort": "Nadgradi","upgradeBtn.plain": "Nadgradi načrt",diff --git a/web/i18n/th-TH/billing.json b/web/i18n/th-TH/billing.jsonindex cd6826a59ba..7c6b0ac434d 100644--- a/web/i18n/th-TH/billing.json+++ b/web/i18n/th-TH/billing.json@@ -167,8 +167,6 @@"upgrade.uploadMultiplePages.title": "อัปเกรดเพื่ออัปโหลดเอกสารหลายฉบับพร้อมกัน","upgrade.workflowRestore.description": "การกู้คืนเวอร์ชันเวิร์กโฟลว์ไม่พร้อมใช้งานในแผนปัจจุบันของคุณ","upgrade.workflowRestore.title": "อัปเกรดเพื่อกู้คืนเวอร์ชันเวิร์กโฟลว์",- "upgrade.workflowVersionRun.description": "แผนปัจจุบันของคุณไม่รองรับการเรียกใช้เวอร์ชันเวิร์กโฟลว์ที่ระบุด้วย ID เวิร์กโฟลว์",- "upgrade.workflowVersionRun.title": "อัปเกรดเพื่อเรียกใช้เวอร์ชันเวิร์กโฟลว์ที่ระบุ","upgradeBtn.encourage": "อัปเกรดเดี๋ยวนี้","upgradeBtn.encourageShort": "อัพ เกรด","upgradeBtn.plain": "แผนการอัปเกรด",diff --git a/web/i18n/tr-TR/billing.json b/web/i18n/tr-TR/billing.jsonindex aca8350844b..cf5fa55bd11 100644--- a/web/i18n/tr-TR/billing.json+++ b/web/i18n/tr-TR/billing.json@@ -167,8 +167,6 @@"upgrade.uploadMultiplePages.title": "Aynı anda birden fazla belge yüklemek için yükseltin","upgrade.workflowRestore.description": "İş akışı sürümü geri yükleme mevcut planınızda kullanılamaz.","upgrade.workflowRestore.title": "İş akışı sürümlerini geri yüklemek için yükseltin",- "upgrade.workflowVersionRun.description": "İş akışı kimliğiyle belirli bir iş akışı sürümünü çalıştırmak mevcut planınızda kullanılamaz.",- "upgrade.workflowVersionRun.title": "Belirli iş akışı sürümlerini çalıştırmak için yükseltin","upgradeBtn.encourage": "Şimdi Yükselt","upgradeBtn.encourageShort": "Yükselt","upgradeBtn.plain": "Planı Yükselt",diff --git a/web/i18n/uk-UA/billing.json b/web/i18n/uk-UA/billing.jsonindex f417ad5c3f8..41565b36709 100644--- a/web/i18n/uk-UA/billing.json+++ b/web/i18n/uk-UA/billing.json@@ -167,8 +167,6 @@"upgrade.uploadMultiplePages.title": "Оновіть, щоб завантажувати кілька документів одночасно","upgrade.workflowRestore.description": "Відновлення версій робочого процесу недоступне у вашому поточному плані.","upgrade.workflowRestore.title": "Оновіть план, щоб відновлювати версії робочого процесу",- "upgrade.workflowVersionRun.description": "Запуск певної версії робочого процесу за його ідентифікатором недоступний у вашому поточному плані.",- "upgrade.workflowVersionRun.title": "Оновіть план, щоб запускати певні версії робочого процесу","upgradeBtn.encourage": "Оновити зараз","upgradeBtn.encourageShort": "Оновити","upgradeBtn.plain": "Оновити план",diff --git a/web/i18n/vi-VN/billing.json b/web/i18n/vi-VN/billing.jsonindex 3fdd2a57426..eb8a67602f8 100644--- a/web/i18n/vi-VN/billing.json+++ b/web/i18n/vi-VN/billing.json@@ -167,8 +167,6 @@"upgrade.uploadMultiplePages.title": "Nâng cấp để tải lên nhiều tài liệu cùng lúc","upgrade.workflowRestore.description": "Tính năng khôi phục phiên bản quy trình không khả dụng trong gói hiện tại của bạn.","upgrade.workflowRestore.title": "Nâng cấp để khôi phục các phiên bản quy trình",- "upgrade.workflowVersionRun.description": "Gói hiện tại của bạn không hỗ trợ chạy một phiên bản quy trình cụ thể bằng ID quy trình.",- "upgrade.workflowVersionRun.title": "Nâng cấp để chạy các phiên bản quy trình cụ thể","upgradeBtn.encourage": "Nâng cấp Ngay","upgradeBtn.encourageShort": "Nâng cấp","upgradeBtn.plain": "Nâng cấp Kế hoạch",diff --git a/web/i18n/zh-Hans/billing.json b/web/i18n/zh-Hans/billing.jsonindex 7a86ef074a9..d04a6f52d97 100644--- a/web/i18n/zh-Hans/billing.json+++ b/web/i18n/zh-Hans/billing.json@@ -167,8 +167,6 @@"upgrade.uploadMultiplePages.title": "升级以一次性上传多个文档","upgrade.workflowRestore.description": "当前套餐不支持恢复工作流版本。","upgrade.workflowRestore.title": "升级以恢复工作流版本",- "upgrade.workflowVersionRun.description": "当前套餐不支持通过工作流 ID 执行指定版本。",- "upgrade.workflowVersionRun.title": "升级以执行指定工作流版本","upgradeBtn.encourage": "立即升级","upgradeBtn.encourageShort": "升级","upgradeBtn.plain": "查看套餐",diff --git a/web/i18n/zh-Hant/billing.json b/web/i18n/zh-Hant/billing.jsonindex 7fbf1c78151..8e11a8112eb 100644--- a/web/i18n/zh-Hant/billing.json+++ b/web/i18n/zh-Hant/billing.json@@ -167,8 +167,6 @@"upgrade.uploadMultiplePages.title": "升級以一次上傳多個文件","upgrade.workflowRestore.description": "目前方案不支援還原工作流程版本。","upgrade.workflowRestore.title": "升級以還原工作流程版本",- "upgrade.workflowVersionRun.description": "目前方案不支援透過工作流程 ID 執行指定版本。",- "upgrade.workflowVersionRun.title": "升級以執行指定工作流程版本","upgradeBtn.encourage": "立即升級","upgradeBtn.encourageShort": "升級","upgradeBtn.plain": "升級套餐",diff --git a/web/next.config.ts b/web/next.config.tsindex dcfc356bfac..aff1c791d67 100644--- a/web/next.config.ts+++ b/web/next.config.ts@@ -1,10 +1,8 @@import type { NextConfig } from '@/next'-import createMDX from '@next/mdx'import { codeInspectorPlugin } from 'code-inspector-plugin'import { env } from './env'const isDev = process.env.NODE_ENV === 'development'-const withMDX = createMDX()const allowedDevOrigins = process.env.NEXT_ALLOWED_DEV_ORIGINS?.split(',').map((origin) => origin.trim()).filter(Boolean)@@ -25,8 +23,6 @@ const nextConfig: NextConfig = {useTypeScriptCli: false,},productionBrowserSourceMaps: false, // enable browser source map generation during the production build- // Configure pageExtensions to include md and mdx- pageExtensions: ['ts', 'tsx', 'js', 'jsx', 'md', 'mdx'],typescript: {// https://nextjs.org/docs/api-reference/next.config.js/ignoring-typescript-errorsignoreBuildErrors: true,@@ -52,4 +48,4 @@ const nextConfig: NextConfig = {},}-export default withMDX(nextConfig)+export default nextConfigdiff --git a/web/package.json b/web/package.jsonindex ca23f7614c2..d0871c22d0c 100644--- a/web/package.json+++ b/web/package.json@@ -61,7 +61,6 @@"@streamdown/math": "catalog:","@svgdotjs/svg.js": "catalog:","@t3-oss/env-nextjs": "catalog:",- "@tailwindcss/typography": "catalog:","@tanstack/query-core": "catalog:","@tanstack/react-form": "catalog:","@tanstack/react-hotkeys": "catalog:",@@ -151,10 +150,6 @@"@iconify-json/ri": "catalog:","@langgenius/dev-proxy": "workspace:*","@langgenius/dify-ui": "workspace:*",- "@mdx-js/loader": "catalog:",- "@mdx-js/react": "catalog:",- "@mdx-js/rollup": "catalog:",- "@next/mdx": "catalog:","@rgrove/parse-xml": "catalog:","@storybook/addon-docs": "catalog:","@storybook/addon-links": "catalog:",diff --git a/web/types/mdx.d.ts b/web/types/mdx.d.tsdeleted file mode 100644index fab7616911b..00000000000--- a/web/types/mdx.d.ts+++ /dev/null@@ -1,4 +0,0 @@-declare module '*.mdx' {- const MDXComponent: (props?: Record<string, unknown>) => JSX.Element- export default MDXComponent-}diff --git a/web/vite.config.ts b/web/vite.config.tsindex aaa86b0eab4..99e18a13170 100644--- a/web/vite.config.ts+++ b/web/vite.config.ts@@ -23,18 +23,7 @@ export default defineConfig(({ mode }) => {const { default: react } = await import('@vitejs/plugin-react')if (isTest) {- return [- nextStaticImageTestPlugin({ projectRoot }),- react(),- {- // Stub .mdx files so components importing them can be unit-tested- name: 'mdx-stub',- enforce: 'pre',- transform(_: string, id: string) {- if (id.endsWith('.mdx')) return { code: 'export default () => null', map: null }- },- },- ]+ return [nextStaticImageTestPlugin({ projectRoot }), react()]}if (isStorybook) return [react()]