template_advanced_chat.zh.mdx 41 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079
  1. import { CodeGroup } from '../code.tsx'
  2. import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx'
  3. # 工作流编排对话型应用 API
  4. 对话应用支持会话持久化,可将之前的聊天记录作为上下进行回答,可适用于聊天/客服 AI 等。
  5. <div>
  6. ### 基础 URL
  7. <CodeGroup title="Code" targetCode={props.appDetail.api_base_url}>
  8. ```javascript
  9. ```
  10. </CodeGroup>
  11. ### 鉴权
  12. Service API 使用 `API-Key` 进行鉴权。
  13. <i>**强烈建议开发者把 `API-Key` 放在后端存储,而非分享或者放在客户端存储,以免 `API-Key` 泄露,导致财产损失。**</i>
  14. 所有 API 请求都应在 **`Authorization`** HTTP Header 中包含您的 `API-Key`,如下所示:
  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='发送对话消息'
  26. name='#Create-Chat-Message'
  27. />
  28. <Row>
  29. <Col>
  30. 创建会话消息。
  31. ### Request Body
  32. <Properties>
  33. <Property name='query' type='string' key='query'>
  34. 用户输入/提问内容。
  35. </Property>
  36. <Property name='inputs' type='object' key='inputs'>
  37. 允许传入 App 定义的各变量值。
  38. inputs 参数包含了多组键值对(Key/Value pairs),每组的键对应一个特定变量,每组的值则是该变量的具体值。
  39. 默认 `{}`
  40. </Property>
  41. <Property name='response_mode' type='string' key='response_mode'>
  42. - `streaming` 流式模式(推荐)。基于 SSE(**[Server-Sent Events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events)**)实现类似打字机输出方式的流式返回。
  43. - `blocking` 阻塞模式,等待执行完毕后返回结果。(请求若流程较长可能会被中断)。
  44. <i>由于 Cloudflare 限制,请求会在 100 秒超时无返回后中断。</i>
  45. </Property>
  46. <Property name='user' type='string' key='user'>
  47. 用户标识,用于定义终端用户的身份,方便检索、统计。
  48. 由开发者定义规则,需保证用户标识在应用内唯一。
  49. </Property>
  50. <Property name='conversation_id' type='string' key='conversation_id'>
  51. (选填)会话 ID,需要基于之前的聊天记录继续对话,必须传之前消息的 conversation_id。
  52. </Property>
  53. <Property name='files' type='array[object]' key='files'>
  54. 上传的文件。
  55. - `type` (string) 支持类型:图片 `image`(目前仅支持图片格式) 。
  56. - `transfer_method` (string) 传递方式:
  57. - `remote_url`: 图片地址。
  58. - `local_file`: 上传文件。
  59. - `url` 图片地址。(仅当传递方式为 `remote_url` 时)。
  60. - `upload_file_id` 上传文件 ID。(仅当传递方式为 `local_file `时)。
  61. </Property>
  62. <Property name='auto_generate_name' type='bool' key='auto_generate_name'>
  63. (选填)自动生成标题,默认 `true`。 若设置为 `false`,则可通过调用会话重命名接口并设置 `auto_generate` 为 `true` 实现异步生成标题。
  64. </Property>
  65. </Properties>
  66. ### Response
  67. <Properties>
  68. 当 `response_mode` 为 `blocking` 时,返回 ChatCompletionResponse object。
  69. 当 `response_mode` 为 `streaming`时,返回 ChunkChatCompletionResponse object 流式序列。
  70. ### ChatCompletionResponse
  71. 返回完整的 App 结果,`Content-Type` 为 `application/json`。
  72. - `message_id` (string) 消息唯一 ID
  73. - `conversation_id` (string) 会话 ID
  74. - `mode` (string) App 模式,固定为 chat
  75. - `answer` (string) 完整回复内容
  76. - `metadata` (object) 元数据
  77. - `usage` (Usage) 模型用量信息
  78. - `retriever_resources` (array[RetrieverResource]) 引用和归属分段列表
  79. - `created_at` (int) 消息创建时间戳,如:1705395332
  80. ### ChunkChatCompletionResponse
  81. 返回 App 输出的流式块,`Content-Type` 为 `text/event-stream`。
  82. 每个流式块均为 data: 开头,块之间以 \n\n 即两个换行符分隔,如下所示:
  83. <CodeGroup>
  84. ```streaming {{ title: 'Response' }}
  85. data: {"event": "message", "task_id": "900bbd43-dc0b-4383-a372-aa6e6c414227", "id": "663c5084-a254-4040-8ad3-51f2a3c1a77c", "answer": "Hi", "created_at": 1705398420}\n\n
  86. ```
  87. </CodeGroup>
  88. 流式块中根据 event 不同,结构也不同:
  89. - `event: message` LLM 返回文本块事件,即:完整的文本以分块的方式输出。
  90. - `task_id` (string) 任务 ID,用于请求跟踪和下方的停止响应接口
  91. - `message_id` (string) 消息唯一 ID
  92. - `conversation_id` (string) 会话 ID
  93. - `answer` (string) LLM 返回文本块内容
  94. - `created_at` (int) 创建时间戳,如:1705395332
  95. - `event: message_file` 文件事件,表示有新文件需要展示
  96. - `id` (string) 文件唯一ID
  97. - `type` (string) 文件类型,目前仅为image
  98. - `belongs_to` (string) 文件归属,user或assistant,该接口返回仅为 `assistant`
  99. - `url` (string) 文件访问地址
  100. - `conversation_id` (string) 会话ID
  101. - `event: message_end` 消息结束事件,收到此事件则代表流式返回结束。
  102. - `task_id` (string) 任务 ID,用于请求跟踪和下方的停止响应接口
  103. - `message_id` (string) 消息唯一 ID
  104. - `conversation_id` (string) 会话 ID
  105. - `metadata` (object) 元数据
  106. - `usage` (Usage) 模型用量信息
  107. - `retriever_resources` (array[RetrieverResource]) 引用和归属分段列表
  108. - `event: message_replace` 消息内容替换事件。
  109. 开启内容审查和审查输出内容时,若命中了审查条件,则会通过此事件替换消息内容为预设回复。
  110. - `task_id` (string) 任务 ID,用于请求跟踪和下方的停止响应接口
  111. - `message_id` (string) 消息唯一 ID
  112. - `conversation_id` (string) 会话 ID
  113. - `answer` (string) 替换内容(直接替换 LLM 所有回复文本)
  114. - `created_at` (int) 创建时间戳,如:1705395332
  115. - `event: workflow_started` workflow 开始执行
  116. - `task_id` (string) 任务 ID,用于请求跟踪和下方的停止响应接口
  117. - `workflow_run_id` (string) workflow 执行 ID
  118. - `event` (string) 固定为 `workflow_started`
  119. - `data` (object) 详细内容
  120. - `id` (string) workflow 执行 ID
  121. - `workflow_id` (string) 关联 Workflow ID
  122. - `sequence_number` (int) 自增序号,App 内自增,从 1 开始
  123. - `created_at` (timestamp) 开始时间
  124. - `event: node_started` node 开始执行
  125. - `task_id` (string) 任务 ID,用于请求跟踪和下方的停止响应接口
  126. - `workflow_run_id` (string) workflow 执行 ID
  127. - `event` (string) 固定为 `node_started`
  128. - `data` (object) 详细内容
  129. - `id` (string) workflow 执行 ID
  130. - `node_id` (string) 节点 ID
  131. - `node_type` (string) 节点类型
  132. - `title` (string) 节点名称
  133. - `index` (int) 执行序号,用于展示 Tracing Node 顺序
  134. - `predecessor_node_id` (string) 前置节点 ID,用于画布展示执行路径
  135. - `inputs` (array[object]) 节点中所有使用到的前置节点变量内容
  136. - `created_at` (timestamp) 开始时间
  137. - `event: node_finished` node 执行结束,成功失败同一事件中不同状态
  138. - `task_id` (string) 任务 ID,用于请求跟踪和下方的停止响应接口
  139. - `workflow_run_id` (string) workflow 执行 ID
  140. - `event` (string) 固定为 `node_finished`
  141. - `data` (object) 详细内容
  142. - `id` (string) node 执行 ID
  143. - `node_id` (string) 节点 ID
  144. - `index` (int) 执行序号,用于展示 Tracing Node 顺序
  145. - `predecessor_node_id` (string) optional 前置节点 ID,用于画布展示执行路径
  146. - `inputs` (array[object]) 节点中所有使用到的前置节点变量内容
  147. - `process_data` (json) Optional 节点过程数据
  148. - `outputs` (json) Optional 输出内容
  149. - `status` (string) 执行状态 `running` / `succeeded` / `failed` / `stopped`
  150. - `error` (string) Optional 错误原因
  151. - `elapsed_time` (float) Optional 耗时(s)
  152. - `execution_metadata` (json) 元数据
  153. - `total_tokens` (int) optional 总使用 tokens
  154. - `total_price` (decimal) optional 总费用
  155. - `currency` (string) optional 货币,如 `USD` / `RMB`
  156. - `created_at` (timestamp) 开始时间
  157. - `event: workflow_finished` workflow 执行结束,成功失败同一事件中不同状态
  158. - `task_id` (string) 任务 ID,用于请求跟踪和下方的停止响应接口
  159. - `workflow_run_id` (string) workflow 执行 ID
  160. - `event` (string) 固定为 `workflow_finished`
  161. - `data` (object) 详细内容
  162. - `id` (string) workflow 执行 ID
  163. - `workflow_id` (string) 关联 Workflow ID
  164. - `status` (string) 执行状态 `running` / `succeeded` / `failed` / `stopped`
  165. - `outputs` (json) Optional 输出内容
  166. - `error` (string) Optional 错误原因
  167. - `elapsed_time` (float) Optional 耗时(s)
  168. - `total_tokens` (int) Optional 总使用 tokens
  169. - `total_steps` (int) 总步数(冗余),默认 0
  170. - `created_at` (timestamp) 开始时间
  171. - `finished_at` (timestamp) 结束时间
  172. - `event: error`
  173. 流式输出过程中出现的异常会以 stream event 形式输出,收到异常事件后即结束。
  174. - `task_id` (string) 任务 ID,用于请求跟踪和下方的停止响应接口
  175. - `message_id` (string) 消息唯一 ID
  176. - `status` (int) HTTP 状态码
  177. - `code` (string) 错误码
  178. - `message` (string) 错误消息
  179. - `event: ping` 每 10s 一次的 ping 事件,保持连接存活。
  180. ### Errors
  181. - 404,对话不存在
  182. - 400,`invalid_param`,传入参数异常
  183. - 400,`app_unavailable`,App 配置不可用
  184. - 400,`provider_not_initialize`,无可用模型凭据配置
  185. - 400,`provider_quota_exceeded`,模型调用额度不足
  186. - 400,`model_currently_not_support`,当前模型不可用
  187. - 400,`completion_request_error`,文本生成失败
  188. - 500,服务内部异常
  189. </Properties>
  190. </Col>
  191. <Col sticky>
  192. <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}'`}>
  193. ```bash {{ title: 'cURL' }}
  194. curl -X POST '${props.appDetail.api_base_url}/chat-messages' \
  195. -H 'Authorization: Bearer {api_key}' \
  196. -H 'Content-Type: application/json' \
  197. --data-raw '{
  198. "inputs": {
  199. "name": "dify"
  200. },
  201. "query": "What are the specs of the iPhone 13 Pro Max?",
  202. "conversation_id": "101b4c97-fc2e-463c-90b1-5261a4cdcafb",
  203. "response_mode": "streaming",
  204. "user": "abc-123",
  205. "files": [
  206. {
  207. "type": "image",
  208. "transfer_method": "remote_url",
  209. "url": "https://cloud.dify.ai/logo/logo-site.png"
  210. }
  211. ]
  212. }'
  213. ```
  214. </CodeGroup>
  215. ### 阻塞模式
  216. <CodeGroup title="Response">
  217. ```json {{ title: 'Response' }}
  218. {
  219. "event": "message",
  220. "message_id": "9da23599-e713-473b-982c-4328d4f5c78a",
  221. "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2",
  222. "mode": "chat",
  223. "answer": "iPhone 13 Pro Max specs are listed heere:...",
  224. "metadata": {
  225. "usage": {
  226. "prompt_tokens": 1033,
  227. "prompt_unit_price": "0.001",
  228. "prompt_price_unit": "0.001",
  229. "prompt_price": "0.0010330",
  230. "completion_tokens": 128,
  231. "completion_unit_price": "0.002",
  232. "completion_price_unit": "0.001",
  233. "completion_price": "0.0002560",
  234. "total_tokens": 1161,
  235. "total_price": "0.0012890",
  236. "currency": "USD",
  237. "latency": 0.7682376249867957
  238. },
  239. "retriever_resources": [
  240. {
  241. "position": 1,
  242. "dataset_id": "101b4c97-fc2e-463c-90b1-5261a4cdcafb",
  243. "dataset_name": "iPhone",
  244. "document_id": "8dd1ad74-0b5f-4175-b735-7d98bbbb4e00",
  245. "document_name": "iPhone List",
  246. "segment_id": "ed599c7f-2766-4294-9d1d-e5235a61270a",
  247. "score": 0.98457545,
  248. "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\""
  249. }
  250. ]
  251. },
  252. "created_at": 1705407629
  253. }
  254. ```
  255. </CodeGroup>
  256. ### 流式模式
  257. <CodeGroup title="Response">
  258. ```streaming {{ title: 'Response' }}
  259. 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", "sequence_number": 1, "created_at": 1679586595}}
  260. 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}}
  261. 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}}
  262. 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}}
  263. data: {"event": "message", "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " I", "created_at": 1679586595}
  264. data: {"event": "message", "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": "'m", "created_at": 1679586595}
  265. data: {"event": "message", "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " glad", "created_at": 1679586595}
  266. data: {"event": "message", "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " to", "created_at": 1679586595}
  267. data: {"event": "message", "message_id": : "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " meet", "created_at": 1679586595}
  268. data: {"event": "message", "message_id": : "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " you", "created_at": 1679586595}
  269. 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\""}]}}}
  270. ```
  271. </CodeGroup>
  272. </Col>
  273. </Row>
  274. ---
  275. <Heading
  276. url='/files/upload'
  277. method='POST'
  278. title='上传文件'
  279. name='#files-upload'
  280. />
  281. <Row>
  282. <Col>
  283. 上传文件(目前仅支持图片)并在发送消息时使用,可实现图文多模态理解。
  284. 支持 png, jpg, jpeg, webp, gif 格式。
  285. <i>上传的文件仅供当前终端用户使用。</i>
  286. ### Request Body
  287. 该接口需使用 `multipart/form-data` 进行请求。
  288. <Properties>
  289. <Property name='file' type='file' key='file'>
  290. 要上传的文件。
  291. </Property>
  292. <Property name='user' type='string' key='user'>
  293. 用户标识,用于定义终端用户的身份,必须和发送消息接口传入 user 保持一致。
  294. </Property>
  295. </Properties>
  296. ### Response
  297. 成功上传后,服务器会返回文件的 ID 和相关信息。
  298. - `id` (uuid) ID
  299. - `name` (string) 文件名
  300. - `size` (int) 文件大小(byte)
  301. - `extension` (string) 文件后缀
  302. - `mime_type` (string) 文件 mime-type
  303. - `created_by` (uuid) 上传人 ID
  304. - `created_at` (timestamp) 上传时间
  305. ### Errors
  306. - 400,`no_file_uploaded`,必须提供文件
  307. - 400,`too_many_files`,目前只接受一个文件
  308. - 400,`unsupported_preview`,该文件不支持预览
  309. - 400,`unsupported_estimate`,该文件不支持估算
  310. - 413,`file_too_large`,文件太大
  311. - 415,`unsupported_file_type`,不支持的扩展名,当前只接受文档类文件
  312. - 503,`s3_connection_failed`,无法连接到 S3 服务
  313. - 503,`s3_permission_denied`,无权限上传文件到 S3
  314. - 503,`s3_file_too_large`,文件超出 S3 大小限制
  315. </Col>
  316. <Col sticky>
  317. <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'`}>
  318. ```bash {{ title: 'cURL' }}
  319. curl -X POST '${props.appDetail.api_base_url}/files/upload' \
  320. --header 'Authorization: Bearer {api_key}' \
  321. --form 'file=@"/path/to/file"'
  322. ```
  323. </CodeGroup>
  324. <CodeGroup title="Response">
  325. ```json {{ title: 'Response' }}
  326. {
  327. "id": "72fa9618-8f89-4a37-9b33-7e1178a24a67",
  328. "name": "example.png",
  329. "size": 1024,
  330. "extension": "png",
  331. "mime_type": "image/png",
  332. "created_by": 123,
  333. "created_at": 1577836800,
  334. }
  335. ```
  336. </CodeGroup>
  337. </Col>
  338. </Row>
  339. ---
  340. <Heading
  341. url='/chat-messages/:task_id/stop'
  342. method='POST'
  343. title='停止响应'
  344. name='#Stop'
  345. />
  346. <Row>
  347. <Col>
  348. 仅支持流式模式。
  349. ### Path
  350. - `task_id` (string) 任务 ID,可在流式返回 Chunk 中获取
  351. ### Request Body
  352. - `user` (string) Required
  353. 用户标识,用于定义终端用户的身份,必须和发送消息接口传入 user 保持一致。
  354. ### Response
  355. - `result` (string) 固定返回 success
  356. </Col>
  357. <Col sticky>
  358. <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"}'`}>
  359. ```bash {{ title: 'cURL' }}
  360. curl -X POST '${props.appDetail.api_base_url}/chat-messages/:task_id/stop' \
  361. -H 'Authorization: Bearer {api_key}' \
  362. -H 'Content-Type: application/json' \
  363. --data-raw '{
  364. "user": "abc-123"
  365. }'
  366. ```
  367. </CodeGroup>
  368. <CodeGroup title="Response">
  369. ```json {{ title: 'Response' }}
  370. {
  371. "result": "success"
  372. }
  373. ```
  374. </CodeGroup>
  375. </Col>
  376. </Row>
  377. ---
  378. <Heading
  379. url='/messages/:message_id/feedbacks'
  380. method='POST'
  381. title='消息反馈(点赞)'
  382. name='#feedbacks'
  383. />
  384. <Row>
  385. <Col>
  386. 消息终端用户反馈、点赞,方便应用开发者优化输出预期。
  387. ### Path Params
  388. <Properties>
  389. <Property name='message_id' type='string' key='message_id'>
  390. 消息 ID
  391. </Property>
  392. </Properties>
  393. ### Request Body
  394. <Properties>
  395. <Property name='rating' type='string' key='rating'>
  396. 点赞 like, 点踩 dislike, 撤销点赞 null
  397. </Property>
  398. <Property name='user' type='string' key='user'>
  399. 用户标识,由开发者定义规则,需保证用户标识在应用内唯一。
  400. </Property>
  401. </Properties>
  402. ### Response
  403. - `result` (string) 固定返回 success
  404. </Col>
  405. <Col sticky>
  406. <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}'`}>
  407. ```bash {{ title: 'cURL' }}
  408. curl -X POST '${props.appDetail.api_base_url}/messages/:message_id/feedbacks' \
  409. --header 'Authorization: Bearer {api_key}' \
  410. --header 'Content-Type: application/json' \
  411. --data-raw '{
  412. "rating": "like",
  413. "user": "abc-123"
  414. }'
  415. ```
  416. </CodeGroup>
  417. <CodeGroup title="Response">
  418. ```json {{ title: 'Response' }}
  419. {
  420. "result": "success"
  421. }
  422. ```
  423. </CodeGroup>
  424. </Col>
  425. </Row>
  426. ---
  427. <Heading
  428. url='/messages/{message_id}/suggested'
  429. method='GET'
  430. title='获取下一轮建议问题列表'
  431. name='#suggested'
  432. />
  433. <Row>
  434. <Col>
  435. 获取下一轮建议问题列表。
  436. ### Path Params
  437. <Properties>
  438. <Property name='message_id' type='string' key='message_id'>
  439. Message ID
  440. </Property>
  441. </Properties>
  442. </Col>
  443. <Col sticky>
  444. <CodeGroup title="Request" tag="GET" label="/messages/{message_id}/suggested" targetCode={`curl --location --request GET '${props.appDetail.api_base_url}/messages/{message_id}/suggested \\\n--header 'Authorization: Bearer ENTER-YOUR-SECRET-KEY' \\\n--header 'Content-Type: application/json'`}>
  445. ```bash {{ title: 'cURL' }}
  446. curl --location --request GET '${props.appDetail.api_base_url}/messages/{message_id}/suggested' \
  447. --header 'Authorization: Bearer ENTER-YOUR-SECRET-KEY' \
  448. --header 'Content-Type: application/json' \
  449. ```
  450. </CodeGroup>
  451. <CodeGroup title="Response">
  452. ```json {{ title: 'Response' }}
  453. {
  454. "result": "success",
  455. "data": [
  456. "a",
  457. "b",
  458. "c"
  459. ]
  460. }
  461. ```
  462. </CodeGroup>
  463. </Col>
  464. </Row>
  465. ---
  466. ---
  467. <Heading
  468. url='/messages'
  469. method='GET'
  470. title='获取会话历史消息'
  471. name='#messages'
  472. />
  473. <Row>
  474. <Col>
  475. 滚动加载形式返回历史聊天记录,第一页返回最新 `limit` 条,即:倒序返回。
  476. ### Query
  477. <Properties>
  478. <Property name='conversation_id' type='string' key='conversation_id'>
  479. 会话 ID
  480. </Property>
  481. <Property name='user' type='string' key='user'>
  482. 用户标识,由开发者定义规则,需保证用户标识在应用内唯一。
  483. </Property>
  484. <Property name='first_id' type='string' key='first_id'>
  485. 当前页第一条聊天记录的 ID,默认 null
  486. </Property>
  487. <Property name='limit' type='int' key='limit'>
  488. 一次请求返回多少条聊天记录,默认 20 条。
  489. </Property>
  490. </Properties>
  491. ### Response
  492. - `data` (array[object]) 消息列表
  493. - `id` (string) 消息 ID
  494. - `conversation_id` (string) 会话 ID
  495. - `inputs` (array[object]) 用户输入参数。
  496. - `query` (string) 用户输入 / 提问内容。
  497. - `message_files` (array[object]) 消息文件
  498. - `id` (string) ID
  499. - `type` (string) 文件类型,image 图片
  500. - `url` (string) 预览图片地址
  501. - `belongs_to` (string) 文件归属方,user 或 assistant
  502. - `answer` (string) 回答消息内容
  503. - `created_at` (timestamp) 创建时间
  504. - `feedback` (object) 反馈信息
  505. - `rating` (string) 点赞 like / 点踩 dislike
  506. - `retriever_resources` (array[RetrieverResource]) 引用和归属分段列表
  507. - `has_more` (bool) 是否存在下一页
  508. - `limit` (int) 返回条数,若传入超过系统限制,返回系统限制数量
  509. </Col>
  510. <Col sticky>
  511. ### Request Example
  512. <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}'`}>
  513. ```bash {{ title: 'cURL' }}
  514. curl -X GET '${props.appDetail.api_base_url}/messages?user=abc-123&conversation_id='
  515. --header 'Authorization: Bearer {api_key}'
  516. ```
  517. </CodeGroup>
  518. ### Response Example
  519. <CodeGroup title="Response">
  520. ```json {{ title: 'Response' }}
  521. {
  522. "limit": 20,
  523. "has_more": false,
  524. "data": [
  525. {
  526. "id": "a076a87f-31e5-48dc-b452-0061adbbc922",
  527. "conversation_id": "cd78daf6-f9e4-4463-9ff2-54257230a0ce",
  528. "inputs": {
  529. "name": "dify"
  530. },
  531. "query": "iphone 13 pro",
  532. "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.",
  533. "message_files": [],
  534. "feedback": null,
  535. "retriever_resources": [
  536. {
  537. "position": 1,
  538. "dataset_id": "101b4c97-fc2e-463c-90b1-5261a4cdcafb",
  539. "dataset_name": "iPhone",
  540. "document_id": "8dd1ad74-0b5f-4175-b735-7d98bbbb4e00",
  541. "document_name": "iPhone List",
  542. "segment_id": "ed599c7f-2766-4294-9d1d-e5235a61270a",
  543. "score": 0.98457545,
  544. "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\""
  545. }
  546. ],
  547. "created_at": 1705569239
  548. }
  549. ]
  550. }
  551. ```
  552. </CodeGroup>
  553. ### Response Example(智能助手)
  554. <CodeGroup title="Response">
  555. ```json {{ title: 'Response' }}
  556. {
  557. "limit": 20,
  558. "has_more": false,
  559. "data": [
  560. {
  561. "id": "d35e006c-7c4d-458f-9142-be4930abdf94",
  562. "conversation_id": "957c068b-f258-4f89-ba10-6e8a0361c457",
  563. "inputs": {},
  564. "query": "draw a cat",
  565. "answer": "I have generated an image of a cat for you. Please check your messages to view the image.",
  566. "message_files": [
  567. {
  568. "id": "976990d2-5294-47e6-8f14-7356ba9d2d76",
  569. "type": "image",
  570. "url": "http://127.0.0.1:5001/files/tools/976990d2-5294-47e6-8f14-7356ba9d2d76.png?timestamp=1705988524&nonce=55df3f9f7311a9acd91bf074cd524092&sign=z43nMSO1L2HBvoqADLkRxr7Biz0fkjeDstnJiCK1zh8=",
  571. "belongs_to": "assistant"
  572. }
  573. ],
  574. "feedback": null,
  575. "retriever_resources": [],
  576. "created_at": 1705988187
  577. }
  578. ]
  579. }
  580. ```
  581. </CodeGroup>
  582. </Col>
  583. </Row>
  584. ---
  585. <Heading
  586. url='/conversations'
  587. method='GET'
  588. title='获取会话列表'
  589. name='#conversations'
  590. />
  591. <Row>
  592. <Col>
  593. 获取当前用户的会话列表,默认返回最近的 20 条。
  594. ### Query
  595. <Properties>
  596. <Property name='user' type='string' key='user'>
  597. 用户标识,由开发者定义规则,需保证用户标识在应用内唯一。
  598. </Property>
  599. <Property name='last_id' type='string' key='last_id'>
  600. 当前页最后面一条记录的 ID,默认 null
  601. </Property>
  602. <Property name='limit' type='int' key='limit'>
  603. 一次请求返回多少条记录
  604. </Property>
  605. <Property name='pinned' type='bool' key='pinned'>
  606. 只返回置顶 true,只返回非置顶 false
  607. </Property>
  608. </Properties>
  609. ### Response
  610. - `data` (array[object]) 会话列表
  611. - `id` (string) 会话 ID
  612. - `name` (string) 会话名称,默认为会话中用户最开始问题的截取。
  613. - `inputs` (array[object]) 用户输入参数。
  614. - `introduction` (string) 开场白
  615. - `created_at` (timestamp) 创建时间
  616. - `has_more` (bool)
  617. - `limit` (int) 返回条数,若传入超过系统限制,返回系统限制数量
  618. </Col>
  619. <Col sticky>
  620. <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}'`}>
  621. ```bash {{ title: 'cURL' }}
  622. curl -X GET '${props.appDetail.api_base_url}/conversations?user=abc-123&last_id=&limit=20' \
  623. --header 'Authorization: Bearer {api_key}'
  624. ```
  625. </CodeGroup>
  626. <CodeGroup title="Response">
  627. ```json {{ title: 'Response' }}
  628. {
  629. "limit": 20,
  630. "has_more": false,
  631. "data": [
  632. {
  633. "id": "10799fb8-64f7-4296-bbf7-b42bfbe0ae54",
  634. "name": "New chat",
  635. "inputs": {
  636. "book": "book",
  637. "myName": "Lucy"
  638. },
  639. "status": "normal",
  640. "created_at": 1679667915
  641. },
  642. {
  643. "id": "hSIhXBhNe8X1d8Et"
  644. // ...
  645. }
  646. ]
  647. }
  648. ```
  649. </CodeGroup>
  650. </Col>
  651. </Row>
  652. ---
  653. <Heading
  654. url='/conversations/:conversation_id'
  655. method='DELETE'
  656. title='删除会话'
  657. name='#delete'
  658. />
  659. <Row>
  660. <Col>
  661. 删除会话。
  662. ### Path
  663. - `conversation_id` (string) 会话 ID
  664. ### Request Body
  665. <Properties>
  666. <Property name='user' type='string' key='user'>
  667. 用户标识,由开发者定义规则,需保证用户标识在应用内唯一。
  668. </Property>
  669. </Properties>
  670. ### Response
  671. - `result` (string) 固定返回 success
  672. </Col>
  673. <Col sticky>
  674. <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}'`}>
  675. ```bash {{ title: 'cURL' }}
  676. curl -X DELETE '${props.appDetail.api_base_url}/conversations/{convsation_id}' \
  677. --header 'Content-Type: application/json' \
  678. --header 'Accept: application/json' \
  679. --header 'Authorization: Bearer {api_key}' \
  680. --data '{
  681. "user": "abc-123"
  682. }'
  683. ```
  684. </CodeGroup>
  685. <CodeGroup title="Response">
  686. ```json {{ title: 'Response' }}
  687. {
  688. "result": "success"
  689. }
  690. ```
  691. </CodeGroup>
  692. </Col>
  693. </Row>
  694. ---
  695. <Heading
  696. url='/conversations/:conversation_id/name'
  697. method='POST'
  698. title='会话重命名'
  699. name='#rename'
  700. />
  701. <Row>
  702. <Col>
  703. 对会话进行重命名,会话名称用于显示在支持多会话的客户端上。
  704. ### Request Body
  705. <Properties>
  706. <Property name='name' type='string' key='name'>
  707. 名称,若 `auto_generate` 为 `true` 时,该参数可不传。
  708. </Property>
  709. <Property name='auto_generate' type='string' key='auto_generate'>
  710. 自动生成标题,默认 false。
  711. </Property>
  712. <Property name='user' type='string' key='user'>
  713. 用户标识,由开发者定义规则,需保证用户标识在应用内唯一。
  714. </Property>
  715. </Properties>
  716. ### Response
  717. - `id` (string) 会话 ID
  718. - `name` (string) 会话名称
  719. - `inputs` array[object] 用户输入参数。
  720. - `introduction` (string) 开场白
  721. - `created_at` (timestamp) 创建时间
  722. </Col>
  723. <Col sticky>
  724. <CodeGroup title="Request" tag="POST" label="/conversations/:conversation_id/name" targetCode={`curl -X POST '${props.appDetail.api_base_url}/conversations/name' \\\n--header 'Authorization: Bearer {api_key}' \\\n--header 'Content-Type: application/json' \\\n--data-raw '{ \n "name": "", \n "user": "abc-123"\n}'`}>
  725. ```bash {{ title: 'cURL' }}
  726. curl -X POST '${props.appDetail.api_base_url}/conversations/:conversation_id/name' \
  727. --header 'Authorization: Bearer {api_key}' \
  728. --header 'Content-Type: application/json' \
  729. --data-raw '{
  730. "name": "",
  731. "user": "abc-123"
  732. }'
  733. ```
  734. </CodeGroup>
  735. <CodeGroup title="Response">
  736. ```json {{ title: 'Response' }}
  737. {
  738. "result": "success"
  739. }
  740. ```
  741. </CodeGroup>
  742. </Col>
  743. </Row>
  744. ---
  745. <Heading
  746. url='/audio-to-text'
  747. method='POST'
  748. title='语音转文字'
  749. name='#audio'
  750. />
  751. <Row>
  752. <Col>
  753. ### Request Body
  754. 该接口需使用 `multipart/form-data` 进行请求。
  755. <Properties>
  756. <Property name='file' type='file' key='file'>
  757. 语音文件。
  758. 支持格式:`['mp3', 'mp4', 'mpeg', 'mpga', 'm4a', 'wav', 'webm']`
  759. 文件大小限制:15MB
  760. </Property>
  761. <Property name='user' type='string' key='user'>
  762. 用户标识,由开发者定义规则,需保证用户标识在应用内唯一。
  763. </Property>
  764. </Properties>
  765. ### Response
  766. - `text` (string) 输出文字
  767. </Col>
  768. <Col sticky>
  769. <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]`}>
  770. ```bash {{ title: 'cURL' }}
  771. curl -X POST '${props.appDetail.api_base_url}/conversations/name' \
  772. --header 'Authorization: Bearer {api_key}' \
  773. --form 'file=@localfile;type=audio/mp3'
  774. ```
  775. </CodeGroup>
  776. <CodeGroup title="Response">
  777. ```json {{ title: 'Response' }}
  778. {
  779. "text": "hello"
  780. }
  781. ```
  782. </CodeGroup>
  783. </Col>
  784. </Row>
  785. ---
  786. <Heading
  787. url='/text-to-audio'
  788. method='POST'
  789. title='文字转语音'
  790. name='#audio'
  791. />
  792. <Row>
  793. <Col>
  794. 文字转语音。
  795. ### Request Body
  796. <Properties>
  797. <Property name='text' type='str' key='text'>
  798. 语音生成内容。
  799. </Property>
  800. <Property name='user' type='string' key='user'>
  801. 用户标识,由开发者定义规则,需保证用户标识在应用内唯一。
  802. </Property>
  803. <Property name='streaming' type='bool' key='streaming'>
  804. 是否启用流式输出true、false。
  805. </Property>
  806. </Properties>
  807. </Col>
  808. <Col sticky>
  809. <CodeGroup title="Request" tag="POST" label="/text-to-audio" targetCode={`curl --location --request POST '${props.appDetail.api_base_url}/text-to-audio' \\\n--header 'Authorization: Bearer ENTER-YOUR-SECRET-KEY' \\\n--form 'text=你好Dify;user=abc-123;streaming=false`}>
  810. ```bash {{ title: 'cURL' }}
  811. curl --location --request POST '${props.appDetail.api_base_url}/text-to-audio' \
  812. --header 'Authorization: Bearer ENTER-YOUR-SECRET-KEY' \
  813. --form 'file=你好Dify;user=abc-123;streaming=false'
  814. ```
  815. </CodeGroup>
  816. <CodeGroup title="headers">
  817. ```json {{ title: 'headers' }}
  818. {
  819. "Content-Type": "audio/wav"
  820. }
  821. ```
  822. </CodeGroup>
  823. </Col>
  824. </Row>
  825. ---
  826. <Heading
  827. url='/parameters'
  828. method='GET'
  829. title='获取应用配置信息'
  830. name='#parameters'
  831. />
  832. <Row>
  833. <Col>
  834. 用于进入页面一开始,获取功能开关、输入参数名称、类型及默认值等使用。
  835. ### Query
  836. <Properties>
  837. <Property name='user' type='string' key='user'>
  838. 用户标识,由开发者定义规则,需保证用户标识在应用内唯一。
  839. </Property>
  840. </Properties>
  841. ### Response
  842. - `opening_statement` (string) 开场白
  843. - `suggested_questions` (array[string]) 开场推荐问题列表
  844. - `suggested_questions_after_answer` (object) 启用回答后给出推荐问题。
  845. - `enabled` (bool) 是否开启
  846. - `speech_to_text` (object) 语音转文本
  847. - `enabled` (bool) 是否开启
  848. - `retriever_resource` (object) 引用和归属
  849. - `enabled` (bool) 是否开启
  850. - `annotation_reply` (object) 标记回复
  851. - `enabled` (bool) 是否开启
  852. - `user_input_form` (array[object]) 用户输入表单配置
  853. - `text-input` (object) 文本输入控件
  854. - `label` (string) 控件展示标签名
  855. - `variable` (string) 控件 ID
  856. - `required` (bool) 是否必填
  857. - `default` (string) 默认值
  858. - `paragraph` (object) 段落文本输入控件
  859. - `label` (string) 控件展示标签名
  860. - `variable` (string) 控件 ID
  861. - `required` (bool) 是否必填
  862. - `default` (string) 默认值
  863. - `select` (object) 下拉控件
  864. - `label` (string) 控件展示标签名
  865. - `variable` (string) 控件 ID
  866. - `required` (bool) 是否必填
  867. - `default` (string) 默认值
  868. - `options` (array[string]) 选项值
  869. - `file_upload` (object) 文件上传配置
  870. - `image` (object) 图片设置
  871. 当前仅支持图片类型:`png`, `jpg`, `jpeg`, `webp`, `gif`
  872. - `enabled` (bool) 是否开启
  873. - `number_limits` (int) 图片数量限制,默认 3
  874. - `transfer_methods` (array[string]) 传递方式列表,remote_url , local_file,必选一个
  875. - `system_parameters` (object) 系统参数
  876. - `image_file_size_limit` (string) 图片文件上传大小限制(MB)
  877. </Col>
  878. <Col sticky>
  879. <CodeGroup title="Request" tag="GET" label="/parameters" targetCode={` curl -X GET '${props.appDetail.api_base_url}/parameters'\\\n--header 'Authorization: Bearer {api_key}'`}>
  880. ```bash {{ title: 'cURL' }}
  881. curl -X GET '${props.appDetail.api_base_url}/parameters?user=abc-123' \
  882. --header 'Authorization: Bearer {api_key}'
  883. ```
  884. </CodeGroup>
  885. <CodeGroup title="Response">
  886. ```json {{ title: 'Response' }}
  887. {
  888. "introduction": "nice to meet you",
  889. "user_input_form": [
  890. {
  891. "text-input": {
  892. "label": "a",
  893. "variable": "a",
  894. "required": true,
  895. "max_length": 48,
  896. "default": ""
  897. }
  898. },
  899. {
  900. // ...
  901. }
  902. ],
  903. "file_upload": {
  904. "image": {
  905. "enabled": true,
  906. "number_limits": 3,
  907. "transfer_methods": [
  908. "remote_url",
  909. "local_file"
  910. ]
  911. }
  912. }
  913. }
  914. ```
  915. </CodeGroup>
  916. </Col>
  917. </Row>
  918. ---
  919. <Heading
  920. url='/meta'
  921. method='GET'
  922. title='获取应用Meta信息'
  923. name='#meta'
  924. />
  925. <Row>
  926. <Col>
  927. 用于获取工具icon
  928. ### Query
  929. <Properties>
  930. <Property name='user' type='string' key='user'>
  931. 用户标识,由开发者定义规则,需保证用户标识在应用内唯一。
  932. </Property>
  933. </Properties>
  934. ### Response
  935. - `tool_icons`(object[string]) 工具图标
  936. - `工具名称` (string)
  937. - `icon` (object|string)
  938. - (object) 图标
  939. - `background` (string) hex格式的背景色
  940. - `content`(string) emoji
  941. - (string) 图标URL
  942. </Col>
  943. <Col>
  944. <CodeGroup title="Request" tag="POST" label="/meta" targetCode={`curl -X GET '${props.appDetail.api_base_url}/meta?user=abc-123' \\\n-H 'Authorization: Bearer {api_key}'`}>
  945. ```bash {{ title: 'cURL' }}
  946. curl -X GET '${props.appDetail.api_base_url}/meta?user=abc-123' \
  947. -H 'Authorization: Bearer {api_key}'
  948. ```
  949. </CodeGroup>
  950. <CodeGroup title="Response">
  951. ```json {{ title: 'Response' }}
  952. {
  953. "tool_icons": {
  954. "dalle2": "https://cloud.dify.ai/console/api/workspaces/current/tool-provider/builtin/dalle/icon",
  955. "api_tool": {
  956. "background": "#252525",
  957. "content": "\ud83d\ude01"
  958. }
  959. }
  960. }
  961. ```
  962. </CodeGroup>
  963. </Col>
  964. </Row>