You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

template_advanced_chat.ja.mdx 62KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400
  1. import { CodeGroup } from '../code.tsx'
  2. import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from '../md.tsx'
  3. # 高度なチャットアプリ API
  4. チャットアプリケーションはセッションの持続性をサポートしており、以前のチャット履歴を応答のコンテキストとして使用できます。これは、チャットボットやカスタマーサービス AI などに適用できます。
  5. <div>
  6. ### ベース URL
  7. <CodeGroup title="コード" targetCode={props.appDetail.api_base_url}>
  8. ```javascript
  9. ```
  10. </CodeGroup>
  11. ### 認証
  12. サービス API は `API-Key` 認証を使用します。
  13. <i>**API キーはサーバー側に保存し、クライアント側で共有または保存しないことを強くお勧めします。API キーの漏洩は深刻な結果を招く可能性があります。**</i>
  14. すべての API リクエストには、以下のように `Authorization`HTTP ヘッダーに API キーを含めてください:
  15. <CodeGroup title="コード">
  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='#Send-Chat-Message'
  27. />
  28. <Row>
  29. <Col>
  30. チャットアプリケーションにリクエストを送信します。
  31. ### リクエストボディ
  32. <Properties>
  33. <Property name='query' type='string' key='query'>
  34. ユーザー入力/質問内容
  35. </Property>
  36. <Property name='inputs' type='object' key='inputs'>
  37. アプリによって定義されたさまざまな変数値の入力を許可します。
  38. `inputs`パラメータには複数のキー/値ペアが含まれ、各キーは特定の変数に対応し、各値はその変数の特定の値です。
  39. 変数がファイルタイプの場合、以下の`files`で説明されているキーを持つオブジェクトを指定します。
  40. デフォルト`{}`
  41. </Property>
  42. <Property name='response_mode' type='string' key='response_mode'>
  43. 応答の返却モードを指定します。サポートされているモード:
  44. - `streaming` ストリーミングモード(推奨)、SSE([サーバー送信イベント](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events))を通じてタイプライターのような出力を実装します。
  45. - `blocking` ブロッキングモード、実行完了後に結果を返します。(プロセスが長い場合、リクエストが中断される可能性があります)
  46. Cloudflareの制限により、リクエストは100秒後に返答なしで中断されます。
  47. </Property>
  48. <Property name='user' type='string' key='user'>
  49. ユーザー識別子、エンドユーザーの身元を定義するために使用され、統計のために使用されます。
  50. アプリケーション内で開発者によって一意に定義されるべきです。サービス API は WebApp によって作成された会話を共有しません。
  51. </Property>
  52. <Property name='conversation_id' type='string' key='conversation_id'>
  53. 会話ID、以前のチャット記録に基づいて会話を続けるには、以前のメッセージのconversation_idを渡す必要があります。
  54. </Property>
  55. <Property name='files' type='array[object]' key='files'>
  56. ファイルリスト、テキストの理解と質問への回答を組み合わせたファイルの入力に適しており、モデルがビジョン機能をサポートしている場合にのみ利用可能です。
  57. - `type` (string) サポートされているタイプ:
  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` (他のファイルタイプ)
  63. - `transfer_method` (string) 転送方法、画像URLの場合は`remote_url` / ファイルアップロードの場合は`local_file`
  64. - `url` (string) 画像URL(転送方法が`remote_url`の場合)
  65. - `upload_file_id` (string) アップロードされたファイルID、事前にファイルアップロードAPIを通じて取得する必要があります(転送方法が`local_file`の場合)
  66. </Property>
  67. <Property name='auto_generate_name' type='bool' key='auto_generate_name'>
  68. タイトルを自動生成、デフォルトは`true`。
  69. `false`に設定すると、会話のリネームAPIを呼び出し、`auto_generate`を`true`に設定することで非同期タイトル生成を実現できます。
  70. </Property>
  71. </Properties>
  72. ### 応答
  73. response_modeがブロッキングの場合、CompletionResponseオブジェクトを返します。
  74. response_modeがストリーミングの場合、ChunkCompletionResponseストリームを返します。
  75. ### ChatCompletionResponse
  76. 完全なアプリ結果を返します。`Content-Type`は`application/json`です。
  77. - `event` (string) イベントタイプ、固定で `message`
  78. - `task_id` (string) タスクID、リクエスト追跡と以下のStop Generate APIに使用
  79. - `id` (string) ユニークID
  80. - `message_id` (string) 一意のメッセージID
  81. - `conversation_id` (string) 会話ID
  82. - `mode` (string) アプリモード、`chat`として固定
  83. - `answer` (string) 完全な応答内容
  84. - `metadata` (object) メタデータ
  85. - `usage` (Usage) モデル使用情報
  86. - `retriever_resources` (array[RetrieverResource]) 引用と帰属リスト
  87. - `created_at` (int) メッセージ作成タイムスタンプ、例:1705395332
  88. ### ChunkChatCompletionResponse
  89. アプリによって出力されたストリームチャンクを返します。`Content-Type`は`text/event-stream`です。
  90. 各ストリーミングチャンクは`data:`で始まり、2つの改行文字`\n\n`で区切られます。以下のように表示されます:
  91. <CodeGroup>
  92. ```streaming {{ title: '応答' }}
  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. ストリーミングチャンクの構造は`event`に応じて異なります:
  97. - `event: message` LLMがテキストチャンクイベントを返します。つまり、完全なテキストがチャンク形式で出力されます。
  98. - `task_id` (string) タスクID、リクエスト追跡と以下のStop Generate APIに使用
  99. - `message_id` (string) 一意のメッセージID
  100. - `conversation_id` (string) 会話ID
  101. - `answer` (string) LLMが返したテキストチャンク内容
  102. - `created_at` (int) 作成タイムスタンプ、例:1705395332
  103. - `event: message_file` メッセージファイルイベント、ツールによって新しいファイルが作成されました
  104. - `id` (string) ファイル一意ID
  105. - `type` (string) ファイルタイプ、現在は"image"のみ許可
  106. - `belongs_to` (string) 所属、ここでは'assistant'のみ
  107. - `url` (string) ファイルのリモートURL
  108. - `conversation_id` (string) 会話ID
  109. - `event: message_end` メッセージ終了イベント、このイベントを受信するとストリーミングが終了したことを意味します。
  110. - `task_id` (string) タスクID、リクエスト追跡と以下のStop Generate APIに使用
  111. - `message_id` (string) 一意のメッセージID
  112. - `conversation_id` (string) 会話ID
  113. - `metadata` (object) メタデータ
  114. - `usage` (Usage) モデル使用情報
  115. - `retriever_resources` (array[RetrieverResource]) 引用と帰属リスト
  116. - `event: tts_message` TTSオーディオストリームイベント、つまり音声合成出力。内容はMp3形式のオーディオブロックで、base64文字列としてエンコードされています。再生時には、base64をデコードしてプレーヤーに入力するだけです。(このメッセージは自動再生が有効な場合にのみ利用可能)
  117. - `task_id` (string) タスクID、リクエスト追跡と以下のストップ応答インターフェースに使用
  118. - `message_id` (string) 一意のメッセージID
  119. - `audio` (string) 音声合成後のオーディオ、base64テキストコンテンツとしてエンコードされており、再生時にはbase64をデコードしてプレーヤーに入力するだけです
  120. - `created_at` (int) 作成タイムスタンプ、例:1705395332
  121. - `event: tts_message_end` TTSオーディオストリーム終了イベント、このイベントを受信するとオーディオストリームが終了したことを示します。
  122. - `task_id` (string) タスクID、リクエスト追跡と以下のストップ応答インターフェースに使用
  123. - `message_id` (string) 一意のメッセージID
  124. - `audio` (string) 終了イベントにはオーディオがないため、これは空の文字列です
  125. - `created_at` (int) 作成タイムスタンプ、例:1705395332
  126. - `event: message_replace` メッセージ内容置換イベント。
  127. 出力内容のモデレーションが有効な場合、内容がフラグ付けされると、このイベントを通じてメッセージ内容がプリセットの返信に置き換えられます。
  128. - `task_id` (string) タスクID、リクエスト追跡と以下のStop Generate APIに使用
  129. - `message_id` (string) 一意のメッセージID
  130. - `conversation_id` (string) 会話ID
  131. - `answer` (string) 置換内容(すべてのLLM返信テキストを直接置き換えます)
  132. - `created_at` (int) 作成タイムスタンプ、例:1705395332
  133. - `event: workflow_started` ワークフローが実行を開始
  134. - `task_id` (string) タスクID、リクエスト追跡と以下のStop Generate APIに使用
  135. - `workflow_run_id` (string) ワークフロー実行の一意ID
  136. - `event` (string) `workflow_started`に固定
  137. - `data` (object) 詳細
  138. - `id` (string) ワークフロー実行の一意ID
  139. - `workflow_id` (string) 関連ワークフローのID
  140. - `created_at` (timestamp) 作成タイムスタンプ、例:1705395332
  141. - `event: node_started` ノード実行が開始
  142. - `task_id` (string) タスクID、リクエスト追跡と以下のStop Generate APIに使用
  143. - `workflow_run_id` (string) ワークフロー実行の一意ID
  144. - `event` (string) `node_started`に固定
  145. - `data` (object) 詳細
  146. - `id` (string) ワークフロー実行の一意ID
  147. - `node_id` (string) ノードのID
  148. - `node_type` (string) ノードのタイプ
  149. - `title` (string) ノードの名前
  150. - `index` (int) 実行シーケンス番号、トレースノードシーケンスを表示するために使用
  151. - `predecessor_node_id` (string) オプションのプレフィックスノードID、キャンバス表示実行パスに使用
  152. - `inputs` (object) ノードで使用されるすべての前のノード変数の内容
  153. - `created_at` (timestamp) 開始のタイムスタンプ、例:1705395332
  154. - `event: node_finished` ノード実行が終了、成功または失敗は同じイベント内で異なる状態で示されます
  155. - `task_id` (string) タスクID、リクエスト追跡と以下のStop Generate APIに使用
  156. - `workflow_run_id` (string) ワークフロー実行の一意ID
  157. - `event` (string) `node_finished`に固定
  158. - `data` (object) 詳細
  159. - `id` (string) ワークフロー実行の一意ID
  160. - `node_id` (string) ノードのID
  161. - `node_type` (string) ノードのタイプ
  162. - `title` (string) ノードの名前
  163. - `index` (int) 実行シーケンス番号、トレースノードシーケンスを表示するために使用
  164. - `predecessor_node_id` (string) オプションのプレフィックスノードID、キャンバス表示実行パスに使用
  165. - `inputs` (object) ノードで使用されるすべての前のノード変数の内容
  166. - `process_data` (json) オプションのノードプロセスデータ
  167. - `outputs` (json) オプションの出力内容
  168. - `status` (string) 実行の状態、`running` / `succeeded` / `failed` / `stopped`
  169. - `error` (string) オプションのエラー理由
  170. - `elapsed_time` (float) オプションの使用される合計秒数
  171. - `execution_metadata` (json) メタデータ
  172. - `total_tokens` (int) オプションの使用されるトークン数
  173. - `total_price` (decimal) オプションの合計コスト
  174. - `currency` (string) オプション、例:`USD` / `RMB`
  175. - `created_at` (timestamp) 開始のタイムスタンプ、例:1705395332
  176. - `event: workflow_finished` ワークフロー実行が終了、成功または失敗は同じイベント内で異なる状態で示されます
  177. - `task_id` (string) タスクID、リクエスト追跡と以下のStop Generate APIに使用
  178. - `workflow_run_id` (string) ワークフロー実行の一意ID
  179. - `event` (string) `workflow_finished`に固定
  180. - `data` (object) 詳細
  181. - `id` (string) ワークフロー実行のID
  182. - `workflow_id` (string) 関連ワークフローのID
  183. - `status` (string) 実行の状態、`running` / `succeeded` / `failed` / `stopped`
  184. - `outputs` (json) オプションの出力内容
  185. - `error` (string) オプションのエラー理由
  186. - `elapsed_time` (float) オプションの使用される合計秒数
  187. - `total_tokens` (int) オプションの使用されるトークン数
  188. - `total_steps` (int) デフォルト0
  189. - `created_at` (timestamp) 開始時間
  190. - `finished_at` (timestamp) 終了時間
  191. - `event: error`
  192. ストリーミングプロセス中に発生する例外はストリームイベントの形式で出力され、エラーイベントを受信するとストリームが終了します。
  193. - `task_id` (string) タスクID、リクエスト追跡と以下のStop Generate APIに使用
  194. - `message_id` (string) 一意のメッセージID
  195. - `status` (int) HTTPステータスコード
  196. - `code` (string) エラーコード
  197. - `message` (string) エラーメッセージ
  198. - `event: ping` 接続を維持するために10秒ごとにpingイベントが発生します。
  199. ### エラー
  200. - 404, 会話が存在しません
  201. - 400, `invalid_param`, 異常なパラメータ入力
  202. - 400, `app_unavailable`, アプリ構成が利用できません
  203. - 400, `provider_not_initialize`, 利用可能なモデル資格情報構成がありません
  204. - 400, `provider_quota_exceeded`, モデル呼び出しクォータが不足しています
  205. - 400, `model_currently_not_support`, 現在のモデルが利用できません
  206. - 400, `completion_request_error`, テキスト生成に失敗しました
  207. - 500, 内部サーバーエラー
  208. </Col>
  209. <Col sticky>
  210. <CodeGroup title="リクエスト" 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": "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. ### ブロッキングモード
  225. <CodeGroup title="応答">
  226. ```json {{ title: '応答' }}
  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の仕様は次のとおりです:...",
  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. ### ストリーミングモード
  268. <CodeGroup title="応答">
  269. ```streaming {{ title: '応答' }}
  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='ファイルアップロード'
  292. name='#file-upload'
  293. />
  294. <Row>
  295. <Col>
  296. メッセージ送信時に使用するファイルをアップロードし、画像とテキストのマルチモーダル理解を可能にします。
  297. アプリケーションでサポートされている形式をサポートします。
  298. アップロードされたファイルは現在のエンドユーザーのみが使用できます。
  299. ### リクエストボディ
  300. このインターフェースは`multipart/form-data`リクエストを必要とします。
  301. - `file` (File) 必須
  302. アップロードするファイル。
  303. - `user` (string) 必須
  304. ユーザー識別子、開発者のルールによって定義され、アプリケーション内で一意でなければなりません。サービス API は WebApp によって作成された会話を共有しません。
  305. ### 応答
  306. アップロードが成功すると、サーバーはファイルの ID と関連情報を返します。
  307. - `id` (uuid) ID
  308. - `name` (string) ファイル名
  309. - `size` (int) ファイルサイズ(バイト)
  310. - `extension` (string) ファイル拡張子
  311. - `mime_type` (string) ファイルの MIME タイプ
  312. - `created_by` (uuid) エンドユーザーID
  313. - `created_at` (timestamp) 作成タイムスタンプ、例:1705395332
  314. ### エラー
  315. - 400, `no_file_uploaded`, ファイルが提供されなければなりません
  316. - 400, `too_many_files`, 現在は 1 つのファイルのみ受け付けます
  317. - 400, `unsupported_preview`, ファイルはプレビューをサポートしていません
  318. - 400, `unsupported_estimate`, ファイルは推定をサポートしていません
  319. - 413, `file_too_large`, ファイルが大きすぎます
  320. - 415, `unsupported_file_type`, サポートされていない拡張子、現在はドキュメントファイルのみ受け付けます
  321. - 503, `s3_connection_failed`, S3 サービスに接続できません
  322. - 503, `s3_permission_denied`, S3 にファイルをアップロードする権限がありません
  323. - 503, `s3_file_too_large`, ファイルが S3 のサイズ制限を超えています
  324. - 500, 内部サーバーエラー
  325. </Col>
  326. <Col sticky>
  327. ### リクエスト例
  328. <CodeGroup title="リクエスト" 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. ### 応答例
  336. <CodeGroup title="応答">
  337. ```json {{ title: '応答' }}
  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='生成を停止'
  356. name='#stop-generatebacks'
  357. />
  358. <Row>
  359. <Col>
  360. ストリーミングモードでのみサポートされています。
  361. ### パス
  362. - `task_id` (string) タスク ID、ストリーミングチャンクの返り値から取得できます
  363. ### リクエストボディ
  364. - `user` (string) 必須
  365. ユーザー識別子、エンドユーザーの身元を定義するために使用され、送信メッセージインターフェースで渡されたユーザーと一致している必要があります。サービス API は WebApp によって作成された会話を共有しません。
  366. ### 応答
  367. - `result` (string) 常に"success"を返します
  368. </Col>
  369. <Col sticky>
  370. ### リクエスト例
  371. <CodeGroup title="リクエスト" 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. ### 応答例
  382. <CodeGroup title="応答">
  383. ```json {{ title: '応答' }}
  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='メッセージフィードバック'
  396. name='#feedbacks'
  397. />
  398. <Row>
  399. <Col>
  400. エンドユーザーはフィードバックメッセージを提供でき、アプリケーション開発者が期待される出力を最適化するのを支援します。
  401. ### パス
  402. <Properties>
  403. <Property name='message_id' type='string' key='message_id'>
  404. メッセージID
  405. </Property>
  406. </Properties>
  407. ### リクエストボディ
  408. <Properties>
  409. <Property name='rating' type='string' key='rating'>
  410. アップボートは`like`、ダウンボートは`dislike`、アップボートの取り消しは`null`
  411. </Property>
  412. <Property name='user' type='string' key='user'>
  413. ユーザー識別子、開発者のルールによって定義され、アプリケーション内で一意でなければなりません。
  414. </Property>
  415. <Property name='content' type='string' key='content'>
  416. メッセージのフィードバックです。
  417. </Property>
  418. </Properties>
  419. ### 応答
  420. - `result` (string) 常に"success"を返します
  421. </Col>
  422. <Col sticky>
  423. <CodeGroup title="リクエスト" 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="応答">
  436. ```json {{ title: '応答' }}
  437. {
  438. "result": "success"
  439. }
  440. ```
  441. </CodeGroup>
  442. </Col>
  443. </Row>
  444. ---
  445. <Heading
  446. url='/app/feedbacks'
  447. method='GET'
  448. title='アプリのメッセージの「いいね」とフィードバックを取得'
  449. name='#app-feedbacks'
  450. />
  451. <Row>
  452. <Col>
  453. アプリのエンドユーザーからのフィードバックや「いいね」を取得します。
  454. ### クエリ
  455. <Properties>
  456. <Property name='page' type='string' key='page'>
  457. (任意)ページ番号。デフォルト値:1
  458. </Property>
  459. </Properties>
  460. <Properties>
  461. <Property name='limit' type='string' key='limit'>
  462. (任意)1ページあたりの件数。デフォルト値:20
  463. </Property>
  464. </Properties>
  465. ### レスポンス
  466. - `data` (リスト) このアプリの「いいね」とフィードバックの一覧を返します。
  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='次の推奨質問'
  504. name='#suggested'
  505. />
  506. <Row>
  507. <Col>
  508. 現在のメッセージに対する次の質問の提案を取得します
  509. ### パスパラメータ
  510. <Properties>
  511. <Property name='message_id' type='string' key='message_id'>
  512. メッセージID
  513. </Property>
  514. </Properties>
  515. ### クエリ
  516. <Properties>
  517. <Property name='user' type='string' key='user'>
  518. ユーザー識別子、エンドユーザーの身元を定義するために使用され、統計のために使用されます。
  519. アプリケーション内で開発者によって一意に定義されるべきです。
  520. </Property>
  521. </Properties>
  522. </Col>
  523. <Col sticky>
  524. <CodeGroup title="リクエスト" 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="応答">
  532. ```json {{ title: '応答' }}
  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='会話履歴メッセージを取得'
  550. name='#messages'
  551. />
  552. <Row>
  553. <Col>
  554. スクロールロード形式で履歴チャット記録を返し、最初のページは最新の`{limit}`メッセージを返します。つまり、逆順です。
  555. ### クエリ
  556. <Properties>
  557. <Property name='conversation_id' type='string' key='conversation_id'>
  558. 会話ID
  559. </Property>
  560. <Property name='user' type='string' key='user'>
  561. ユーザー識別子、エンドユーザーの身元を定義するために使用され、統計のために使用されます。
  562. アプリケーション内で開発者によって一意に定義されるべきです。
  563. </Property>
  564. <Property name='first_id' type='string' key='first_id'>
  565. 現在のページの最初のチャット記録のID、デフォルトはnullです。
  566. </Property>
  567. <Property name='limit' type='int' key='limit'>
  568. 1回のリクエストで返すチャット履歴メッセージの数、デフォルトは20です。
  569. </Property>
  570. </Properties>
  571. ### 応答
  572. - `data` (array[object]) メッセージリスト
  573. - `id` (string) メッセージID
  574. - `conversation_id` (string) 会話ID
  575. - `inputs` (object) ユーザー入力パラメータ。
  576. - `query` (string) ユーザー入力/質問内容。
  577. - `message_files` (array[object]) メッセージファイル
  578. - `id` (string) ID
  579. - `type` (string) ファイルタイプ、画像の場合はimage
  580. - `url` (string) プレビュー画像URL
  581. - `belongs_to` (string) 所属、userまたはassistant
  582. - `answer` (string) 応答メッセージ内容
  583. - `created_at` (timestamp) 作成タイムスタンプ、例:1705395332
  584. - `feedback` (object) フィードバック情報
  585. - `rating` (string) アップボートは`like` / ダウンボートは`dislike`
  586. - `retriever_resources` (array[RetrieverResource]) 引用と帰属リスト
  587. - `has_more` (bool) 次のページがあるかどうか
  588. - `limit` (int) 返された項目数、入力がシステム制限を超える場合、システム制限数を返します
  589. </Col>
  590. <Col sticky>
  591. <CodeGroup title="リクエスト" 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. ### 応答例
  598. <CodeGroup title="応答">
  599. ```json {{ title: '応答' }}
  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": "iPhone 13 Proは2021年9月24日に発売され、6.1インチのディスプレイと1170 x 2532の解像度を備えています。Hexa-core (2x3.23 GHz Avalanche + 4x1.82 GHz Blizzard)プロセッサ、6 GBのRAMを搭載し、128 GB、256 GB、512 GB、1 TBのストレージオプションを提供します。カメラは12 MP、バッテリー容量は3095 mAhで、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='会話を取得'
  639. name='#conversations'
  640. />
  641. <Row>
  642. <Col>
  643. 現在のユーザーの会話リストを取得し、デフォルトで最新の 20 件を返します。
  644. ### クエリ
  645. <Properties>
  646. <Property name='user' type='string' key='user'>
  647. ユーザー識別子、エンドユーザーの身元を定義するために使用され、統計のために使用されます。
  648. アプリケーション内で開発者によって一意に定義されるべきです。
  649. </Property>
  650. <Property name='last_id' type='string' key='last_id'>
  651. (Optional)現在のページの最後の記録のID、デフォルトはnullです。
  652. </Property>
  653. <Property name='limit' type='int' key='limit'>
  654. (Optional)1回のリクエストで返す記録の数、デフォルトは最新の20件です。最大100、最小1。
  655. </Property>
  656. <Property name='sort_by' type='string' key='sort_by'>
  657. (Optional)ソートフィールド、デフォルト:-updated_at(更新時間で降順にソート)
  658. - 利用可能な値:created_at, -created_at, updated_at, -updated_at
  659. - フィールドの前の記号は順序または逆順を表し、"-"は逆順を表します。
  660. </Property>
  661. </Properties>
  662. ### 応答
  663. - `data` (array[object]) 会話のリスト
  664. - `id` (string) 会話ID
  665. - `name` (string) 会話名、デフォルトではLLMによって生成されます。
  666. - `inputs` (object) ユーザー入力パラメータ。
  667. - `introduction` (string) 紹介
  668. - `created_at` (timestamp) 作成タイムスタンプ、例:1705395332
  669. - `updated_at` (timestamp) 更新タイムスタンプ、例:1705395332
  670. - `has_more` (bool)
  671. - `limit` (int) 返されたエントリ数、入力がシステム制限を超える場合、システム制限数が返されます
  672. </Col>
  673. <Col sticky>
  674. <CodeGroup title="リクエスト" 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}'`}>
  675. ```bash {{ title: 'cURL' }}
  676. curl -X GET '${props.appDetail.api_base_url}/conversations?user=abc-123&last_id=&limit=20' \
  677. --header 'Authorization: Bearer {api_key}'
  678. ```
  679. </CodeGroup>
  680. <CodeGroup title="応答">
  681. ```json {{ title: '応答' }}
  682. {
  683. "limit": 20,
  684. "has_more": false,
  685. "data": [
  686. {
  687. "id": "10799fb8-64f7-4296-bbf7-b42bfbe0ae54",
  688. "name": "新しいチャット",
  689. "inputs": {
  690. "book": "book",
  691. "myName": "Lucy"
  692. },
  693. "status": "normal",
  694. "created_at": 1679667915,
  695. "updated_at": 1679667915
  696. },
  697. {
  698. "id": "hSIhXBhNe8X1d8Et"
  699. // ...
  700. }
  701. ]
  702. }
  703. ```
  704. </CodeGroup>
  705. </Col>
  706. </Row>
  707. ---
  708. <Heading
  709. url='/conversations/:conversation_id'
  710. method='DELETE'
  711. title='会話を削除'
  712. name='#delete'
  713. />
  714. <Row>
  715. <Col>
  716. 会話を削除します。
  717. ### パス
  718. - `conversation_id` (string) 会話ID
  719. ### リクエストボディ
  720. <Properties>
  721. <Property name='user' type='string' key='user'>
  722. ユーザー識別子、開発者によって定義され、アプリケーション内で一意であることを保証しなければなりません。
  723. </Property>
  724. </Properties>
  725. ### 応答
  726. - `result` (string) 常に"success"を返します
  727. </Col>
  728. <Col sticky>
  729. <CodeGroup title="リクエスト" 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}'`}>
  730. ```bash {{ title: 'cURL' }}
  731. curl -X DELETE '${props.appDetail.api_base_url}/conversations/{conversation_id}' \
  732. --header 'Content-Type: application/json' \
  733. --header 'Accept: application/json' \
  734. --header 'Authorization: Bearer {api_key}' \
  735. --data '{
  736. "user": "abc-123"
  737. }'
  738. ```
  739. </CodeGroup>
  740. <CodeGroup title="応答">
  741. ```text {{ title: '応答' }}
  742. 204 No Content
  743. ```
  744. </CodeGroup>
  745. </Col>
  746. </Row>
  747. ---
  748. <Heading
  749. url='/conversations/:conversation_id/name'
  750. method='POST'
  751. title='会話の名前を変更'
  752. name='#rename'
  753. />
  754. <Row>
  755. <Col>
  756. ### リクエストボディ
  757. セッションの名前を変更します。セッション名は、複数のセッションをサポートするクライアントでの表示に使用されます。
  758. ### パス
  759. - `conversation_id` (string) 会話ID
  760. <Properties>
  761. <Property name='name' type='string' key='name'>
  762. (Optional)会話の名前。`auto_generate`が`true`に設定されている場合、このパラメータは省略できます。
  763. </Property>
  764. <Property name='auto_generate' type='bool' key='auto_generate'>
  765. (Optional)タイトルを自動生成、デフォルトは`false`
  766. </Property>
  767. <Property name='user' type='string' key='user'>
  768. ユーザー識別子、開発者によって定義され、アプリケーション内で一意であることを保証しなければなりません。
  769. </Property>
  770. </Properties>
  771. ### 応答
  772. - `id` (string) 会話ID
  773. - `name` (string) 会話名
  774. - `inputs` (object) ユーザー入力パラメータ
  775. - `status` (string) 会話状態
  776. - `introduction` (string) 紹介
  777. - `created_at` (timestamp) 作成タイムスタンプ、例:1705395332
  778. - `updated_at` (timestamp) 更新タイムスタンプ、例:1705395332
  779. </Col>
  780. <Col sticky>
  781. <CodeGroup title="リクエスト" 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}'`}>
  782. ```bash {{ title: 'cURL' }}
  783. curl -X POST '${props.appDetail.api_base_url}/conversations/{conversation_id}/name' \
  784. --header 'Content-Type: application/json' \
  785. --header 'Authorization: Bearer {api_key}' \
  786. --data-raw '{
  787. "name": "",
  788. "auto_generate": true,
  789. "user": "abc-123"
  790. }'
  791. ```
  792. </CodeGroup>
  793. <CodeGroup title="応答">
  794. ```json {{ title: '応答' }}
  795. {
  796. "id": "cd78daf6-f9e4-4463-9ff2-54257230a0ce",
  797. "name": "チャット vs AI",
  798. "inputs": {},
  799. "status": "normal",
  800. "introduction": "",
  801. "created_at": 1705569238,
  802. "updated_at": 1705569238
  803. }
  804. ```
  805. </CodeGroup>
  806. </Col>
  807. </Row>
  808. ---
  809. <Heading
  810. url='/conversations/:conversation_id/variables'
  811. method='GET'
  812. title='会話変数の取得'
  813. name='#conversation-variables'
  814. />
  815. <Row>
  816. <Col>
  817. 特定の会話から変数を取得します。このエンドポイントは、会話中に取得された構造化データを抽出するのに役立ちます。
  818. ### パスパラメータ
  819. <Properties>
  820. <Property name='conversation_id' type='string' key='conversation_id'>
  821. 変数を取得する会話のID。
  822. </Property>
  823. </Properties>
  824. ### クエリパラメータ
  825. <Properties>
  826. <Property name='user' type='string' key='user'>
  827. ユーザー識別子。開発者によって定義されたルールに従い、アプリケーション内で一意である必要があります。
  828. </Property>
  829. <Property name='last_id' type='string' key='last_id'>
  830. (Optional)現在のページの最後の記録のID、デフォルトはnullです。
  831. </Property>
  832. <Property name='limit' type='int' key='limit'>
  833. (Optional)1回のリクエストで返す記録の数、デフォルトは最新の20件です。最大100、最小1。
  834. </Property>
  835. </Properties>
  836. ### レスポンス
  837. - `limit` (int) ページごとのアイテム数
  838. - `has_more` (bool) さらにアイテムがあるかどうか
  839. - `data` (array[object]) 変数のリスト
  840. - `id` (string) 変数 ID
  841. - `name` (string) 変数名
  842. - `value_type` (string) 変数タイプ(文字列、数値、真偽値など)
  843. - `value` (string) 変数値
  844. - `description` (string) 変数の説明
  845. - `created_at` (int) 作成タイムスタンプ
  846. - `updated_at` (int) 最終更新タイムスタンプ
  847. ### エラー
  848. - 404, `conversation_not_exists`, 会話が見つかりません
  849. </Col>
  850. <Col sticky>
  851. <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}'`}>
  852. ```bash {{ title: 'cURL' }}
  853. curl -X GET '${props.appDetail.api_base_url}/conversations/{conversation_id}/variables?user=abc-123' \
  854. --header 'Authorization: Bearer {api_key}'
  855. ```
  856. </CodeGroup>
  857. <CodeGroup title="Request with variable name filter">
  858. ```bash {{ title: 'cURL' }}
  859. curl -X GET '${props.appDetail.api_base_url}/conversations/{conversation_id}/variables?user=abc-123&variable_name=customer_name' \
  860. --header 'Authorization: Bearer {api_key}'
  861. ```
  862. </CodeGroup>
  863. <CodeGroup title="Response">
  864. ```json {{ title: 'Response' }}
  865. {
  866. "limit": 100,
  867. "has_more": false,
  868. "data": [
  869. {
  870. "id": "variable-uuid-1",
  871. "name": "customer_name",
  872. "value_type": "string",
  873. "value": "John Doe",
  874. "description": "会話から抽出された顧客名",
  875. "created_at": 1650000000000,
  876. "updated_at": 1650000000000
  877. },
  878. {
  879. "id": "variable-uuid-2",
  880. "name": "order_details",
  881. "value_type": "json",
  882. "value": "{\"product\":\"Widget\",\"quantity\":5,\"price\":19.99}",
  883. "description": "顧客の注文詳細",
  884. "created_at": 1650000000000,
  885. "updated_at": 1650000000000
  886. }
  887. ]
  888. }
  889. ```
  890. </CodeGroup>
  891. </Col>
  892. </Row>
  893. ---
  894. <Heading
  895. url='/audio-to-text'
  896. method='POST'
  897. title='音声からテキストへ'
  898. name='#audio'
  899. />
  900. <Row>
  901. <Col>
  902. このエンドポイントは multipart/form-data リクエストを必要とします。
  903. ### リクエストボディ
  904. <Properties>
  905. <Property name='file' type='file' key='file'>
  906. オーディオファイル。
  907. サポートされている形式:`['mp3', 'mp4', 'mpeg', 'mpga', 'm4a', 'wav', 'webm']`
  908. ファイルサイズ制限:15MB
  909. </Property>
  910. <Property name='user' type='string' key='user'>
  911. ユーザー識別子、開発者のルールによって定義され、アプリケーション内で一意でなければなりません。
  912. </Property>
  913. </Properties>
  914. ### 応答
  915. - `text` (string) 出力テキスト
  916. </Col>
  917. <Col sticky>
  918. <CodeGroup title="リクエスト" 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]'`}>
  919. ```bash {{ title: 'cURL' }}
  920. curl -X POST '${props.appDetail.api_base_url}/conversations/name' \
  921. --header 'Authorization: Bearer {api_key}' \
  922. --form 'file=@localfile;type=audio/mp3'
  923. ```
  924. </CodeGroup>
  925. <CodeGroup title="応答">
  926. ```json {{ title: '応答' }}
  927. {
  928. "text": ""
  929. }
  930. ```
  931. </CodeGroup>
  932. </Col>
  933. </Row>
  934. ---
  935. <Heading
  936. url='/text-to-audio'
  937. method='POST'
  938. title='テキストから音声へ'
  939. name='#audio'
  940. />
  941. <Row>
  942. <Col>
  943. テキストを音声に変換します。
  944. ### リクエストボディ
  945. <Properties>
  946. <Property name='message_id' type='str' key='message_id'>
  947. Difyによって生成されたテキストメッセージの場合、生成されたメッセージIDを直接渡します。バックエンドはメッセージIDを使用して対応する内容を検索し、音声情報を直接合成します。message_idとtextが同時に提供される場合、message_idが優先されます。
  948. </Property>
  949. <Property name='text' type='str' key='text'>
  950. 音声生成コンテンツ。
  951. </Property>
  952. <Property name='user' type='string' key='user'>
  953. ユーザー識別子、開発者によって定義され、アプリ内で一意であることを保証しなければなりません。
  954. </Property>
  955. </Properties>
  956. </Col>
  957. <Col sticky>
  958. <CodeGroup title="リクエスト" 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}'`}>
  959. ```bash {{ title: 'cURL' }}
  960. curl -o text-to-audio.mp3 -X POST '${props.appDetail.api_base_url}/text-to-audio' \
  961. --header 'Authorization: Bearer {api_key}' \
  962. --header 'Content-Type: application/json' \
  963. --data-raw '{
  964. "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290",
  965. "text": "Hello Dify",
  966. "user": "abc-123",
  967. "streaming": false
  968. }'
  969. ```
  970. </CodeGroup>
  971. <CodeGroup title="ヘッダー">
  972. ```json {{ title: 'ヘッダー' }}
  973. {
  974. "Content-Type": "audio/wav"
  975. }
  976. ```
  977. </CodeGroup>
  978. </Col>
  979. </Row>
  980. ---
  981. <Heading
  982. url='/info'
  983. method='GET'
  984. title='アプリケーションの基本情報を取得'
  985. name='#info'
  986. />
  987. <Row>
  988. <Col>
  989. このアプリケーションの基本情報を取得するために使用されます
  990. ### Response
  991. - `name` (string) アプリケーションの名前
  992. - `description` (string) アプリケーションの説明
  993. - `tags` (array[string]) アプリケーションのタグ
  994. - `mode` (string) アプリケーションのモード
  995. - `author_name` (string) 作者の名前
  996. </Col>
  997. <Col>
  998. <CodeGroup title="Request" tag="GET" label="/info" targetCode={`curl -X GET '${props.appDetail.api_base_url}/info' \\\n-H 'Authorization: Bearer {api_key}'`}>
  999. ```bash {{ title: 'cURL' }}
  1000. curl -X GET '${props.appDetail.api_base_url}/info' \
  1001. -H 'Authorization: Bearer {api_key}'
  1002. ```
  1003. </CodeGroup>
  1004. <CodeGroup title="Response">
  1005. ```json {{ title: 'Response' }}
  1006. {
  1007. "name": "My App",
  1008. "description": "This is my app.",
  1009. "tags": [
  1010. "tag1",
  1011. "tag2"
  1012. ],
  1013. "mode": "advanced-chat",
  1014. "author_name": "Dify"
  1015. }
  1016. ```
  1017. </CodeGroup>
  1018. </Col>
  1019. </Row>
  1020. ---
  1021. <Heading
  1022. url='/parameters'
  1023. method='GET'
  1024. title='アプリケーションのパラメータ情報を取得'
  1025. name='#parameters'
  1026. />
  1027. <Row>
  1028. <Col>
  1029. ページに入る際に、機能、入力パラメータ名、タイプ、デフォルト値などの情報を取得するために使用されます。
  1030. ### 応答
  1031. - `opening_statement` (string) 開始の挨拶
  1032. - `suggested_questions` (array[string]) 開始時の推奨質問のリスト
  1033. - `suggested_questions_after_answer` (object) 答えを有効にした後の質問を提案します。
  1034. - `enabled` (bool) 有効かどうか
  1035. - `speech_to_text` (object) 音声からテキストへ
  1036. - `enabled` (bool) 有効かどうか
  1037. - `text_to_speech` (object) テキストから音声へ
  1038. - `enabled` (bool) 有効かどうか
  1039. - `voice` (string) 音声タイプ
  1040. - `language` (string) 言語
  1041. - `autoPlay` (string) 自動再生
  1042. - `enabled` 有効
  1043. - `disabled` 無効
  1044. - `retriever_resource` (object) 引用と帰属
  1045. - `enabled` (bool) 有効かどうか
  1046. - `annotation_reply` (object) 注釈返信
  1047. - `enabled` (bool) 有効かどうか
  1048. - `user_input_form` (array[object]) ユーザー入力フォームの設定
  1049. - `text-input` (object) テキスト入力コントロール
  1050. - `label` (string) 変数表示ラベル名
  1051. - `variable` (string) 変数ID
  1052. - `required` (bool) 必須かどうか
  1053. - `default` (string) デフォルト値
  1054. - `paragraph` (object) 段落テキスト入力コントロール
  1055. - `label` (string) 変数表示ラベル名
  1056. - `variable` (string) 変数ID
  1057. - `required` (bool) 必須かどうか
  1058. - `default` (string) デフォルト値
  1059. - `select` (object) ドロップダウンコントロール
  1060. - `label` (string) 変数表示ラベル名
  1061. - `variable` (string) 変数ID
  1062. - `required` (bool) 必須かどうか
  1063. - `default` (string) デフォルト値
  1064. - `options` (array[string]) オプション値
  1065. - `file_upload` (object) ファイルアップロード設定
  1066. - `document` (object) ドキュメント設定
  1067. 現在サポートされているドキュメントタイプ:`txt`, `md`, `markdown`, `pdf`, `html`, `xlsx`, `xls`, `docx`, `csv`, `eml`, `msg`, `pptx`, `ppt`, `xml`, `epub`。
  1068. - `enabled` (bool) 有効かどうか
  1069. - `number_limits` (int) ドキュメント数の上限。デフォルトは 3
  1070. - `transfer_methods` (array[string]) 転送方法リスト:`remote_url`, `local_file`。いずれかを選択する必要があります。
  1071. - `image` (object) 画像設定
  1072. 現在サポートされている画像タイプ:`png`, `jpg`, `jpeg`, `webp`, `gif`。
  1073. - `enabled` (bool) 有効かどうか
  1074. - `number_limits` (int) 画像数の上限。デフォルトは 3
  1075. - `transfer_methods` (array[string]) 転送方法リスト:`remote_url`, `local_file`。いずれかを選択する必要があります。
  1076. - `audio` (object) オーディオ設定
  1077. 現在サポートされているオーディオタイプ:`mp3`, `m4a`, `wav`, `webm`, `amr`。
  1078. - `enabled` (bool) 有効かどうか
  1079. - `number_limits` (int) オーディオ数の上限。デフォルトは 3
  1080. - `transfer_methods` (array[string]) 転送方法リスト:`remote_url`, `local_file`。いずれかを選択する必要があります。
  1081. - `video` (object) ビデオ設定
  1082. 現在サポートされているビデオタイプ:`mp4`, `mov`, `mpeg`, `mpga`。
  1083. - `enabled` (bool) 有効かどうか
  1084. - `number_limits` (int) ビデオ数の上限。デフォルトは 3
  1085. - `transfer_methods` (array[string]) 転送方法リスト:`remote_url`, `local_file`。いずれかを選択する必要があります。
  1086. - `custom` (object) カスタム設定
  1087. - `enabled` (bool) 有効かどうか
  1088. - `number_limits` (int) カスタム数の上限。デフォルトは 3
  1089. - `transfer_methods` (array[string]) 転送方法リスト:`remote_url`, `local_file`。いずれかを選択する必要があります。
  1090. - `system_parameters` (object) システムパラメータ
  1091. - `file_size_limit` (int) ドキュメントアップロードサイズ制限(MB)
  1092. - `image_file_size_limit` (int) 画像ファイルアップロードサイズ制限(MB)
  1093. - `audio_file_size_limit` (int) オーディオファイルアップロードサイズ制限(MB)
  1094. - `video_file_size_limit` (int) ビデオファイルアップロードサイズ制限(MB)
  1095. </Col>
  1096. <Col sticky>
  1097. <CodeGroup title="リクエスト" tag="GET" label="/parameters" targetCode={` curl -X GET '${props.appDetail.api_base_url}/parameters'`}>
  1098. ```bash {{ title: 'cURL' }}
  1099. curl -X GET '${props.appDetail.api_base_url}/parameters' \
  1100. --header 'Authorization: Bearer {api_key}'
  1101. ```
  1102. </CodeGroup>
  1103. <CodeGroup title="応答">
  1104. ```json {{ title: '応答' }}
  1105. {
  1106. "opening_statement": "こんにちは!",
  1107. "suggested_questions_after_answer": {
  1108. "enabled": true
  1109. },
  1110. "speech_to_text": {
  1111. "enabled": true
  1112. },
  1113. "text_to_speech": {
  1114. "enabled": true,
  1115. "voice": "sambert-zhinan-v1",
  1116. "language": "zh-Hans",
  1117. "autoPlay": "disabled"
  1118. },
  1119. "retriever_resource": {
  1120. "enabled": true
  1121. },
  1122. "annotation_reply": {
  1123. "enabled": true
  1124. },
  1125. "user_input_form": [
  1126. {
  1127. "paragraph": {
  1128. "label": "クエリ",
  1129. "variable": "query",
  1130. "required": true,
  1131. "default": ""
  1132. }
  1133. }
  1134. ],
  1135. "file_upload": {
  1136. "image": {
  1137. "enabled": false,
  1138. "number_limits": 3,
  1139. "detail": "high",
  1140. "transfer_methods": [
  1141. "remote_url",
  1142. "local_file"
  1143. ]
  1144. }
  1145. },
  1146. "system_parameters": {
  1147. "file_size_limit": 15,
  1148. "image_file_size_limit": 10,
  1149. "audio_file_size_limit": 50,
  1150. "video_file_size_limit": 100
  1151. }
  1152. }
  1153. ```
  1154. </CodeGroup>
  1155. </Col>
  1156. </Row>
  1157. ---
  1158. <Heading
  1159. url='/meta'
  1160. method='GET'
  1161. title='アプリケーションのメタ情報を取得'
  1162. name='#meta'
  1163. />
  1164. <Row>
  1165. <Col>
  1166. このアプリケーションのツールのアイコンを取得するために使用されます
  1167. ### 応答
  1168. - `tool_icons`(object[string]) ツールアイコン
  1169. - `tool_name` (string)
  1170. - `icon` (object|string)
  1171. - (object) アイコンオブジェクト
  1172. - `background` (string) 背景色(16 進数形式)
  1173. - `content`(string) 絵文字
  1174. - (string) アイコンの URL
  1175. </Col>
  1176. <Col>
  1177. <CodeGroup title="リクエスト" tag="GET" label="/meta" targetCode={`curl -X GET '${props.appDetail.api_base_url}/meta' \\\n-H 'Authorization: Bearer {api_key}'`}>
  1178. ```bash {{ title: 'cURL' }}
  1179. curl -X GET '${props.appDetail.api_base_url}/meta' \
  1180. -H 'Authorization: Bearer {api_key}'
  1181. ```
  1182. </CodeGroup>
  1183. <CodeGroup title="応答">
  1184. ```json {{ title: '応答' }}
  1185. {
  1186. "tool_icons": {
  1187. "dalle2": "https://cloud.dify.ai/console/api/workspaces/current/tool-provider/builtin/dalle/icon",
  1188. "api_tool": {
  1189. "background": "#252525",
  1190. "content": "\ud83d\ude01"
  1191. }
  1192. }
  1193. }
  1194. ```
  1195. </CodeGroup>
  1196. </Col>
  1197. </Row>
  1198. ---
  1199. <Heading
  1200. url='/site'
  1201. method='GET'
  1202. title='アプリのWebApp設定を取得'
  1203. name='#site'
  1204. />
  1205. <Row>
  1206. <Col>
  1207. アプリの WebApp 設定を取得するために使用します。
  1208. ### 応答
  1209. - `title` (string) WebApp 名
  1210. - `chat_color_theme` (string) チャットの色テーマ、16 進数形式
  1211. - `chat_color_theme_inverted` (bool) チャットの色テーマを反転するかどうか
  1212. - `icon_type` (string) アイコンタイプ、`emoji`-絵文字、`image`-画像
  1213. - `icon` (string) アイコン。`emoji`タイプの場合は絵文字、`image`タイプの場合は画像 URL
  1214. - `icon_background` (string) 16 進数形式の背景色
  1215. - `icon_url` (string) アイコンの URL
  1216. - `description` (string) 説明
  1217. - `copyright` (string) 著作権情報
  1218. - `privacy_policy` (string) プライバシーポリシーのリンク
  1219. - `custom_disclaimer` (string) カスタム免責事項
  1220. - `default_language` (string) デフォルト言語
  1221. - `show_workflow_steps` (bool) ワークフローの詳細を表示するかどうか
  1222. - `use_icon_as_answer_icon` (bool) WebApp のアイコンをチャット内の🤖に置き換えるかどうか
  1223. </Col>
  1224. <Col>
  1225. <CodeGroup title="Request" tag="POST" label="/meta" targetCode={`curl -X GET '${props.appDetail.api_base_url}/site' \\\n-H 'Authorization: Bearer {api_key}'`}>
  1226. ```bash {{ title: 'cURL' }}
  1227. curl -X GET '${props.appDetail.api_base_url}/site' \
  1228. -H 'Authorization: Bearer {api_key}'
  1229. ```
  1230. </CodeGroup>
  1231. <CodeGroup title="Response">
  1232. ```json {{ title: 'Response' }}
  1233. {
  1234. "title": "My App",
  1235. "chat_color_theme": "#ff4a4a",
  1236. "chat_color_theme_inverted": false,
  1237. "icon_type": "emoji",
  1238. "icon": "😄",
  1239. "icon_background": "#FFEAD5",
  1240. "icon_url": null,
  1241. "description": "This is my app.",
  1242. "copyright": "all rights reserved",
  1243. "privacy_policy": "",
  1244. "custom_disclaimer": "All generated by AI",
  1245. "default_language": "en-US",
  1246. "show_workflow_steps": false,
  1247. "use_icon_as_answer_icon": false,
  1248. }
  1249. ```
  1250. </CodeGroup>
  1251. </Col>
  1252. </Row>
  1253. ___