diff --git a/web/app/components/develop/code.tsx b/web/app/components/develop/code.tsx index 9fb5c4fca..ee6792103 100644 --- a/web/app/components/develop/code.tsx +++ b/web/app/components/develop/code.tsx @@ -7,10 +7,11 @@ import { useRef, useState, } from 'react' -import { Tab, TabList, TabPanel, TabPanels } from '@headlessui/react' +import { Tab, TabGroup, TabList, TabPanel, TabPanels } from '@headlessui/react' import { Tag } from './tag' import classNames from '@/utils/classnames' import { writeTextToClipboard } from '@/utils/clipboard' +import type { PropsWithChildren, ReactElement, ReactNode } from 'react' const languageNames = { js: 'JavaScript', @@ -28,11 +29,6 @@ type IChildrenProps = { [key: string]: any } -function getPanelTitle({ className }: { className: string }) { - const language = className.split('-')[1] - return languageNames[language] ?? 'Code' -} - function ClipboardIcon(props: any) { return (
{/*
{children}
*/} {/* */} {/* */} -
{targetCode || children}
- +
+          {targetCode?.code ? (
+            {targetCode?.code}
+          ) : (
+            child
+          )}
+        
+
) } -function CodeGroupHeader({ title, children, selectedIndex }: IChildrenProps) { - const hasTabs = Children.count(children) > 1 +type CodeGroupHeaderProps = { + title?: string + tabTitles?: string[] + selectedIndex?: number +} - if (!title && !hasTabs) - return null +function CodeGroupHeader({ title, tabTitles, selectedIndex }: CodeGroupHeaderProps) { + const hasTabs = (tabTitles?.length ?? 0) > 1 return (
@@ -163,16 +176,17 @@ function CodeGroupHeader({ title, children, selectedIndex }: IChildrenProps) { )} {hasTabs && ( - {Children.map(children, (child, childIndex) => ( + {tabTitles!.map((tabTitle, tabIndex) => ( - {getPanelTitle(child.props.children.props)} + {tabTitle} ))} @@ -181,26 +195,25 @@ function CodeGroupHeader({ title, children, selectedIndex }: IChildrenProps) { ) } -type ICodeGroupPanelsProps = { - children: React.ReactNode +type ICodeGroupPanelsProps = PropsWithChildren<{ + targetCode?: CodeExample[] [key: string]: any -} -function CodeGroupPanels({ children, targetCode, ...props }: ICodeGroupPanelsProps) { - const hasTabs = Children.count(children) > 1 +}> - if (hasTabs) { +function CodeGroupPanels({ children, targetCode, ...props }: ICodeGroupPanelsProps) { + if ((targetCode?.length ?? 0) > 1) { return ( - {Children.map(children, child => ( + {targetCode!.map(code => ( - {child} + ))} ) } - return {children} + return {children} } function usePreventLayoutShift() { @@ -231,10 +244,10 @@ function usePreventLayoutShift() { function useTabGroupProps(availableLanguages: string[]) { const [preferredLanguages, addPreferredLanguage] = useState([]) const [selectedIndex, setSelectedIndex] = useState(0) - const activeLanguage = [...availableLanguages].sort( + const activeLanguage = [...(availableLanguages || [])].sort( (a, z) => preferredLanguages.indexOf(z) - preferredLanguages.indexOf(a), )[0] - const languageIndex = availableLanguages.indexOf(activeLanguage) + const languageIndex = availableLanguages?.indexOf(activeLanguage) || 0 const newSelectedIndex = languageIndex === -1 ? selectedIndex : languageIndex if (newSelectedIndex !== selectedIndex) setSelectedIndex(newSelectedIndex) @@ -255,16 +268,26 @@ function useTabGroupProps(availableLanguages: string[]) { const CodeGroupContext = createContext(false) -export function CodeGroup({ children, title, inputs, targetCode, ...props }: IChildrenProps) { - const languages = Children.map(children, child => - getPanelTitle(child.props.children.props), - ) - const tabGroupProps = useTabGroupProps(languages) - const hasTabs = Children.count(children) > 1 - const Container = hasTabs ? Tab.Group : 'div' +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 tabTitles = examples?.map(({ title }) => title || 'Code') || [] + const tabGroupProps = useTabGroupProps(tabTitles) + const hasTabs = tabTitles.length > 1 + const Container = hasTabs ? TabGroup : 'div' const containerProps = hasTabs ? tabGroupProps : {} const headerProps = hasTabs - ? { selectedIndex: tabGroupProps.selectedIndex } + ? { selectedIndex: tabGroupProps.selectedIndex, tabTitles } : {} return ( @@ -273,25 +296,19 @@ export function CodeGroup({ children, title, inputs, targetCode, ...props }: ICh {...containerProps} className="not-prose my-6 overflow-hidden rounded-2xl bg-zinc-900 shadow-md dark:ring-1 dark:ring-white/10" > - - {children} - - {children} + + {children} ) } type IChildProps = { - children: string + children: ReactNode [key: string]: any } + export function Code({ children, ...props }: IChildProps) { - const isGrouped = useContext(CodeGroupContext) - - if (isGrouped) - return - return {children} } @@ -303,3 +320,7 @@ export function Pre({ children, ...props }: IChildrenProps) { return {children} } + +export function Embed({ value, ...props }: IChildrenProps) { + return {value} +} diff --git a/web/app/components/develop/template/template.en.mdx b/web/app/components/develop/template/template.en.mdx index bee9261ef..5e8070763 100755 --- a/web/app/components/develop/template/template.en.mdx +++ b/web/app/components/develop/template/template.en.mdx @@ -7,10 +7,7 @@ The text generation application offers non-session support and is ideal for tran
### Base URL - - ```javascript - ``` - + ### Authentication @@ -19,12 +16,7 @@ The text generation application offers non-session support and is ideal for tran For all API requests, include your API Key in the `Authorization` HTTP Header, as shown below: - - ```javascript - Authorization: Bearer {API_KEY} - - ``` - +
--- @@ -42,7 +34,7 @@ The text generation application offers non-session support and is ideal for tran ### Request Body - + 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. @@ -141,22 +133,19 @@ The text generation application offers non-session support and is ideal for tran - - - ```bash {{ title: 'cURL' }} - 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 ```json {{ title: 'Response' }} @@ -248,15 +237,15 @@ The text generation application offers non-session support and is ideal for tran ### Request Example - - - ```bash {{ title: 'cURL' }} - curl -X POST '${props.appDetail.api_base_url}/files/upload' \ - --header 'Authorization: Bearer {api_key}' \ - --form 'file=@"/path/to/file"' - ``` - - + ### Response Example @@ -286,7 +275,7 @@ The text generation application offers non-session support and is ideal for tran Preview or download uploaded files. This endpoint allows you to access files that have been previously uploaded via the File Upload API. - + Files can only be accessed if they belong to messages within the requesting application. ### Path Parameters @@ -314,25 +303,24 @@ The text generation application offers non-session support and is ideal for tran ### Request Example - - - ```bash {{ title: 'cURL' }} - curl -X GET '${props.appDetail.api_base_url}/files/72fa9618-8f89-4a37-9b33-7e1178a24a67/preview' \ - --header 'Authorization: Bearer {api_key}' - ``` - - + ### Download as Attachment - - - ```bash {{ title: 'cURL' }} - 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 @@ -374,17 +362,16 @@ The text generation application offers non-session support and is ideal for tran - `result` (string) Always returns "success" - ### Request Example - - ```bash {{ title: 'cURL' }} - 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" - }' - ``` - + ### Request Example + ### Response Example @@ -435,20 +422,19 @@ The text generation application offers non-session support and is ideal for tran - - - ```bash {{ title: 'cURL' }} - 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" - }' - ``` - - + ```json {{ title: 'Response' }} @@ -490,15 +476,12 @@ The text generation application offers non-session support and is ideal for tran - - - ```bash {{ title: 'cURL' }} - curl -X GET '${props.appDetail.api_base_url}/app/feedbacks?page=1&limit=20' \ - --header 'Authorization: Bearer {api_key}' \ - --header 'Content-Type: application/json' - ``` - - + ```json {{ title: 'Response' }} @@ -551,20 +534,19 @@ The text generation application offers non-session support and is ideal for tran - - - ```bash {{ title: 'cURL' }} - 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" - }' - ``` - - + ```json {{ title: 'headers' }} @@ -595,12 +577,13 @@ The text generation application offers non-session support and is ideal for tran - `author_name` (string) author name - - ```bash {{ title: 'cURL' }} - curl -X GET '${props.appDetail.api_base_url}/info' \ - -H 'Authorization: Bearer {api_key}' - ``` - + ```json {{ title: 'Response' }} { @@ -659,30 +642,30 @@ The text generation application offers non-session support and is ideal for tran - `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. + - `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) @@ -692,14 +675,12 @@ The text generation application offers non-session support and is ideal for tran - - - ```bash {{ title: 'cURL' }} - curl -X GET '${props.appDetail.api_base_url}/parameters' \ - --header 'Authorization: Bearer {api_key}' - ``` - - + ```json {{ title: 'Response' }} @@ -777,13 +758,13 @@ The text generation application offers non-session support and is ideal for tran - `use_icon_as_answer_icon` (bool) Whether to replace 🤖 in chat with the WebApp icon - - ```bash {{ title: 'cURL' }} - curl -X GET '${props.appDetail.api_base_url}/site' \ - -H 'Authorization: Bearer {api_key}' - ``` - - + ```json {{ title: 'Response' }} diff --git a/web/app/components/develop/template/template.ja.mdx b/web/app/components/develop/template/template.ja.mdx index 64633c2b8..0bd8649d9 100755 --- a/web/app/components/develop/template/template.ja.mdx +++ b/web/app/components/develop/template/template.ja.mdx @@ -7,10 +7,7 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from
### ベース URL - - ```javascript - ``` - + ### 認証 @@ -19,12 +16,7 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from すべての API リクエストで、以下のように `Authorization` HTTP ヘッダーに API キーを含めてください: - - ```javascript - Authorization: Bearer {API_KEY} - - ``` - +
--- @@ -42,7 +34,7 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from ### リクエストボディ - + アプリで定義された各種変数値を入力できます。 `inputs`パラメータには複数のキー/値ペアが含まれ、各キーは特定の変数に対応し、各値はその変数の具体的な値となります。 @@ -141,22 +133,19 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from - - - ```bash {{ title: 'cURL' }} - 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" - }' - ``` - - + ### ブロッキングモード ```json {{ title: 'Response' }} @@ -247,15 +236,15 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from ### リクエスト例 - - - ```bash {{ title: 'cURL' }} - curl -X POST '${props.appDetail.api_base_url}/files/upload' \ - --header 'Authorization: Bearer {api_key}' \ - --form 'file=@"/path/to/file"' - ``` - - + ### レスポンス例 @@ -285,7 +274,7 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from アップロードされたファイルをプレビューまたはダウンロードします。このエンドポイントを使用すると、以前にファイルアップロード API でアップロードされたファイルにアクセスできます。 - + ファイルは、リクエストしているアプリケーションのメッセージ範囲内にある場合のみアクセス可能です。 ### パスパラメータ @@ -313,25 +302,23 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from ### リクエスト例 - - - ```bash {{ title: 'cURL' }} - 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?as_attachment=true' \ - --header 'Authorization: Bearer {api_key}' \ - --output downloaded_file.png - ``` - - + ### レスポンスヘッダー例 @@ -373,17 +360,16 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from - `result` (string) 常に"success"を返します - ### リクエスト例 - - ```bash {{ title: 'cURL' }} - 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" - }' - ``` - + ### リクエスト例 + ### レスポンス例 @@ -434,20 +420,19 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from - - - ```bash {{ title: 'cURL' }} - 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" - }' - ``` - - + ```json {{ title: 'Response' }} @@ -488,15 +473,12 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from - - - ```bash {{ title: 'cURL' }} - curl -X GET '${props.appDetail.api_base_url}/app/feedbacks?page=1&limit=20' \ - --header 'Authorization: Bearer {api_key}' \ - --header 'Content-Type: application/json' - ``` - - + ```json {{ title: 'Response' }} @@ -549,20 +531,19 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from - - - ```bash {{ title: 'cURL' }} - 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" - }' - ``` - - + ```json {{ title: 'headers' }} @@ -593,12 +574,13 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from - `author_name` (string) 作者の名前 - - ```bash {{ title: 'cURL' }} - curl -X GET '${props.appDetail.api_base_url}/info' \ - -H 'Authorization: Bearer {api_key}' - ``` - + ```json {{ title: 'Response' }} { @@ -657,30 +639,30 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from - `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`。いずれかを選択する必要があります。 + - `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) @@ -690,14 +672,12 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from - - - ```bash {{ title: 'cURL' }} - curl -X GET '${props.appDetail.api_base_url}/parameters' \ - --header 'Authorization: Bearer {api_key}' - ``` - - + ```json {{ title: 'Response' }} @@ -775,13 +755,13 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from - `use_icon_as_answer_icon` (bool) WebApp のアイコンをチャット内の🤖に置き換えるかどうか - - ```bash {{ title: 'cURL' }} - curl -X GET '${props.appDetail.api_base_url}/site' \ - -H 'Authorization: Bearer {api_key}' - ``` - - + ```json {{ title: 'Response' }} diff --git a/web/app/components/develop/template/template.zh.mdx b/web/app/components/develop/template/template.zh.mdx index 16a2a36c4..ff77cbb74 100755 --- a/web/app/components/develop/template/template.zh.mdx +++ b/web/app/components/develop/template/template.zh.mdx @@ -7,10 +7,7 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx'
### 基础 URL - - ```javascript - ``` - + ### 鉴权 @@ -19,11 +16,7 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx' **强烈建议开发者把 `API-Key` 放在后端存储,而非分享或者放在客户端存储,以免 `API-Key` 泄露,导致财产损失。** 所有 API 请求都应在 **`Authorization`** HTTP Header 中包含您的 `API-Key`,如下所示: - - ```javascript - Authorization: Bearer {API_KEY} - ``` - +
--- @@ -142,21 +135,19 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx' - - - ```bash {{ title: 'cURL' }} - 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 ```json {{ title: 'Response' }} @@ -226,15 +217,15 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx' - - - ```bash {{ title: 'cURL' }} - curl -X POST '${props.appDetail.api_base_url}/files/upload' \ - --header 'Authorization: Bearer {api_key}' \ - --form 'file=@"/path/to/file"' - ``` - - + ```json {{ title: 'Response' }} @@ -262,7 +253,7 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx' 预览或下载已上传的文件。此端点允许您访问先前通过文件上传 API 上传的文件。 - + 文件只能在属于请求应用程序的消息范围内访问。 ### 路径参数 @@ -290,25 +281,23 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx' ### 请求示例 - - - ```bash {{ title: 'cURL' }} - 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?as_attachment=true' \ - --header 'Authorization: Bearer {api_key}' \ - --output downloaded_file.png - ``` - - + ### 响应标头示例 @@ -351,17 +340,15 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx' - `result` (string) 固定返回 success - - ```bash {{ title: 'cURL' }} - 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" - }' - ``` - - + ```json {{ title: 'Response' }} @@ -410,20 +397,19 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx' - - - ```bash {{ title: 'cURL' }} - 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" - }' - ``` - - + ```json {{ title: 'Response' }} @@ -464,15 +450,12 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx' - - - ```bash {{ title: 'cURL' }} - curl -X GET '${props.appDetail.api_base_url}/app/feedbacks?page=1&limit=20' \ - --header 'Authorization: Bearer {api_key}' \ - --header 'Content-Type: application/json' - ``` - - + ```json {{ title: 'Response' }} @@ -525,21 +508,19 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx' - - - ```bash {{ title: 'cURL' }} - 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", - "streaming": false - }' - ``` - - + ```json {{ title: 'headers' }} @@ -569,12 +550,13 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx' - 'author_name' (string) 作者名称 - - ```bash {{ title: 'cURL' }} - curl -X GET '${props.appDetail.api_base_url}/info' \ - -H 'Authorization: Bearer {api_key}' - ``` - + ```json {{ title: 'Response' }} { @@ -632,30 +614,30 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx' - `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`,必须选择一个。 + - `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) @@ -664,14 +646,13 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx' - - - ```bash {{ title: 'cURL' }} - curl -X GET '${props.appDetail.api_base_url}/parameters' \ - --header 'Authorization: Bearer {api_key}' - ``` - - + ```json {{ title: 'Response' }} @@ -740,13 +721,13 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx' - `use_icon_as_answer_icon` (bool) 是否使用 WebApp 图标替换聊天中的 🤖 - - ```bash {{ title: 'cURL' }} - curl -X GET '${props.appDetail.api_base_url}/site' \ - -H 'Authorization: Bearer {api_key}' - ``` - - + ```json {{ title: 'Response' }} @@ -849,18 +830,11 @@ ___ title="Request" tag="POST" label="/apps/annotations" - targetCode={`curl --location --request POST '${props.apiBaseUrl}/apps/annotations' \\\n--header 'Authorization: Bearer {api_key}' \\\n--header 'Content-Type: application/json' \\\n--data-raw '{"question": "What is your name?","answer": "I am Dify."}'`} - > - ```bash {{ title: 'cURL' }} - 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." - }' - ``` - + 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."}'`} + /> ```json {{ title: 'Response' }} @@ -903,18 +877,11 @@ ___ title="Request" tag="PUT" label="/apps/annotations/{annotation_id}" - targetCode={`curl --location --request PUT '${props.apiBaseUrl}/apps/annotations/{annotation_id}' \\\n--header 'Authorization: Bearer {api_key}' \\\n--header 'Content-Type: application/json' \\\n--data-raw '{"question": "What is your name?","answer": "I am Dify."}'`} - > - ```bash {{ title: 'cURL' }} - 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." - }' - ``` - + 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."}'`} + /> ```json {{ title: 'Response' }} @@ -951,7 +918,9 @@ ___ title="Request" tag="PUT" label="/apps/annotations/{annotation_id}" - targetCode={`curl --location --request DELETE '${props.apiBaseUrl}/apps/annotations/{annotation_id}' \\\n--header 'Authorization: Bearer {api_key}' \\\n--header 'Content-Type: application/json'`} + 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}' \ @@ -999,19 +968,11 @@ ___ title="Request" tag="POST" label="/apps/annotation-reply/{action}" - targetCode={`curl --location --request POST '${props.apiBaseUrl}/apps/annotation-reply/{action}' \\\n--header 'Authorization: Bearer {api_key}' \\\n--header 'Content-Type: application/json' \\\n--data-raw '{"score_threshold": 0.9, "embedding_provider_name": "zhipu", "embedding_model_name": "embedding_3"}'`} - > - ```bash {{ title: 'cURL' }} - curl --location --request POST 'https://api.dify.ai/v1/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" - }' - ``` - + 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"}'`} + /> ```json {{ title: 'Response' }} @@ -1020,7 +981,7 @@ ___ "job_status": "waiting" } ``` - + @@ -1049,13 +1010,9 @@ ___ title="Request" tag="GET" label="/apps/annotations" - targetCode={`curl --location --request GET '${props.apiBaseUrl}/apps/annotation-reply/{action}/status/{job_id}' \\\n--header 'Authorization: Bearer {api_key}'`} - > - ```bash {{ title: 'cURL' }} - curl --location --request GET '${props.apiBaseUrl}/apps/annotation-reply/{action}/status/{job_id}' \ - --header 'Authorization: Bearer {api_key}' - ``` - + targetCode={`curl --location --request GET '${props.apiBaseUrl}/apps/annotation-reply/{action}/status/{job_id}' \\ +--header 'Authorization: Bearer {api_key}'`} + /> ```json {{ title: 'Response' }} diff --git a/web/app/components/develop/template/template_advanced_chat.en.mdx b/web/app/components/develop/template/template_advanced_chat.en.mdx index 4b049d5b7..508bebb48 100644 --- a/web/app/components/develop/template/template_advanced_chat.en.mdx +++ b/web/app/components/develop/template/template_advanced_chat.en.mdx @@ -1,4 +1,4 @@ -import { CodeGroup } from '../code.tsx' +import { CodeGroup, Embed } from '../code.tsx' import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from '../md.tsx' # Advanced Chat App API @@ -7,10 +7,7 @@ Chat applications support session persistence, allowing previous chat history to
### Base URL - - ```javascript - ``` - + ### Authentication @@ -19,12 +16,7 @@ Chat applications support session persistence, allowing previous chat history to For all API requests, include your API Key in the `Authorization`HTTP Header, as shown below: - - ```javascript - Authorization: Bearer {API_KEY} - - ``` - +
--- @@ -66,7 +58,7 @@ Chat applications support session persistence, allowing previous chat history to
File list, suitable for inputting files combined with text understanding and answering questions, available only when the model supports Vision capability. - - `type` (string) Supported type: + - `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') @@ -237,27 +229,34 @@ Chat applications support session persistence, allowing previous chat history to - - - ```bash {{ title: 'cURL' }} - curl -X POST '${props.appDetail.api_base_url}/chat-messages' \ - --header 'Authorization: Bearer {api_key}' \ - --header 'Content-Type: application/json' \ - --data-raw '{ - "inputs": {}, - "query": "eh", - "response_mode": "streaming", - "conversation_id": "1c7e55fb-1ba2-4e10-81b5-30addcea2276", - "user": "abc-123" - }' - ``` - + ### Blocking Mode ```json {{ title: 'Response' }} { "event": "message", - "task_id": "c3800678-a077-43df-a102-53f23ed20b88", + "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", @@ -363,16 +362,15 @@ Chat applications support session persistence, allowing previous chat history to ### Request Example - - - ```bash {{ title: 'cURL' }} - curl -X POST '${props.appDetail.api_base_url}/files/upload' \ - --header 'Authorization: Bearer {api_key}' \ - --form 'file=@"/path/to/file"' - ``` - - - + ### Response Example @@ -401,7 +399,7 @@ Chat applications support session persistence, allowing previous chat history to Preview or download uploaded files. This endpoint allows you to access files that have been previously uploaded via the File Upload API. - + Files can only be accessed if they belong to messages within the requesting application. ### Path Parameters @@ -429,25 +427,23 @@ Chat applications support session persistence, allowing previous chat history to ### Request Example - - - ```bash {{ title: 'cURL' }} - curl -X GET '${props.appDetail.api_base_url}/files/72fa9618-8f89-4a37-9b33-7e1178a24a67/preview' \ - --header 'Authorization: Bearer {api_key}' - ``` - - + ### Download as Attachment - - - ```bash {{ title: 'cURL' }} - 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 @@ -479,27 +475,28 @@ Chat applications support session persistence, allowing previous chat history to /> - 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" + 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" - ### Request Example - - ```bash {{ title: 'cURL' }} - 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" - }' - ``` - + ### Request Example + ### Response Example @@ -550,20 +547,19 @@ Chat applications support session persistence, allowing previous chat history to - - - ```bash {{ title: 'cURL' }} - 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" - }' - ``` - - + ```json {{ title: 'Response' }} @@ -605,15 +601,14 @@ Chat applications support session persistence, allowing previous chat history to - - - ```bash {{ title: 'cURL' }} - curl -X GET '${props.appDetail.api_base_url}/app/feedbacks?page=1&limit=20' \ - --header 'Authorization: Bearer {api_key}' \ - --header 'Content-Type: application/json' - ``` - - + ```json {{ title: 'Response' }} @@ -668,15 +663,14 @@ Chat applications support session persistence, allowing previous chat history to - - - ```bash {{ title: 'cURL' }} - 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' \ - ``` - - + ```json {{ title: 'Response' }} @@ -745,14 +739,14 @@ Chat applications support session persistence, allowing previous chat history to - + - ```bash {{ title: 'cURL' }} - curl -X GET '${props.appDetail.api_base_url}/messages?user=abc-123&conversation_id=' - --header 'Authorization: Bearer {api_key}' - ``` - - ### Response Example ```json {{ title: 'Response' }} @@ -838,14 +832,13 @@ Chat applications support session persistence, allowing previous chat history to - - - ```bash {{ title: 'cURL' }} - curl -X GET '${props.appDetail.api_base_url}/conversations?user=abc-123&last_id=&limit=20' \ - --header 'Authorization: Bearer {api_key}' - ``` - - + ```json {{ title: 'Response' }} @@ -903,19 +896,18 @@ Chat applications support session persistence, allowing previous chat history to - - - ```bash {{ title: 'cURL' }} - 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" - }' - ``` - - + ```text {{ title: 'Response' }} @@ -963,20 +955,19 @@ Chat applications support session persistence, allowing previous chat history to - - - ```bash {{ title: 'cURL' }} - 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" - }' - ``` - - + ```json {{ title: 'Response' }} @@ -1047,21 +1038,20 @@ Chat applications support session persistence, allowing previous chat history to - + - ```bash {{ title: 'cURL' }} - curl -X GET '${props.appDetail.api_base_url}/conversations/{conversation_id}/variables?user=abc-123' \ - --header 'Authorization: Bearer {api_key}' - ``` - - - - - ```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}' - ``` - + ```json {{ title: 'Response' }} @@ -1147,51 +1137,52 @@ Chat applications support session persistence, allowing previous chat history to - + - ```bash {{ title: 'cURL' }} - 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" - }' - ``` - - - - - ```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" - }' - ``` - + ```json {{ title: 'Response' }} @@ -1240,15 +1231,14 @@ Chat applications support session persistence, allowing previous chat history to - - - ```bash {{ title: 'cURL' }} - curl -X POST '${props.appDetail.api_base_url}/conversations/name' \ - --header 'Authorization: Bearer {api_key}' \ - --form 'file=@localfile;type=audio/mp3' - ``` - - + ```json {{ title: 'Response' }} @@ -1288,20 +1278,19 @@ Chat applications support session persistence, allowing previous chat history to - - - ```bash {{ title: 'cURL' }} - 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", - "streaming": false - }' - ``` - + ```json {{ title: 'headers' }} @@ -1332,12 +1321,14 @@ Chat applications support session persistence, allowing previous chat history to - `author_name` (string) application author name - - ```bash {{ title: 'cURL' }} - curl -X GET '${props.appDetail.api_base_url}/info' \ - -H 'Authorization: Bearer {api_key}' - ``` - + + ```json {{ title: 'Response' }} { @@ -1403,30 +1394,30 @@ Chat applications support session persistence, allowing previous chat history to - `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. + - `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) @@ -1436,14 +1427,12 @@ Chat applications support session persistence, allowing previous chat history to - - - ```bash {{ title: 'cURL' }} - curl -X GET '${props.appDetail.api_base_url}/parameters' \ - --header 'Authorization: Bearer {api_key}' - ``` - - + ```json {{ title: 'Response' }} @@ -1521,13 +1510,13 @@ Chat applications support session persistence, allowing previous chat history to - (string) url of icon - - ```bash {{ title: 'cURL' }} - curl -X GET '${props.appDetail.api_base_url}/meta' \ - -H 'Authorization: Bearer {api_key}' - ``` - - + ```json {{ title: 'Response' }} @@ -1572,13 +1561,13 @@ Chat applications support session persistence, allowing previous chat history to - `use_icon_as_answer_icon` (bool) Whether to replace 🤖 in chat with the WebApp icon - - ```bash {{ title: 'cURL' }} - curl -X GET '${props.appDetail.api_base_url}/site' \ - -H 'Authorization: Bearer {api_key}' - ``` - - + ```json {{ title: 'Response' }} @@ -1627,13 +1616,9 @@ ___ 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}' - ``` - + targetCode={`curl --location --request GET '${props.appDetail.api_base_url}/apps/annotations?page=1&limit=20' \\ +--header 'Authorization: Bearer {api_key}'`} + /> ```json {{ title: 'Response' }} @@ -1681,18 +1666,14 @@ ___ title="Request" tag="POST" label="/apps/annotations" - targetCode={`curl --location --request POST '${props.apiBaseUrl}/apps/annotations' \\\n--header 'Authorization: Bearer {api_key}' \\\n--header 'Content-Type: application/json' \\\n--data-raw '{"question": "What is your name?","answer": "I am Dify."}'`} - > - ```bash {{ title: 'cURL' }} - 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." - }' - ``` - + 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." +}'`} + /> ```json {{ title: 'Response' }} @@ -1735,18 +1716,14 @@ ___ title="Request" tag="PUT" label="/apps/annotations/{annotation_id}" - targetCode={`curl --location --request PUT '${props.apiBaseUrl}/apps/annotations/{annotation_id}' \\\n--header 'Authorization: Bearer {api_key}' \\\n--header 'Content-Type: application/json' \\\n--data-raw '{"question": "What is your name?","answer": "I am Dify."}'`} - > - ```bash {{ title: 'cURL' }} - 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." - }' - ``` - + 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." +}'`} + /> ```json {{ title: 'Response' }} @@ -1781,15 +1758,12 @@ ___ - ```bash {{ title: 'cURL' }} - curl --location --request DELETE '${props.apiBaseUrl}/apps/annotations/{annotation_id}' \ - --header 'Authorization: Bearer {api_key}' - ``` - + targetCode={`curl --location --request DELETE '${props.appDetail.api_base_url}/apps/annotations/{annotation_id}' \\ +--header 'Authorization: Bearer {api_key}' \\ +--header 'Content-Type: application/json'`} + /> ```text {{ title: 'Response' }} @@ -1830,19 +1804,15 @@ ___ title="Request" tag="POST" label="/apps/annotation-reply/{action}" - targetCode={`curl --location --request POST '${props.apiBaseUrl}/apps/annotation-reply/{action}' \\\n--header 'Authorization: Bearer {api_key}' \\\n--header 'Content-Type: application/json' \\\n--data-raw '{"score_threshold": 0.9, "embedding_provider_name": "zhipu", "embedding_model_name": "embedding_3"}'`} - > - ```bash {{ title: 'cURL' }} - curl --location --request POST 'https://api.dify.ai/v1/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" - }' - ``` - + 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" +}'`} + /> ```json {{ title: 'Response' }} @@ -1880,13 +1850,9 @@ ___ title="Request" tag="GET" label="/apps/annotations" - targetCode={`curl --location --request GET '${props.apiBaseUrl}/apps/annotation-reply/{action}/status/{job_id}' \\\n--header 'Authorization: Bearer {api_key}'`} - > - ```bash {{ title: 'cURL' }} - curl --location --request GET '${props.apiBaseUrl}/apps/annotation-reply/{action}/status/{job_id}' \ - --header 'Authorization: Bearer {api_key}' - ``` - + targetCode={`curl --location --request GET '${props.appDetail.api_base_url}/apps/annotation-reply/{action}/status/{job_id}' \\ +--header 'Authorization: Bearer {api_key}'`} + /> ```json {{ title: 'Response' }} diff --git a/web/app/components/develop/template/template_advanced_chat.ja.mdx b/web/app/components/develop/template/template_advanced_chat.ja.mdx index bbe0f29b7..cb4cf7815 100644 --- a/web/app/components/develop/template/template_advanced_chat.ja.mdx +++ b/web/app/components/develop/template/template_advanced_chat.ja.mdx @@ -7,10 +7,7 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from
### ベース URL - - ```javascript - ``` - + ### 認証 @@ -19,12 +16,7 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from すべての API リクエストには、以下のように `Authorization`HTTP ヘッダーに API キーを含めてください: - - ```javascript - Authorization: Bearer {API_KEY} - - ``` - +
--- @@ -66,7 +58,7 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from
ファイルリスト、テキストの理解と質問への回答を組み合わせたファイルの入力に適しており、モデルがビジョン機能をサポートしている場合にのみ利用可能です。 - - `type` (string) サポートされているタイプ: + - `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') @@ -237,27 +229,34 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from - - - ```bash {{ title: 'cURL' }} - curl -X POST '${props.appDetail.api_base_url}/chat-messages' \ - --header 'Authorization: Bearer {api_key}' \ - --header 'Content-Type: application/json' \ - --data-raw '{ - "inputs": {}, - "query": "eh", - "response_mode": "streaming", - "conversation_id": "1c7e55fb-1ba2-4e10-81b5-30addcea2276", - "user": "abc-123" - }' - ``` - + ### ブロッキングモード ```json {{ title: '応答' }} { "event": "message", - "task_id": "c3800678-a077-43df-a102-53f23ed20b88", + "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", @@ -363,16 +362,16 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from ### リクエスト例 - - - ```bash {{ title: 'cURL' }} - curl -X POST '${props.appDetail.api_base_url}/files/upload' \ - --header 'Authorization: Bearer {api_key}' \ - --form 'file=@"/path/to/file"' - ``` - - + ### 応答例 @@ -401,7 +400,7 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from アップロードされたファイルをプレビューまたはダウンロードします。このエンドポイントを使用すると、以前にファイルアップロード API でアップロードされたファイルにアクセスできます。 - + ファイルは、リクエストしているアプリケーションのメッセージ範囲内にある場合のみアクセス可能です。 ### パスパラメータ @@ -429,25 +428,23 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from ### リクエスト例 - - - ```bash {{ title: 'cURL - ブラウザプレビュー' }} - 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?as_attachment=true' \ - --header 'Authorization: Bearer {api_key}' \ - --output downloaded_file.png - ``` - - + ### レスポンスヘッダー例 @@ -491,17 +488,17 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from ### リクエスト例 - - ```bash {{ title: 'cURL' }} - 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" - }' - ``` - - + ### 応答例 ```json {{ title: '応答' }} @@ -551,20 +548,19 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from - - - ```bash {{ title: 'cURL' }} - 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" - }' - ``` - - + ```json {{ title: '応答' }} @@ -606,15 +602,14 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from - - - ```bash {{ title: 'cURL' }} - curl -X GET '${props.appDetail.api_base_url}/app/feedbacks?page=1&limit=20' \ - --header 'Authorization: Bearer {api_key}' \ - --header 'Content-Type: application/json' - ``` - - + ```json {{ title: 'Response' }} @@ -670,15 +665,14 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from - - - ```bash {{ title: 'cURL' }} - 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' \ - ``` - - + ```json {{ title: '応答' }} @@ -747,14 +741,13 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from - - - ```bash {{ title: 'cURL' }} - curl -X GET '${props.appDetail.api_base_url}/messages?user=abc-123&conversation_id=' - --header 'Authorization: Bearer {api_key}' - ``` - - + ### 応答例 ```json {{ title: '応答' }} @@ -839,14 +832,13 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from - - - ```bash {{ title: 'cURL' }} - curl -X GET '${props.appDetail.api_base_url}/conversations?user=abc-123&last_id=&limit=20' \ - --header 'Authorization: Bearer {api_key}' - ``` - - + ```json {{ title: '応答' }} @@ -904,19 +896,18 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from - - - ```bash {{ title: 'cURL' }} - 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" - }' - ``` - - + ```text {{ title: '応答' }} @@ -964,20 +955,19 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from - - - ```bash {{ title: 'cURL' }} - 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" - }' - ``` - - + ```json {{ title: '応答' }} @@ -1048,21 +1038,20 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from - + - ```bash {{ title: 'cURL' }} - curl -X GET '${props.appDetail.api_base_url}/conversations/{conversation_id}/variables?user=abc-123' \ - --header 'Authorization: Bearer {api_key}' - ``` - - - - - ```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}' - ``` - + ```json {{ title: 'Response' }} @@ -1148,51 +1137,52 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from - + - ```bash {{ title: 'cURL' }} - 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" - }' - ``` - - - - - ```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" - }' - ``` - + ```json {{ title: 'Response' }} @@ -1241,15 +1231,14 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from - - - ```bash {{ title: 'cURL' }} - curl -X POST '${props.appDetail.api_base_url}/conversations/name' \ - --header 'Authorization: Bearer {api_key}' \ - --form 'file=@localfile;type=audio/mp3' - ``` - - + ```json {{ title: '応答' }} @@ -1289,20 +1278,19 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from - - - ```bash {{ title: 'cURL' }} - 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", - "streaming": false - }' - ``` - + ```json {{ title: 'ヘッダー' }} @@ -1333,12 +1321,14 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from - `author_name` (string) 作者の名前 - - ```bash {{ title: 'cURL' }} - curl -X GET '${props.appDetail.api_base_url}/info' \ - -H 'Authorization: Bearer {api_key}' - ``` - + + ```json {{ title: 'Response' }} { @@ -1404,30 +1394,30 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from - `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`。いずれかを選択する必要があります。 + - `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) @@ -1437,14 +1427,12 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from - - - ```bash {{ title: 'cURL' }} - curl -X GET '${props.appDetail.api_base_url}/parameters' \ - --header 'Authorization: Bearer {api_key}' - ``` - - + ```json {{ title: '応答' }} @@ -1522,13 +1510,14 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from - (string) アイコンの URL - - ```bash {{ title: 'cURL' }} - curl -X GET '${props.appDetail.api_base_url}/meta' \ - -H 'Authorization: Bearer {api_key}' - ``` - + ```json {{ title: '応答' }} @@ -1574,13 +1563,13 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from - `use_icon_as_answer_icon` (bool) WebApp のアイコンをチャット内の🤖に置き換えるかどうか - - ```bash {{ title: 'cURL' }} - curl -X GET '${props.appDetail.api_base_url}/site' \ - -H 'Authorization: Bearer {api_key}' - ``` - - + ```json {{ title: 'Response' }} diff --git a/web/app/components/develop/template/template_advanced_chat.zh.mdx b/web/app/components/develop/template/template_advanced_chat.zh.mdx index 1a7060abc..56d9a2a07 100755 --- a/web/app/components/develop/template/template_advanced_chat.zh.mdx +++ b/web/app/components/develop/template/template_advanced_chat.zh.mdx @@ -7,10 +7,7 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx'
### 基础 URL - - ```javascript - ``` - + ### 鉴权 @@ -18,11 +15,7 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx' **强烈建议开发者把 `API-Key` 放在后端存储,而非分享或者放在客户端存储,以免 `API-Key` 泄露,导致财产损失。** 所有 API 请求都应在 **`Authorization`** HTTP Header 中包含您的 `API-Key`,如下所示: - - ```javascript - Authorization: Bearer {API_KEY} - ``` - +
--- @@ -237,37 +230,34 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx' - - - ```bash {{ title: 'cURL' }} - curl -X POST '${props.appDetail.api_base_url}/chat-messages' \ - -H 'Authorization: Bearer {api_key}' \ - -H 'Content-Type: application/json' \ - --data-raw '{ - "inputs": { - "name": "dify" - }, - "query": "What are the specs of the iPhone 13 Pro Max?", - "conversation_id": "101b4c97-fc2e-463c-90b1-5261a4cdcafb", - "response_mode": "streaming", - "user": "abc-123", - "files": [ - { + + } + ] +}'`} + /> ### 阻塞模式 ```json {{ title: 'Response' }} { "event": "message", - "task_id": "c3800678-a077-43df-a102-53f23ed20b88", + "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", @@ -373,15 +363,15 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx' - - - ```bash {{ title: 'cURL' }} - curl -X POST '${props.appDetail.api_base_url}/files/upload' \ - --header 'Authorization: Bearer {api_key}' \ - --form 'file=@"/path/to/file"' - ``` - - + ```json {{ title: 'Response' }} @@ -409,7 +399,7 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx' 预览或下载已上传的文件。此端点允许您访问先前通过文件上传 API 上传的文件。 - + 文件只能在属于请求应用程序的消息范围内访问。 ### 路径参数 @@ -437,25 +427,23 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx' ### 请求示例 - - - ```bash {{ title: 'cURL' }} - 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?as_attachment=true' \ - --header 'Authorization: Bearer {api_key}' \ - --output downloaded_file.png - ``` - - + ### 响应标头示例 @@ -498,17 +486,17 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx' - `result` (string) 固定返回 success - - ```bash {{ title: 'cURL' }} - 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" - }' - ``` - - + ```json {{ title: 'Response' }} @@ -557,20 +545,19 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx' - - - ```bash {{ title: 'cURL' }} - 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" - }' - ``` - - + ```json {{ title: 'Response' }} @@ -612,15 +599,14 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx' - - - ```bash {{ title: 'cURL' }} - curl -X GET '${props.appDetail.api_base_url}/app/feedbacks?page=1&limit=20' \ - --header 'Authorization: Bearer {api_key}' \ - --header 'Content-Type: application/json' - ``` - - + ```json {{ title: 'Response' }} @@ -676,15 +662,14 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx' - - - ```bash {{ title: 'cURL' }} - 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' \ - ``` - - + ```json {{ title: 'Response' }} @@ -753,14 +738,13 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx' ### Request Example - - - ```bash {{ title: 'cURL' }} - curl -X GET '${props.appDetail.api_base_url}/messages?user=abc-123&conversation_id=' - --header 'Authorization: Bearer {api_key}' - ``` - - + ### Response Example @@ -876,14 +860,13 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx' - - - ```bash {{ title: 'cURL' }} - curl -X GET '${props.appDetail.api_base_url}/conversations?user=abc-123&last_id=&limit=20' \ - --header 'Authorization: Bearer {api_key}' - ``` - - + ```json {{ title: 'Response' }} @@ -940,19 +923,18 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx' - - - ```bash {{ title: 'cURL' }} - 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" - }' - ``` - - + ```text {{ title: 'Response' }} @@ -1002,20 +984,19 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx' - - - ```bash {{ title: 'cURL' }} - 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" - }' - ``` - - + ```json {{ title: 'Response' }} @@ -1086,21 +1067,20 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx' - + - ```bash {{ title: 'cURL' }} - curl -X GET '${props.appDetail.api_base_url}/conversations/{conversation_id}/variables?user=abc-123' \ - --header 'Authorization: Bearer {api_key}' - ``` - - - - - ```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}' - ``` - + ```json {{ title: 'Response' }} @@ -1186,51 +1166,52 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx' - + - ```bash {{ title: 'cURL' }} - 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" - }' - ``` - - - - - ```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" - }' - ``` - + ```json {{ title: 'Response' }} @@ -1276,15 +1257,14 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx' - - - ```bash {{ title: 'cURL' }} - curl -X POST '${props.appDetail.api_base_url}/conversations/name' \ - --header 'Authorization: Bearer {api_key}' \ - --form 'file=@localfile;type=audio/mp3' - ``` - - + ```json {{ title: 'Response' }} @@ -1324,20 +1304,19 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx' - - - ```bash {{ title: 'cURL' }} - 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" - }' - ``` - - + ```json {{ title: 'headers' }} @@ -1365,12 +1344,13 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx' - `tags` (array[string]) 应用标签 - - ```bash {{ title: 'cURL' }} - curl -X GET '${props.appDetail.api_base_url}/info' \ - -H 'Authorization: Bearer {api_key}' - ``` - + ```json {{ title: 'Response' }} { @@ -1436,30 +1416,30 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx' - `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`,必须选择一个。 + - `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) @@ -1468,14 +1448,12 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx' - - - ```bash {{ title: 'cURL' }} - curl -X GET '${props.appDetail.api_base_url}/parameters' \ - --header 'Authorization: Bearer {api_key}' - ``` - - + ```json {{ title: 'Response' }} @@ -1538,13 +1516,13 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx' - (string) 图标 URL - - ```bash {{ title: 'cURL' }} - curl -X GET '${props.appDetail.api_base_url}/meta' \ - -H 'Authorization: Bearer {api_key}' - ``` - - + ```json {{ title: 'Response' }} @@ -1589,13 +1567,13 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx' - `use_icon_as_answer_icon` (bool) 是否使用 WebApp 图标替换聊天中的 🤖 - - ```bash {{ title: 'cURL' }} - curl -X GET '${props.appDetail.api_base_url}/site' \ - -H 'Authorization: Bearer {api_key}' - ``` - - + ```json {{ title: 'Response' }} @@ -1644,13 +1622,9 @@ ___ title="Request" tag="GET" label="/apps/annotations" - targetCode={`curl --location --request GET '${props.appDetail.api_base_url}/apps/annotations?page=1&limit=20' \\\n--header 'Authorization: Bearer {api_key}'`} - > - ```bash {{ title: 'cURL' }} - curl --location --request GET '${props.appDetail.api_base_url}/apps/annotations?page=1&limit=20' \ - --header 'Authorization: Bearer {api_key}' - ``` - + targetCode={`curl --location --request GET '${props.appDetail.api_base_url}/apps/annotations?page=1&limit=20' \\ +--header 'Authorization: Bearer {api_key}'`} + /> ```json {{ title: 'Response' }} @@ -1698,18 +1672,14 @@ ___ title="Request" tag="POST" label="/apps/annotations" - targetCode={`curl --location --request POST '${props.appDetail.api_base_url}/apps/annotations' \\\n--header 'Authorization: Bearer {api_key}' \\\n--header 'Content-Type: application/json' \\\n--data-raw '{"question": "What is your name?","answer": "I am Dify."}'`} - > - ```bash {{ title: 'cURL' }} - 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." - }' - ``` - + 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." +}'`} + /> ```json {{ title: 'Response' }} @@ -1752,18 +1722,14 @@ ___ title="Request" tag="PUT" label="/apps/annotations/{annotation_id}" - targetCode={`curl --location --request PUT '${props.appDetail.api_base_url}/apps/annotations/{annotation_id}' \\\n--header 'Authorization: Bearer {api_key}' \\\n--header 'Content-Type: application/json' \\\n--data-raw '{"question": "What is your name?","answer": "I am Dify."}'`} - > - ```bash {{ title: 'cURL' }} - 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." - }' - ``` - + 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." +}'`} + /> ```json {{ title: 'Response' }} @@ -1798,15 +1764,12 @@ ___ - ```bash {{ title: 'cURL' }} - curl --location --request DELETE '${props.appDetail.api_base_url}/apps/annotations/{annotation_id}' \ - --header 'Authorization: Bearer {api_key}' - ``` - + targetCode={`curl --location --request DELETE '${props.appDetail.api_base_url}/apps/annotations/{annotation_id}' \\ +--header 'Authorization: Bearer {api_key}' \\ +--header 'Content-Type: application/json'`} + /> ```text {{ title: 'Response' }} @@ -1847,19 +1810,15 @@ ___ title="Request" tag="POST" label="/apps/annotation-reply/{action}" - targetCode={`curl --location --request POST '${props.appDetail.api_base_url}/apps/annotation-reply/{action}' \\\n--header 'Authorization: Bearer {api_key}' \\\n--header 'Content-Type: application/json' \\\n--data-raw '{"score_threshold": 0.9, "embedding_provider_name": "zhipu", "embedding_model_name": "embedding_3"}'`} - > - ```bash {{ title: 'cURL' }} - curl --location --request POST 'https://api.dify.ai/v1/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" - }' - ``` - + 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" +}'`} + /> ```json {{ title: 'Response' }} @@ -1897,13 +1856,9 @@ ___ title="Request" tag="GET" label="/apps/annotations" - targetCode={`curl --location --request GET '${props.appDetail.api_base_url}/apps/annotation-reply/{action}/status/{job_id}' \\\n--header 'Authorization: Bearer {api_key}'`} - > - ```bash {{ title: 'cURL' }} - curl --location --request GET '${props.appDetail.api_base_url}/apps/annotation-reply/{action}/status/{job_id}' \ - --header 'Authorization: Bearer {api_key}' - ``` - + targetCode={`curl --location --request GET '${props.appDetail.api_base_url}/apps/annotation-reply/{action}/status/{job_id}' \\ +--header 'Authorization: Bearer {api_key}'`} + /> ```json {{ title: 'Response' }} diff --git a/web/app/components/develop/template/template_chat.en.mdx b/web/app/components/develop/template/template_chat.en.mdx index 7647da445..b47d658d4 100644 --- a/web/app/components/develop/template/template_chat.en.mdx +++ b/web/app/components/develop/template/template_chat.en.mdx @@ -7,10 +7,7 @@ Chat applications support session persistence, allowing previous chat history to
### Base URL - - ```javascript - ``` - + ### Authentication @@ -19,12 +16,7 @@ Chat applications support session persistence, allowing previous chat history to For all API requests, include your API Key in the `Authorization`HTTP Header, as shown below: - - ```javascript - Authorization: Bearer {API_KEY} - - ``` - +
--- @@ -192,27 +184,34 @@ Chat applications support session persistence, allowing previous chat history to - - - ```bash {{ title: 'cURL' }} - curl -X POST '${props.appDetail.api_base_url}/chat-messages' \ - --header 'Authorization: Bearer {api_key}' \ - --header 'Content-Type: application/json' \ - --data-raw '{ - "inputs": {}, - "query": "eh", - "response_mode": "streaming", - "conversation_id": "1c7e55fb-1ba2-4e10-81b5-30addcea2276", - "user": "abc-123" - }' - ``` - + ### Blocking Mode ```json {{ title: 'Response' }} { "event": "message", - "task_id": "c3800678-a077-43df-a102-53f23ed20b88", + "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", @@ -327,16 +326,15 @@ Chat applications support session persistence, allowing previous chat history to ### Request Example - - - ```bash {{ title: 'cURL' }} - curl -X POST '${props.appDetail.api_base_url}/files/upload' \ - --header 'Authorization: Bearer {api_key}' \ - --form 'file=@"/path/to/file"' - ``` - - - + ### Response Example @@ -365,7 +363,7 @@ Chat applications support session persistence, allowing previous chat history to Preview or download uploaded files. This endpoint allows you to access files that have been previously uploaded via the File Upload API. - + Files can only be accessed if they belong to messages within the requesting application. ### Path Parameters @@ -393,25 +391,23 @@ Chat applications support session persistence, allowing previous chat history to ### Request Example - - - ```bash {{ title: 'cURL' }} - curl -X GET '${props.appDetail.api_base_url}/files/72fa9618-8f89-4a37-9b33-7e1178a24a67/preview' \ - --header 'Authorization: Bearer {api_key}' - ``` - - + ### Download as Attachment - - - ```bash {{ title: 'cURL' }} - 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 @@ -453,17 +449,16 @@ Chat applications support session persistence, allowing previous chat history to - `result` (string) Always returns "success" - ### Request Example - - ```bash {{ title: 'cURL' }} - 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" - }' - ``` - + ### Request Example + ### Response Example @@ -514,20 +509,19 @@ Chat applications support session persistence, allowing previous chat history to - - - ```bash {{ title: 'cURL' }} - 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" - }' - ``` - - + ```json {{ title: 'Response' }} @@ -569,15 +563,12 @@ Chat applications support session persistence, allowing previous chat history to - - - ```bash {{ title: 'cURL' }} - curl -X GET '${props.appDetail.api_base_url}/app/feedbacks?page=1&limit=20' \ - --header 'Authorization: Bearer {api_key}' \ - --header 'Content-Type: application/json' - ``` - - + ```json {{ title: 'Response' }} @@ -632,15 +623,14 @@ Chat applications support session persistence, allowing previous chat history to - - - ```bash {{ title: 'cURL' }} - curl --location --request GET '${props.appDetail.api_base_url}/messages/{message_id}/suggested' \ - --header 'Authorization: Bearer ENTER-YOUR-SECRET-KEY' \ - --header 'Content-Type: application/json' \ - ``` - - + ```json {{ title: 'Response' }} @@ -720,14 +710,14 @@ Chat applications support session persistence, allowing previous chat history to - + - ```bash {{ title: 'cURL' }} - curl -X GET '${props.appDetail.api_base_url}/messages?user=abc-123&conversation_id=' - --header 'Authorization: Bearer {api_key}' - ``` - - ### Response Example (Basic Assistant) ```json {{ title: 'Response' }} @@ -872,14 +862,13 @@ Chat applications support session persistence, allowing previous chat history to - - - ```bash {{ title: 'cURL' }} - curl -X GET '${props.appDetail.api_base_url}/conversations?user=abc-123&last_id=&limit=20' \ - --header 'Authorization: Bearer {api_key}' - ``` - - + ```json {{ title: 'Response' }} @@ -937,19 +926,17 @@ Chat applications support session persistence, allowing previous chat history to - - - ```bash {{ title: 'cURL' }} - 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" - }' - ``` - - + ```text {{ title: 'Response' }} @@ -997,20 +984,19 @@ Chat applications support session persistence, allowing previous chat history to - - - ```bash {{ title: 'cURL' }} - 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" - }' - ``` - - + ```json {{ title: 'Response' }} @@ -1081,14 +1067,13 @@ Chat applications support session persistence, allowing previous chat history to - - - ```bash {{ title: 'cURL' }} - curl -X GET '${props.appDetail.api_base_url}/conversations/{conversation_id}/variables?user=abc-123' \ - --header 'Authorization: Bearer {api_key}' - ``` - - + ```bash {{ title: 'cURL' }} @@ -1181,19 +1166,18 @@ Chat applications support session persistence, allowing previous chat history to - - - ```bash {{ title: 'cURL' }} - 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" - }' - ``` - - + ```bash {{ title: 'String Value' }} @@ -1274,15 +1258,14 @@ Chat applications support session persistence, allowing previous chat history to - - - ```bash {{ title: 'cURL' }} - curl -X POST '${props.appDetail.api_base_url}/conversations/name' \ - --header 'Authorization: Bearer {api_key}' \ - --form 'file=@localfile;type=audio/mp3' - ``` - - + ```json {{ title: 'Response' }} @@ -1322,15 +1305,14 @@ Chat applications support session persistence, allowing previous chat history to - - - ```bash {{ title: 'cURL' }} - curl --location --request POST '${props.appDetail.api_base_url}/text-to-audio' \ - --header 'Authorization: Bearer ENTER-YOUR-SECRET-KEY' \ - --form 'file=Hello Dify;user=abc-123;message_id=5ad4cb98-f0c7-4085-b384-88c403be6290' - ``` - - + ```json {{ title: 'headers' }} @@ -1361,12 +1343,13 @@ Chat applications support session persistence, allowing previous chat history to - `author_name` (string) application author name - - ```bash {{ title: 'cURL' }} - curl -X GET '${props.appDetail.api_base_url}/info' \ - -H 'Authorization: Bearer {api_key}' - ``` - + ```json {{ title: 'Response' }} { @@ -1440,30 +1423,30 @@ Chat applications support session persistence, allowing previous chat history to - `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. + - `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) @@ -1473,14 +1456,12 @@ Chat applications support session persistence, allowing previous chat history to - - - ```bash {{ title: 'cURL' }} - curl -X GET '${props.appDetail.api_base_url}/parameters' \ - --header 'Authorization: Bearer {api_key}' - ``` - - + ```json {{ title: 'Response' }} @@ -1558,13 +1539,13 @@ Chat applications support session persistence, allowing previous chat history to - (string) url of icon - - ```bash {{ title: 'cURL' }} - curl -X GET '${props.appDetail.api_base_url}/meta' \ - -H 'Authorization: Bearer {api_key}' - ``` - - + ```json {{ title: 'Response' }} @@ -1609,13 +1590,13 @@ Chat applications support session persistence, allowing previous chat history to - `use_icon_as_answer_icon` (bool) Whether to replace 🤖 in chat with the WebApp icon - - ```bash {{ title: 'cURL' }} - curl -X GET '${props.appDetail.api_base_url}/site' \ - -H 'Authorization: Bearer {api_key}' - ``` - - + ```json {{ title: 'Response' }} @@ -1664,13 +1645,9 @@ ___ 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}' - ``` - + targetCode={`curl --location --request GET '${props.apiBaseUrl}/apps/annotations?page=1&limit=20' \\ +--header 'Authorization: Bearer {api_key}'`} + /> ```json {{ title: 'Response' }} @@ -1718,18 +1695,11 @@ ___ title="Request" tag="POST" label="/apps/annotations" - targetCode={`curl --location --request POST '${props.apiBaseUrl}/apps/annotations' \\\n--header 'Authorization: Bearer {api_key}' \\\n--header 'Content-Type: application/json' \\\n--data-raw '{"question": "What is your name?","answer": "I am Dify."}'`} - > - ```bash {{ title: 'cURL' }} - 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." - }' - ``` - + 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."}'`} + /> ```json {{ title: 'Response' }} @@ -1774,18 +1744,11 @@ ___ title="Request" tag="PUT" label="/apps/annotations/{annotation_id}" - targetCode={`curl --location --request POST '${props.apiBaseUrl}/apps/annotations/{annotation_id}' \\\n--header 'Authorization: Bearer {api_key}' \\\n--header 'Content-Type: application/json' \\\n--data-raw '{"question": "What is your name?","answer": "I am Dify."}'`} - > - ```bash {{ title: 'cURL' }} - 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." - }' - ``` - + 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."}'`} + /> ```json {{ title: 'Response' }} @@ -1824,13 +1787,10 @@ ___ title="Request" tag="PUT" label="/apps/annotations/{annotation_id}" - targetCode={`curl --location --request DELETE '${props.apiBaseUrl}/apps/annotations/{annotation_id}' \\\n--header 'Authorization: Bearer {api_key}' \\\n--header 'Content-Type: application/json'`} - > - ```bash {{ title: 'cURL' }} - curl --location --request DELETE '${props.apiBaseUrl}/apps/annotations/{annotation_id}' \ - --header 'Authorization: Bearer {api_key}' - ``` - + targetCode={`curl --location --request DELETE '${props.apiBaseUrl}/apps/annotations/{annotation_id}' \\ +--header 'Authorization: Bearer {api_key}' \\ +--header 'Content-Type: application/json'`} + /> ```text {{ title: 'Response' }} @@ -1871,19 +1831,11 @@ ___ title="Request" tag="POST" label="/apps/annotation-reply/{action}" - targetCode={`curl --location --request POST '${props.apiBaseUrl}/apps/annotation-reply/{action}' \\\n--header 'Authorization: Bearer {api_key}' \\\n--header 'Content-Type: application/json' \\\n--data-raw '{"score_threshold": 0.9, "embedding_provider_name": "zhipu", "embedding_model_name": "embedding_3"}'`} - > - ```bash {{ title: 'cURL' }} - curl --location --request POST 'https://api.dify.ai/v1/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" - }' - ``` - + 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"}'`} + /> ```json {{ title: 'Response' }} @@ -1912,7 +1864,7 @@ ___ Action, can only be 'enable' or 'disable', must be the same as the action in the initial annotation reply settings interface
- Job ID, + Job ID,
@@ -1921,13 +1873,9 @@ ___ title="Request" tag="GET" label="/apps/annotations" - targetCode={`curl --location --request GET '${props.apiBaseUrl}/apps/annotation-reply/{action}/status/{job_id}' \\\n--header 'Authorization: Bearer {api_key}'`} - > - ```bash {{ title: 'cURL' }} - curl --location --request GET '${props.apiBaseUrl}/apps/annotation-reply/{action}/status/{job_id}' \ - --header 'Authorization: Bearer {api_key}' - ``` -
+ targetCode={`curl --location --request GET '${props.apiBaseUrl}/apps/annotation-reply/{action}/status/{job_id}' \\ +--header 'Authorization: Bearer {api_key}'`} + /> ```json {{ title: 'Response' }} diff --git a/web/app/components/develop/template/template_chat.ja.mdx b/web/app/components/develop/template/template_chat.ja.mdx index 2b41881e1..d63479478 100644 --- a/web/app/components/develop/template/template_chat.ja.mdx +++ b/web/app/components/develop/template/template_chat.ja.mdx @@ -7,10 +7,7 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from
### ベース URL - - ```javascript - ``` - + ### 認証 @@ -19,12 +16,7 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from すべての API リクエストにおいて、以下のように `Authorization`HTTP ヘッダーに API キーを含めてください: - - ```javascript - Authorization: Bearer {API_KEY} - - ``` - +
--- @@ -192,27 +184,34 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from - - - ```bash {{ title: 'cURL' }} - curl -X POST '${props.appDetail.api_base_url}/chat-messages' \ - --header 'Authorization: Bearer {api_key}' \ - --header 'Content-Type: application/json' \ - --data-raw '{ - "inputs": {}, - "query": "eh", - "response_mode": "streaming", - "conversation_id": "1c7e55fb-1ba2-4e10-81b5-30addcea2276", - "user": "abc-123" - }' - ``` - + ### ブロッキングモード ```json {{ title: '応答' }} { "event": "message", - "task_id": "c3800678-a077-43df-a102-53f23ed20b88", + "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", @@ -327,16 +326,15 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from ### リクエスト例 - - - ```bash {{ title: 'cURL' }} - curl -X POST '${props.appDetail.api_base_url}/files/upload' \ - --header 'Authorization: Bearer {api_key}' \ - --form 'file=@"/path/to/file"' - ``` - - - + ### 応答例 @@ -365,7 +363,7 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from アップロードされたファイルをプレビューまたはダウンロードします。このエンドポイントを使用すると、以前にファイルアップロード API でアップロードされたファイルにアクセスできます。 - + ファイルは、リクエストしているアプリケーションのメッセージ範囲内にある場合のみアクセス可能です。 ### パスパラメータ @@ -393,25 +391,23 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from ### リクエスト例 - - - ```bash {{ title: 'cURL' }} - 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?as_attachment=true' \ - --header 'Authorization: Bearer {api_key}' \ - --output downloaded_file.png - ``` - - + ### レスポンスヘッダー例 @@ -453,17 +449,16 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from - `result` (string) 常に"success"を返します - ### リクエスト例 - - ```bash {{ title: 'cURL' }} - 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" - }' - ``` - + ### リクエスト例 + ### 応答例 @@ -514,20 +509,19 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from - - - ```bash {{ title: 'cURL' }} - 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" - }' - ``` - - + ```json {{ title: '応答' }} @@ -569,17 +563,14 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from - + - ```bash {{ title: 'cURL' }} - curl -X GET '${props.appDetail.api_base_url}/app/feedbacks?page=1&limit=20' \ - --header 'Authorization: Bearer {api_key}' \ - --header 'Content-Type: application/json' - ``` - - - - + ```json {{ title: 'Response' }} { "data": [ @@ -633,15 +624,14 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from - - - ```bash {{ title: 'cURL' }} - curl --location --request GET '${props.appDetail.api_base_url}/messages/{message_id}/suggested' \ - --header 'Authorization: Bearer ENTER-YOUR-SECRET-KEY' \ - --header 'Content-Type: application/json' \ - ``` - - + ```json {{ title: '応答' }} @@ -721,14 +711,13 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from - - - ```bash {{ title: 'cURL' }} - curl -X GET '${props.appDetail.api_base_url}/messages?user=abc-123&conversation_id=' - --header 'Authorization: Bearer {api_key}' - ``` - - + ### 応答例(基本アシスタント) ```json {{ title: '応答' }} @@ -872,14 +861,9 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from - - - ```bash {{ title: 'cURL' }} - curl -X GET '${props.appDetail.api_base_url}/conversations?user=abc-123&last_id=&limit=20' \ - --header 'Authorization: Bearer {api_key}' - ``` - - + ```json {{ title: '応答' }} @@ -937,19 +921,17 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from - - - ```bash {{ title: 'cURL' }} - 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" - }' - ``` - - + ```text {{ title: '応答' }} @@ -997,20 +979,19 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from - - - ```bash {{ title: 'cURL' }} - 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" - }' - ``` - - + ```json {{ title: '応答' }} @@ -1080,14 +1061,13 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from - - - ```bash {{ title: 'cURL' }} - curl -X GET '${props.appDetail.api_base_url}/conversations/{conversation_id}/variables?user=abc-123' \ - --header 'Authorization: Bearer {api_key}' - ``` - - + ```bash {{ title: 'cURL' }} @@ -1096,7 +1076,7 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from ``` - + ```json {{ title: 'Response' }} { "limit": 100, @@ -1180,19 +1160,18 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from - - - ```bash {{ title: 'cURL' }} - 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" - }' - ``` - - + ```bash {{ title: '文字列値' }} @@ -1226,7 +1205,7 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from ``` - + ```json {{ title: 'Response' }} { "id": "variable-uuid-1", @@ -1273,15 +1252,14 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from - - - ```bash {{ title: 'cURL' }} - curl -X POST '${props.appDetail.api_base_url}/conversations/name' \ - --header 'Authorization: Bearer {api_key}' \ - --form 'file=@localfile;type=audio/mp3' - ``` - - + ```json {{ title: '応答' }} @@ -1321,15 +1299,14 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from - - - ```bash {{ title: 'cURL' }} - curl --location --request POST '${props.appDetail.api_base_url}/text-to-audio' \ - --header 'Authorization: Bearer ENTER-YOUR-SECRET-KEY' \ - --form 'file=Hello Dify;user=abc-123;message_id=5ad4cb98-f0c7-4085-b384-88c403be6290' - ``` - - + ```json {{ title: 'ヘッダー' }} @@ -1360,13 +1337,14 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from - `author_name` (string) 作者の名前 - - ```bash {{ title: 'cURL' }} - curl -X GET '${props.appDetail.api_base_url}/info' \ - -H 'Authorization: Bearer {api_key}' - ``` - - + + ```json {{ title: 'Response' }} { "name": "My App", @@ -1431,30 +1409,30 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from - `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`。いずれかを選択する必要があります。 + - `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) @@ -1464,14 +1442,12 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from - - - ```bash {{ title: 'cURL' }} - curl -X GET '${props.appDetail.api_base_url}/parameters' \ - --header 'Authorization: Bearer {api_key}' - ``` - - + ```json {{ title: '応答' }} @@ -1549,13 +1525,13 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from - (string) アイコンの URL - - ```bash {{ title: 'cURL' }} - curl -X GET '${props.appDetail.api_base_url}/meta' \ - -H 'Authorization: Bearer {api_key}' - ``` - - + ```json {{ title: '応答' }} @@ -1601,15 +1577,15 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from - `use_icon_as_answer_icon` (bool) WebApp のアイコンをチャット内の🤖に置き換えるかどうか - - ```bash {{ title: 'cURL' }} - curl -X GET '${props.appDetail.api_base_url}/site' \ - -H 'Authorization: Bearer {api_key}' - ``` + - - - + ```json {{ title: 'Response' }} { "title": "My App", diff --git a/web/app/components/develop/template/template_chat.zh.mdx b/web/app/components/develop/template/template_chat.zh.mdx index c975749c1..6ecf5724a 100644 --- a/web/app/components/develop/template/template_chat.zh.mdx +++ b/web/app/components/develop/template/template_chat.zh.mdx @@ -7,10 +7,7 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx'
### 基础 URL - - ```javascript - ``` - + ### 鉴权 @@ -18,11 +15,7 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx' **强烈建议开发者把 `API-Key` 放在后端存储,而非分享或者放在客户端存储,以免 `API-Key` 泄露,导致财产损失。** 所有 API 请求都应在 **`Authorization`** HTTP Header 中包含您的 `API-Key`,如下所示: - - ```javascript - Authorization: Bearer {API_KEY} - ``` - +
--- @@ -194,37 +187,34 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx' - - - ```bash {{ title: 'cURL' }} - curl -X POST '${props.appDetail.api_base_url}/chat-messages' \ - -H 'Authorization: Bearer {api_key}' \ - -H 'Content-Type: application/json' \ - --data-raw '{ - "inputs": { - "name": "dify" - }, - "query": "What are the specs of the iPhone 13 Pro Max?", - "conversation_id": "101b4c97-fc2e-463c-90b1-5261a4cdcafb", - "response_mode": "streaming", - "user": "abc-123", - "files": [ - { - "type": "image", - "transfer_method": "remote_url", - "url": "https://cloud.dify.ai/logo/logo-site.png" - } - ] - }' - ``` - - + ### 阻塞模式 ```json {{ title: 'Response' }} { "event": "message", - "task_id": "c3800678-a077-43df-a102-53f23ed20b88", + "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", @@ -345,15 +335,15 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx' - - - ```bash {{ title: 'cURL' }} - curl -X POST '${props.appDetail.api_base_url}/files/upload' \ - --header 'Authorization: Bearer {api_key}' \ - --form 'file=@"/path/to/file"' - ``` - - + ```json {{ title: 'Response' }} @@ -381,7 +371,7 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx' 预览或下载已上传的文件。此端点允许您访问先前通过文件上传 API 上传的文件。 - + 文件只能在属于请求应用程序的消息范围内访问。 ### 路径参数 @@ -409,7 +399,12 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx' ### 请求示例 - + ```bash {{ title: 'cURL' }} curl -X GET '${props.appDetail.api_base_url}/files/72fa9618-8f89-4a37-9b33-7e1178a24a67/preview' \ @@ -419,15 +414,10 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx' ### 作为附件下载 - - - ```bash {{ title: 'cURL' }} - 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 - ``` - - + ### 响应标头示例 @@ -470,17 +460,15 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx' - `result` (string) 固定返回 success - - ```bash {{ title: 'cURL' }} - 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" - }' - ``` - - + ```json {{ title: 'Response' }} @@ -529,20 +517,19 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx' - - - ```bash {{ title: 'cURL' }} - 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" - }' - ``` - - + ```json {{ title: 'Response' }} @@ -584,15 +571,12 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx' - - - ```bash {{ title: 'cURL' }} - curl -X GET '${props.appDetail.api_base_url}/app/feedbacks?page=1&limit=20' \ - --header 'Authorization: Bearer {api_key}' \ - --header 'Content-Type: application/json' - ``` - - + ```json {{ title: 'Response' }} @@ -646,15 +630,14 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx' - - - ```bash {{ title: 'cURL' }} - curl --location --request GET '${props.appDetail.api_base_url}/messages/{message_id}/suggested' \ - --header 'Authorization: Bearer ENTER-YOUR-SECRET-KEY' \ - --header 'Content-Type: application/json' \ - ``` - - + ```json {{ title: 'Response' }} @@ -735,14 +718,13 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx' ### Request Example - - - ```bash {{ title: 'cURL' }} - curl -X GET '${props.appDetail.api_base_url}/messages?user=abc-123&conversation_id=' - --header 'Authorization: Bearer {api_key}' - ``` - - + ### Response Example(基础助手) @@ -887,14 +869,13 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx' - - - ```bash {{ title: 'cURL' }} - curl -X GET '${props.appDetail.api_base_url}/conversations?user=abc-123&last_id=&limit=20' \ - --header 'Authorization: Bearer {api_key}' - ``` - - + ```json {{ title: 'Response' }} @@ -951,19 +932,17 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx' - - - ```bash {{ title: 'cURL' }} - 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" - }' - ``` - - + ```text {{ title: 'Response' }} @@ -1013,20 +992,19 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx' - - - ```bash {{ title: 'cURL' }} - 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" - }' - ``` - - + ```json {{ title: 'Response' }} @@ -1097,14 +1075,13 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx' - - - ```bash {{ title: 'cURL' }} - curl -X GET '${props.appDetail.api_base_url}/conversations/{conversation_id}/variables?user=abc-123' \ - --header 'Authorization: Bearer {api_key}' - ``` - - + ```bash {{ title: 'cURL' }} @@ -1197,19 +1174,18 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx' - - - ```bash {{ title: 'cURL' }} - 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" - }' - ``` - - + ```bash {{ title: '字符串值' }} @@ -1287,15 +1263,14 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx' - - - ```bash {{ title: 'cURL' }} - curl -X POST '${props.appDetail.api_base_url}/conversations/name' \ - --header 'Authorization: Bearer {api_key}' \ - --form 'file=@localfile;type=audio/mp3' - ``` - - + ```json {{ title: 'Response' }} @@ -1335,15 +1310,14 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx' - - - ```bash {{ title: 'cURL' }} - curl --location --request POST '${props.appDetail.api_base_url}/text-to-audio' \ - --header 'Authorization: Bearer ENTER-YOUR-SECRET-KEY' \ - --form 'file=你好Dify;user=abc-123;message_id=5ad4cb98-f0c7-4085-b384-88c403be6290' - ``` - - + ```json {{ title: 'headers' }} @@ -1373,12 +1347,13 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx' - 'author_name' (string) 作者名称 - - ```bash {{ title: 'cURL' }} - curl -X GET '${props.appDetail.api_base_url}/info' \ - -H 'Authorization: Bearer {api_key}' - ``` - + ```json {{ title: 'Response' }} { @@ -1444,30 +1419,30 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx' - `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`,必须选择一个。 + - `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) @@ -1476,14 +1451,13 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx' - - - ```bash {{ title: 'cURL' }} - curl -X GET '${props.appDetail.api_base_url}/parameters' \ - --header 'Authorization: Bearer {api_key}' - ``` - - + ```json {{ title: 'Response' }} @@ -1546,13 +1520,13 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx' - (string) 图标 URL - - ```bash {{ title: 'cURL' }} - curl -X GET '${props.appDetail.api_base_url}/meta' \ - -H 'Authorization: Bearer {api_key}' - ``` - - + ```json {{ title: 'Response' }} @@ -1598,13 +1572,13 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx' - `use_icon_as_answer_icon` (bool) 是否使用 WebApp 图标替换聊天中的 🤖 - - ```bash {{ title: 'cURL' }} - curl -X GET '${props.appDetail.api_base_url}/site' \ - -H 'Authorization: Bearer {api_key}' - ``` - - + ```json {{ title: 'Response' }} diff --git a/web/app/components/develop/template/template_workflow.en.mdx b/web/app/components/develop/template/template_workflow.en.mdx index abf97695f..5daf41449 100644 --- a/web/app/components/develop/template/template_workflow.en.mdx +++ b/web/app/components/develop/template/template_workflow.en.mdx @@ -7,10 +7,7 @@ Workflow applications offers non-session support and is ideal for translation, a
### Base URL - - ```javascript - ``` - + ### Authentication @@ -19,12 +16,7 @@ Workflow applications offers non-session support and is ideal for translation, a For all API requests, include your API Key in the `Authorization` HTTP Header, as shown below: - - ```javascript - Authorization: Bearer {API_KEY} - - ``` - +
--- @@ -45,8 +37,8 @@ Workflow applications offers non-session support and is ideal for translation, a 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: + 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') @@ -123,9 +115,9 @@ Workflow applications offers non-session support and is ideal for translation, a - `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: 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 @@ -190,25 +182,24 @@ Workflow applications offers non-session support and is ideal for translation, a - - - ```bash {{ title: 'cURL' }} - curl -X POST '${props.appDetail.api_base_url}/workflows/run' \ - --header 'Authorization: Bearer {api_key}' \ - --header 'Content-Type: application/json' \ - --data-raw '{ - "inputs": {}, - "response_mode": "streaming", - "user": "abc-123" - }' - ``` - - + ```json {{ title: 'File variable example' }} { "inputs": { - "{variable_name}": + "{variable_name}": [ { "transfer_method": "local_file", @@ -264,7 +255,7 @@ Workflow applications offers non-session support and is ideal for translation, a headers = { "Authorization": "Bearer app-xxxxxxxx", } - + try: print("Upload file...") with open(file_path, 'rb') as file: @@ -275,7 +266,7 @@ Workflow applications offers non-session support and is ideal for translation, a "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") @@ -350,7 +341,7 @@ Workflow applications offers non-session support and is ideal for translation, a ### 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 @@ -359,8 +350,8 @@ Workflow applications offers non-session support and is ideal for translation, a 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: + 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') @@ -437,8 +428,8 @@ Workflow applications offers non-session support and is ideal for translation, a - `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 + - `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 @@ -505,23 +496,24 @@ Workflow applications offers non-session support and is ideal for translation, a - - ```bash {{ title: 'cURL' }} - 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": {}, - "response_mode": "streaming", - "user": "abc-123" - }' - ``` - + ```json {{ title: 'File variable example' }} { "inputs": { - "{variable_name}": + "{variable_name}": [ { "transfer_method": "local_file", @@ -598,13 +590,14 @@ Workflow applications offers non-session support and is ideal for translation, a ### Request Example - - ```bash {{ title: 'cURL' }} - 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 @@ -647,17 +640,16 @@ Workflow applications offers non-session support and is ideal for translation, a - `result` (string) Always returns "success" - ### Request Example - - ```bash {{ title: 'cURL' }} - 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" - }' - ``` - + ### Request Example + ### Response Example @@ -717,16 +709,15 @@ Workflow applications offers non-session support and is ideal for translation, a ### Request Example - - - ```bash {{ title: 'cURL' }} - curl -X POST '${props.appDetail.api_base_url}/files/upload' \ - --header 'Authorization: Bearer {api_key}' \ - --form 'file=@"/path/to/file"' - ``` - - - + ### Response Example @@ -756,7 +747,7 @@ Workflow applications offers non-session support and is ideal for translation, a Preview or download uploaded files. This endpoint allows you to access files that have been previously uploaded via the File Upload API. - + Files can only be accessed if they belong to messages within the requesting application. ### Path Parameters @@ -784,25 +775,23 @@ Workflow applications offers non-session support and is ideal for translation, a ### Request Example - - - ```bash {{ title: 'cURL' }} - curl -X GET '${props.appDetail.api_base_url}/files/72fa9618-8f89-4a37-9b33-7e1178a24a67/preview' \ - --header 'Authorization: Bearer {api_key}' - ``` - - + ### Download as Attachment - - - ```bash {{ title: 'cURL' }} - 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 @@ -889,14 +878,13 @@ Workflow applications offers non-session support and is ideal for translation, a - - - ```bash {{ title: 'cURL' }} - curl -X GET '${props.appDetail.api_base_url}/workflows/logs?limit=1' - --header 'Authorization: Bearer {api_key}' - ``` - - + ### Response Example ```json {{ title: 'Response' }} @@ -956,12 +944,13 @@ Workflow applications offers non-session support and is ideal for translation, a - `author_name` (string) application author name - - ```bash {{ title: 'cURL' }} - curl -X GET '${props.appDetail.api_base_url}/info' \ - -H 'Authorization: Bearer {api_key}' - ``` - + ```json {{ title: 'Response' }} { @@ -1010,30 +999,30 @@ Workflow applications offers non-session support and is ideal for translation, a - `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. + - `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) @@ -1043,14 +1032,12 @@ Workflow applications offers non-session support and is ideal for translation, a - - - ```bash {{ title: 'cURL' }} - curl -X GET '${props.appDetail.api_base_url}/parameters' \ - --header 'Authorization: Bearer {api_key}' - ``` - - + ```json {{ title: 'Response' }} @@ -1112,13 +1099,13 @@ Workflow applications offers non-session support and is ideal for translation, a - `show_workflow_steps` (bool) Whether to show workflow details - - ```bash {{ title: 'cURL' }} - curl -X GET '${props.appDetail.api_base_url}/site' \ - -H 'Authorization: Bearer {api_key}' - ``` - - + ```json {{ title: 'Response' }} diff --git a/web/app/components/develop/template/template_workflow.ja.mdx b/web/app/components/develop/template/template_workflow.ja.mdx index 0a1c0408a..afd98c7ef 100644 --- a/web/app/components/develop/template/template_workflow.ja.mdx +++ b/web/app/components/develop/template/template_workflow.ja.mdx @@ -7,10 +7,7 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from
### ベース URL - - ```javascript - ``` - + ### 認証 @@ -19,12 +16,7 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from すべての API リクエストにおいて、以下のように `Authorization`HTTP ヘッダーに API キーを含めてください: - - ```javascript - Authorization: Bearer {API_KEY} - - ``` - +
--- @@ -47,7 +39,7 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from ファイルリストは、テキスト理解と質問への回答を組み合わせたファイルの入力に適しています。モデルがファイルの解析と理解機能をサポートしている場合にのみ使用できます。 変数がファイルリストの場合、リストの各要素は以下の属性を持つ必要があります。 - - `type` (string) サポートされているタイプ: + - `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') @@ -71,7 +63,7 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from 1. Header:HTTPヘッダー `X-Trace-Id` で渡す(最優先)。 2. クエリパラメータ:URLクエリパラメータ `trace_id` で渡す。 3. リクエストボディ:リクエストボディの `trace_id` フィールドで渡す(本フィールド)。 - + ### 応答 `response_mode`が`blocking`の場合、CompletionResponse オブジェクトを返します。 @@ -190,25 +182,24 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from - - - ```bash {{ title: 'cURL' }} - curl -X POST '${props.appDetail.api_base_url}/workflows/run' \ - --header 'Authorization: Bearer {api_key}' \ - --header 'Content-Type: application/json' \ - --data-raw '{ - "inputs": {}, - "response_mode": "streaming", - "user": "abc-123" - }' - ``` - - + ```json {{ title: 'ファイル変数の例' }} { "inputs": { - "{variable_name}": + "{variable_name}": [ { "transfer_method": "local_file", @@ -264,7 +255,7 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from headers = { "Authorization": "Bearer app-xxxxxxxx", } - + try: print("ファイルをアップロードしています...") with open(file_path, 'rb') as file: @@ -275,7 +266,7 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from "user": user, "type": "TXT" # ファイルタイプをTXTに設定します } - + response = requests.post(upload_url, headers=headers, files=files, data=data) if response.status_code == 201: # 201 は作成が成功したことを意味します print("ファイルが正常にアップロードされました") @@ -350,7 +341,7 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from ### パス - `workflow_id` (string) 必須 特定バージョンのワークフローを指定するためのワークフローID - + 取得方法:バージョン履歴で特定バージョンのワークフローIDを照会できます。 ### リクエストボディ @@ -500,23 +491,24 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from - - ```bash {{ title: 'cURL' }} - 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": {}, - "response_mode": "streaming", - "user": "abc-123" - }' - ``` - + ```json {{ title: 'ファイル変数の例' }} { "inputs": { - "{variable_name}": + "{variable_name}": [ { "transfer_method": "local_file", @@ -593,13 +585,14 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from ### リクエスト例 - - ```bash {{ title: 'cURL' }} - curl -X GET '${props.appDetail.api_base_url}/workflows/run/:workflow_run_id' \ - -H 'Authorization: Bearer {api_key}' \ - -H 'Content-Type: application/json' - ``` - + ### 応答例 @@ -642,17 +635,16 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from - `result` (string) 常に"success"を返します - ### リクエスト例 - - ```bash {{ title: 'cURL' }} - 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" - }' - ``` - + ### リクエスト例 + ### 応答例 @@ -712,15 +704,15 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from ### リクエスト例 - - - ```bash {{ title: 'cURL' }} - curl -X POST '${props.appDetail.api_base_url}/files/upload' \ - --header 'Authorization: Bearer {api_key}' \ - --form 'file=@"/path/to/file"' - ``` - - + ### 応答例 @@ -751,7 +743,7 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from アップロードされたファイルをプレビューまたはダウンロードします。このエンドポイントを使用すると、以前にファイルアップロード API でアップロードされたファイルにアクセスできます。 - + ファイルは、リクエストしているアプリケーションのメッセージ範囲内にある場合のみアクセス可能です。 ### パスパラメータ @@ -779,25 +771,23 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from ### リクエスト例 - - - ```bash {{ title: 'cURL - ブラウザプレビュー' }} - 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?as_attachment=true' \ - --header 'Authorization: Bearer {api_key}' \ - --output downloaded_file.png - ``` - - + ### レスポンスヘッダー例 @@ -884,14 +874,13 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from - - - ```bash {{ title: 'cURL' }} - curl -X GET '${props.appDetail.api_base_url}/workflows/logs?limit=1' - --header 'Authorization: Bearer {api_key}' - ``` - - + ### 応答例 ```json {{ title: '応答' }} @@ -951,12 +940,13 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from - `author_name` (string) 作者の名前 - - ```bash {{ title: 'cURL' }} - curl -X GET '${props.appDetail.api_base_url}/info' \ - -H 'Authorization: Bearer {api_key}' - ``` - + ```json {{ title: 'Response' }} { @@ -1005,30 +995,30 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from - `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) ビデオ設定 + - `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`。いずれかを選択する必要があります。 + - `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) @@ -1038,14 +1028,12 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from - - - ```bash {{ title: 'cURL' }} - curl -X GET '${props.appDetail.api_base_url}/parameters' \ - --header 'Authorization: Bearer {api_key}' - ``` - - + ```json {{ title: '応答' }} @@ -1107,13 +1095,13 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from - `show_workflow_steps` (bool) ワークフローの詳細を表示するかどうか - - ```bash {{ title: 'cURL' }} - curl -X GET '${props.appDetail.api_base_url}/site' \ - -H 'Authorization: Bearer {api_key}' - ``` - - + ```json {{ title: 'Response' }} diff --git a/web/app/components/develop/template/template_workflow.zh.mdx b/web/app/components/develop/template/template_workflow.zh.mdx index 5c00f03a7..f40167718 100644 --- a/web/app/components/develop/template/template_workflow.zh.mdx +++ b/web/app/components/develop/template/template_workflow.zh.mdx @@ -7,10 +7,7 @@ Workflow 应用无会话支持,适合用于翻译/文章写作/总结 AI 等
### Base URL - - ```javascript - ``` - + ### Authentication @@ -18,12 +15,7 @@ Workflow 应用无会话支持,适合用于翻译/文章写作/总结 AI 等 **强烈建议开发者把 `API-Key` 放在后端存储,而非分享或者放在客户端存储,以免 `API-Key` 泄露,导致财产损失。** 所有 API 请求都应在 **`Authorization`** HTTP Header 中包含您的 `API-Key`,如下所示: - - ```javascript - Authorization: Bearer {API_KEY} - - ``` - +
--- @@ -31,7 +23,7 @@ Workflow 应用无会话支持,适合用于翻译/文章写作/总结 AI 等 @@ -182,23 +174,24 @@ Workflow 应用无会话支持,适合用于翻译/文章写作/总结 AI 等 - - ```bash {{ title: 'cURL' }} - curl -X POST '${props.appDetail.api_base_url}/workflows/run' \ - --header 'Authorization: Bearer {api_key}' \ - --header 'Content-Type: application/json' \ - --data-raw '{ - "inputs": {}, - "response_mode": "streaming", - "user": "abc-123" - }' - ``` - + ```json {{ title: 'File variable example' }} { "inputs": { - "{variable_name}": + "{variable_name}": [ { "transfer_method": "local_file", @@ -254,7 +247,7 @@ Workflow 应用无会话支持,适合用于翻译/文章写作/总结 AI 等 headers = { "Authorization": "Bearer app-xxxxxxxx", } - + try: print("上传文件中...") with open(file_path, 'rb') as file: @@ -265,7 +258,7 @@ Workflow 应用无会话支持,适合用于翻译/文章写作/总结 AI 等 "user": user, "type": "TXT" # 设置文件类型为TXT } - + response = requests.post(upload_url, headers=headers, files=files, data=data) if response.status_code == 201: # 201 表示创建成功 print("文件上传成功") @@ -331,7 +324,7 @@ Workflow 应用无会话支持,适合用于翻译/文章写作/总结 AI 等 @@ -340,7 +333,7 @@ Workflow 应用无会话支持,适合用于翻译/文章写作/总结 AI 等 ### Path - `workflow_id` (string) Required 工作流ID,用于指定特定版本的工作流 - + 获取方式:可以在版本历史中查询特定版本的工作流ID。 ### Request Body @@ -490,23 +483,24 @@ Workflow 应用无会话支持,适合用于翻译/文章写作/总结 AI 等 - - ```bash {{ title: 'cURL' }} - 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": {}, - "response_mode": "streaming", - "user": "abc-123" - }' - ``` - + ```json {{ title: 'File variable example' }} { "inputs": { - "{variable_name}": + "{variable_name}": [ { "transfer_method": "local_file", @@ -560,7 +554,7 @@ Workflow 应用无会话支持,适合用于翻译/文章写作/总结 AI 等 @@ -583,13 +577,14 @@ Workflow 应用无会话支持,适合用于翻译/文章写作/总结 AI 等 ### Request Example - - ```bash {{ title: 'cURL' }} - 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 @@ -633,16 +628,15 @@ Workflow 应用无会话支持,适合用于翻译/文章写作/总结 AI 等 ### Request Example - - ```bash {{ title: 'cURL' }} - 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 @@ -703,15 +697,15 @@ Workflow 应用无会话支持,适合用于翻译/文章写作/总结 AI 等 - - - ```bash {{ title: 'cURL' }} - curl -X POST '${props.appDetail.api_base_url}/files/upload' \ - --header 'Authorization: Bearer {api_key}' \ - --form 'file=@"/path/to/file"' - ``` - - + ```json {{ title: 'Response' }} @@ -739,7 +733,7 @@ Workflow 应用无会话支持,适合用于翻译/文章写作/总结 AI 等 预览或下载已上传的文件。此端点允许您访问先前通过文件上传 API 上传的文件。 - + 文件只能在属于请求应用程序的消息范围内访问。 ### 路径参数 @@ -767,25 +761,23 @@ Workflow 应用无会话支持,适合用于翻译/文章写作/总结 AI 等 ### 请求示例 - - - ```bash {{ title: 'cURL' }} - 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?as_attachment=true' \ - --header 'Authorization: Bearer {api_key}' \ - --output downloaded_file.png - ``` - - + ### 响应标头示例 @@ -812,7 +804,7 @@ Workflow 应用无会话支持,适合用于翻译/文章写作/总结 AI 等 @@ -871,14 +863,13 @@ Workflow 应用无会话支持,适合用于翻译/文章写作/总结 AI 等 - - - ```bash {{ title: 'cURL' }} - curl -X GET '${props.appDetail.api_base_url}/workflows/logs?limit=1' - --header 'Authorization: Bearer {api_key}' - ``` - - + ### Response Example ```json {{ title: 'Response' }} @@ -937,12 +928,13 @@ Workflow 应用无会话支持,适合用于翻译/文章写作/总结 AI 等 - 'author_name' (string) 作者名称 - - ```bash {{ title: 'cURL' }} - curl -X GET '${props.appDetail.api_base_url}/info' \ - -H 'Authorization: Bearer {api_key}' - ``` - + ```json {{ title: 'Response' }} { @@ -991,30 +983,30 @@ Workflow 应用无会话支持,适合用于翻译/文章写作/总结 AI 等 - `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`,必须选择一个。 + - `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) @@ -1024,14 +1016,12 @@ Workflow 应用无会话支持,适合用于翻译/文章写作/总结 AI 等 - - - ```bash {{ title: 'cURL' }} - curl -X GET '${props.appDetail.api_base_url}/parameters' \ - --header 'Authorization: Bearer {api_key}' - ``` - - + ```json {{ title: 'Response' }} @@ -1094,13 +1084,13 @@ Workflow 应用无会话支持,适合用于翻译/文章写作/总结 AI 等 - `show_workflow_steps` (bool) 是否显示工作流详情 - - ```bash {{ title: 'cURL' }} - curl -X GET '${props.appDetail.api_base_url}/site' \ - -H 'Authorization: Bearer {api_key}' - ``` - - + ```json {{ title: 'Response' }}