| | |
| | | ### ChatCompletionResponse |
| | | |
| | | 返回完整的 App 结果,`Content-Type` 为 `application/json`。 |
| | | - `event` (string) 事件类型,固定为 `message` |
| | | - `task_id` (string) 任务 ID,用于请求跟踪和下方的停止响应接口 |
| | | - `id` (string) 唯一ID |
| | | - `message_id` (string) 消息唯一 ID |
| | | - `conversation_id` (string) 会话 ID |
| | | - `mode` (string) App 模式,固定为 chat |
| | |
| | | ```json {{ title: 'Response' }} |
| | | { |
| | | "event": "message", |
| | | "task_id": "c3800678-a077-43df-a102-53f23ed20b88", |
| | | "id": "9da23599-e713-473b-982c-4328d4f5c78a", |
| | | "message_id": "9da23599-e713-473b-982c-4328d4f5c78a", |
| | | "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", |
| | | "mode": "chat", |
| | |
| | | data: {"event": "message", "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": "'m", "created_at": 1679586595} |
| | | data: {"event": "message", "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " glad", "created_at": 1679586595} |
| | | data: {"event": "message", "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " to", "created_at": 1679586595} |
| | | data: {"event": "message", "message_id" : "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " meet", "created_at": 1679586595} |
| | | data: {"event": "message", "message_id" : "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " you", "created_at": 1679586595} |
| | | data: {"event": "message", "message_id": : "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " meet", "created_at": 1679586595} |
| | | data: {"event": "message", "message_id": : "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " you", "created_at": 1679586595} |
| | | data: {"event": "message_end", "id": "5e52ce04-874b-4d27-9045-b3bc80def685", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "metadata": {"usage": {"prompt_tokens": 1033, "prompt_unit_price": "0.001", "prompt_price_unit": "0.001", "prompt_price": "0.0010330", "completion_tokens": 135, "completion_unit_price": "0.002", "completion_price_unit": "0.001", "completion_price": "0.0002700", "total_tokens": 1168, "total_price": "0.0013030", "currency": "USD", "latency": 1.381760165997548}, "retriever_resources": [{"position": 1, "dataset_id": "101b4c97-fc2e-463c-90b1-5261a4cdcafb", "dataset_name": "iPhone", "document_id": "8dd1ad74-0b5f-4175-b735-7d98bbbb4e00", "document_name": "iPhone List", "segment_id": "ed599c7f-2766-4294-9d1d-e5235a61270a", "score": 0.98457545, "content": "\"Model\",\"Release Date\",\"Display Size\",\"Resolution\",\"Processor\",\"RAM\",\"Storage\",\"Camera\",\"Battery\",\"Operating System\"\n\"iPhone 13 Pro Max\",\"September 24, 2021\",\"6.7 inch\",\"1284 x 2778\",\"Hexa-core (2x3.23 GHz Avalanche + 4x1.82 GHz Blizzard)\",\"6 GB\",\"128, 256, 512 GB, 1TB\",\"12 MP\",\"4352 mAh\",\"iOS 15\""}]}} |
| | | data: {"event": "tts_message", "conversation_id": "23dd85f3-1a41-4ea0-b7a9-062734ccfaf9", "message_id": "a8bdc41c-13b2-4c18-bfd9-054b9803038c", "created_at": 1721205487, "task_id": "3bf8a0bb-e73b-4690-9e66-4e429bad8ee7", "audio": "qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq"} |
| | | data: {"event": "tts_message_end", "conversation_id": "23dd85f3-1a41-4ea0-b7a9-062734ccfaf9", "message_id": "a8bdc41c-13b2-4c18-bfd9-054b9803038c", "created_at": 1721205487, "task_id": "3bf8a0bb-e73b-4690-9e66-4e429bad8ee7", "audio": ""} |
| | |
| | | --- |
| | | |
| | | <Heading |
| | | url='/app/feedbacks' |
| | | method='GET' |
| | | title='获取APP的消息点赞和反馈' |
| | | name='#app-feedbacks' |
| | | /> |
| | | <Row> |
| | | <Col> |
| | | 获取应用的终端用户反馈、点赞。 |
| | | |
| | | ### Query |
| | | <Properties> |
| | | <Property name='page' type='string' key='page'> |
| | | (选填)分页,默认值:1 |
| | | </Property> |
| | | </Properties> |
| | | |
| | | <Properties> |
| | | <Property name='limit' type='string' key='limit'> |
| | | (选填)每页数量,默认值:20 |
| | | </Property> |
| | | </Properties> |
| | | |
| | | ### Response |
| | | - `data` (List) 返回该APP的点赞、反馈列表。 |
| | | </Col> |
| | | <Col sticky> |
| | | |
| | | <CodeGroup title="Request" tag="GET" label="/app/feedbacks" targetCode={`curl -X GET '${props.appDetail.api_base_url}/app/feedbacks?page=1&limit=20'`}> |
| | | |
| | | ```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' |
| | | ``` |
| | | |
| | | </CodeGroup> |
| | | |
| | | <CodeGroup title="Response"> |
| | | ```json {{ title: 'Response' }} |
| | | { |
| | | "data": [ |
| | | { |
| | | "id": "8c0fbed8-e2f9-49ff-9f0e-15a35bdd0e25", |
| | | "app_id": "f252d396-fe48-450e-94ec-e184218e7346", |
| | | "conversation_id": "2397604b-9deb-430e-b285-4726e51fd62d", |
| | | "message_id": "709c0b0f-0a96-4a4e-91a4-ec0889937b11", |
| | | "rating": "like", |
| | | "content": "message feedback information-3", |
| | | "from_source": "user", |
| | | "from_end_user_id": "74286412-9a1a-42c1-929c-01edb1d381d5", |
| | | "from_account_id": null, |
| | | "created_at": "2025-04-24T09:24:38", |
| | | "updated_at": "2025-04-24T09:24:38" |
| | | } |
| | | ] |
| | | } |
| | | |
| | | ``` |
| | | </CodeGroup> |
| | | </Col> |
| | | </Row> |
| | | |
| | | --- |
| | | |
| | | <Heading |
| | | url='/messages/{message_id}/suggested' |
| | | method='GET' |
| | | title='获取下一轮建议问题列表' |
| | |
| | | <CodeGroup title="Request" tag="GET" label="/messages/{message_id}/suggested" targetCode={`curl --location --request GET '${props.appDetail.api_base_url}/messages/{message_id}/suggested?user=abc-123 \\\n--header 'Authorization: Bearer ENTER-YOUR-SECRET-KEY' \\\n--header 'Content-Type: application/json'`}> |
| | | |
| | | ```bash {{ title: 'cURL' }} |
| | | curl --location --request GET '${props.appDetail.api_base_url}/messages/{message_id}/suggested?user=abc-123' \ |
| | | curl --location --request GET '${props.appDetail.api_base_url}/messages/{message_id}/suggested'?user=abc-123 \ |
| | | --header 'Authorization: Bearer ENTER-YOUR-SECRET-KEY' \ |
| | | --header 'Content-Type: application/json' \ |
| | | ``` |
| | |
| | | </CodeGroup> |
| | | |
| | | <CodeGroup title="Response"> |
| | | ```text {{ title: 'Response' }} |
| | | 204 No Content |
| | | ```json {{ title: 'Response' }} |
| | | { |
| | | "result": "success" |
| | | } |
| | | ``` |
| | | </CodeGroup> |
| | | </Col> |
| | |
| | | --- |
| | | |
| | | <Heading |
| | | url='/conversations/:conversation_id/variables' |
| | | method='GET' |
| | | title='获取对话变量' |
| | | name='#conversation-variables' |
| | | /> |
| | | <Row> |
| | | <Col> |
| | | 从特定对话中检索变量。此端点对于提取对话过程中捕获的结构化数据非常有用。 |
| | | |
| | | ### 路径参数 |
| | | |
| | | <Properties> |
| | | <Property name='conversation_id' type='string' key='conversation_id'> |
| | | 要从中检索变量的对话ID。 |
| | | </Property> |
| | | </Properties> |
| | | |
| | | ### 查询参数 |
| | | |
| | | <Properties> |
| | | <Property name='user' type='string' key='user'> |
| | | 用户标识符,由开发人员定义的规则,在应用程序内必须唯一。 |
| | | </Property> |
| | | <Property name='last_id' type='string' key='last_id'> |
| | | (选填)当前页最后面一条记录的 ID,默认 null |
| | | </Property> |
| | | <Property name='limit' type='int' key='limit'> |
| | | (选填)一次请求返回多少条记录,默认 20 条,最大 100 条,最小 1 条。 |
| | | </Property> |
| | | </Properties> |
| | | |
| | | ### 响应 |
| | | |
| | | - `limit` (int) 每页项目数 |
| | | - `has_more` (bool) 是否有更多项目 |
| | | - `data` (array[object]) 变量列表 |
| | | - `id` (string) 变量ID |
| | | - `name` (string) 变量名称 |
| | | - `value_type` (string) 变量类型(字符串、数字、布尔等) |
| | | - `value` (string) 变量值 |
| | | - `description` (string) 变量描述 |
| | | - `created_at` (int) 创建时间戳 |
| | | - `updated_at` (int) 最后更新时间戳 |
| | | |
| | | ### 错误 |
| | | - 404, `conversation_not_exists`, 对话不存在 |
| | | |
| | | </Col> |
| | | <Col sticky> |
| | | |
| | | <CodeGroup title="Request" tag="GET" label="/conversations/:conversation_id/variables" targetCode={`curl -X GET '${props.appDetail.api_base_url}/conversations/{conversation_id}/variables?user=abc-123' \\\n--header 'Authorization: Bearer {api_key}'`}> |
| | | |
| | | ```bash {{ title: 'cURL' }} |
| | | curl -X GET '${props.appDetail.api_base_url}/conversations/{conversation_id}/variables?user=abc-123' \ |
| | | --header 'Authorization: Bearer {api_key}' |
| | | ``` |
| | | |
| | | </CodeGroup> |
| | | |
| | | <CodeGroup title="Request with variable name filter"> |
| | | ```bash {{ title: 'cURL' }} |
| | | curl -X GET '${props.appDetail.api_base_url}/conversations/{conversation_id}/variables?user=abc-123&variable_name=customer_name' \ |
| | | --header 'Authorization: Bearer {api_key}' |
| | | ``` |
| | | </CodeGroup> |
| | | |
| | | <CodeGroup title="Response"> |
| | | ```json {{ title: 'Response' }} |
| | | { |
| | | "limit": 100, |
| | | "has_more": false, |
| | | "data": [ |
| | | { |
| | | "id": "variable-uuid-1", |
| | | "name": "customer_name", |
| | | "value_type": "string", |
| | | "value": "John Doe", |
| | | "description": "客户名称(从对话中提取)", |
| | | "created_at": 1650000000000, |
| | | "updated_at": 1650000000000 |
| | | }, |
| | | { |
| | | "id": "variable-uuid-2", |
| | | "name": "order_details", |
| | | "value_type": "json", |
| | | "value": "{\"product\":\"Widget\",\"quantity\":5,\"price\":19.99}", |
| | | "description": "客户的订单详情", |
| | | "created_at": 1650000000000, |
| | | "updated_at": 1650000000000 |
| | | } |
| | | ] |
| | | } |
| | | ``` |
| | | </CodeGroup> |
| | | </Col> |
| | | </Row> |
| | | |
| | | --- |
| | | |
| | | <Heading |
| | | url='/audio-to-text' |
| | | method='POST' |
| | | title='语音转文字' |
| | |
| | | ### Request Body |
| | | |
| | | <Properties> |
| | | <Property name='message_id' type='str' key='message_id'> |
| | | <Property name='message_id' type='str' key='text'> |
| | | Dify 生成的文本消息,那么直接传递生成的message-id 即可,后台会通过 message_id 查找相应的内容直接合成语音信息。如果同时传 message_id 和 text,优先使用 message_id。 |
| | | </Property> |
| | | <Property name='text' type='str' key='text'> |
| | |
| | | "user": "abc-123" |
| | | }' |
| | | ``` |
| | | |
| | | |
| | | </CodeGroup> |
| | | |
| | | <CodeGroup title="headers"> |
| | |
| | | "content": "\ud83d\ude01" |
| | | } |
| | | } |
| | | } |
| | | ``` |
| | | </CodeGroup> |
| | | </Col> |
| | | </Row> |
| | | --- |
| | | |
| | | <Heading |
| | | url='/site' |
| | | method='GET' |
| | | title='获取应用 WebApp 设置' |
| | | name='#site' |
| | | /> |
| | | <Row> |
| | | <Col> |
| | | 用于获取应用的 WebApp 设置 |
| | | ### Response |
| | | - `title` (string) WebApp 名称 |
| | | - `chat_color_theme` (string) 聊天颜色主题, hex 格式 |
| | | - `chat_color_theme_inverted` (bool) 聊天颜色主题是否反转 |
| | | - `icon_type` (string) 图标类型, `emoji`-表情, `image`-图片 |
| | | - `icon` (string) 图标, 如果是 `emoji` 类型, 则是 emoji 表情符号, 如果是 `image` 类型, 则是图片 URL |
| | | - `icon_background` (string) hex 格式的背景色 |
| | | - `icon_url` (string) 图标 URL |
| | | - `description` (string) 描述 |
| | | - `copyright` (string) 版权信息 |
| | | - `privacy_policy` (string) 隐私政策链接 |
| | | - `custom_disclaimer` (string) 自定义免责声明 |
| | | - `default_language` (string) 默认语言 |
| | | - `show_workflow_steps` (bool) 是否显示工作流详情 |
| | | - `use_icon_as_answer_icon` (bool) 是否使用 WebApp 图标替换聊天中的 🤖 |
| | | </Col> |
| | | <Col> |
| | | <CodeGroup title="Request" tag="POST" label="/meta" targetCode={`curl -X GET '${props.appDetail.api_base_url}/site' \\\n-H 'Authorization: Bearer {api_key}'`}> |
| | | ```bash {{ title: 'cURL' }} |
| | | curl -X GET '${props.appDetail.api_base_url}/site' \ |
| | | -H 'Authorization: Bearer {api_key}' |
| | | ``` |
| | | |
| | | </CodeGroup> |
| | | |
| | | <CodeGroup title="Response"> |
| | | ```json {{ title: 'Response' }} |
| | | { |
| | | "title": "My App", |
| | | "chat_color_theme": "#ff4a4a", |
| | | "chat_color_theme_inverted": false, |
| | | "icon_type": "emoji", |
| | | "icon": "😄", |
| | | "icon_background": "#FFEAD5", |
| | | "icon_url": null, |
| | | "description": "This is my app.", |
| | | "copyright": "all rights reserved", |
| | | "privacy_policy": "", |
| | | "custom_disclaimer": "All generated by AI", |
| | | "default_language": "en-US", |
| | | "show_workflow_steps": false, |
| | | "use_icon_as_answer_icon": false, |
| | | } |
| | | ``` |
| | | </CodeGroup> |
| | | </Col> |
| | | </Row> |
| | | ___ |
| | | |
| | | <Heading |
| | | url='/apps/annotations' |
| | | method='GET' |
| | | title='获取标注列表' |
| | | name='#annotation_list' |
| | | /> |
| | | <Row> |
| | | <Col> |
| | | ### Query |
| | | <Properties> |
| | | <Property name='page' type='string' key='page'> |
| | | 页码 |
| | | </Property> |
| | | <Property name='limit' type='string' key='limit'> |
| | | 每页数量 |
| | | </Property> |
| | | </Properties> |
| | | </Col> |
| | | <Col sticky> |
| | | <CodeGroup |
| | | title="Request" |
| | | tag="GET" |
| | | label="/apps/annotations" |
| | | targetCode={`curl --location --request GET '${props.appDetail.api_base_url}/apps/annotations?page=1&limit=20' \\\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}' |
| | | ``` |
| | | </CodeGroup> |
| | | |
| | | <CodeGroup title="Response"> |
| | | ```json {{ title: 'Response' }} |
| | | { |
| | | "data": [ |
| | | { |
| | | "id": "69d48372-ad81-4c75-9c46-2ce197b4d402", |
| | | "question": "What is your name?", |
| | | "answer": "I am Dify.", |
| | | "hit_count": 0, |
| | | "created_at": 1735625869 |
| | | } |
| | | ], |
| | | "has_more": false, |
| | | "limit": 20, |
| | | "total": 1, |
| | | "page": 1 |
| | | } |
| | | ``` |
| | | </CodeGroup> |
| | | </Col> |
| | | </Row> |
| | | --- |
| | | |
| | | <Heading |
| | | url='/apps/annotations' |
| | | method='POST' |
| | | title='创建标注' |
| | | name='#create_annotation' |
| | | /> |
| | | <Row> |
| | | <Col> |
| | | ### Query |
| | | <Properties> |
| | | <Property name='question' type='string' key='question'> |
| | | 问题 |
| | | </Property> |
| | | <Property name='answer' type='string' key='answer'> |
| | | 答案内容 |
| | | </Property> |
| | | </Properties> |
| | | </Col> |
| | | <Col sticky> |
| | | <CodeGroup |
| | | title="Request" |
| | | tag="POST" |
| | | label="/apps/annotations" |
| | | targetCode={`curl --location --request POST '${props.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." |
| | | }' |
| | | ``` |
| | | </CodeGroup> |
| | | |
| | | <CodeGroup title="Response"> |
| | | ```json {{ title: 'Response' }} |
| | | { |
| | | "id": "69d48372-ad81-4c75-9c46-2ce197b4d402", |
| | | "question": "What is your name?", |
| | | "answer": "I am Dify.", |
| | | "hit_count": 0, |
| | | "created_at": 1735625869 |
| | | } |
| | | ``` |
| | | </CodeGroup> |
| | | </Col> |
| | | </Row> |
| | | --- |
| | | |
| | | <Heading |
| | | url='/apps/annotations/{annotation_id}' |
| | | method='PUT' |
| | | title='更新标注' |
| | | name='#update_annotation' |
| | | /> |
| | | <Row> |
| | | <Col> |
| | | ### Query |
| | | <Properties> |
| | | <Property name='annotation_id' type='string' key='annotation_id'> |
| | | 标注 ID |
| | | </Property> |
| | | <Property name='question' type='string' key='question'> |
| | | 问题 |
| | | </Property> |
| | | <Property name='answer' type='string' key='answer'> |
| | | 答案内容 |
| | | </Property> |
| | | </Properties> |
| | | </Col> |
| | | <Col sticky> |
| | | <CodeGroup |
| | | title="Request" |
| | | tag="PUT" |
| | | label="/apps/annotations/{annotation_id}" |
| | | targetCode={`curl --location --request PUT '${props.appDetail.api_base_url}/apps/annotations/{annotation_id}' \\\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." |
| | | }' |
| | | ``` |
| | | </CodeGroup> |
| | | |
| | | <CodeGroup title="Response"> |
| | | ```json {{ title: 'Response' }} |
| | | { |
| | | "id": "69d48372-ad81-4c75-9c46-2ce197b4d402", |
| | | "question": "What is your name?", |
| | | "answer": "I am Dify.", |
| | | "hit_count": 0, |
| | | "created_at": 1735625869 |
| | | } |
| | | ``` |
| | | </CodeGroup> |
| | | </Col> |
| | | </Row> |
| | | --- |
| | | |
| | | <Heading |
| | | url='/apps/annotations/{annotation_id}' |
| | | method='DELETE' |
| | | title='删除标注' |
| | | name='#delete_annotation' |
| | | /> |
| | | <Row> |
| | | <Col> |
| | | ### Query |
| | | <Properties> |
| | | <Property name='annotation_id' type='string' key='annotation_id'> |
| | | 标注 ID |
| | | </Property> |
| | | </Properties> |
| | | </Col> |
| | | <Col sticky> |
| | | <CodeGroup |
| | | title="Request" |
| | | tag="PUT" |
| | | label="/apps/annotations/{annotation_id}" |
| | | targetCode={`curl --location --request DELETE '${props.appDetail.api_base_url}/apps/annotations/{annotation_id}' \\\n--header 'Authorization: Bearer {api_key}' \\\n--header 'Content-Type: application/json'`} |
| | | > |
| | | ```bash {{ title: 'cURL' }} |
| | | curl --location --request DELETE '${props.appDetail.api_base_url}/apps/annotations/{annotation_id}' \ |
| | | --header 'Authorization: Bearer {api_key}' |
| | | ``` |
| | | </CodeGroup> |
| | | |
| | | <CodeGroup title="Response"> |
| | | ```text {{ title: 'Response' }} |
| | | 204 No Content |
| | | ``` |
| | | </CodeGroup> |
| | | </Col> |
| | | </Row> |
| | | --- |
| | | |
| | | <Heading |
| | | url='/apps/annotation-reply/{action}' |
| | | method='POST' |
| | | title='标注回复初始设置' |
| | | name='#initial_annotation_reply_settings' |
| | | /> |
| | | <Row> |
| | | <Col> |
| | | ### Query |
| | | <Properties> |
| | | <Property name='action' type='string' key='action'> |
| | | 动作,只能是 'enable' 或 'disable' |
| | | </Property> |
| | | <Property name='embedding_provider_name' type='string' key='embedding_provider_name'> |
| | | 指定的嵌入模型提供商, 必须先在系统内设定好接入的模型,对应的是provider字段 |
| | | </Property> |
| | | <Property name='embedding_model_name' type='string' key='embedding_model_name'> |
| | | 指定的嵌入模型,对应的是model字段 |
| | | </Property> |
| | | <Property name='score_threshold' type='number' key='score_threshold'> |
| | | 相似度阈值,当相似度大于该阈值时,系统会自动回复,否则不回复 |
| | | </Property> |
| | | </Properties> |
| | | </Col> |
| | | <Col sticky> |
| | | 嵌入模型的提供商和模型名称可以通过以下接口获取:v1/workspaces/current/models/model-types/text-embedding, 具体见:通过 API 维护知识库。 使用的Authorization是Dataset的API Token。 |
| | | <CodeGroup |
| | | 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" |
| | | }' |
| | | ``` |
| | | </CodeGroup> |
| | | |
| | | <CodeGroup title="Response"> |
| | | ```json {{ title: 'Response' }} |
| | | { |
| | | "job_id": "b15c8f68-1cf4-4877-bf21-ed7cf2011802", |
| | | "job_status": "waiting" |
| | | } |
| | | ``` |
| | | </CodeGroup> |
| | | 该接口是异步执行,所以会返回一个job_id,通过查询job状态接口可以获取到最终的执行结果。 |
| | | </Col> |
| | | </Row> |
| | | --- |
| | | |
| | | <Heading |
| | | url='/apps/annotation-reply/{action}/status/{job_id}' |
| | | method='GET' |
| | | title='查询标注回复初始设置任务状态' |
| | | name='#initial_annotation_reply_settings_task_status' |
| | | /> |
| | | <Row> |
| | | <Col> |
| | | ### Query |
| | | <Properties> |
| | | <Property name='action' type='string' key='action'> |
| | | 动作,只能是 'enable' 或 'disable',并且必须和标注回复初始设置接口的动作一致 |
| | | </Property> |
| | | <Property name='job_id' type='string' key='job_id'> |
| | | 任务 ID,从标注回复初始设置接口返回的 job_id |
| | | </Property> |
| | | </Properties> |
| | | </Col> |
| | | <Col sticky> |
| | | <CodeGroup |
| | | title="Request" |
| | | tag="GET" |
| | | label="/apps/annotations" |
| | | targetCode={`curl --location --request GET '${props.appDetail.api_base_url}/apps/annotation-reply/{action}/status/{job_id}' \\\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}' |
| | | ``` |
| | | </CodeGroup> |
| | | |
| | | <CodeGroup title="Response"> |
| | | ```json {{ title: 'Response' }} |
| | | { |
| | | "job_id": "b15c8f68-1cf4-4877-bf21-ed7cf2011802", |
| | | "job_status": "waiting", |
| | | "error_msg": "" |
| | | } |
| | | ``` |
| | | </CodeGroup> |