template_advanced_chat.zh.mdx 41 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091
  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. ### Query
  443. <Properties>
  444. <Property name='user' type='string' key='user'>
  445. 用户标识,由开发者定义规则,需保证用户标识在应用内唯一。
  446. </Property>
  447. </Properties>
  448. </Col>
  449. <Col sticky>
  450. <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'`}>
  451. ```bash {{ title: 'cURL' }}
  452. curl --location --request GET '${props.appDetail.api_base_url}/messages/{message_id}/suggested'?user=abc-123 \
  453. --header 'Authorization: Bearer ENTER-YOUR-SECRET-KEY' \
  454. --header 'Content-Type: application/json' \
  455. ```
  456. </CodeGroup>
  457. <CodeGroup title="Response">
  458. ```json {{ title: 'Response' }}
  459. {
  460. "result": "success",
  461. "data": [
  462. "a",
  463. "b",
  464. "c"
  465. ]
  466. }
  467. ```
  468. </CodeGroup>
  469. </Col>
  470. </Row>
  471. ---
  472. ---
  473. <Heading
  474. url='/messages'
  475. method='GET'
  476. title='获取会话历史消息'
  477. name='#messages'
  478. />
  479. <Row>
  480. <Col>
  481. 滚动加载形式返回历史聊天记录,第一页返回最新 `limit` 条,即:倒序返回。
  482. ### Query
  483. <Properties>
  484. <Property name='conversation_id' type='string' key='conversation_id'>
  485. 会话 ID
  486. </Property>
  487. <Property name='user' type='string' key='user'>
  488. 用户标识,由开发者定义规则,需保证用户标识在应用内唯一。
  489. </Property>
  490. <Property name='first_id' type='string' key='first_id'>
  491. 当前页第一条聊天记录的 ID,默认 null
  492. </Property>
  493. <Property name='limit' type='int' key='limit'>
  494. 一次请求返回多少条聊天记录,默认 20 条。
  495. </Property>
  496. </Properties>
  497. ### Response
  498. - `data` (array[object]) 消息列表
  499. - `id` (string) 消息 ID
  500. - `conversation_id` (string) 会话 ID
  501. - `inputs` (array[object]) 用户输入参数。
  502. - `query` (string) 用户输入 / 提问内容。
  503. - `message_files` (array[object]) 消息文件
  504. - `id` (string) ID
  505. - `type` (string) 文件类型,image 图片
  506. - `url` (string) 预览图片地址
  507. - `belongs_to` (string) 文件归属方,user 或 assistant
  508. - `answer` (string) 回答消息内容
  509. - `created_at` (timestamp) 创建时间
  510. - `feedback` (object) 反馈信息
  511. - `rating` (string) 点赞 like / 点踩 dislike
  512. - `retriever_resources` (array[RetrieverResource]) 引用和归属分段列表
  513. - `has_more` (bool) 是否存在下一页
  514. - `limit` (int) 返回条数,若传入超过系统限制,返回系统限制数量
  515. </Col>
  516. <Col sticky>
  517. ### Request Example
  518. <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}'`}>
  519. ```bash {{ title: 'cURL' }}
  520. curl -X GET '${props.appDetail.api_base_url}/messages?user=abc-123&conversation_id='
  521. --header 'Authorization: Bearer {api_key}'
  522. ```
  523. </CodeGroup>
  524. ### Response Example
  525. <CodeGroup title="Response">
  526. ```json {{ title: 'Response' }}
  527. {
  528. "limit": 20,
  529. "has_more": false,
  530. "data": [
  531. {
  532. "id": "a076a87f-31e5-48dc-b452-0061adbbc922",
  533. "conversation_id": "cd78daf6-f9e4-4463-9ff2-54257230a0ce",
  534. "inputs": {
  535. "name": "dify"
  536. },
  537. "query": "iphone 13 pro",
  538. "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.",
  539. "message_files": [],
  540. "feedback": null,
  541. "retriever_resources": [
  542. {
  543. "position": 1,
  544. "dataset_id": "101b4c97-fc2e-463c-90b1-5261a4cdcafb",
  545. "dataset_name": "iPhone",
  546. "document_id": "8dd1ad74-0b5f-4175-b735-7d98bbbb4e00",
  547. "document_name": "iPhone List",
  548. "segment_id": "ed599c7f-2766-4294-9d1d-e5235a61270a",
  549. "score": 0.98457545,
  550. "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\""
  551. }
  552. ],
  553. "created_at": 1705569239
  554. }
  555. ]
  556. }
  557. ```
  558. </CodeGroup>
  559. ### Response Example(智能助手)
  560. <CodeGroup title="Response">
  561. ```json {{ title: 'Response' }}
  562. {
  563. "limit": 20,
  564. "has_more": false,
  565. "data": [
  566. {
  567. "id": "d35e006c-7c4d-458f-9142-be4930abdf94",
  568. "conversation_id": "957c068b-f258-4f89-ba10-6e8a0361c457",
  569. "inputs": {},
  570. "query": "draw a cat",
  571. "answer": "I have generated an image of a cat for you. Please check your messages to view the image.",
  572. "message_files": [
  573. {
  574. "id": "976990d2-5294-47e6-8f14-7356ba9d2d76",
  575. "type": "image",
  576. "url": "http://127.0.0.1:5001/files/tools/976990d2-5294-47e6-8f14-7356ba9d2d76.png?timestamp=1705988524&nonce=55df3f9f7311a9acd91bf074cd524092&sign=z43nMSO1L2HBvoqADLkRxr7Biz0fkjeDstnJiCK1zh8=",
  577. "belongs_to": "assistant"
  578. }
  579. ],
  580. "feedback": null,
  581. "retriever_resources": [],
  582. "created_at": 1705988187
  583. }
  584. ]
  585. }
  586. ```
  587. </CodeGroup>
  588. </Col>
  589. </Row>
  590. ---
  591. <Heading
  592. url='/conversations'
  593. method='GET'
  594. title='获取会话列表'
  595. name='#conversations'
  596. />
  597. <Row>
  598. <Col>
  599. 获取当前用户的会话列表,默认返回最近的 20 条。
  600. ### Query
  601. <Properties>
  602. <Property name='user' type='string' key='user'>
  603. 用户标识,由开发者定义规则,需保证用户标识在应用内唯一。
  604. </Property>
  605. <Property name='last_id' type='string' key='last_id'>
  606. 当前页最后面一条记录的 ID,默认 null
  607. </Property>
  608. <Property name='limit' type='int' key='limit'>
  609. 一次请求返回多少条记录
  610. </Property>
  611. <Property name='pinned' type='bool' key='pinned'>
  612. 只返回置顶 true,只返回非置顶 false
  613. </Property>
  614. </Properties>
  615. ### Response
  616. - `data` (array[object]) 会话列表
  617. - `id` (string) 会话 ID
  618. - `name` (string) 会话名称,默认由大语言模型生成。
  619. - `inputs` (array[object]) 用户输入参数。
  620. - `introduction` (string) 开场白
  621. - `created_at` (timestamp) 创建时间
  622. - `has_more` (bool)
  623. - `limit` (int) 返回条数,若传入超过系统限制,返回系统限制数量
  624. </Col>
  625. <Col sticky>
  626. <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}'`}>
  627. ```bash {{ title: 'cURL' }}
  628. curl -X GET '${props.appDetail.api_base_url}/conversations?user=abc-123&last_id=&limit=20' \
  629. --header 'Authorization: Bearer {api_key}'
  630. ```
  631. </CodeGroup>
  632. <CodeGroup title="Response">
  633. ```json {{ title: 'Response' }}
  634. {
  635. "limit": 20,
  636. "has_more": false,
  637. "data": [
  638. {
  639. "id": "10799fb8-64f7-4296-bbf7-b42bfbe0ae54",
  640. "name": "New chat",
  641. "inputs": {
  642. "book": "book",
  643. "myName": "Lucy"
  644. },
  645. "status": "normal",
  646. "created_at": 1679667915
  647. },
  648. {
  649. "id": "hSIhXBhNe8X1d8Et"
  650. // ...
  651. }
  652. ]
  653. }
  654. ```
  655. </CodeGroup>
  656. </Col>
  657. </Row>
  658. ---
  659. <Heading
  660. url='/conversations/:conversation_id'
  661. method='DELETE'
  662. title='删除会话'
  663. name='#delete'
  664. />
  665. <Row>
  666. <Col>
  667. 删除会话。
  668. ### Path
  669. - `conversation_id` (string) 会话 ID
  670. ### Request Body
  671. <Properties>
  672. <Property name='user' type='string' key='user'>
  673. 用户标识,由开发者定义规则,需保证用户标识在应用内唯一。
  674. </Property>
  675. </Properties>
  676. ### Response
  677. - `result` (string) 固定返回 success
  678. </Col>
  679. <Col sticky>
  680. <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}'`}>
  681. ```bash {{ title: 'cURL' }}
  682. curl -X DELETE '${props.appDetail.api_base_url}/conversations/{convsation_id}' \
  683. --header 'Content-Type: application/json' \
  684. --header 'Accept: application/json' \
  685. --header 'Authorization: Bearer {api_key}' \
  686. --data '{
  687. "user": "abc-123"
  688. }'
  689. ```
  690. </CodeGroup>
  691. <CodeGroup title="Response">
  692. ```json {{ title: 'Response' }}
  693. {
  694. "result": "success"
  695. }
  696. ```
  697. </CodeGroup>
  698. </Col>
  699. </Row>
  700. ---
  701. <Heading
  702. url='/conversations/:conversation_id/name'
  703. method='POST'
  704. title='会话重命名'
  705. name='#rename'
  706. />
  707. <Row>
  708. <Col>
  709. 对会话进行重命名,会话名称用于显示在支持多会话的客户端上。
  710. ### Request Body
  711. <Properties>
  712. <Property name='name' type='string' key='name'>
  713. 名称,若 `auto_generate` 为 `true` 时,该参数可不传。
  714. </Property>
  715. <Property name='auto_generate' type='string' key='auto_generate'>
  716. 自动生成标题,默认 false。
  717. </Property>
  718. <Property name='user' type='string' key='user'>
  719. 用户标识,由开发者定义规则,需保证用户标识在应用内唯一。
  720. </Property>
  721. </Properties>
  722. ### Response
  723. - `id` (string) 会话 ID
  724. - `name` (string) 会话名称
  725. - `inputs` array[object] 用户输入参数。
  726. - `introduction` (string) 开场白
  727. - `created_at` (timestamp) 创建时间
  728. </Col>
  729. <Col sticky>
  730. <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}'`}>
  731. ```bash {{ title: 'cURL' }}
  732. curl -X POST '${props.appDetail.api_base_url}/conversations/:conversation_id/name' \
  733. --header 'Authorization: Bearer {api_key}' \
  734. --header 'Content-Type: application/json' \
  735. --data-raw '{
  736. "name": "",
  737. "user": "abc-123"
  738. }'
  739. ```
  740. </CodeGroup>
  741. <CodeGroup title="Response">
  742. ```json {{ title: 'Response' }}
  743. {
  744. "result": "success"
  745. }
  746. ```
  747. </CodeGroup>
  748. </Col>
  749. </Row>
  750. ---
  751. <Heading
  752. url='/audio-to-text'
  753. method='POST'
  754. title='语音转文字'
  755. name='#audio'
  756. />
  757. <Row>
  758. <Col>
  759. ### Request Body
  760. 该接口需使用 `multipart/form-data` 进行请求。
  761. <Properties>
  762. <Property name='file' type='file' key='file'>
  763. 语音文件。
  764. 支持格式:`['mp3', 'mp4', 'mpeg', 'mpga', 'm4a', 'wav', 'webm']`
  765. 文件大小限制:15MB
  766. </Property>
  767. <Property name='user' type='string' key='user'>
  768. 用户标识,由开发者定义规则,需保证用户标识在应用内唯一。
  769. </Property>
  770. </Properties>
  771. ### Response
  772. - `text` (string) 输出文字
  773. </Col>
  774. <Col sticky>
  775. <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]`}>
  776. ```bash {{ title: 'cURL' }}
  777. curl -X POST '${props.appDetail.api_base_url}/conversations/name' \
  778. --header 'Authorization: Bearer {api_key}' \
  779. --form 'file=@localfile;type=audio/mp3'
  780. ```
  781. </CodeGroup>
  782. <CodeGroup title="Response">
  783. ```json {{ title: 'Response' }}
  784. {
  785. "text": "hello"
  786. }
  787. ```
  788. </CodeGroup>
  789. </Col>
  790. </Row>
  791. ---
  792. <Heading
  793. url='/text-to-audio'
  794. method='POST'
  795. title='文字转语音'
  796. name='#audio'
  797. />
  798. <Row>
  799. <Col>
  800. 文字转语音。
  801. ### Request Body
  802. <Properties>
  803. <Property name='text' type='str' key='text'>
  804. 语音生成内容。
  805. </Property>
  806. <Property name='user' type='string' key='user'>
  807. 用户标识,由开发者定义规则,需保证用户标识在应用内唯一。
  808. </Property>
  809. <Property name='streaming' type='bool' key='streaming'>
  810. 是否启用流式输出true、false。
  811. </Property>
  812. </Properties>
  813. </Col>
  814. <Col sticky>
  815. <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 "text": "你好Dify",\n "user": "abc-123",\n "streaming": false\n}'`}>
  816. ```bash {{ title: 'cURL' }}
  817. curl -o text-to-audio.mp3 -X POST '${props.appDetail.api_base_url}/text-to-audio' \
  818. --header 'Authorization: Bearer {api_key}' \
  819. --header 'Content-Type: application/json' \
  820. --data-raw '{
  821. "text": "你好Dify",
  822. "user": "abc-123",
  823. "streaming": false
  824. }'
  825. ```
  826. </CodeGroup>
  827. <CodeGroup title="headers">
  828. ```json {{ title: 'headers' }}
  829. {
  830. "Content-Type": "audio/wav"
  831. }
  832. ```
  833. </CodeGroup>
  834. </Col>
  835. </Row>
  836. ---
  837. <Heading
  838. url='/parameters'
  839. method='GET'
  840. title='获取应用配置信息'
  841. name='#parameters'
  842. />
  843. <Row>
  844. <Col>
  845. 用于进入页面一开始,获取功能开关、输入参数名称、类型及默认值等使用。
  846. ### Query
  847. <Properties>
  848. <Property name='user' type='string' key='user'>
  849. 用户标识,由开发者定义规则,需保证用户标识在应用内唯一。
  850. </Property>
  851. </Properties>
  852. ### Response
  853. - `opening_statement` (string) 开场白
  854. - `suggested_questions` (array[string]) 开场推荐问题列表
  855. - `suggested_questions_after_answer` (object) 启用回答后给出推荐问题。
  856. - `enabled` (bool) 是否开启
  857. - `speech_to_text` (object) 语音转文本
  858. - `enabled` (bool) 是否开启
  859. - `retriever_resource` (object) 引用和归属
  860. - `enabled` (bool) 是否开启
  861. - `annotation_reply` (object) 标记回复
  862. - `enabled` (bool) 是否开启
  863. - `user_input_form` (array[object]) 用户输入表单配置
  864. - `text-input` (object) 文本输入控件
  865. - `label` (string) 控件展示标签名
  866. - `variable` (string) 控件 ID
  867. - `required` (bool) 是否必填
  868. - `default` (string) 默认值
  869. - `paragraph` (object) 段落文本输入控件
  870. - `label` (string) 控件展示标签名
  871. - `variable` (string) 控件 ID
  872. - `required` (bool) 是否必填
  873. - `default` (string) 默认值
  874. - `select` (object) 下拉控件
  875. - `label` (string) 控件展示标签名
  876. - `variable` (string) 控件 ID
  877. - `required` (bool) 是否必填
  878. - `default` (string) 默认值
  879. - `options` (array[string]) 选项值
  880. - `file_upload` (object) 文件上传配置
  881. - `image` (object) 图片设置
  882. 当前仅支持图片类型:`png`, `jpg`, `jpeg`, `webp`, `gif`
  883. - `enabled` (bool) 是否开启
  884. - `number_limits` (int) 图片数量限制,默认 3
  885. - `transfer_methods` (array[string]) 传递方式列表,remote_url , local_file,必选一个
  886. - `system_parameters` (object) 系统参数
  887. - `image_file_size_limit` (string) 图片文件上传大小限制(MB)
  888. </Col>
  889. <Col sticky>
  890. <CodeGroup title="Request" tag="GET" label="/parameters" targetCode={` curl -X GET '${props.appDetail.api_base_url}/parameters'\\\n--header 'Authorization: Bearer {api_key}'`}>
  891. ```bash {{ title: 'cURL' }}
  892. curl -X GET '${props.appDetail.api_base_url}/parameters?user=abc-123' \
  893. --header 'Authorization: Bearer {api_key}'
  894. ```
  895. </CodeGroup>
  896. <CodeGroup title="Response">
  897. ```json {{ title: 'Response' }}
  898. {
  899. "introduction": "nice to meet you",
  900. "user_input_form": [
  901. {
  902. "text-input": {
  903. "label": "a",
  904. "variable": "a",
  905. "required": true,
  906. "max_length": 48,
  907. "default": ""
  908. }
  909. },
  910. {
  911. // ...
  912. }
  913. ],
  914. "file_upload": {
  915. "image": {
  916. "enabled": true,
  917. "number_limits": 3,
  918. "transfer_methods": [
  919. "remote_url",
  920. "local_file"
  921. ]
  922. }
  923. }
  924. }
  925. ```
  926. </CodeGroup>
  927. </Col>
  928. </Row>
  929. ---
  930. <Heading
  931. url='/meta'
  932. method='GET'
  933. title='获取应用Meta信息'
  934. name='#meta'
  935. />
  936. <Row>
  937. <Col>
  938. 用于获取工具icon
  939. ### Query
  940. <Properties>
  941. <Property name='user' type='string' key='user'>
  942. 用户标识,由开发者定义规则,需保证用户标识在应用内唯一。
  943. </Property>
  944. </Properties>
  945. ### Response
  946. - `tool_icons`(object[string]) 工具图标
  947. - `工具名称` (string)
  948. - `icon` (object|string)
  949. - (object) 图标
  950. - `background` (string) hex格式的背景色
  951. - `content`(string) emoji
  952. - (string) 图标URL
  953. </Col>
  954. <Col>
  955. <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}'`}>
  956. ```bash {{ title: 'cURL' }}
  957. curl -X GET '${props.appDetail.api_base_url}/meta?user=abc-123' \
  958. -H 'Authorization: Bearer {api_key}'
  959. ```
  960. </CodeGroup>
  961. <CodeGroup title="Response">
  962. ```json {{ title: 'Response' }}
  963. {
  964. "tool_icons": {
  965. "dalle2": "https://cloud.dify.ai/console/api/workspaces/current/tool-provider/builtin/dalle/icon",
  966. "api_tool": {
  967. "background": "#252525",
  968. "content": "\ud83d\ude01"
  969. }
  970. }
  971. }
  972. ```
  973. </CodeGroup>
  974. </Col>
  975. </Row>