Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

template_advanced_chat.en.mdx 63KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676
  1. import { CodeGroup } from '../code.tsx'
  2. import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from '../md.tsx'
  3. # Advanced Chat App API
  4. Chat applications support session persistence, allowing previous chat history to be used as context for responses. This can be applicable for chatbot, customer service AI, etc.
  5. <div>
  6. ### Base URL
  7. <CodeGroup title="Code" targetCode={props.appDetail.api_base_url}>
  8. ```javascript
  9. ```
  10. </CodeGroup>
  11. ### Authentication
  12. The Service API uses `API-Key` authentication.
  13. <i>**Strongly recommend storing your API Key on the server-side, not shared or stored on the client-side, to avoid possible API-Key leakage that can lead to serious consequences.**</i>
  14. For all API requests, include your API Key in the `Authorization`HTTP Header, as shown below:
  15. <CodeGroup title="Code">
  16. ```javascript
  17. Authorization: Bearer {API_KEY}
  18. ```
  19. </CodeGroup>
  20. </div>
  21. ---
  22. <Heading
  23. url='/chat-messages'
  24. method='POST'
  25. title='Send Chat Message'
  26. name='#Send-Chat-Message'
  27. />
  28. <Row>
  29. <Col>
  30. Send a request to the chat application.
  31. ### Request Body
  32. <Properties>
  33. <Property name='query' type='string' key='query'>
  34. User Input/Question content
  35. </Property>
  36. <Property name='inputs' type='object' key='inputs'>
  37. Allows the entry of various variable values defined by the App.
  38. 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.
  39. If the variable is of file type, specify an object that has the keys described in `files` below.
  40. Default `{}`
  41. </Property>
  42. <Property name='response_mode' type='string' key='response_mode'>
  43. The mode of response return, supporting:
  44. - `streaming` Streaming mode (recommended), implements a typewriter-like output through SSE ([Server-Sent Events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events)).
  45. - `blocking` Blocking mode, returns result after execution is complete. (Requests may be interrupted if the process is long)
  46. Due to Cloudflare restrictions, the request will be interrupted without a return after 100 seconds.
  47. </Property>
  48. <Property name='user' type='string' key='user'>
  49. User identifier, used to define the identity of the end-user for retrieval and statistics.
  50. Should be uniquely defined by the developer within the application. The Service API does not share conversations created by the WebApp.
  51. </Property>
  52. <Property name='conversation_id' type='string' key='conversation_id'>
  53. Conversation ID, to continue the conversation based on previous chat records, it is necessary to pass the previous message's conversation_id.
  54. </Property>
  55. <Property name='files' type='array[object]' key='files'>
  56. File list, suitable for inputting files combined with text understanding and answering questions, available only when the model supports Vision capability.
  57. - `type` (string) Supported type:
  58. - `document` ('TXT', 'MD', 'MARKDOWN', 'PDF', 'HTML', 'XLSX', 'XLS', 'DOCX', 'CSV', 'EML', 'MSG', 'PPTX', 'PPT', 'XML', 'EPUB')
  59. - `image` ('JPG', 'JPEG', 'PNG', 'GIF', 'WEBP', 'SVG')
  60. - `audio` ('MP3', 'M4A', 'WAV', 'WEBM', 'AMR')
  61. - `video` ('MP4', 'MOV', 'MPEG', 'MPGA')
  62. - `custom` (Other file types)
  63. - `transfer_method` (string) Transfer method, `remote_url` for image URL / `local_file` for file upload
  64. - `url` (string) Image URL (when the transfer method is `remote_url`)
  65. - `upload_file_id` (string) Uploaded file ID, which must be obtained by uploading through the File Upload API in advance (when the transfer method is `local_file`)
  66. </Property>
  67. <Property name='auto_generate_name' type='bool' key='auto_generate_name'>
  68. Auto-generate title, default is `true`.
  69. If set to `false`, can achieve async title generation by calling the conversation rename API and setting `auto_generate` to `true`.
  70. </Property>
  71. </Properties>
  72. ### Response
  73. When response_mode is blocking, return a CompletionResponse object.
  74. When response_mode is streaming, return a ChunkCompletionResponse stream.
  75. ### ChatCompletionResponse
  76. Returns the complete App result, `Content-Type` is `application/json`.
  77. - `event` (string) Event type, fixed to `message`
  78. - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API
  79. - `id` (string) unique ID
  80. - `message_id` (string) Unique message ID
  81. - `conversation_id` (string) Conversation ID
  82. - `mode` (string) App mode, fixed as `chat`
  83. - `answer` (string) Complete response content
  84. - `metadata` (object) Metadata
  85. - `usage` (Usage) Model usage information
  86. - `retriever_resources` (array[RetrieverResource]) Citation and Attribution List
  87. - `created_at` (int) Message creation timestamp, e.g., 1705395332
  88. ### ChunkChatCompletionResponse
  89. Returns the stream chunks outputted by the App, `Content-Type` is `text/event-stream`.
  90. Each streaming chunk starts with `data:`, separated by two newline characters `\n\n`, as shown below:
  91. <CodeGroup>
  92. ```streaming {{ title: 'Response' }}
  93. data: {"event": "message", "task_id": "900bbd43-dc0b-4383-a372-aa6e6c414227", "id": "663c5084-a254-4040-8ad3-51f2a3c1a77c", "answer": "Hi", "created_at": 1705398420}\n\n
  94. ```
  95. </CodeGroup>
  96. The structure of the streaming chunks varies depending on the `event`:
  97. - `event: message` LLM returns text chunk event, i.e., the complete text is output in a chunked fashion.
  98. - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API
  99. - `message_id` (string) Unique message ID
  100. - `conversation_id` (string) Conversation ID
  101. - `answer` (string) LLM returned text chunk content
  102. - `created_at` (int) Creation timestamp, e.g., 1705395332
  103. - `event: message_file` Message file event, a new file has created by tool
  104. - `id` (string) File unique ID
  105. - `type` (string) File type,only allow "image" currently
  106. - `belongs_to` (string) Belongs to, it will only be an 'assistant' here
  107. - `url` (string) Remote url of file
  108. - `conversation_id` (string) Conversation ID
  109. - `event: message_end` Message end event, receiving this event means streaming has ended.
  110. - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API
  111. - `message_id` (string) Unique message ID
  112. - `conversation_id` (string) Conversation ID
  113. - `metadata` (object) Metadata
  114. - `usage` (Usage) Model usage information
  115. - `retriever_resources` (array[RetrieverResource]) Citation and Attribution List
  116. - `event: tts_message` TTS audio stream event, that is, speech synthesis output. The content is an audio block in Mp3 format, encoded as a base64 string. When playing, simply decode the base64 and feed it into the player. (This message is available only when auto-play is enabled)
  117. - `task_id` (string) Task ID, used for request tracking and the stop response interface below
  118. - `message_id` (string) Unique message ID
  119. - `audio` (string) The audio after speech synthesis, encoded in base64 text content, when playing, simply decode the base64 and feed it into the player
  120. - `created_at` (int) Creation timestamp, e.g.: 1705395332
  121. - `event: tts_message_end` TTS audio stream end event, receiving this event indicates the end of the audio stream.
  122. - `task_id` (string) Task ID, used for request tracking and the stop response interface below
  123. - `message_id` (string) Unique message ID
  124. - `audio` (string) The end event has no audio, so this is an empty string
  125. - `created_at` (int) Creation timestamp, e.g.: 1705395332
  126. - `event: message_replace` Message content replacement event.
  127. When output content moderation is enabled, if the content is flagged, then the message content will be replaced with a preset reply through this event.
  128. - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API
  129. - `message_id` (string) Unique message ID
  130. - `conversation_id` (string) Conversation ID
  131. - `answer` (string) Replacement content (directly replaces all LLM reply text)
  132. - `created_at` (int) Creation timestamp, e.g., 1705395332
  133. - `event: workflow_started` workflow starts execution
  134. - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API
  135. - `workflow_run_id` (string) Unique ID of workflow execution
  136. - `event` (string) fixed to `workflow_started`
  137. - `data` (object) detail
  138. - `id` (string) Unique ID of workflow execution
  139. - `workflow_id` (string) ID of related workflow
  140. - `created_at` (timestamp) Creation timestamp, e.g., 1705395332
  141. - `event: node_started` node execution started
  142. - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API
  143. - `workflow_run_id` (string) Unique ID of workflow execution
  144. - `event` (string) fixed to `node_started`
  145. - `data` (object) detail
  146. - `id` (string) Unique ID of workflow execution
  147. - `node_id` (string) ID of node
  148. - `node_type` (string) type of node
  149. - `title` (string) name of node
  150. - `index` (int) Execution sequence number, used to display Tracing Node sequence
  151. - `predecessor_node_id` (string) optional Prefix node ID, used for canvas display execution path
  152. - `inputs` (object) Contents of all preceding node variables used in the node
  153. - `created_at` (timestamp) timestamp of start, e.g., 1705395332
  154. - `event: node_finished` node execution ends, success or failure in different states in the same event
  155. - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API
  156. - `workflow_run_id` (string) Unique ID of workflow execution
  157. - `event` (string) fixed to `node_finished`
  158. - `data` (object) detail
  159. - `id` (string) Unique ID of workflow execution
  160. - `node_id` (string) ID of node
  161. - `node_type` (string) type of node
  162. - `title` (string) name of node
  163. - `index` (int) Execution sequence number, used to display Tracing Node sequence
  164. - `predecessor_node_id` (string) optional Prefix node ID, used for canvas display execution path
  165. - `inputs` (object) Contents of all preceding node variables used in the node
  166. - `process_data` (json) Optional node process data
  167. - `outputs` (json) Optional content of output
  168. - `status` (string) status of execution, `running` / `succeeded` / `failed` / `stopped`
  169. - `error` (string) Optional reason of error
  170. - `elapsed_time` (float) Optional total seconds to be used
  171. - `execution_metadata` (json) meta data
  172. - `total_tokens` (int) optional tokens to be used
  173. - `total_price` (decimal) optional Total cost
  174. - `currency` (string) optional e.g. `USD` / `RMB`
  175. - `created_at` (timestamp) timestamp of start, e.g., 1705395332
  176. - `event: workflow_finished` workflow execution ends, success or failure in different states in the same event
  177. - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API
  178. - `workflow_run_id` (string) Unique ID of workflow execution
  179. - `event` (string) fixed to `workflow_finished`
  180. - `data` (object) detail
  181. - `id` (string) ID of workflow execution
  182. - `workflow_id` (string) ID of related workflow
  183. - `status` (string) status of execution, `running` / `succeeded` / `failed` / `stopped`
  184. - `outputs` (json) Optional content of output
  185. - `error` (string) Optional reason of error
  186. - `elapsed_time` (float) Optional total seconds to be used
  187. - `total_tokens` (int) Optional tokens to be used
  188. - `total_steps` (int) default 0
  189. - `created_at` (timestamp) start time
  190. - `finished_at` (timestamp) end time
  191. - `event: error`
  192. Exceptions that occur during the streaming process will be output in the form of stream events, and reception of an error event will end the stream.
  193. - `task_id` (string) Task ID, used for request tracking and the below Stop Generate API
  194. - `message_id` (string) Unique message ID
  195. - `status` (int) HTTP status code
  196. - `code` (string) Error code
  197. - `message` (string) Error message
  198. - `event: ping` Ping event every 10 seconds to keep the connection alive.
  199. ### Errors
  200. - 404, Conversation does not exists
  201. - 400, `invalid_param`, abnormal parameter input
  202. - 400, `app_unavailable`, App configuration unavailable
  203. - 400, `provider_not_initialize`, no available model credential configuration
  204. - 400, `provider_quota_exceeded`, model invocation quota insufficient
  205. - 400, `model_currently_not_support`, current model unavailable
  206. - 400, `completion_request_error`, text generation failed
  207. - 500, internal server error
  208. </Col>
  209. <Col sticky>
  210. <CodeGroup title="Request" tag="POST" label="/chat-messages" targetCode={`curl -X POST '${props.appDetail.api_base_url}/chat-messages' \\\n--header 'Authorization: Bearer {api_key}' \\\n--header 'Content-Type: application/json' \\\n--data-raw '{\n "inputs": ${JSON.stringify(props.inputs)},\n "query": "What are the specs of the iPhone 13 Pro Max?",\n "response_mode": "streaming",\n "conversation_id": "",\n "user": "abc-123",\n "files": [\n {\n "type": "image",\n "transfer_method": "remote_url",\n "url": "https://cloud.dify.ai/logo/logo-site.png"\n }\n ]\n}'`}>
  211. ```bash {{ title: 'cURL' }}
  212. curl -X POST '${props.appDetail.api_base_url}/chat-messages' \
  213. --header 'Authorization: Bearer {api_key}' \
  214. --header 'Content-Type: application/json' \
  215. --data-raw '{
  216. "inputs": {},
  217. "query": "eh",
  218. "response_mode": "streaming",
  219. "conversation_id": "1c7e55fb-1ba2-4e10-81b5-30addcea2276",
  220. "user": "abc-123"
  221. }'
  222. ```
  223. </CodeGroup>
  224. ### Blocking Mode
  225. <CodeGroup title="Response">
  226. ```json {{ title: 'Response' }}
  227. {
  228. "event": "message",
  229. "task_id": "c3800678-a077-43df-a102-53f23ed20b88",
  230. "id": "9da23599-e713-473b-982c-4328d4f5c78a",
  231. "message_id": "9da23599-e713-473b-982c-4328d4f5c78a",
  232. "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2",
  233. "mode": "chat",
  234. "answer": "iPhone 13 Pro Max specs are listed here:...",
  235. "metadata": {
  236. "usage": {
  237. "prompt_tokens": 1033,
  238. "prompt_unit_price": "0.001",
  239. "prompt_price_unit": "0.001",
  240. "prompt_price": "0.0010330",
  241. "completion_tokens": 128,
  242. "completion_unit_price": "0.002",
  243. "completion_price_unit": "0.001",
  244. "completion_price": "0.0002560",
  245. "total_tokens": 1161,
  246. "total_price": "0.0012890",
  247. "currency": "USD",
  248. "latency": 0.7682376249867957
  249. },
  250. "retriever_resources": [
  251. {
  252. "position": 1,
  253. "dataset_id": "101b4c97-fc2e-463c-90b1-5261a4cdcafb",
  254. "dataset_name": "iPhone",
  255. "document_id": "8dd1ad74-0b5f-4175-b735-7d98bbbb4e00",
  256. "document_name": "iPhone List",
  257. "segment_id": "ed599c7f-2766-4294-9d1d-e5235a61270a",
  258. "score": 0.98457545,
  259. "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\""
  260. }
  261. ]
  262. },
  263. "created_at": 1705407629
  264. }
  265. ```
  266. </CodeGroup>
  267. ### Streaming Mode
  268. <CodeGroup title="Response">
  269. ```streaming {{ title: 'Response' }}
  270. data: {"event": "workflow_started", "task_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "workflow_run_id": "5ad498-f0c7-4085-b384-88cbe6290", "data": {"id": "5ad498-f0c7-4085-b384-88cbe6290", "workflow_id": "dfjasklfjdslag", "created_at": 1679586595}}
  271. data: {"event": "node_started", "task_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "workflow_run_id": "5ad498-f0c7-4085-b384-88cbe6290", "data": {"id": "5ad498-f0c7-4085-b384-88cbe6290", "node_id": "dfjasklfjdslag", "node_type": "start", "title": "Start", "index": 0, "predecessor_node_id": "fdljewklfklgejlglsd", "inputs": {}, "created_at": 1679586595}}
  272. data: {"event": "node_finished", "task_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "workflow_run_id": "5ad498-f0c7-4085-b384-88cbe6290", "data": {"id": "5ad498-f0c7-4085-b384-88cbe6290", "node_id": "dfjasklfjdslag", "node_type": "start", "title": "Start", "index": 0, "predecessor_node_id": "fdljewklfklgejlglsd", "inputs": {}, "outputs": {}, "status": "succeeded", "elapsed_time": 0.324, "execution_metadata": {"total_tokens": 63127864, "total_price": 2.378, "currency": "USD"}, "created_at": 1679586595}}
  273. data: {"event": "workflow_finished", "task_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "workflow_run_id": "5ad498-f0c7-4085-b384-88cbe6290", "data": {"id": "5ad498-f0c7-4085-b384-88cbe6290", "workflow_id": "dfjasklfjdslag", "outputs": {}, "status": "succeeded", "elapsed_time": 0.324, "total_tokens": 63127864, "total_steps": "1", "created_at": 1679586595, "finished_at": 1679976595}}
  274. data: {"event": "message", "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " I", "created_at": 1679586595}
  275. data: {"event": "message", "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": "'m", "created_at": 1679586595}
  276. data: {"event": "message", "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " glad", "created_at": 1679586595}
  277. data: {"event": "message", "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " to", "created_at": 1679586595}
  278. data: {"event": "message", "message_id" : "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " meet", "created_at": 1679586595}
  279. data: {"event": "message", "message_id" : "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " you", "created_at": 1679586595}
  280. 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\""}]}}
  281. 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"}
  282. 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": ""}
  283. ```
  284. </CodeGroup>
  285. </Col>
  286. </Row>
  287. ---
  288. <Heading
  289. url='/files/upload'
  290. method='POST'
  291. title='File Upload'
  292. name='#file-upload'
  293. />
  294. <Row>
  295. <Col>
  296. Upload a file for use when sending messages, enabling multimodal understanding of images and text.
  297. Supports any formats that are supported by your application.
  298. Uploaded files are for use by the current end-user only.
  299. ### Request Body
  300. This interface requires a `multipart/form-data` request.
  301. - `file` (File) Required
  302. The file to be uploaded.
  303. - `user` (string) Required
  304. User identifier, defined by the developer's rules, must be unique within the application. The Service API does not share conversations created by the WebApp.
  305. ### Response
  306. After a successful upload, the server will return the file's ID and related information.
  307. - `id` (uuid) ID
  308. - `name` (string) File name
  309. - `size` (int) File size (bytes)
  310. - `extension` (string) File extension
  311. - `mime_type` (string) File mime-type
  312. - `created_by` (uuid) End-user ID
  313. - `created_at` (timestamp) Creation timestamp, e.g., 1705395332
  314. ### Errors
  315. - 400, `no_file_uploaded`, a file must be provided
  316. - 400, `too_many_files`, currently only one file is accepted
  317. - 400, `unsupported_preview`, the file does not support preview
  318. - 400, `unsupported_estimate`, the file does not support estimation
  319. - 413, `file_too_large`, the file is too large
  320. - 415, `unsupported_file_type`, unsupported extension, currently only document files are accepted
  321. - 503, `s3_connection_failed`, unable to connect to S3 service
  322. - 503, `s3_permission_denied`, no permission to upload files to S3
  323. - 503, `s3_file_too_large`, file exceeds S3 size limit
  324. - 500, internal server error
  325. </Col>
  326. <Col sticky>
  327. ### Request Example
  328. <CodeGroup title="Request" tag="POST" label="/files/upload" targetCode={`curl -X POST '${props.appDetail.api_base_url}/files/upload' \\\n--header 'Authorization: Bearer {api_key}' \\\n--form 'file=@localfile;type=image/[png|jpeg|jpg|webp|gif]' \\\n--form 'user=abc-123'`}>
  329. ```bash {{ title: 'cURL' }}
  330. curl -X POST '${props.appDetail.api_base_url}/files/upload' \
  331. --header 'Authorization: Bearer {api_key}' \
  332. --form 'file=@"/path/to/file"'
  333. ```
  334. </CodeGroup>
  335. ### Response Example
  336. <CodeGroup title="Response">
  337. ```json {{ title: 'Response' }}
  338. {
  339. "id": "72fa9618-8f89-4a37-9b33-7e1178a24a67",
  340. "name": "example.png",
  341. "size": 1024,
  342. "extension": "png",
  343. "mime_type": "image/png",
  344. "created_by": "6ad1ab0a-73ff-4ac1-b9e4-cdb312f71f13",
  345. "created_at": 1577836800,
  346. }
  347. ```
  348. </CodeGroup>
  349. </Col>
  350. </Row>
  351. ---
  352. <Heading
  353. url='/chat-messages/:task_id/stop'
  354. method='POST'
  355. title='Stop Generate'
  356. name='#stop-generatebacks'
  357. />
  358. <Row>
  359. <Col>
  360. Only supported in streaming mode.
  361. ### Path
  362. - `task_id` (string) Task ID, can be obtained from the streaming chunk return
  363. ### Request Body
  364. - `user` (string) Required
  365. 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.
  366. ### Response
  367. - `result` (string) Always returns "success"
  368. </Col>
  369. <Col sticky>
  370. ### Request Example
  371. <CodeGroup title="Request" tag="POST" label="/chat-messages/:task_id/stop" targetCode={`curl -X POST '${props.appDetail.api_base_url}/chat-messages/:task_id/stop' \\\n-H 'Authorization: Bearer {api_key}' \\\n-H 'Content-Type: application/json' \\\n--data-raw '{"user": "abc-123"}'`}>
  372. ```bash {{ title: 'cURL' }}
  373. curl -X POST '${props.appDetail.api_base_url}/chat-messages/:task_id/stop' \
  374. -H 'Authorization: Bearer {api_key}' \
  375. -H 'Content-Type: application/json' \
  376. --data-raw '{
  377. "user": "abc-123"
  378. }'
  379. ```
  380. </CodeGroup>
  381. ### Response Example
  382. <CodeGroup title="Response">
  383. ```json {{ title: 'Response' }}
  384. {
  385. "result": "success"
  386. }
  387. ```
  388. </CodeGroup>
  389. </Col>
  390. </Row>
  391. ---
  392. <Heading
  393. url='/messages/:message_id/feedbacks'
  394. method='POST'
  395. title='Message Feedback'
  396. name='#feedbacks'
  397. />
  398. <Row>
  399. <Col>
  400. End-users can provide feedback messages, facilitating application developers to optimize expected outputs.
  401. ### Path
  402. <Properties>
  403. <Property name='message_id' type='string' key='message_id'>
  404. Message ID
  405. </Property>
  406. </Properties>
  407. ### Request Body
  408. <Properties>
  409. <Property name='rating' type='string' key='rating'>
  410. Upvote as `like`, downvote as `dislike`, revoke upvote as `null`
  411. </Property>
  412. <Property name='user' type='string' key='user'>
  413. User identifier, defined by the developer's rules, must be unique within the application. The Service API does not share conversations created by the WebApp.
  414. </Property>
  415. <Property name='content' type='string' key='content'>
  416. The specific content of message feedback.
  417. </Property>
  418. </Properties>
  419. ### Response
  420. - `result` (string) Always returns "success"
  421. </Col>
  422. <Col sticky>
  423. <CodeGroup title="Request" tag="POST" label="/messages/:message_id/feedbacks" targetCode={`curl -X POST '${props.appDetail.api_base_url}/messages/:message_id/feedbacks \\\n --header 'Authorization: Bearer {api_key}' \\\n--header 'Content-Type: application/json' \\\n--data-raw '{\n "rating": "like",\n "user": "abc-123",\n "content": "message feedback information"\n}'`}>
  424. ```bash {{ title: 'cURL' }}
  425. curl -X POST '${props.appDetail.api_base_url}/messages/:message_id/feedbacks' \
  426. --header 'Authorization: Bearer {api_key}' \
  427. --header 'Content-Type: application/json' \
  428. --data-raw '{
  429. "rating": "like",
  430. "user": "abc-123",
  431. "content": "message feedback information"
  432. }'
  433. ```
  434. </CodeGroup>
  435. <CodeGroup title="Response">
  436. ```json {{ title: 'Response' }}
  437. {
  438. "result": "success"
  439. }
  440. ```
  441. </CodeGroup>
  442. </Col>
  443. </Row>
  444. ---
  445. <Heading
  446. url='/app/feedbacks'
  447. method='GET'
  448. title='Get feedbacks of application'
  449. name='#app-feedbacks'
  450. />
  451. <Row>
  452. <Col>
  453. Get application's feedbacks.
  454. ### Query
  455. <Properties>
  456. <Property name='page' type='string' key='page'>
  457. (optional)pagination,default:1
  458. </Property>
  459. </Properties>
  460. <Properties>
  461. <Property name='limit' type='string' key='limit'>
  462. (optional) records per page default:20
  463. </Property>
  464. </Properties>
  465. ### Response
  466. - `data` (List) return apps feedback list.
  467. </Col>
  468. <Col sticky>
  469. <CodeGroup title="Request" tag="GET" label="/app/feedbacks" targetCode={`curl -X GET '${props.appDetail.api_base_url}/app/feedbacks?page=1&limit=20'`}>
  470. ```bash {{ title: 'cURL' }}
  471. curl -X GET '${props.appDetail.api_base_url}/app/feedbacks?page=1&limit=20' \
  472. --header 'Authorization: Bearer {api_key}' \
  473. --header 'Content-Type: application/json'
  474. ```
  475. </CodeGroup>
  476. <CodeGroup title="Response">
  477. ```json {{ title: 'Response' }}
  478. {
  479. "data": [
  480. {
  481. "id": "8c0fbed8-e2f9-49ff-9f0e-15a35bdd0e25",
  482. "app_id": "f252d396-fe48-450e-94ec-e184218e7346",
  483. "conversation_id": "2397604b-9deb-430e-b285-4726e51fd62d",
  484. "message_id": "709c0b0f-0a96-4a4e-91a4-ec0889937b11",
  485. "rating": "like",
  486. "content": "message feedback information-3",
  487. "from_source": "user",
  488. "from_end_user_id": "74286412-9a1a-42c1-929c-01edb1d381d5",
  489. "from_account_id": null,
  490. "created_at": "2025-04-24T09:24:38",
  491. "updated_at": "2025-04-24T09:24:38"
  492. }
  493. ]
  494. }
  495. ```
  496. </CodeGroup>
  497. </Col>
  498. </Row>
  499. ---
  500. <Heading
  501. url='/messages/{message_id}/suggested'
  502. method='GET'
  503. title='Next Suggested Questions'
  504. name='#suggested'
  505. />
  506. <Row>
  507. <Col>
  508. Get next questions suggestions for the current message
  509. ### Path Params
  510. <Properties>
  511. <Property name='message_id' type='string' key='message_id'>
  512. Message ID
  513. </Property>
  514. </Properties>
  515. ### Query
  516. <Properties>
  517. <Property name='user' type='string' key='user'>
  518. User identifier, used to define the identity of the end-user for retrieval and statistics.
  519. Should be uniquely defined by the developer within the application.
  520. </Property>
  521. </Properties>
  522. </Col>
  523. <Col sticky>
  524. <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'`}>
  525. ```bash {{ title: 'cURL' }}
  526. curl --location --request GET '${props.appDetail.api_base_url}/messages/{message_id}/suggested?user=abc-123' \
  527. --header 'Authorization: Bearer ENTER-YOUR-SECRET-KEY' \
  528. --header 'Content-Type: application/json' \
  529. ```
  530. </CodeGroup>
  531. <CodeGroup title="Response">
  532. ```json {{ title: 'Response' }}
  533. {
  534. "result": "success",
  535. "data": [
  536. "a",
  537. "b",
  538. "c"
  539. ]
  540. }
  541. ```
  542. </CodeGroup>
  543. </Col>
  544. </Row>
  545. ---
  546. <Heading
  547. url='/messages'
  548. method='GET'
  549. title='Get Conversation History Messages'
  550. name='#messages'
  551. />
  552. <Row>
  553. <Col>
  554. Returns historical chat records in a scrolling load format, with the first page returning the latest `{limit}` messages, i.e., in reverse order.
  555. ### Query
  556. <Properties>
  557. <Property name='conversation_id' type='string' key='conversation_id'>
  558. Conversation ID
  559. </Property>
  560. <Property name='user' type='string' key='user'>
  561. User identifier, used to define the identity of the end-user for retrieval and statistics.
  562. Should be uniquely defined by the developer within the application.
  563. </Property>
  564. <Property name='first_id' type='string' key='first_id'>
  565. The ID of the first chat record on the current page, default is null.
  566. </Property>
  567. <Property name='limit' type='int' key='limit'>
  568. How many chat history messages to return in one request, default is 20.
  569. </Property>
  570. </Properties>
  571. ### Response
  572. - `data` (array[object]) Message list
  573. - `id` (string) Message ID
  574. - `conversation_id` (string) Conversation ID
  575. - `inputs` (object) User input parameters.
  576. - `query` (string) User input / question content.
  577. - `message_files` (array[object]) Message files
  578. - `id` (string) ID
  579. - `type` (string) File type, image for images
  580. - `url` (string) Preview image URL
  581. - `belongs_to` (string) belongs to,user orassistant
  582. - `answer` (string) Response message content
  583. - `created_at` (timestamp) Creation timestamp, e.g., 1705395332
  584. - `feedback` (object) Feedback information
  585. - `rating` (string) Upvote as `like` / Downvote as `dislike`
  586. - `retriever_resources` (array[RetrieverResource]) Citation and Attribution List
  587. - `has_more` (bool) Whether there is a next page
  588. - `limit` (int) Number of returned items, if input exceeds system limit, returns system limit amount
  589. </Col>
  590. <Col sticky>
  591. <CodeGroup title="Request" tag="GET" label="/messages" targetCode={`curl -X GET '${props.appDetail.api_base_url}/messages?user=abc-123&conversation_id='\\\n --header 'Authorization: Bearer {api_key}'`}>
  592. ```bash {{ title: 'cURL' }}
  593. curl -X GET '${props.appDetail.api_base_url}/messages?user=abc-123&conversation_id='
  594. --header 'Authorization: Bearer {api_key}'
  595. ```
  596. </CodeGroup>
  597. ### Response Example
  598. <CodeGroup title="Response">
  599. ```json {{ title: 'Response' }}
  600. {
  601. "limit": 20,
  602. "has_more": false,
  603. "data": [
  604. {
  605. "id": "a076a87f-31e5-48dc-b452-0061adbbc922",
  606. "conversation_id": "cd78daf6-f9e4-4463-9ff2-54257230a0ce",
  607. "inputs": {
  608. "name": "dify"
  609. },
  610. "query": "iphone 13 pro",
  611. "answer": "The iPhone 13 Pro, released on September 24, 2021, features a 6.1-inch display with a resolution of 1170 x 2532. It is equipped with a Hexa-core (2x3.23 GHz Avalanche + 4x1.82 GHz Blizzard) processor, 6 GB of RAM, and offers storage options of 128 GB, 256 GB, 512 GB, and 1 TB. The camera is 12 MP, the battery capacity is 3095 mAh, and it runs on iOS 15.",
  612. "message_files": [],
  613. "feedback": null,
  614. "retriever_resources": [
  615. {
  616. "position": 1,
  617. "dataset_id": "101b4c97-fc2e-463c-90b1-5261a4cdcafb",
  618. "dataset_name": "iPhone",
  619. "document_id": "8dd1ad74-0b5f-4175-b735-7d98bbbb4e00",
  620. "document_name": "iPhone List",
  621. "segment_id": "ed599c7f-2766-4294-9d1d-e5235a61270a",
  622. "score": 0.98457545,
  623. "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\""
  624. }
  625. ],
  626. "created_at": 1705569239,
  627. }
  628. ]
  629. }
  630. ```
  631. </CodeGroup>
  632. </Col>
  633. </Row>
  634. ---
  635. <Heading
  636. url='/conversations'
  637. method='GET'
  638. title='Get Conversations'
  639. name='#conversations'
  640. />
  641. <Row>
  642. <Col>
  643. Retrieve the conversation list for the current user, defaulting to the most recent 20 entries.
  644. ### Query
  645. <Properties>
  646. <Property name='user' type='string' key='user'>
  647. User identifier, used to define the identity of the end-user for retrieval and statistics.
  648. Should be uniquely defined by the developer within the application.
  649. </Property>
  650. <Property name='last_id' type='string' key='last_id'>
  651. (Optional) The ID of the last record on the current page, default is null.
  652. </Property>
  653. <Property name='limit' type='int' key='limit'>
  654. (Optional) How many records to return in one request, default is the most recent 20 entries. Maximum 100, minimum 1.
  655. </Property>
  656. <Property name='sort_by' type='string' key='sort_by'>
  657. (Optional) Sorting Field, Default: -updated_at (sorted in descending order by update time)
  658. - Available Values: created_at, -created_at, updated_at, -updated_at
  659. - The symbol before the field represents the order or reverse, "-" represents reverse order.
  660. </Property>
  661. </Properties>
  662. ### Response
  663. - `data` (array[object]) List of conversations
  664. - `id` (string) Conversation ID
  665. - `name` (string) Conversation name, by default, is generated by LLM.
  666. - `inputs` (object) User input parameters.
  667. - `status` (string) Conversation status
  668. - `introduction` (string) Introduction
  669. - `created_at` (timestamp) Creation timestamp, e.g., 1705395332
  670. - `updated_at` (timestamp) Update timestamp, e.g., 1705395332
  671. - `has_more` (bool)
  672. - `limit` (int) Number of entries returned, if input exceeds system limit, system limit number is returned
  673. </Col>
  674. <Col sticky>
  675. <CodeGroup title="Request" tag="GET" label="/conversations" targetCode={`curl -X GET '${props.appDetail.api_base_url}/conversations?user=abc-123&last_id=&limit=20' \\\n --header 'Authorization: Bearer {api_key}'`}>
  676. ```bash {{ title: 'cURL' }}
  677. curl -X GET '${props.appDetail.api_base_url}/conversations?user=abc-123&last_id=&limit=20' \
  678. --header 'Authorization: Bearer {api_key}'
  679. ```
  680. </CodeGroup>
  681. <CodeGroup title="Response">
  682. ```json {{ title: 'Response' }}
  683. {
  684. "limit": 20,
  685. "has_more": false,
  686. "data": [
  687. {
  688. "id": "10799fb8-64f7-4296-bbf7-b42bfbe0ae54",
  689. "name": "New chat",
  690. "inputs": {
  691. "book": "book",
  692. "myName": "Lucy"
  693. },
  694. "status": "normal",
  695. "created_at": 1679667915,
  696. "updated_at": 1679667915
  697. },
  698. {
  699. "id": "hSIhXBhNe8X1d8Et"
  700. // ...
  701. }
  702. ]
  703. }
  704. ```
  705. </CodeGroup>
  706. </Col>
  707. </Row>
  708. ---
  709. <Heading
  710. url='/conversations/:conversation_id'
  711. method='DELETE'
  712. title='Delete Conversation'
  713. name='#delete'
  714. />
  715. <Row>
  716. <Col>
  717. Delete a conversation.
  718. ### Path
  719. - `conversation_id` (string) Conversation ID
  720. ### Request Body
  721. <Properties>
  722. <Property name='user' type='string' key='user'>
  723. The user identifier, defined by the developer, must ensure uniqueness within the application.
  724. </Property>
  725. </Properties>
  726. ### Response
  727. - `result` (string) Always returns "success"
  728. </Col>
  729. <Col sticky>
  730. <CodeGroup title="Request" tag="DELETE" label="/conversations/:conversation_id" targetCode={`curl -X DELETE '${props.appDetail.api_base_url}/conversations/:conversation_id' \\\n--header 'Authorization: Bearer {api_key}' \\\n--header 'Content-Type: application/json' \\\n--data-raw '{ \n "user": "abc-123"\n}'`}>
  731. ```bash {{ title: 'cURL' }}
  732. curl -X DELETE '${props.appDetail.api_base_url}/conversations/{conversation_id}' \
  733. --header 'Content-Type: application/json' \
  734. --header 'Accept: application/json' \
  735. --header 'Authorization: Bearer {api_key}' \
  736. --data '{
  737. "user": "abc-123"
  738. }'
  739. ```
  740. </CodeGroup>
  741. <CodeGroup title="Response">
  742. ```text {{ title: 'Response' }}
  743. 204 No Content
  744. ```
  745. </CodeGroup>
  746. </Col>
  747. </Row>
  748. ---
  749. <Heading
  750. url='/conversations/:conversation_id/name'
  751. method='POST'
  752. title='Conversation Rename'
  753. name='#rename'
  754. />
  755. <Row>
  756. <Col>
  757. ### Request Body
  758. Rename the session, the session name is used for display on clients that support multiple sessions.
  759. ### Path
  760. - `conversation_id` (string) Conversation ID
  761. <Properties>
  762. <Property name='name' type='string' key='name'>
  763. (Optional) The name of the conversation. This parameter can be omitted if `auto_generate` is set to `true`.
  764. </Property>
  765. <Property name='auto_generate' type='bool' key='auto_generate'>
  766. (Optional) Automatically generate the title, default is `false`
  767. </Property>
  768. <Property name='user' type='string' key='user'>
  769. The user identifier, defined by the developer, must ensure uniqueness within the application.
  770. </Property>
  771. </Properties>
  772. ### Response
  773. - `id` (string) Conversation ID
  774. - `name` (string) Conversation name
  775. - `inputs` (object) User input parameters
  776. - `status` (string) Conversation status
  777. - `introduction` (string) Introduction
  778. - `created_at` (timestamp) Creation timestamp, e.g., 1705395332
  779. - `updated_at` (timestamp) Update timestamp, e.g., 1705395332
  780. </Col>
  781. <Col sticky>
  782. <CodeGroup title="Request" tag="POST" label="/conversations/:conversation_id/name" targetCode={`curl -X POST '${props.appDetail.api_base_url}/conversations/:conversation_id/name' \\\n--header 'Authorization: Bearer {api_key}' \\\n--header 'Content-Type: application/json' \\\n--data-raw '{ \n "name": "", \n "auto_generate": true, \n "user": "abc-123"\n}'`}>
  783. ```bash {{ title: 'cURL' }}
  784. curl -X POST '${props.appDetail.api_base_url}/conversations/{conversation_id}/name' \
  785. --header 'Content-Type: application/json' \
  786. --header 'Authorization: Bearer {api_key}' \
  787. --data-raw '{
  788. "name": "",
  789. "auto_generate": true,
  790. "user": "abc-123"
  791. }'
  792. ```
  793. </CodeGroup>
  794. <CodeGroup title="Response">
  795. ```json {{ title: 'Response' }}
  796. {
  797. "id": "cd78daf6-f9e4-4463-9ff2-54257230a0ce",
  798. "name": "Chat vs AI",
  799. "inputs": {},
  800. "status": "normal",
  801. "introduction": "",
  802. "created_at": 1705569238,
  803. "updated_at": 1705569238
  804. }
  805. ```
  806. </CodeGroup>
  807. </Col>
  808. </Row>
  809. ---
  810. <Heading
  811. url='/conversations/:conversation_id/variables'
  812. method='GET'
  813. title='Get Conversation Variables'
  814. name='#conversation-variables'
  815. />
  816. <Row>
  817. <Col>
  818. Retrieve variables from a specific conversation. This endpoint is useful for extracting structured data that was captured during the conversation.
  819. ### Path Parameters
  820. <Properties>
  821. <Property name='conversation_id' type='string' key='conversation_id'>
  822. The ID of the conversation to retrieve variables from.
  823. </Property>
  824. </Properties>
  825. ### Query Parameters
  826. <Properties>
  827. <Property name='user' type='string' key='user'>
  828. The user identifier, defined by the developer, must ensure uniqueness within the application
  829. </Property>
  830. <Property name='last_id' type='string' key='last_id'>
  831. (Optional) The ID of the last record on the current page, default is null.
  832. </Property>
  833. <Property name='limit' type='int' key='limit'>
  834. (Optional) How many records to return in one request, default is the most recent 20 entries. Maximum 100, minimum 1.
  835. </Property>
  836. </Properties>
  837. ### Response
  838. - `limit` (int) Number of items per page
  839. - `has_more` (bool) Whether there is a next page
  840. - `data` (array[object]) List of variables
  841. - `id` (string) Variable ID
  842. - `name` (string) Variable name
  843. - `value_type` (string) Variable type (string, number, object, etc.)
  844. - `value` (string) Variable value
  845. - `description` (string) Variable description
  846. - `created_at` (int) Creation timestamp
  847. - `updated_at` (int) Last update timestamp
  848. ### Errors
  849. - 404, `conversation_not_exists`, Conversation not found
  850. </Col>
  851. <Col sticky>
  852. <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}'`}>
  853. ```bash {{ title: 'cURL' }}
  854. curl -X GET '${props.appDetail.api_base_url}/conversations/{conversation_id}/variables?user=abc-123' \
  855. --header 'Authorization: Bearer {api_key}'
  856. ```
  857. </CodeGroup>
  858. <CodeGroup title="Request with variable name filter">
  859. ```bash {{ title: 'cURL' }}
  860. curl -X GET '${props.appDetail.api_base_url}/conversations/{conversation_id}/variables?user=abc-123&variable_name=customer_name' \
  861. --header 'Authorization: Bearer {api_key}'
  862. ```
  863. </CodeGroup>
  864. <CodeGroup title="Response">
  865. ```json {{ title: 'Response' }}
  866. {
  867. "limit": 100,
  868. "has_more": false,
  869. "data": [
  870. {
  871. "id": "variable-uuid-1",
  872. "name": "customer_name",
  873. "value_type": "string",
  874. "value": "John Doe",
  875. "description": "Customer name extracted from the conversation",
  876. "created_at": 1650000000000,
  877. "updated_at": 1650000000000
  878. },
  879. {
  880. "id": "variable-uuid-2",
  881. "name": "order_details",
  882. "value_type": "json",
  883. "value": "{\"product\":\"Widget\",\"quantity\":5,\"price\":19.99}",
  884. "description": "Order details from the customer",
  885. "created_at": 1650000000000,
  886. "updated_at": 1650000000000
  887. }
  888. ]
  889. }
  890. ```
  891. </CodeGroup>
  892. </Col>
  893. </Row>
  894. ---
  895. <Heading
  896. url='/audio-to-text'
  897. method='POST'
  898. title='Speech to Text'
  899. name='#audio'
  900. />
  901. <Row>
  902. <Col>
  903. This endpoint requires a multipart/form-data request.
  904. ### Request Body
  905. <Properties>
  906. <Property name='file' type='file' key='file'>
  907. Audio file.
  908. Supported formats: `['mp3', 'mp4', 'mpeg', 'mpga', 'm4a', 'wav', 'webm']`
  909. File size limit: 15MB
  910. </Property>
  911. <Property name='user' type='string' key='user'>
  912. User identifier, defined by the developer's rules, must be unique within the application.
  913. </Property>
  914. </Properties>
  915. ### Response
  916. - `text` (string) Output text
  917. </Col>
  918. <Col sticky>
  919. <CodeGroup title="Request" tag="POST" label="/audio-to-text" targetCode={`curl -X POST '${props.appDetail.api_base_url}/audio-to-text' \\\n--header 'Authorization: Bearer {api_key}' \\\n--form 'file=@localfile;type=audio/[mp3|mp4|mpeg|mpga|m4a|wav|webm]'`}>
  920. ```bash {{ title: 'cURL' }}
  921. curl -X POST '${props.appDetail.api_base_url}/conversations/name' \
  922. --header 'Authorization: Bearer {api_key}' \
  923. --form 'file=@localfile;type=audio/mp3'
  924. ```
  925. </CodeGroup>
  926. <CodeGroup title="Response">
  927. ```json {{ title: 'Response' }}
  928. {
  929. "text": ""
  930. }
  931. ```
  932. </CodeGroup>
  933. </Col>
  934. </Row>
  935. ---
  936. <Heading
  937. url='/text-to-audio'
  938. method='POST'
  939. title='Text to Audio'
  940. name='#audio'
  941. />
  942. <Row>
  943. <Col>
  944. Text to speech.
  945. ### Request Body
  946. <Properties>
  947. <Property name='message_id' type='str' key='message_id'>
  948. 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.
  949. </Property>
  950. <Property name='text' type='str' key='text'>
  951. Speech generated content。
  952. </Property>
  953. <Property name='user' type='string' key='user'>
  954. The user identifier, defined by the developer, must ensure uniqueness within the app.
  955. </Property>
  956. </Properties>
  957. </Col>
  958. <Col sticky>
  959. <CodeGroup title="Request" tag="POST" label="/text-to-audio" targetCode={`curl -o text-to-audio.mp3 -X POST '${props.appDetail.api_base_url}/text-to-audio' \\\n--header 'Authorization: Bearer {api_key}' \\\n--header 'Content-Type: application/json' \\\n--data-raw '{\n "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290",\n "text": "Hello Dify",\n "user": "abc-123"\n}'`}>
  960. ```bash {{ title: 'cURL' }}
  961. curl -o text-to-audio.mp3 -X POST '${props.appDetail.api_base_url}/text-to-audio' \
  962. --header 'Authorization: Bearer {api_key}' \
  963. --header 'Content-Type: application/json' \
  964. --data-raw '{
  965. "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290",
  966. "text": "Hello Dify",
  967. "user": "abc-123",
  968. "streaming": false
  969. }'
  970. ```
  971. </CodeGroup>
  972. <CodeGroup title="headers">
  973. ```json {{ title: 'headers' }}
  974. {
  975. "Content-Type": "audio/wav"
  976. }
  977. ```
  978. </CodeGroup>
  979. </Col>
  980. </Row>
  981. ---
  982. <Heading
  983. url='/info'
  984. method='GET'
  985. title='Get Application Basic Information'
  986. name='#info'
  987. />
  988. <Row>
  989. <Col>
  990. Used to get basic information about this application
  991. ### Response
  992. - `name` (string) application name
  993. - `description` (string) application description
  994. - `tags` (array[string]) application tags
  995. - `mode` (string) application mode
  996. - `author_name` (string) application author name
  997. </Col>
  998. <Col>
  999. <CodeGroup title="Request" tag="GET" label="/info" targetCode={`curl -X GET '${props.appDetail.api_base_url}/info' \\\n-H 'Authorization: Bearer {api_key}'`}>
  1000. ```bash {{ title: 'cURL' }}
  1001. curl -X GET '${props.appDetail.api_base_url}/info' \
  1002. -H 'Authorization: Bearer {api_key}'
  1003. ```
  1004. </CodeGroup>
  1005. <CodeGroup title="Response">
  1006. ```json {{ title: 'Response' }}
  1007. {
  1008. "name": "My App",
  1009. "description": "This is my app.",
  1010. "tags": [
  1011. "tag1",
  1012. "tag2"
  1013. ],
  1014. "mode": "advanced-chat",
  1015. "author_name": "Dify"
  1016. }
  1017. ```
  1018. </CodeGroup>
  1019. </Col>
  1020. </Row>
  1021. ---
  1022. <Heading
  1023. url='/parameters'
  1024. method='GET'
  1025. title='Get Application Parameters Information'
  1026. name='#parameters'
  1027. />
  1028. <Row>
  1029. <Col>
  1030. Used at the start of entering the page to obtain information such as features, input parameter names, types, and default values.
  1031. ### Response
  1032. - `opening_statement` (string) Opening statement
  1033. - `suggested_questions` (array[string]) List of suggested questions for the opening
  1034. - `suggested_questions_after_answer` (object) Suggest questions after enabling the answer.
  1035. - `enabled` (bool) Whether it is enabled
  1036. - `speech_to_text` (object) Speech to text
  1037. - `enabled` (bool) Whether it is enabled
  1038. - `text_to_speech` (object) Text to speech
  1039. - `enabled` (bool) Whether it is enabled
  1040. - `voice` (string) Voice type
  1041. - `language` (string) Language
  1042. - `autoPlay` (string) Auto play
  1043. - `enabled` Enabled
  1044. - `disabled` Disabled
  1045. - `retriever_resource` (object) Citation and Attribution
  1046. - `enabled` (bool) Whether it is enabled
  1047. - `annotation_reply` (object) Annotation reply
  1048. - `enabled` (bool) Whether it is enabled
  1049. - `user_input_form` (array[object]) User input form configuration
  1050. - `text-input` (object) Text input control
  1051. - `label` (string) Variable display label name
  1052. - `variable` (string) Variable ID
  1053. - `required` (bool) Whether it is required
  1054. - `default` (string) Default value
  1055. - `paragraph` (object) Paragraph text input control
  1056. - `label` (string) Variable display label name
  1057. - `variable` (string) Variable ID
  1058. - `required` (bool) Whether it is required
  1059. - `default` (string) Default value
  1060. - `select` (object) Dropdown control
  1061. - `label` (string) Variable display label name
  1062. - `variable` (string) Variable ID
  1063. - `required` (bool) Whether it is required
  1064. - `default` (string) Default value
  1065. - `options` (array[string]) Option values
  1066. - `file_upload` (object) File upload configuration
  1067. - `image` (object) Image settings
  1068. Currently only supports image types: `png`, `jpg`, `jpeg`, `webp`, `gif`
  1069. - `enabled` (bool) Whether it is enabled
  1070. - `number_limits` (int) Image number limit, default is 3
  1071. - `transfer_methods` (array[string]) List of transfer methods, remote_url, local_file, must choose one
  1072. - `system_parameters` (object) System parameters
  1073. - `file_size_limit` (int) Document upload size limit (MB)
  1074. - `image_file_size_limit` (int) Image file upload size limit (MB)
  1075. - `audio_file_size_limit` (int) Audio file upload size limit (MB)
  1076. - `video_file_size_limit` (int) Video file upload size limit (MB)
  1077. </Col>
  1078. <Col sticky>
  1079. <CodeGroup title="Request" tag="GET" label="/parameters" targetCode={` curl -X GET '${props.appDetail.api_base_url}/parameters'`}>
  1080. ```bash {{ title: 'cURL' }}
  1081. curl -X GET '${props.appDetail.api_base_url}/parameters' \
  1082. --header 'Authorization: Bearer {api_key}'
  1083. ```
  1084. </CodeGroup>
  1085. <CodeGroup title="Response">
  1086. ```json {{ title: 'Response' }}
  1087. {
  1088. "opening_statement": "Hello!",
  1089. "suggested_questions_after_answer": {
  1090. "enabled": true
  1091. },
  1092. "speech_to_text": {
  1093. "enabled": true
  1094. },
  1095. "text_to_speech": {
  1096. "enabled": true,
  1097. "voice": "sambert-zhinan-v1",
  1098. "language": "zh-Hans",
  1099. "autoPlay": "disabled"
  1100. },
  1101. "retriever_resource": {
  1102. "enabled": true
  1103. },
  1104. "annotation_reply": {
  1105. "enabled": true
  1106. },
  1107. "user_input_form": [
  1108. {
  1109. "paragraph": {
  1110. "label": "Query",
  1111. "variable": "query",
  1112. "required": true,
  1113. "default": ""
  1114. }
  1115. }
  1116. ],
  1117. "file_upload": {
  1118. "image": {
  1119. "enabled": false,
  1120. "number_limits": 3,
  1121. "detail": "high",
  1122. "transfer_methods": [
  1123. "remote_url",
  1124. "local_file"
  1125. ]
  1126. }
  1127. },
  1128. "system_parameters": {
  1129. "file_size_limit": 15,
  1130. "image_file_size_limit": 10,
  1131. "audio_file_size_limit": 50,
  1132. "video_file_size_limit": 100
  1133. }
  1134. }
  1135. ```
  1136. </CodeGroup>
  1137. </Col>
  1138. </Row>
  1139. ---
  1140. <Heading
  1141. url='/meta'
  1142. method='GET'
  1143. title='Get Application Meta Information'
  1144. name='#meta'
  1145. />
  1146. <Row>
  1147. <Col>
  1148. Used to get icons of tools in this application
  1149. ### Response
  1150. - `tool_icons`(object[string]) tool icons
  1151. - `tool_name` (string)
  1152. - `icon` (object|string)
  1153. - (object) icon object
  1154. - `background` (string) background color in hex format
  1155. - `content`(string) emoji
  1156. - (string) url of icon
  1157. </Col>
  1158. <Col>
  1159. <CodeGroup title="Request" tag="GET" label="/meta" targetCode={`curl -X GET '${props.appDetail.api_base_url}/meta' \\\n-H 'Authorization: Bearer {api_key}'`}>
  1160. ```bash {{ title: 'cURL' }}
  1161. curl -X GET '${props.appDetail.api_base_url}/meta' \
  1162. -H 'Authorization: Bearer {api_key}'
  1163. ```
  1164. </CodeGroup>
  1165. <CodeGroup title="Response">
  1166. ```json {{ title: 'Response' }}
  1167. {
  1168. "tool_icons": {
  1169. "dalle2": "https://cloud.dify.ai/console/api/workspaces/current/tool-provider/builtin/dalle/icon",
  1170. "api_tool": {
  1171. "background": "#252525",
  1172. "content": "\ud83d\ude01"
  1173. }
  1174. }
  1175. }
  1176. ```
  1177. </CodeGroup>
  1178. </Col>
  1179. </Row>
  1180. ---
  1181. <Heading
  1182. url='/site'
  1183. method='GET'
  1184. title='Get Application WebApp Settings'
  1185. name='#site'
  1186. />
  1187. <Row>
  1188. <Col>
  1189. Used to get the WebApp settings of the application.
  1190. ### Response
  1191. - `title` (string) WebApp name
  1192. - `chat_color_theme` (string) Chat color theme, in hex format
  1193. - `chat_color_theme_inverted` (bool) Whether the chat color theme is inverted
  1194. - `icon_type` (string) Icon type, `emoji` - emoji, `image` - picture
  1195. - `icon` (string) Icon. If it's `emoji` type, it's an emoji symbol; if it's `image` type, it's an image URL
  1196. - `icon_background` (string) Background color in hex format
  1197. - `icon_url` (string) Icon URL
  1198. - `description` (string) Description
  1199. - `copyright` (string) Copyright information
  1200. - `privacy_policy` (string) Privacy policy link
  1201. - `custom_disclaimer` (string) Custom disclaimer
  1202. - `default_language` (string) Default language
  1203. - `show_workflow_steps` (bool) Whether to show workflow details
  1204. - `use_icon_as_answer_icon` (bool) Whether to replace 🤖 in chat with the WebApp icon
  1205. </Col>
  1206. <Col>
  1207. <CodeGroup title="Request" tag="POST" label="/meta" targetCode={`curl -X GET '${props.appDetail.api_base_url}/site' \\\n-H 'Authorization: Bearer {api_key}'`}>
  1208. ```bash {{ title: 'cURL' }}
  1209. curl -X GET '${props.appDetail.api_base_url}/site' \
  1210. -H 'Authorization: Bearer {api_key}'
  1211. ```
  1212. </CodeGroup>
  1213. <CodeGroup title="Response">
  1214. ```json {{ title: 'Response' }}
  1215. {
  1216. "title": "My App",
  1217. "chat_color_theme": "#ff4a4a",
  1218. "chat_color_theme_inverted": false,
  1219. "icon_type": "emoji",
  1220. "icon": "😄",
  1221. "icon_background": "#FFEAD5",
  1222. "icon_url": null,
  1223. "description": "This is my app.",
  1224. "copyright": "all rights reserved",
  1225. "privacy_policy": "",
  1226. "custom_disclaimer": "All generated by AI",
  1227. "default_language": "en-US",
  1228. "show_workflow_steps": false,
  1229. "use_icon_as_answer_icon": false,
  1230. }
  1231. ```
  1232. </CodeGroup>
  1233. </Col>
  1234. </Row>
  1235. ___
  1236. <Heading
  1237. url='/apps/annotations'
  1238. method='GET'
  1239. title='Get Annotation List'
  1240. name='#annotation_list'
  1241. />
  1242. <Row>
  1243. <Col>
  1244. ### Query
  1245. <Properties>
  1246. <Property name='page' type='string' key='page'>
  1247. Page number
  1248. </Property>
  1249. <Property name='limit' type='string' key='limit'>
  1250. Number of items returned, default 20, range 1-100
  1251. </Property>
  1252. </Properties>
  1253. </Col>
  1254. <Col sticky>
  1255. <CodeGroup
  1256. title="Request"
  1257. tag="GET"
  1258. label="/apps/annotations"
  1259. targetCode={`curl --location --request GET '${props.apiBaseUrl}/apps/annotations?page=1&limit=20' \\\n--header 'Authorization: Bearer {api_key}'`}
  1260. >
  1261. ```bash {{ title: 'cURL' }}
  1262. curl --location --request GET '${props.apiBaseUrl}/apps/annotations?page=1&limit=20' \
  1263. --header 'Authorization: Bearer {api_key}'
  1264. ```
  1265. </CodeGroup>
  1266. <CodeGroup title="Response">
  1267. ```json {{ title: 'Response' }}
  1268. {
  1269. "data": [
  1270. {
  1271. "id": "69d48372-ad81-4c75-9c46-2ce197b4d402",
  1272. "question": "What is your name?",
  1273. "answer": "I am Dify.",
  1274. "hit_count": 0,
  1275. "created_at": 1735625869
  1276. }
  1277. ],
  1278. "has_more": false,
  1279. "limit": 20,
  1280. "total": 1,
  1281. "page": 1
  1282. }
  1283. ```
  1284. </CodeGroup>
  1285. </Col>
  1286. </Row>
  1287. ---
  1288. <Heading
  1289. url='/apps/annotations'
  1290. method='POST'
  1291. title='Create Annotation'
  1292. name='#create_annotation'
  1293. />
  1294. <Row>
  1295. <Col>
  1296. ### Query
  1297. <Properties>
  1298. <Property name='question' type='string' key='question'>
  1299. Question
  1300. </Property>
  1301. <Property name='answer' type='string' key='answer'>
  1302. Answer
  1303. </Property>
  1304. </Properties>
  1305. </Col>
  1306. <Col sticky>
  1307. <CodeGroup
  1308. title="Request"
  1309. tag="POST"
  1310. label="/apps/annotations"
  1311. 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."}'`}
  1312. >
  1313. ```bash {{ title: 'cURL' }}
  1314. curl --location --request POST '${props.apiBaseUrl}/apps/annotations' \
  1315. --header 'Authorization: Bearer {api_key}' \
  1316. --header 'Content-Type: application/json' \
  1317. --data-raw '{
  1318. "question": "What is your name?",
  1319. "answer": "I am Dify."
  1320. }'
  1321. ```
  1322. </CodeGroup>
  1323. <CodeGroup title="Response">
  1324. ```json {{ title: 'Response' }}
  1325. {
  1326. "id": "69d48372-ad81-4c75-9c46-2ce197b4d402",
  1327. "question": "What is your name?",
  1328. "answer": "I am Dify.",
  1329. "hit_count": 0,
  1330. "created_at": 1735625869
  1331. }
  1332. ```
  1333. </CodeGroup>
  1334. </Col>
  1335. </Row>
  1336. ---
  1337. <Heading
  1338. url='/apps/annotations/{annotation_id}'
  1339. method='PUT'
  1340. title='Update Annotation'
  1341. name='#update_annotation'
  1342. />
  1343. <Row>
  1344. <Col>
  1345. ### Query
  1346. <Properties>
  1347. <Property name='annotation_id' type='string' key='annotation_id'>
  1348. Annotation ID
  1349. </Property>
  1350. <Property name='question' type='string' key='question'>
  1351. Question
  1352. </Property>
  1353. <Property name='answer' type='string' key='answer'>
  1354. Answer
  1355. </Property>
  1356. </Properties>
  1357. </Col>
  1358. <Col sticky>
  1359. <CodeGroup
  1360. title="Request"
  1361. tag="PUT"
  1362. label="/apps/annotations/{annotation_id}"
  1363. 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."}'`}
  1364. >
  1365. ```bash {{ title: 'cURL' }}
  1366. curl --location --request PUT '${props.apiBaseUrl}/apps/annotations/{annotation_id}' \
  1367. --header 'Authorization: Bearer {api_key}' \
  1368. --header 'Content-Type: application/json' \
  1369. --data-raw '{
  1370. "question": "What is your name?",
  1371. "answer": "I am Dify."
  1372. }'
  1373. ```
  1374. </CodeGroup>
  1375. <CodeGroup title="Response">
  1376. ```json {{ title: 'Response' }}
  1377. {
  1378. "id": "69d48372-ad81-4c75-9c46-2ce197b4d402",
  1379. "question": "What is your name?",
  1380. "answer": "I am Dify.",
  1381. "hit_count": 0,
  1382. "created_at": 1735625869
  1383. }
  1384. ```
  1385. </CodeGroup>
  1386. </Col>
  1387. </Row>
  1388. ---
  1389. <Heading
  1390. url='/apps/annotations/{annotation_id}'
  1391. method='DELETE'
  1392. title='Delete Annotation'
  1393. name='#delete_annotation'
  1394. />
  1395. <Row>
  1396. <Col>
  1397. ### Query
  1398. <Properties>
  1399. <Property name='annotation_id' type='string' key='annotation_id'>
  1400. Annotation ID
  1401. </Property>
  1402. </Properties>
  1403. </Col>
  1404. <Col sticky>
  1405. <CodeGroup
  1406. title="Request"
  1407. tag="PUT"
  1408. label="/apps/annotations/{annotation_id}"
  1409. targetCode={`curl --location --request DELETE '${props.apiBaseUrl}/apps/annotations/{annotation_id}' \\\n--header 'Authorization: Bearer {api_key}' \\\n--header 'Content-Type: application/json'`}
  1410. >
  1411. ```bash {{ title: 'cURL' }}
  1412. curl --location --request DELETE '${props.apiBaseUrl}/apps/annotations/{annotation_id}' \
  1413. --header 'Authorization: Bearer {api_key}'
  1414. ```
  1415. </CodeGroup>
  1416. <CodeGroup title="Response">
  1417. ```text {{ title: 'Response' }}
  1418. 204 No Content
  1419. ```
  1420. </CodeGroup>
  1421. </Col>
  1422. </Row>
  1423. ---
  1424. <Heading
  1425. url='/apps/annotation-reply/{action}'
  1426. method='POST'
  1427. title='Initial Annotation Reply Settings'
  1428. name='#initial_annotation_reply_settings'
  1429. />
  1430. <Row>
  1431. <Col>
  1432. ### Query
  1433. <Properties>
  1434. <Property name='action' type='string' key='action'>
  1435. Action, can only be 'enable' or 'disable'
  1436. </Property>
  1437. <Property name='embedding_provider_name' type='string' key='embedding_provider_name'>
  1438. Specified embedding model provider, must be set up in the system first, corresponding to the provider field(Optional)
  1439. </Property>
  1440. <Property name='embedding_model_name' type='string' key='embedding_model_name'>
  1441. Specified embedding model, corresponding to the model field(Optional)
  1442. </Property>
  1443. <Property name='score_threshold' type='number' key='score_threshold'>
  1444. The similarity threshold for matching annotated replies. Only annotations with scores above this threshold will be recalled.
  1445. </Property>
  1446. </Properties>
  1447. </Col>
  1448. <Col sticky>
  1449. 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.
  1450. <CodeGroup
  1451. title="Request"
  1452. tag="POST"
  1453. label="/apps/annotation-reply/{action}"
  1454. 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"}'`}
  1455. >
  1456. ```bash {{ title: 'cURL' }}
  1457. curl --location --request POST 'https://api.dify.ai/v1/apps/annotation-reply/{action}' \
  1458. --header 'Authorization: Bearer {api_key}' \
  1459. --header 'Content-Type: application/json' \
  1460. --data-raw '{
  1461. "score_threshold": 0.9,
  1462. "embedding_provider_name": "zhipu",
  1463. "embedding_model_name": "embedding_3"
  1464. }'
  1465. ```
  1466. </CodeGroup>
  1467. <CodeGroup title="Response">
  1468. ```json {{ title: 'Response' }}
  1469. {
  1470. "job_id": "b15c8f68-1cf4-4877-bf21-ed7cf2011802",
  1471. "job_status": "waiting"
  1472. }
  1473. ```
  1474. </CodeGroup>
  1475. 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.
  1476. </Col>
  1477. </Row>
  1478. ---
  1479. <Heading
  1480. url='/apps/annotation-reply/{action}/status/{job_id}'
  1481. method='GET'
  1482. title='Query Initial Annotation Reply Settings Task Status'
  1483. name='#initial_annotation_reply_settings_task_status'
  1484. />
  1485. <Row>
  1486. <Col>
  1487. ### Query
  1488. <Properties>
  1489. <Property name='action' type='string' key='action'>
  1490. Action, can only be 'enable' or 'disable', must be the same as the action in the initial annotation reply settings interface
  1491. </Property>
  1492. <Property name='job_id' type='string' key='job_id'>
  1493. Job ID, obtained from the initial annotation reply settings interface
  1494. </Property>
  1495. </Properties>
  1496. </Col>
  1497. <Col sticky>
  1498. <CodeGroup
  1499. title="Request"
  1500. tag="GET"
  1501. label="/apps/annotations"
  1502. targetCode={`curl --location --request GET '${props.apiBaseUrl}/apps/annotation-reply/{action}/status/{job_id}' \\\n--header 'Authorization: Bearer {api_key}'`}
  1503. >
  1504. ```bash {{ title: 'cURL' }}
  1505. curl --location --request GET '${props.apiBaseUrl}/apps/annotation-reply/{action}/status/{job_id}' \
  1506. --header 'Authorization: Bearer {api_key}'
  1507. ```
  1508. </CodeGroup>
  1509. <CodeGroup title="Response">
  1510. ```json {{ title: 'Response' }}
  1511. {
  1512. "job_id": "b15c8f68-1cf4-4877-bf21-ed7cf2011802",
  1513. "job_status": "waiting",
  1514. "error_msg": ""
  1515. }
  1516. ```
  1517. </CodeGroup>
  1518. </Col>
  1519. </Row>