| | |
| | | |
| | | ### ChatCompletionResponse |
| | | Returns the complete App result, `Content-Type` is `application/json`. |
| | | - `event` (string) 事件类型,固定为 `message` |
| | | - `task_id` (string) 任务 ID,用于请求跟踪和下方的停止响应接口 |
| | | - `id` (string) 唯一ID |
| | | - `message_id` (string) Unique message ID |
| | | - `conversation_id` (string) Conversation ID |
| | | - `mode` (string) App mode, fixed as `chat` |
| | |
| | | - `created_at` (int) Creation timestamp, e.g.: 1705395332 |
| | | - `event: agent_thought` thought of Agent, contains the thought of LLM, input and output of tool calls (Only supported in Agent mode) |
| | | - `id` (string) Agent thought ID, every iteration has a unique agent thought ID |
| | | - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API |
| | | - `task_id` (string) (string) Task ID, used for request tracking and the below Stop Generate API |
| | | - `message_id` (string) Unique message ID |
| | | - `position` (int) Position of current agent thought, each message may have multiple thoughts in order. |
| | | - `thought` (string) What LLM is thinking about |
| | |
| | | ```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": ""} |
| | |
| | | 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": ""} |
| | |
| | | </Col> |
| | | </Row> |
| | | |
| | | --- |
| | | |
| | | <Heading |
| | | url='/app/feedbacks' |
| | | method='GET' |
| | | title='Get feedbacks of application' |
| | | name='#app-feedbacks' |
| | | /> |
| | | <Row> |
| | | <Col> |
| | | Get application's feedbacks. |
| | | |
| | | ### Query |
| | | <Properties> |
| | | <Property name='page' type='string' key='page'> |
| | | (optional)pagination,default:1 |
| | | </Property> |
| | | </Properties> |
| | | |
| | | <Properties> |
| | | <Property name='limit' type='string' key='limit'> |
| | | (optional) records per page default:20 |
| | | </Property> |
| | | </Properties> |
| | | |
| | | ### Response |
| | | - `data` (List) return apps feedback list. |
| | | </Col> |
| | | <Col sticky> |
| | | |
| | | <CodeGroup title="Request" tag="GET" label="/app/feedbacks" targetCode={`curl -X GET '${props.appDetail.api_base_url}/app/feedbacks?page=1&limit=20'`}> |
| | | |
| | | ```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 |
| | |
| | | "tool_input": "{\"dalle2\": {\"prompt\": \"cat\"}}", |
| | | "created_at": 1705988186, |
| | | "observation": "image has been created and sent to user already, you should tell user to check it now.", |
| | | "files": [ |
| | | "message_files": [ |
| | | "976990d2-5294-47e6-8f14-7356ba9d2d76" |
| | | ] |
| | | }, |
| | |
| | | "tool_input": "", |
| | | "created_at": 1705988199, |
| | | "observation": "", |
| | | "files": [] |
| | | "message_files": [] |
| | | } |
| | | ] |
| | | } |
| | |
| | | </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='Get Conversation Variables' |
| | | name='#conversation-variables' |
| | | /> |
| | | <Row> |
| | | <Col> |
| | | Retrieve variables from a specific conversation. This endpoint is useful for extracting structured data that was captured during the conversation. |
| | | |
| | | ### Path Parameters |
| | | |
| | | <Properties> |
| | | <Property name='conversation_id' type='string' key='conversation_id'> |
| | | The ID of the conversation to retrieve variables from. |
| | | </Property> |
| | | </Properties> |
| | | |
| | | ### Query Parameters |
| | | |
| | | <Properties> |
| | | <Property name='user' type='string' key='user'> |
| | | The user identifier, defined by the developer, must ensure uniqueness within the application |
| | | </Property> |
| | | <Property name='last_id' type='string' key='last_id'> |
| | | (Optional) The ID of the last record on the current page, default is null. |
| | | </Property> |
| | | <Property name='limit' type='int' key='limit'> |
| | | (Optional) How many records to return in one request, default is the most recent 20 entries. Maximum 100, minimum 1. |
| | | </Property> |
| | | </Properties> |
| | | |
| | | ### Response |
| | | |
| | | - `limit` (int) Number of items per page |
| | | - `has_more` (bool) Whether there is a next page |
| | | - `data` (array[object]) List of variables |
| | | - `id` (string) Variable ID |
| | | - `name` (string) Variable name |
| | | - `value_type` (string) Variable type (string, number, object, etc.) |
| | | - `value` (string) Variable value |
| | | - `description` (string) Variable description |
| | | - `created_at` (int) Creation timestamp |
| | | - `updated_at` (int) Last update timestamp |
| | | |
| | | ### Errors |
| | | - 404, `conversation_not_exists`, Conversation not found |
| | | |
| | | </Col> |
| | | <Col sticky> |
| | | |
| | | <CodeGroup title="Request" tag="GET" label="/conversations/:conversation_id/variables" targetCode={`curl -X GET '${props.appDetail.api_base_url}/conversations/{conversation_id}/variables?user=abc-123' \\\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": "Customer name extracted from the conversation", |
| | | "created_at": 1650000000000, |
| | | "updated_at": 1650000000000 |
| | | }, |
| | | { |
| | | "id": "variable-uuid-2", |
| | | "name": "order_details", |
| | | "value_type": "json", |
| | | "value": "{\"product\":\"Widget\",\"quantity\":5,\"price\":19.99}", |
| | | "description": "Order details from the customer", |
| | | "created_at": 1650000000000, |
| | | "updated_at": 1650000000000 |
| | | } |
| | | ] |
| | | } |
| | | ``` |
| | | </CodeGroup> |
| | | </Col> |
| | | </Row> |
| | | |
| | | --- |
| | | |
| | | <Heading |
| | | url='/audio-to-text' |
| | | method='POST' |
| | | title='Speech to Text' |
| | |
| | | </CodeGroup> |
| | | |
| | | <CodeGroup title="Response"> |
| | | ```json {{ title: 'Response' }} |
| | | ```json {{ text: 'hello' }} |
| | | { |
| | | "text": "" |
| | | } |
| | |
| | | ### Request Body |
| | | |
| | | <Properties> |
| | | <Property name='message_id' type='str' key='message_id'> |
| | | <Property name='message_id' type='str' key='text'> |
| | | For text messages generated by Dify, simply pass the generated message-id directly. The backend will use the message-id to look up the corresponding content and synthesize the voice information directly. If both message_id and text are provided simultaneously, the message_id is given priority. |
| | | </Property> |
| | | <Property name='text' type='str' key='text'> |
| | |
| | | "content": "\ud83d\ude01" |
| | | } |
| | | } |
| | | } |
| | | ``` |
| | | </CodeGroup> |
| | | </Col> |
| | | </Row> |
| | | --- |
| | | |
| | | <Heading |
| | | url='/site' |
| | | method='GET' |
| | | title='Get Application WebApp Settings' |
| | | name='#site' |
| | | /> |
| | | <Row> |
| | | <Col> |
| | | Used to get the WebApp settings of the application. |
| | | ### Response |
| | | - `title` (string) WebApp name |
| | | - `chat_color_theme` (string) Chat color theme, in hex format |
| | | - `chat_color_theme_inverted` (bool) Whether the chat color theme is inverted |
| | | - `icon_type` (string) Icon type, `emoji` - emoji, `image` - picture |
| | | - `icon` (string) Icon. If it's `emoji` type, it's an emoji symbol; if it's `image` type, it's an image URL |
| | | - `icon_background` (string) Background color in hex format |
| | | - `icon_url` (string) Icon URL |
| | | - `description` (string) Description |
| | | - `copyright` (string) Copyright information |
| | | - `privacy_policy` (string) Privacy policy link |
| | | - `custom_disclaimer` (string) Custom disclaimer |
| | | - `default_language` (string) Default language |
| | | - `show_workflow_steps` (bool) Whether to show workflow details |
| | | - `use_icon_as_answer_icon` (bool) Whether to replace 🤖 in chat with the WebApp icon |
| | | </Col> |
| | | <Col> |
| | | <CodeGroup title="Request" tag="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='Get Annotation List' |
| | | name='#annotation_list' |
| | | /> |
| | | <Row> |
| | | <Col> |
| | | ### Query |
| | | <Properties> |
| | | <Property name='page' type='string' key='page'> |
| | | Page number |
| | | </Property> |
| | | <Property name='limit' type='string' key='limit'> |
| | | Number of items returned, default 20, range 1-100 |
| | | </Property> |
| | | </Properties> |
| | | </Col> |
| | | <Col sticky> |
| | | <CodeGroup |
| | | title="Request" |
| | | tag="GET" |
| | | label="/apps/annotations" |
| | | targetCode={`curl --location --request GET '${props.apiBaseUrl}/apps/annotations?page=1&limit=20' \\\n--header 'Authorization: Bearer {api_key}'`} |
| | | > |
| | | ```bash {{ title: 'cURL' }} |
| | | curl --location --request GET '${props.apiBaseUrl}/apps/annotations?page=1&limit=20' \ |
| | | --header 'Authorization: Bearer {api_key}' |
| | | ``` |
| | | </CodeGroup> |
| | | |
| | | <CodeGroup title="Response"> |
| | | ```json {{ title: 'Response' }} |
| | | { |
| | | "data": [ |
| | | { |
| | | "id": "69d48372-ad81-4c75-9c46-2ce197b4d402", |
| | | "question": "What is your name?", |
| | | "answer": "I am Dify.", |
| | | "hit_count": 0, |
| | | "created_at": 1735625869 |
| | | } |
| | | ], |
| | | "has_more": false, |
| | | "limit": 20, |
| | | "total": 1, |
| | | "page": 1 |
| | | } |
| | | ``` |
| | | </CodeGroup> |
| | | </Col> |
| | | </Row> |
| | | --- |
| | | |
| | | <Heading |
| | | url='/apps/annotations' |
| | | method='POST' |
| | | title='Create Annotation' |
| | | name='#create_annotation' |
| | | /> |
| | | <Row> |
| | | <Col> |
| | | ### Query |
| | | <Properties> |
| | | <Property name='question' type='string' key='question'> |
| | | Question |
| | | </Property> |
| | | <Property name='answer' type='string' key='answer'> |
| | | Answer |
| | | </Property> |
| | | </Properties> |
| | | </Col> |
| | | <Col sticky> |
| | | <CodeGroup |
| | | title="Request" |
| | | tag="POST" |
| | | label="/apps/annotations" |
| | | targetCode={`curl --location --request POST '${props.apiBaseUrl}/apps/annotations' \\\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." |
| | | }' |
| | | ``` |
| | | </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='Update Annotation' |
| | | name='#update_annotation' |
| | | /> |
| | | <Row> |
| | | <Col> |
| | | ### Query |
| | | <Properties> |
| | | <Property name='annotation_id' type='string' key='annotation_id'> |
| | | Annotation ID |
| | | </Property> |
| | | <Property name='question' type='string' key='question'> |
| | | Question |
| | | </Property> |
| | | <Property name='answer' type='string' key='answer'> |
| | | Answer |
| | | </Property> |
| | | </Properties> |
| | | </Col> |
| | | <Col sticky> |
| | | <CodeGroup |
| | | title="Request" |
| | | tag="PUT" |
| | | label="/apps/annotations/{annotation_id}" |
| | | targetCode={`curl --location --request POST '${props.apiBaseUrl}/apps/annotations/{annotation_id}' \\\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." |
| | | }' |
| | | ``` |
| | | </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='Delete Annotation' |
| | | name='#delete_annotation' |
| | | /> |
| | | <Row> |
| | | <Col> |
| | | ### Query |
| | | <Properties> |
| | | <Property name='annotation_id' type='string' key='annotation_id'> |
| | | Annotation ID |
| | | </Property> |
| | | </Properties> |
| | | </Col> |
| | | <Col sticky> |
| | | <CodeGroup |
| | | title="Request" |
| | | tag="PUT" |
| | | label="/apps/annotations/{annotation_id}" |
| | | targetCode={`curl --location --request DELETE '${props.apiBaseUrl}/apps/annotations/{annotation_id}' \\\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}' |
| | | ``` |
| | | </CodeGroup> |
| | | |
| | | <CodeGroup title="Response"> |
| | | ```text {{ title: 'Response' }} |
| | | 204 No Content |
| | | ``` |
| | | </CodeGroup> |
| | | </Col> |
| | | </Row> |
| | | --- |
| | | |
| | | <Heading |
| | | url='/apps/annotation-reply/{action}' |
| | | method='POST' |
| | | title='Initial Annotation Reply Settings' |
| | | name='#initial_annotation_reply_settings' |
| | | /> |
| | | <Row> |
| | | <Col> |
| | | ### Query |
| | | <Properties> |
| | | <Property name='action' type='string' key='action'> |
| | | Action, can only be 'enable' or 'disable' |
| | | </Property> |
| | | <Property name='embedding_model_provider' type='string' key='embedding_model_provider'> |
| | | Specified embedding model provider, must be set up in the system first, corresponding to the provider field(Optional) |
| | | </Property> |
| | | <Property name='embedding_model' type='string' key='embedding_model'> |
| | | Specified embedding model, corresponding to the model field(Optional) |
| | | </Property> |
| | | <Property name='score_threshold' type='number' key='score_threshold'> |
| | | The similarity threshold for matching annotated replies. Only annotations with scores above this threshold will be recalled. |
| | | </Property> |
| | | </Properties> |
| | | </Col> |
| | | <Col sticky> |
| | | The provider and model name of the embedding model can be obtained through the following interface: v1/workspaces/current/models/model-types/text-embedding. For specific instructions, see: Maintain Knowledge Base via API. The Authorization used is the Dataset API Token. |
| | | <CodeGroup |
| | | title="Request" |
| | | tag="POST" |
| | | label="/apps/annotation-reply/{action}" |
| | | targetCode={`curl --location --request POST '${props.apiBaseUrl}/apps/annotation-reply/{action}' \\\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> |
| | | This interface is executed asynchronously, so it will return a job_id. You can get the final execution result by querying the job status interface. |
| | | </Col> |
| | | </Row> |
| | | --- |
| | | |
| | | <Heading |
| | | url='/apps/annotation-reply/{action}/status/{job_id}' |
| | | method='GET' |
| | | title='Query Initial Annotation Reply Settings Task Status' |
| | | name='#initial_annotation_reply_settings_task_status' |
| | | /> |
| | | <Row> |
| | | <Col> |
| | | ### Query |
| | | <Properties> |
| | | <Property name='action' type='string' key='action'> |
| | | Action, can only be 'enable' or 'disable', must be the same as the action in the initial annotation reply settings interface |
| | | </Property> |
| | | <Property name='job_id' type='string' key='job_id'> |
| | | Job ID, |
| | | </Property> |
| | | </Properties> |
| | | </Col> |
| | | <Col sticky> |
| | | <CodeGroup |
| | | title="Request" |
| | | tag="GET" |
| | | label="/apps/annotations" |
| | | targetCode={`curl --location --request GET '${props.apiBaseUrl}/apps/annotation-reply/{action}/status/{job_id}' \\\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}' |
| | | ``` |
| | | </CodeGroup> |
| | | |
| | | <CodeGroup title="Response"> |
| | | ```json {{ title: 'Response' }} |
| | | { |
| | | "job_id": "b15c8f68-1cf4-4877-bf21-ed7cf2011802", |
| | | "job_status": "waiting", |
| | | "error_msg": "" |
| | | } |
| | | ``` |
| | | </CodeGroup> |