Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

template_chat.ja.mdx 73KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634
  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. </Property>
  40. <Property name='response_mode' type='string' key='response_mode'>
  41. 応答の返却モードを指定します。サポートされているモード:
  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. Cloudflareの制限により、100秒後に応答がない場合、リクエストは中断されます。
  45. <i>注:エージェントアシスタントモードではブロッキングモードはサポートされていません</i>
  46. </Property>
  47. <Property name='user' type='string' key='user'>
  48. ユーザー識別子、エンドユーザーのアイデンティティを定義するために使用されます。
  49. アプリケーション内で開発者によって一意に定義される必要があります。
  50. </Property>
  51. <Property name='conversation_id' type='string' key='conversation_id'>
  52. 会話ID、以前のチャット記録に基づいて会話を続けるには、前のメッセージのconversation_idを渡す必要があります。
  53. </Property>
  54. <Property name='files' type='array[object]' key='files'>
  55. ファイルリスト、テキストの理解と質問への回答を組み合わせたファイル(画像)の入力に適しており、モデルがビジョン機能をサポートしている場合にのみ利用可能です。
  56. - `type` (string) サポートされているタイプ:`image`(現在は画像タイプのみサポート)
  57. - `transfer_method` (string) 転送方法、画像URLの場合は`remote_url` / ファイルアップロードの場合は`local_file`
  58. - `url` (string) 画像URL(転送方法が`remote_url`の場合)
  59. - `upload_file_id` (string) アップロードされたファイルID、事前にファイルアップロードAPIを通じて取得する必要があります(転送方法が`local_file`の場合)
  60. </Property>
  61. <Property name='auto_generate_name' type='bool' key='auto_generate_name'>
  62. タイトルを自動生成します。デフォルトは`true`です。
  63. `false`に設定すると、会話のリネームAPIを呼び出し、`auto_generate`を`true`に設定することで非同期タイトル生成を実現できます。
  64. </Property>
  65. <Property name='workflow_id' type='string' key='workflow_id'>
  66. (オプション)ワークフローID、特定のバージョンを指定するために使用、提供されない場合はデフォルトの公開バージョンを使用。
  67. </Property>
  68. <Property name='trace_id' type='string' key='trace_id'>
  69. (オプション)トレースID。既存の業務システムのトレースコンポーネントと連携し、エンドツーエンドの分散トレーシングを実現するために使用します。指定がない場合、システムが自動的に trace_id を生成します。以下の3つの方法で渡すことができ、優先順位は次のとおりです:<br/>
  70. - Header:HTTPヘッダー <code>X-Trace-Id</code> で渡す(最優先)。<br/>
  71. - クエリパラメータ:URLクエリパラメータ <code>trace_id</code> で渡す。<br/>
  72. - リクエストボディ:リクエストボディの <code>trace_id</code> フィールドで渡す(本フィールド)。<br/>
  73. </Property>
  74. </Properties>
  75. ### 応答
  76. response_modeがブロッキングの場合、CompletionResponseオブジェクトを返します。
  77. response_modeがストリーミングの場合、ChunkCompletionResponseストリームを返します。
  78. ### ChatCompletionResponse
  79. 完全なアプリ結果を返します。`Content-Type`は`application/json`です。
  80. - `event` (string) イベントタイプ、固定で `message`
  81. - `task_id` (string) タスクID、リクエスト追跡と以下のStop Generate APIに使用
  82. - `id` (string) ユニークID
  83. - `message_id` (string) 一意のメッセージID
  84. - `conversation_id` (string) 会話ID
  85. - `mode` (string) アプリモード、`chat`として固定
  86. - `answer` (string) 完全な応答内容
  87. - `metadata` (object) メタデータ
  88. - `usage` (Usage) モデル使用情報
  89. - `retriever_resources` (array[RetrieverResource]) 引用と帰属リスト
  90. - `created_at` (int) メッセージ作成タイムスタンプ、例:1705395332
  91. ### ChunkChatCompletionResponse
  92. アプリによって出力されたストリームチャンクを返します。`Content-Type`は`text/event-stream`です。
  93. 各ストリーミングチャンクは`data:`で始まり、2つの改行文字`\n\n`で区切られます。以下のように表示されます:
  94. <CodeGroup>
  95. ```streaming {{ title: '応答' }}
  96. data: {"event": "message", "task_id": "900bbd43-dc0b-4383-a372-aa6e6c414227", "id": "663c5084-a254-4040-8ad3-51f2a3c1a77c", "answer": "Hi", "created_at": 1705398420}\n\n
  97. ```
  98. </CodeGroup>
  99. ストリーミングチャンクの構造は`event`に応じて異なります:
  100. - `event: message` LLMはテキストチャンクイベントを返します。つまり、完全なテキストがチャンク形式で出力されます。
  101. - `task_id` (string) タスクID、リクエスト追跡と以下のStop Generate APIに使用
  102. - `message_id` (string) 一意のメッセージID
  103. - `conversation_id` (string) 会話ID
  104. - `answer` (string) LLMが返したテキストチャンク内容
  105. - `created_at` (int) 作成タイムスタンプ、例:1705395332
  106. - `event: agent_message` LLMはテキストチャンクイベントを返します。つまり、エージェントアシスタントが有効な場合、完全なテキストがチャンク形式で出力されます(エージェントモードでのみサポート)
  107. - `task_id` (string) タスクID、リクエスト追跡と以下のStop Generate APIに使用
  108. - `message_id` (string) 一意のメッセージID
  109. - `conversation_id` (string) 会話ID
  110. - `answer` (string) LLMが返したテキストチャンク内容
  111. - `created_at` (int) 作成タイムスタンプ、例:1705395332
  112. - `event: tts_message` TTSオーディオストリームイベント、つまり音声合成出力。内容はMp3形式のオーディオブロックで、base64文字列としてエンコードされています。再生時には、base64をデコードしてプレーヤーに入力するだけです。(このメッセージは自動再生が有効な場合にのみ利用可能)
  113. - `task_id` (string) タスクID、リクエスト追跡と以下の停止応答インターフェースに使用
  114. - `message_id` (string) 一意のメッセージID
  115. - `audio` (string) 音声合成後のオーディオ、base64テキストコンテンツとしてエンコードされており、再生時にはbase64をデコードしてプレーヤーに入力するだけです
  116. - `created_at` (int) 作成タイムスタンプ、例:1705395332
  117. - `event: tts_message_end` TTSオーディオストリーム終了イベント。このイベントを受信すると、オーディオストリームの終了を示します。
  118. - `task_id` (string) タスクID、リクエスト追跡と以下の停止応答インターフェースに使用
  119. - `message_id` (string) 一意のメッセージID
  120. - `audio` (string) 終了イベントにはオーディオがないため、これは空の文字列です
  121. - `created_at` (int) 作成タイムスタンプ、例:1705395332
  122. - `event: agent_thought` エージェントの思考、LLMの思考、ツール呼び出しの入力と出力を含みます(エージェントモードでのみサポート)
  123. - `id` (string) エージェント思考ID、各反復には一意のエージェント思考IDがあります
  124. - `task_id` (string) タスクID、リクエスト追跡と以下のStop Generate APIに使用
  125. - `message_id` (string) 一意のメッセージID
  126. - `position` (int) 現在のエージェント思考の位置、各メッセージには順番に複数の思考が含まれる場合があります。
  127. - `thought` (string) LLMが考えていること
  128. - `observation` (string) ツール呼び出しからの応答
  129. - `tool` (string) 呼び出されたツールのリスト、;で区切られます
  130. - `tool_input` (string) ツールの入力、JSON形式。例:`{"dalle3": {"prompt": "a cute cat"}}`。
  131. - `created_at` (int) 作成タイムスタンプ、例:1705395332
  132. - `message_files` (array[string]) message_fileイベントを参照
  133. - `file_id` (string) ファイルID
  134. - `conversation_id` (string) 会話ID
  135. - `event: message_file` メッセージファイルイベント、ツールによって新しいファイルが作成されました
  136. - `id` (string) ファイル一意ID
  137. - `type` (string) ファイルタイプ、現在は"image"のみ許可
  138. - `belongs_to` (string) 所属、ここでは'assistant'のみ
  139. - `url` (string) ファイルのリモートURL
  140. - `conversation_id` (string) 会話ID
  141. - `event: message_end` メッセージ終了イベント、このイベントを受信するとストリーミングが終了したことを意味します。
  142. - `task_id` (string) タスクID、リクエスト追跡と以下のStop Generate APIに使用
  143. - `message_id` (string) 一意のメッセージID
  144. - `conversation_id` (string) 会話ID
  145. - `metadata` (object) メタデータ
  146. - `usage` (Usage) モデル使用情報
  147. - `retriever_resources` (array[RetrieverResource]) 引用と帰属リスト
  148. - `event: message_replace` メッセージ内容置換イベント。
  149. 出力内容のモデレーションが有効な場合、内容がフラグされると、このイベントを通じてメッセージ内容が事前設定された返信に置き換えられます。
  150. - `task_id` (string) タスクID、リクエスト追跡と以下のStop Generate APIに使用
  151. - `message_id` (string) 一意のメッセージID
  152. - `conversation_id` (string) 会話ID
  153. - `answer` (string) 置換内容(すべてのLLM返信テキストを直接置換)
  154. - `created_at` (int) 作成タイムスタンプ、例:1705395332
  155. - `event: error`
  156. ストリーミングプロセス中に発生した例外はストリームイベントの形式で出力され、エラーイベントを受信するとストリームが終了します。
  157. - `task_id` (string) タスクID、リクエスト追跡と以下のStop Generate APIに使用
  158. - `message_id` (string) 一意のメッセージID
  159. - `status` (int) HTTPステータスコード
  160. - `code` (string) エラーコード
  161. - `message` (string) エラーメッセージ
  162. - `event: ping` 接続を維持するために10秒ごとにpingイベントが発生します。
  163. ### エラー
  164. - 404, 会話が存在しません
  165. - 400, `invalid_param`, 異常なパラメータ入力
  166. - 400, `app_unavailable`, アプリ構成が利用できません
  167. - 400, `provider_not_initialize`, 利用可能なモデル資格情報構成がありません
  168. - 400, `provider_quota_exceeded`, モデル呼び出しクォータが不足しています
  169. - 400, `model_currently_not_support`, 現在のモデルは利用できません
  170. - 400, `workflow_not_found`, 指定されたワークフローバージョンが見つかりません
  171. - 400, `draft_workflow_error`, ドラフトワークフローバージョンは使用できません
  172. - 400, `workflow_id_format_error`, ワークフローID形式エラー、UUID形式が必要です
  173. - 400, `completion_request_error`, テキスト生成に失敗しました
  174. - 500, 内部サーバーエラー
  175. </Col>
  176. <Col sticky>
  177. <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": "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}'`}>
  178. ```bash {{ title: 'cURL' }}
  179. curl -X POST '${props.appDetail.api_base_url}/chat-messages' \
  180. --header 'Authorization: Bearer {api_key}' \
  181. --header 'Content-Type: application/json' \
  182. --data-raw '{
  183. "inputs": {},
  184. "query": "eh",
  185. "response_mode": "streaming",
  186. "conversation_id": "1c7e55fb-1ba2-4e10-81b5-30addcea2276",
  187. "user": "abc-123"
  188. }'
  189. ```
  190. </CodeGroup>
  191. ### ブロッキングモード
  192. <CodeGroup title="応答">
  193. ```json {{ title: '応答' }}
  194. {
  195. "event": "message",
  196. "task_id": "c3800678-a077-43df-a102-53f23ed20b88",
  197. "id": "9da23599-e713-473b-982c-4328d4f5c78a",
  198. "message_id": "9da23599-e713-473b-982c-4328d4f5c78a",
  199. "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2",
  200. "mode": "chat",
  201. "answer": "iPhone 13 Pro Maxの仕様は次のとおりです:...",
  202. "metadata": {
  203. "usage": {
  204. "prompt_tokens": 1033,
  205. "prompt_unit_price": "0.001",
  206. "prompt_price_unit": "0.001",
  207. "prompt_price": "0.0010330",
  208. "completion_tokens": 128,
  209. "completion_unit_price": "0.002",
  210. "completion_price_unit": "0.001",
  211. "completion_price": "0.0002560",
  212. "total_tokens": 1161,
  213. "total_price": "0.0012890",
  214. "currency": "USD",
  215. "latency": 0.7682376249867957
  216. },
  217. "retriever_resources": [
  218. {
  219. "position": 1,
  220. "dataset_id": "101b4c97-fc2e-463c-90b1-5261a4cdcafb",
  221. "dataset_name": "iPhone",
  222. "document_id": "8dd1ad74-0b5f-4175-b735-7d98bbbb4e00",
  223. "document_name": "iPhone List",
  224. "segment_id": "ed599c7f-2766-4294-9d1d-e5235a61270a",
  225. "score": 0.98457545,
  226. "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\""
  227. }
  228. ]
  229. },
  230. "created_at": 1705407629
  231. }
  232. ```
  233. </CodeGroup>
  234. ### ストリーミングモード(基本アシスタント)
  235. <CodeGroup title="応答">
  236. ```streaming {{ title: '応答' }}
  237. data: {"event": "message", "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " I", "created_at": 1679586595}
  238. data: {"event": "message", "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": "'m", "created_at": 1679586595}
  239. data: {"event": "message", "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " glad", "created_at": 1679586595}
  240. data: {"event": "message", "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " to", "created_at": 1679586595}
  241. data: {"event": "message", "message_id" : "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " meet", "created_at": 1679586595}
  242. data: {"event": "message", "message_id" : "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " you", "created_at": 1679586595}
  243. 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\""}]}}
  244. 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"}
  245. 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": ""}
  246. ```
  247. </CodeGroup>
  248. ### 応答例(エージェントアシスタント)
  249. <CodeGroup title="応答">
  250. ```streaming {{ title: '応答' }}
  251. data: {"event": "message", "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " I", "created_at": 1679586595}
  252. data: {"event": "message", "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": "'m", "created_at": 1679586595}
  253. data: {"event": "message", "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " glad", "created_at": 1679586595}
  254. data: {"event": "message", "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " to", "created_at": 1679586595}
  255. data: {"event": "message", "message_id" : "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " meet", "created_at": 1679586595}
  256. data: {"event": "message", "message_id" : "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " you", "created_at": 1679586595}
  257. 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\""}]}}
  258. 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"}
  259. 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": ""}
  260. ```
  261. </CodeGroup>
  262. </Col>
  263. </Row>
  264. ---
  265. <Heading
  266. url='/files/upload'
  267. method='POST'
  268. title='ファイルアップロード'
  269. name='#file-upload'
  270. />
  271. <Row>
  272. <Col>
  273. メッセージ送信時に使用するためのファイルをアップロードします(現在は画像のみサポート)。画像とテキストのマルチモーダル理解を可能にします。
  274. png、jpg、jpeg、webp、gif 形式をサポートしています。
  275. アップロードされたファイルは現在のエンドユーザーのみが使用できます。
  276. ### リクエストボディ
  277. このインターフェースは`multipart/form-data`リクエストを必要とします。
  278. - `file` (File) 必須
  279. アップロードするファイル。
  280. - `user` (string) 必須
  281. ユーザー識別子、開発者のルールで定義され、アプリケーション内で一意でなければなりません。サービス API は WebApp によって作成された会話を共有しません。
  282. ### 応答
  283. アップロードが成功すると、サーバーはファイルの ID と関連情報を返します。
  284. - `id` (uuid) ID
  285. - `name` (string) ファイル名
  286. - `size` (int) ファイルサイズ(バイト)
  287. - `extension` (string) ファイル拡張子
  288. - `mime_type` (string) ファイルの MIME タイプ
  289. - `created_by` (uuid) エンドユーザーID
  290. - `created_at` (timestamp) 作成タイムスタンプ、例:1705395332
  291. ### エラー
  292. - 400, `no_file_uploaded`, ファイルが提供されなければなりません
  293. - 400, `too_many_files`, 現在は 1 つのファイルのみ受け付けます
  294. - 400, `unsupported_preview`, ファイルはプレビューをサポートしていません
  295. - 400, `unsupported_estimate`, ファイルは推定をサポートしていません
  296. - 413, `file_too_large`, ファイルが大きすぎます
  297. - 415, `unsupported_file_type`, サポートされていない拡張子、現在はドキュメントファイルのみ受け付けます
  298. - 503, `s3_connection_failed`, S3 サービスに接続できません
  299. - 503, `s3_permission_denied`, S3 にファイルをアップロードする権限がありません
  300. - 503, `s3_file_too_large`, ファイルが S3 のサイズ制限を超えています
  301. - 500, 内部サーバーエラー
  302. </Col>
  303. <Col sticky>
  304. ### リクエスト例
  305. <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'`}>
  306. ```bash {{ title: 'cURL' }}
  307. curl -X POST '${props.appDetail.api_base_url}/files/upload' \
  308. --header 'Authorization: Bearer {api_key}' \
  309. --form 'file=@"/path/to/file"'
  310. ```
  311. </CodeGroup>
  312. ### 応答例
  313. <CodeGroup title="応答">
  314. ```json {{ title: '応答' }}
  315. {
  316. "id": "72fa9618-8f89-4a37-9b33-7e1178a24a67",
  317. "name": "example.png",
  318. "size": 1024,
  319. "extension": "png",
  320. "mime_type": "image/png",
  321. "created_by": "6ad1ab0a-73ff-4ac1-b9e4-cdb312f71f13",
  322. "created_at": 1577836800,
  323. }
  324. ```
  325. </CodeGroup>
  326. </Col>
  327. </Row>
  328. ---
  329. <Heading
  330. url='/files/:file_id/preview'
  331. method='GET'
  332. title='ファイルプレビュー'
  333. name='#file-preview'
  334. />
  335. <Row>
  336. <Col>
  337. アップロードされたファイルをプレビューまたはダウンロードします。このエンドポイントを使用すると、以前にファイルアップロード API でアップロードされたファイルにアクセスできます。
  338. <i>ファイルは、リクエストしているアプリケーションのメッセージ範囲内にある場合のみアクセス可能です。</i>
  339. ### パスパラメータ
  340. - `file_id` (string) 必須
  341. プレビューするファイルの一意識別子。ファイルアップロード API レスポンスから取得します。
  342. ### クエリパラメータ
  343. - `as_attachment` (boolean) オプション
  344. ファイルを添付ファイルとして強制ダウンロードするかどうか。デフォルトは `false`(ブラウザでプレビュー)。
  345. ### レスポンス
  346. ブラウザ表示またはダウンロード用の適切なヘッダー付きでファイル内容を返します。
  347. - `Content-Type` ファイル MIME タイプに基づいて設定
  348. - `Content-Length` ファイルサイズ(バイト、利用可能な場合)
  349. - `Content-Disposition` `as_attachment=true` の場合は "attachment" に設定
  350. - `Cache-Control` パフォーマンス向上のためのキャッシュヘッダー
  351. - `Accept-Ranges` 音声/動画ファイルの場合は "bytes" に設定
  352. ### エラー
  353. - 400, `invalid_param`, パラメータ入力異常
  354. - 403, `file_access_denied`, ファイルアクセス拒否またはファイルが現在のアプリケーションに属していません
  355. - 404, `file_not_found`, ファイルが見つからないか削除されています
  356. - 500, サーバー内部エラー
  357. </Col>
  358. <Col sticky>
  359. ### リクエスト例
  360. <CodeGroup title="Request" tag="GET" label="/files/:file_id/preview" targetCode={`curl -X GET '${props.appDetail.api_base_url}/files/72fa9618-8f89-4a37-9b33-7e1178a24a67/preview' \\\n--header 'Authorization: Bearer {api_key}'`}>
  361. ```bash {{ title: 'cURL' }}
  362. curl -X GET '${props.appDetail.api_base_url}/files/72fa9618-8f89-4a37-9b33-7e1178a24a67/preview' \
  363. --header 'Authorization: Bearer {api_key}'
  364. ```
  365. </CodeGroup>
  366. ### 添付ファイルとしてダウンロード
  367. <CodeGroup title="Download Request" tag="GET" label="/files/:file_id/preview?as_attachment=true" targetCode={`curl -X GET '${props.appDetail.api_base_url}/files/72fa9618-8f89-4a37-9b33-7e1178a24a67/preview?as_attachment=true' \\\n--header 'Authorization: Bearer {api_key}' \\\n--output downloaded_file.png`}>
  368. ```bash {{ title: 'cURL' }}
  369. curl -X GET '${props.appDetail.api_base_url}/files/72fa9618-8f89-4a37-9b33-7e1178a24a67/preview?as_attachment=true' \
  370. --header 'Authorization: Bearer {api_key}' \
  371. --output downloaded_file.png
  372. ```
  373. </CodeGroup>
  374. ### レスポンスヘッダー例
  375. <CodeGroup title="Response Headers">
  376. ```http {{ title: 'Headers - 画像プレビュー' }}
  377. Content-Type: image/png
  378. Content-Length: 1024
  379. Cache-Control: public, max-age=3600
  380. ```
  381. </CodeGroup>
  382. ### ダウンロードレスポンスヘッダー
  383. <CodeGroup title="Download Response Headers">
  384. ```http {{ title: 'Headers - ファイルダウンロード' }}
  385. Content-Type: image/png
  386. Content-Length: 1024
  387. Content-Disposition: attachment; filename*=UTF-8''example.png
  388. Cache-Control: public, max-age=3600
  389. ```
  390. </CodeGroup>
  391. </Col>
  392. </Row>
  393. ---
  394. <Heading
  395. url='/chat-messages/:task_id/stop'
  396. method='POST'
  397. title='生成停止'
  398. name='#stop-generatebacks'
  399. />
  400. <Row>
  401. <Col>
  402. ストリーミングモードでのみサポートされています。
  403. ### パス
  404. - `task_id` (string) タスク ID、ストリーミングチャンクの返り値から取得できます
  405. ### リクエストボディ
  406. - `user` (string) 必須
  407. ユーザー識別子、エンドユーザーのアイデンティティを定義するために使用され、メッセージ送信インターフェースで渡されたユーザーと一致している必要があります。サービス API は WebApp によって作成された会話を共有しません。
  408. ### 応答
  409. - `result` (string) 常に"success"を返します
  410. </Col>
  411. <Col sticky>
  412. ### リクエスト例
  413. <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"}'`}>
  414. ```bash {{ title: 'cURL' }}
  415. curl -X POST '${props.appDetail.api_base_url}/chat-messages/:task_id/stop' \
  416. -H 'Authorization: Bearer {api_key}' \
  417. -H 'Content-Type: application/json' \
  418. --data-raw '{
  419. "user": "abc-123"
  420. }'
  421. ```
  422. </CodeGroup>
  423. ### 応答例
  424. <CodeGroup title="応答">
  425. ```json {{ title: '応答' }}
  426. {
  427. "result": "success"
  428. }
  429. ```
  430. </CodeGroup>
  431. </Col>
  432. </Row>
  433. ---
  434. <Heading
  435. url='/messages/:message_id/feedbacks'
  436. method='POST'
  437. title='メッセージフィードバック'
  438. name='#feedbacks'
  439. />
  440. <Row>
  441. <Col>
  442. エンドユーザーはフィードバックメッセージを提供でき、アプリケーション開発者が期待される出力を最適化するのに役立ちます。
  443. ### パス
  444. <Properties>
  445. <Property name='message_id' type='string' key='message_id'>
  446. メッセージID
  447. </Property>
  448. </Properties>
  449. ### リクエストボディ
  450. <Properties>
  451. <Property name='rating' type='string' key='rating'>
  452. アップボートは`like`、ダウンボートは`dislike`、アップボートの取り消しは`null`
  453. </Property>
  454. <Property name='user' type='string' key='user'>
  455. ユーザー識別子、開発者のルールで定義され、アプリケーション内で一意でなければなりません。
  456. </Property>
  457. <Property name='content' type='string' key='content'>
  458. メッセージのフィードバックです。
  459. </Property>
  460. </Properties>
  461. ### 応答
  462. - `result` (string) 常に"success"を返します
  463. </Col>
  464. <Col sticky>
  465. <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}'`}>
  466. ```bash {{ title: 'cURL' }}
  467. curl -X POST '${props.appDetail.api_base_url}/messages/:message_id/feedbacks' \
  468. --header 'Authorization: Bearer {api_key}' \
  469. --header 'Content-Type: application/json' \
  470. --data-raw '{
  471. "rating": "like",
  472. "user": "abc-123",
  473. "content": "message feedback information"
  474. }'
  475. ```
  476. </CodeGroup>
  477. <CodeGroup title="応答">
  478. ```json {{ title: '応答' }}
  479. {
  480. "result": "success"
  481. }
  482. ```
  483. </CodeGroup>
  484. </Col>
  485. </Row>
  486. ---
  487. <Heading
  488. url='/app/feedbacks'
  489. method='GET'
  490. title='アプリのメッセージの「いいね」とフィードバックを取得'
  491. name='#app-feedbacks'
  492. />
  493. <Row>
  494. <Col>
  495. アプリのエンドユーザーからのフィードバックや「いいね」を取得します。
  496. ### クエリ
  497. <Properties>
  498. <Property name='page' type='string' key='page'>
  499. (任意)ページ番号。デフォルト値:1
  500. </Property>
  501. </Properties>
  502. <Properties>
  503. <Property name='limit' type='string' key='limit'>
  504. (任意)1ページあたりの件数。デフォルト値:20
  505. </Property>
  506. </Properties>
  507. ### レスポンス
  508. - `data` (リスト) このアプリの「いいね」とフィードバックの一覧を返します。
  509. </Col>
  510. <Col sticky>
  511. <CodeGroup title="Request" tag="GET" label="/app/feedbacks" targetCode={`curl -X GET '${props.appDetail.api_base_url}/app/feedbacks?page=1&limit=20'`}>
  512. ```bash {{ title: 'cURL' }}
  513. curl -X GET '${props.appDetail.api_base_url}/app/feedbacks?page=1&limit=20' \
  514. --header 'Authorization: Bearer {api_key}' \
  515. --header 'Content-Type: application/json'
  516. ```
  517. </CodeGroup>
  518. <CodeGroup title="Response">
  519. ```json {{ title: 'Response' }}
  520. {
  521. "data": [
  522. {
  523. "id": "8c0fbed8-e2f9-49ff-9f0e-15a35bdd0e25",
  524. "app_id": "f252d396-fe48-450e-94ec-e184218e7346",
  525. "conversation_id": "2397604b-9deb-430e-b285-4726e51fd62d",
  526. "message_id": "709c0b0f-0a96-4a4e-91a4-ec0889937b11",
  527. "rating": "like",
  528. "content": "message feedback information-3",
  529. "from_source": "user",
  530. "from_end_user_id": "74286412-9a1a-42c1-929c-01edb1d381d5",
  531. "from_account_id": null,
  532. "created_at": "2025-04-24T09:24:38",
  533. "updated_at": "2025-04-24T09:24:38"
  534. }
  535. ]
  536. }
  537. ```
  538. </CodeGroup>
  539. </Col>
  540. </Row>
  541. ---
  542. <Heading
  543. url='/messages/{message_id}/suggested'
  544. method='GET'
  545. title='次の推奨質問'
  546. name='#suggested'
  547. />
  548. <Row>
  549. <Col>
  550. 現在のメッセージに対する次の質問の提案を取得します
  551. ### パスパラメータ
  552. <Properties>
  553. <Property name='message_id' type='string' key='message_id'>
  554. メッセージID
  555. </Property>
  556. </Properties>
  557. ### クエリ
  558. <Properties>
  559. <Property name='user' type='string' key='user'>
  560. ユーザー識別子、エンドユーザーのアイデンティティを定義するために使用され、統計のために使用されます。
  561. アプリケーション内で開発者によって一意に定義される必要があります。
  562. </Property>
  563. </Properties>
  564. </Col>
  565. <Col sticky>
  566. <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'`}>
  567. ```bash {{ title: 'cURL' }}
  568. curl --location --request GET '${props.appDetail.api_base_url}/messages/{message_id}/suggested' \
  569. --header 'Authorization: Bearer ENTER-YOUR-SECRET-KEY' \
  570. --header 'Content-Type: application/json' \
  571. ```
  572. </CodeGroup>
  573. <CodeGroup title="応答">
  574. ```json {{ title: '応答' }}
  575. {
  576. "result": "success",
  577. "data": [
  578. "a",
  579. "b",
  580. "c"
  581. ]
  582. }
  583. ```
  584. </CodeGroup>
  585. </Col>
  586. </Row>
  587. ---
  588. <Heading
  589. url='/messages'
  590. method='GET'
  591. title='会話履歴メッセージを取得'
  592. name='#messages'
  593. />
  594. <Row>
  595. <Col>
  596. スクロールロード形式で過去のチャット記録を返し、最初のページは最新の`{limit}`メッセージを返します。つまり、逆順です。
  597. ### クエリ
  598. <Properties>
  599. <Property name='conversation_id' type='string' key='conversation_id'>
  600. 会話ID
  601. </Property>
  602. <Property name='user' type='string' key='user'>
  603. ユーザー識別子、エンドユーザーのアイデンティティを定義するために使用され、統計のために使用されます。
  604. アプリケーション内で開発者によって一意に定義される必要があります。
  605. </Property>
  606. <Property name='first_id' type='string' key='first_id'>
  607. 現在のページの最初のチャット記録のID、デフォルトはnullです。
  608. </Property>
  609. <Property name='limit' type='int' key='limit'>
  610. 1回のリクエストで返すチャット履歴メッセージの数、デフォルトは20です。
  611. </Property>
  612. </Properties>
  613. ### 応答
  614. - `data` (array[object]) メッセージリスト
  615. - `id` (string) メッセージID
  616. - `conversation_id` (string) 会話ID
  617. - `inputs` (object) ユーザー入力パラメータ。
  618. - `query` (string) ユーザー入力/質問内容。
  619. - `message_files` (array[object]) メッセージファイル
  620. - `id` (string) ID
  621. - `type` (string) ファイルタイプ、画像の場合はimage
  622. - `url` (string) ファイルプレビューURL、ファイルアクセスにはファイルプレビューAPI(`/files/{file_id}/preview`)を使用してください
  623. - `belongs_to` (string) 所属、ユーザーまたはアシスタント
  624. - `agent_thoughts` (array[object]) エージェントの思考(基本アシスタントの場合は空)
  625. - `id` (string) エージェント思考ID、各反復には一意のエージェント思考IDがあります
  626. - `message_id` (string) 一意のメッセージID
  627. - `position` (int) 現在のエージェント思考の位置、各メッセージには順番に複数の思考が含まれる場合があります。
  628. - `thought` (string) LLMが考えていること
  629. - `observation` (string) ツール呼び出しからの応答
  630. - `tool` (string) 呼び出されたツールのリスト、;で区切られます
  631. - `tool_input` (string) ツールの入力、JSON形式。例:`{"dalle3": {"prompt": "a cute cat"}}`。
  632. - `created_at` (int) 作成タイムスタンプ、例:1705395332
  633. - `message_files` (array[string]) message_fileイベントを参照
  634. - `file_id` (string) ファイルID
  635. - `answer` (string) 応答メッセージ内容
  636. - `created_at` (timestamp) 作成タイムスタンプ、例:1705395332
  637. - `feedback` (object) フィードバック情報
  638. - `rating` (string) アップボートは`like` / ダウンボートは`dislike`
  639. - `retriever_resources` (array[RetrieverResource]) 引用と帰属リスト
  640. - `has_more` (bool) 次のページがあるかどうか
  641. - `limit` (int) 返されたアイテムの数、入力がシステム制限を超える場合、システム制限の数を返します
  642. </Col>
  643. <Col sticky>
  644. <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}'`}>
  645. ```bash {{ title: 'cURL' }}
  646. curl -X GET '${props.appDetail.api_base_url}/messages?user=abc-123&conversation_id='
  647. --header 'Authorization: Bearer {api_key}'
  648. ```
  649. </CodeGroup>
  650. ### 応答例(基本アシスタント)
  651. <CodeGroup title="応答">
  652. ```json {{ title: '応答' }}
  653. {
  654. "limit": 20,
  655. "has_more": false,
  656. "data": [
  657. {
  658. "id": "a076a87f-31e5-48dc-b452-0061adbbc922",
  659. "conversation_id": "cd78daf6-f9e4-4463-9ff2-54257230a0ce",
  660. "inputs": {
  661. "name": "dify"
  662. },
  663. "query": "iphone 13 pro",
  664. "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を搭載しています。",
  665. "message_files": [],
  666. "feedback": null,
  667. "retriever_resources": [
  668. {
  669. "position": 1,
  670. "dataset_id": "101b4c97-fc2e-463c-90b1-5261a4cdcafb",
  671. "dataset_name": "iPhone",
  672. "document_id": "8dd1ad74-0b5f-4175-b735-7d98bbbb4e00",
  673. "document_name": "iPhone List",
  674. "segment_id": "ed599c7f-2766-4294-9d1d-e5235a61270a",
  675. "score": 0.98457545,
  676. "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\""
  677. }
  678. ],
  679. "agent_thoughts": [],
  680. "created_at": 1705569239,
  681. }
  682. ]
  683. }
  684. ```
  685. </CodeGroup>
  686. ### 応答例(エージェントアシスタント)
  687. <CodeGroup title="応答">
  688. ```json {{ title: '応答' }}
  689. {
  690. "limit": 20,
  691. "has_more": false,
  692. "data": [
  693. {
  694. "id": "d35e006c-7c4d-458f-9142-be4930abdf94",
  695. "conversation_id": "957c068b-f258-4f89-ba10-6e8a0361c457",
  696. "inputs": {},
  697. "query": "draw a cat",
  698. "answer": "猫の画像を生成しました。メッセージを確認して画像を表示してください。",
  699. "message_files": [
  700. {
  701. "id": "976990d2-5294-47e6-8f14-7356ba9d2d76",
  702. "type": "image",
  703. "url": "http://127.0.0.1:5001/files/tools/976990d2-5294-47e6-8f14-7356ba9d2d76.png?timestamp=1705988524&nonce=55df3f9f7311a9acd91bf074cd524092&sign=z43nMSO1L2HBvoqADLkRxr7Biz0fkjeDstnJiCK1zh8=",
  704. "belongs_to": "assistant"
  705. }
  706. ],
  707. "feedback": null,
  708. "retriever_resources": [],
  709. "created_at": 1705988187,
  710. "agent_thoughts": [
  711. {
  712. "id": "592c84cf-07ee-441c-9dcc-ffc66c033469",
  713. "chain_id": null,
  714. "message_id": "d35e006c-7c4d-458f-9142-be4930abdf94",
  715. "position": 1,
  716. "thought": "",
  717. "tool": "dalle2",
  718. "tool_input": "{\"dalle2\": {\"prompt\": \"cat\"}}",
  719. "created_at": 1705988186,
  720. "observation": "画像はすでに作成され、ユーザーに送信されました。今すぐユーザーに確認するように伝えてください。",
  721. "files": [
  722. "976990d2-5294-47e6-8f14-7356ba9d2d76"
  723. ]
  724. },
  725. {
  726. "id": "73ead60d-2370-4780-b5ed-532d2762b0e5",
  727. "chain_id": null,
  728. "message_id": "d35e006c-7c4d-458f-9142-be4930abdf94",
  729. "position": 2,
  730. "thought": "猫の画像を生成しました。メッセージを確認して画像を表示してください。",
  731. "tool": "",
  732. "tool_input": "",
  733. "created_at": 1705988199,
  734. "observation": "",
  735. "files": []
  736. }
  737. ]
  738. }
  739. ]
  740. }
  741. ```
  742. </CodeGroup>
  743. </Col>
  744. </Row>
  745. ---
  746. <Heading
  747. url='/conversations'
  748. method='GET'
  749. title='会話を取得'
  750. name='#conversations'
  751. />
  752. <Row>
  753. <Col>
  754. 現在のユーザーの会話リストを取得し、デフォルトで最新の 20 件を返します。
  755. ### クエリ
  756. <Properties>
  757. <Property name='user' type='string' key='user'>
  758. ユーザー識別子、エンドユーザーのアイデンティティを定義するために使用され、統計のために使用されます。
  759. アプリケーション内で開発者によって一意に定義される必要があります。
  760. </Property>
  761. <Property name='last_id' type='string' key='last_id'>
  762. (Optional)現在のページの最後のレコードのID、デフォルトはnullです。
  763. </Property>
  764. <Property name='limit' type='int' key='limit'>
  765. (Optional)1回のリクエストで返すレコードの数、デフォルトは最新の20件です。最大100、最小1。
  766. </Property>
  767. <Property name='sort_by' type='string' key='sort_by'>
  768. (Optional)ソートフィールド、デフォルト:-updated_at(更新時間で降順にソート)
  769. - 利用可能な値:created_at, -created_at, updated_at, -updated_at
  770. - フィールドの前の記号は順序または逆順を表し、"-"は逆順を表します。
  771. </Property>
  772. </Properties>
  773. ### 応答
  774. - `data` (array[object]) 会話のリスト
  775. - `id` (string) 会話ID
  776. - `name` (string) 会話名、デフォルトでは、ユーザーが会話で最初に尋ねた質問のスニペットです。
  777. - `inputs` (object) ユーザー入力パラメータ。
  778. - `introduction` (string) 紹介
  779. - `created_at` (timestamp) 作成タイムスタンプ、例:1705395332
  780. - `updated_at` (timestamp) 更新タイムスタンプ、例:1705395332
  781. - `has_more` (bool)
  782. - `limit` (int) 返されたエントリの数、入力がシステム制限を超える場合、システム制限の数を返します
  783. </Col>
  784. <Col sticky>
  785. <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}'`}>
  786. ```bash {{ title: 'cURL' }}
  787. curl -X GET '${props.appDetail.api_base_url}/conversations?user=abc-123&last_id=&limit=20' \
  788. --header 'Authorization: Bearer {api_key}'
  789. ```
  790. </CodeGroup>
  791. <CodeGroup title="応答">
  792. ```json {{ title: '応答' }}
  793. {
  794. "limit": 20,
  795. "has_more": false,
  796. "data": [
  797. {
  798. "id": "10799fb8-64f7-4296-bbf7-b42bfbe0ae54",
  799. "name": "新しいチャット",
  800. "inputs": {
  801. "book": "book",
  802. "myName": "Lucy"
  803. },
  804. "status": "normal",
  805. "created_at": 1679667915,
  806. "updated_at": 1679667915
  807. },
  808. {
  809. "id": "hSIhXBhNe8X1d8Et"
  810. // ...
  811. }
  812. ]
  813. }
  814. ```
  815. </CodeGroup>
  816. </Col>
  817. </Row>
  818. ---
  819. <Heading
  820. url='/conversations/:conversation_id'
  821. method='DELETE'
  822. title='会話を削除'
  823. name='#delete'
  824. />
  825. <Row>
  826. <Col>
  827. 会話を削除します。
  828. ### パス
  829. - `conversation_id` (string) 会話ID
  830. ### リクエストボディ
  831. <Properties>
  832. <Property name='user' type='string' key='user'>
  833. ユーザー識別子、開発者によって定義され、アプリケーション内で一意である必要があります。
  834. </Property>
  835. </Properties>
  836. ### 応答
  837. - `result` (string) 常に"success"を返します
  838. </Col>
  839. <Col sticky>
  840. <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}'`}>
  841. ```bash {{ title: 'cURL' }}
  842. curl -X DELETE '${props.appDetail.api_base_url}/conversations/{conversation_id}' \
  843. --header 'Content-Type: application/json' \
  844. --header 'Accept: application/json' \
  845. --header 'Authorization: Bearer {api_key}' \
  846. --data '{
  847. "user": "abc-123"
  848. }'
  849. ```
  850. </CodeGroup>
  851. <CodeGroup title="応答">
  852. ```text {{ title: '応答' }}
  853. 204 No Content
  854. ```
  855. </CodeGroup>
  856. </Col>
  857. </Row>
  858. ---
  859. <Heading
  860. url='/conversations/:conversation_id/name'
  861. method='POST'
  862. title='会話の名前を変更'
  863. name='#rename'
  864. />
  865. <Row>
  866. <Col>
  867. ### リクエストボディ
  868. セッションの名前を変更します。セッション名は、複数のセッションをサポートするクライアントでの表示に使用されます。
  869. ### パス
  870. - `conversation_id` (string) 会話ID
  871. <Properties>
  872. <Property name='name' type='string' key='name'>
  873. (Optional)会話の名前。このパラメータは、`auto_generate`が`true`に設定されている場合、省略できます。
  874. </Property>
  875. <Property name='auto_generate' type='bool' key='auto_generate'>
  876. (Optional)タイトルを自動生成します。デフォルトは`false`です。
  877. </Property>
  878. <Property name='user' type='string' key='user'>
  879. ユーザー識別子、開発者によって定義され、アプリケーション内で一意である必要があります。
  880. </Property>
  881. </Properties>
  882. ### 応答
  883. - `id` (string) 会話ID
  884. - `name` (string) 会話名
  885. - `inputs` (object) ユーザー入力パラメータ
  886. - `status` (string) 会話状態
  887. - `introduction` (string) 紹介
  888. - `created_at` (timestamp) 作成タイムスタンプ、例:1705395332
  889. - `updated_at` (timestamp) 更新タイムスタンプ、例:1705395332
  890. </Col>
  891. <Col sticky>
  892. <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}'`}>
  893. ```bash {{ title: 'cURL' }}
  894. curl -X POST '${props.appDetail.api_base_url}/conversations/{conversation_id}/name' \
  895. --header 'Content-Type: application/json' \
  896. --header 'Authorization: Bearer {api_key}' \
  897. --data-raw '{
  898. "name": "",
  899. "auto_generate": true,
  900. "user": "abc-123"
  901. }'
  902. ```
  903. </CodeGroup>
  904. <CodeGroup title="応答">
  905. ```json {{ title: '応答' }}
  906. {
  907. "id": "cd78daf6-f9e4-4463-9ff2-54257230a0ce",
  908. "name": "Chat vs AI",
  909. "inputs": {},
  910. "introduction": "",
  911. "created_at": 1705569238,
  912. "updated_at": 1705569238
  913. }
  914. ```
  915. </CodeGroup>
  916. </Col>
  917. </Row>
  918. ---
  919. <Heading
  920. url='/conversations/:conversation_id/variables'
  921. method='GET'
  922. title='会話変数の取得'
  923. name='#conversation-variables'
  924. />
  925. <Row>
  926. <Col>
  927. 特定の会話から変数を取得します。このエンドポイントは、会話中に取得された構造化データを抽出するのに役立ちます。
  928. ### パスパラメータ
  929. <Properties>
  930. <Property name='conversation_id' type='string' key='conversation_id'>
  931. 変数を取得する会話のID。
  932. </Property>
  933. </Properties>
  934. ### クエリパラメータ
  935. <Properties>
  936. <Property name='user' type='string' key='user'>
  937. ユーザー識別子。開発者によって定義されたルールに従い、アプリケーション内で一意である必要があります。
  938. </Property>
  939. <Property name='last_id' type='string' key='last_id'>
  940. (Optional)現在のページの最後のレコードのID、デフォルトはnullです。
  941. </Property>
  942. <Property name='limit' type='int' key='limit'>
  943. (Optional)1回のリクエストで返すレコードの数、デフォルトは最新の20件です。最大100、最小1。
  944. </Property>
  945. </Properties>
  946. ### レスポンス
  947. - `limit` (int) ページごとのアイテム数
  948. - `has_more` (bool) さらにアイテムがあるかどうか
  949. - `data` (array[object]) 変数のリスト
  950. - `id` (string) 変数 ID
  951. - `name` (string) 変数名
  952. - `value_type` (string) 変数タイプ(文字列、数値、真偽値など)
  953. - `value` (string) 変数値
  954. - `description` (string) 変数の説明
  955. - `created_at` (int) 作成タイムスタンプ
  956. - `updated_at` (int) 最終更新タイムスタンプ
  957. ### エラー
  958. - 404, `conversation_not_exists`, 会話が見つかりません
  959. </Col>
  960. <Col sticky>
  961. <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}'`}>
  962. ```bash {{ title: 'cURL' }}
  963. curl -X GET '${props.appDetail.api_base_url}/conversations/{conversation_id}/variables?user=abc-123' \
  964. --header 'Authorization: Bearer {api_key}'
  965. ```
  966. </CodeGroup>
  967. <CodeGroup title="Request with variable name filter">
  968. ```bash {{ title: 'cURL' }}
  969. curl -X GET '${props.appDetail.api_base_url}/conversations/{conversation_id}/variables?user=abc-123&variable_name=customer_name' \
  970. --header 'Authorization: Bearer {api_key}'
  971. ```
  972. </CodeGroup>
  973. <CodeGroup title="Response">
  974. ```json {{ title: 'Response' }}
  975. {
  976. "limit": 100,
  977. "has_more": false,
  978. "data": [
  979. {
  980. "id": "variable-uuid-1",
  981. "name": "customer_name",
  982. "value_type": "string",
  983. "value": "John Doe",
  984. "description": "会話から抽出された顧客名",
  985. "created_at": 1650000000000,
  986. "updated_at": 1650000000000
  987. },
  988. {
  989. "id": "variable-uuid-2",
  990. "name": "order_details",
  991. "value_type": "json",
  992. "value": "{\"product\":\"Widget\",\"quantity\":5,\"price\":19.99}",
  993. "description": "顧客の注文詳細",
  994. "created_at": 1650000000000,
  995. "updated_at": 1650000000000
  996. }
  997. ]
  998. }
  999. ```
  1000. </CodeGroup>
  1001. </Col>
  1002. </Row>
  1003. ---
  1004. <Heading
  1005. url='/conversations/:conversation_id/variables/:variable_id'
  1006. method='PUT'
  1007. title='会話変数の更新'
  1008. name='#update-conversation-variable'
  1009. />
  1010. <Row>
  1011. <Col>
  1012. 特定の会話変数の値を更新します。このエンドポイントは、名前、型、説明を保持しながら、会話中にキャプチャされた変数の値を変更することを可能にします。
  1013. ### パスパラメータ
  1014. <Properties>
  1015. <Property name='conversation_id' type='string' key='conversation_id'>
  1016. 更新する変数を含む会話のID。
  1017. </Property>
  1018. <Property name='variable_id' type='string' key='variable_id'>
  1019. 更新する変数のID。
  1020. </Property>
  1021. </Properties>
  1022. ### リクエストボディ
  1023. <Properties>
  1024. <Property name='value' type='any' key='value'>
  1025. 変数の新しい値。変数の期待される型(文字列、数値、オブジェクトなど)と一致する必要があります。
  1026. </Property>
  1027. <Property name='user' type='string' key='user'>
  1028. ユーザー識別子。開発者によって定義されたルールに従い、アプリケーション内で一意である必要があります。
  1029. </Property>
  1030. </Properties>
  1031. ### レスポンス
  1032. 以下を含む更新された変数オブジェクトを返します:
  1033. - `id` (string) 変数ID
  1034. - `name` (string) 変数名
  1035. - `value_type` (string) 変数型(文字列、数値、オブジェクトなど)
  1036. - `value` (any) 更新された変数値
  1037. - `description` (string) 変数の説明
  1038. - `created_at` (int) 作成タイムスタンプ
  1039. - `updated_at` (int) 最終更新タイムスタンプ
  1040. ### エラー
  1041. - 400, `Type mismatch: variable expects {expected_type}, but got {actual_type} type`, 値の型が変数の期待される型と一致しません
  1042. - 404, `conversation_not_exists`, 会話が見つかりません
  1043. - 404, `conversation_variable_not_exists`, 変数が見つかりません
  1044. </Col>
  1045. <Col sticky>
  1046. <CodeGroup title="Request" tag="PUT" label="/conversations/:conversation_id/variables/:variable_id" targetCode={`curl -X PUT '${props.appDetail.api_base_url}/conversations/{conversation_id}/variables/{variable_id}' \\\n--header 'Authorization: Bearer {api_key}' \\\n--header 'Content-Type: application/json' \\\n--data-raw '{\n "value": "Updated Value",\n "user": "abc-123"\n}'`}>
  1047. ```bash {{ title: 'cURL' }}
  1048. curl -X PUT '${props.appDetail.api_base_url}/conversations/{conversation_id}/variables/{variable_id}' \
  1049. --header 'Content-Type: application/json' \
  1050. --header 'Authorization: Bearer {api_key}' \
  1051. --data-raw '{
  1052. "value": "Updated Value",
  1053. "user": "abc-123"
  1054. }'
  1055. ```
  1056. </CodeGroup>
  1057. <CodeGroup title="異なる値型での更新">
  1058. ```bash {{ title: '文字列値' }}
  1059. curl -X PUT '${props.appDetail.api_base_url}/conversations/{conversation_id}/variables/{variable_id}' \
  1060. --header 'Content-Type: application/json' \
  1061. --header 'Authorization: Bearer {api_key}' \
  1062. --data-raw '{
  1063. "value": "新しい文字列値",
  1064. "user": "abc-123"
  1065. }'
  1066. ```
  1067. ```bash {{ title: '数値' }}
  1068. curl -X PUT '${props.appDetail.api_base_url}/conversations/{conversation_id}/variables/{variable_id}' \
  1069. --header 'Content-Type: application/json' \
  1070. --header 'Authorization: Bearer {api_key}' \
  1071. --data-raw '{
  1072. "value": 42,
  1073. "user": "abc-123"
  1074. }'
  1075. ```
  1076. ```bash {{ title: 'オブジェクト値' }}
  1077. curl -X PUT '${props.appDetail.api_base_url}/conversations/{conversation_id}/variables/{variable_id}' \
  1078. --header 'Content-Type: application/json' \
  1079. --header 'Authorization: Bearer {api_key}' \
  1080. --data-raw '{
  1081. "value": {"product": "Widget", "quantity": 10, "price": 29.99},
  1082. "user": "abc-123"
  1083. }'
  1084. ```
  1085. </CodeGroup>
  1086. <CodeGroup title="Response">
  1087. ```json {{ title: 'Response' }}
  1088. {
  1089. "id": "variable-uuid-1",
  1090. "name": "customer_name",
  1091. "value_type": "string",
  1092. "value": "Updated Value",
  1093. "description": "会話から抽出された顧客名",
  1094. "created_at": 1650000000000,
  1095. "updated_at": 1650000001000
  1096. }
  1097. ```
  1098. </CodeGroup>
  1099. </Col>
  1100. </Row>
  1101. ---
  1102. <Heading
  1103. url='/audio-to-text'
  1104. method='POST'
  1105. title='音声からテキストへ'
  1106. name='#audio-to-text'
  1107. />
  1108. <Row>
  1109. <Col>
  1110. このエンドポイントは multipart/form-data リクエストを必要とします。
  1111. ### リクエストボディ
  1112. <Properties>
  1113. <Property name='file' type='file' key='file'>
  1114. オーディオファイル。
  1115. サポートされている形式:`['mp3', 'mp4', 'mpeg', 'mpga', 'm4a', 'wav', 'webm']`
  1116. ファイルサイズ制限:15MB
  1117. </Property>
  1118. <Property name='user' type='string' key='user'>
  1119. ユーザー識別子、開発者のルールで定義され、アプリケーション内で一意でなければなりません。
  1120. </Property>
  1121. </Properties>
  1122. ### 応答
  1123. - `text` (string) 出力テキスト
  1124. </Col>
  1125. <Col sticky>
  1126. <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]'`}>
  1127. ```bash {{ title: 'cURL' }}
  1128. curl -X POST '${props.appDetail.api_base_url}/conversations/name' \
  1129. --header 'Authorization: Bearer {api_key}' \
  1130. --form 'file=@localfile;type=audio/mp3'
  1131. ```
  1132. </CodeGroup>
  1133. <CodeGroup title="応答">
  1134. ```json {{ title: '応答' }}
  1135. {
  1136. "text": ""
  1137. }
  1138. ```
  1139. </CodeGroup>
  1140. </Col>
  1141. </Row>
  1142. ---
  1143. <Heading
  1144. url='/text-to-audio'
  1145. method='POST'
  1146. title='テキストから音声へ'
  1147. name='#text-to-audio'
  1148. />
  1149. <Row>
  1150. <Col>
  1151. テキストを音声に変換します。
  1152. ### リクエストボディ
  1153. <Properties>
  1154. <Property name='message_id' type='str' key='message_id'>
  1155. Difyによって生成されたテキストメッセージの場合、生成されたメッセージIDを直接渡します。バックエンドはメッセージIDを使用して対応するコンテンツを検索し、音声情報を直接合成します。message_idとtextが同時に提供される場合、message_idが優先されます。
  1156. </Property>
  1157. <Property name='text' type='str' key='text'>
  1158. 音声生成コンテンツ。
  1159. </Property>
  1160. <Property name='user' type='string' key='user'>
  1161. ユーザー識別子、開発者によって定義され、アプリ内で一意である必要があります。
  1162. </Property>
  1163. </Properties>
  1164. </Col>
  1165. <Col sticky>
  1166. <CodeGroup title="リクエスト" tag="POST" label="/text-to-audio" targetCode={`curl --location --request POST '${props.appDetail.api_base_url}/text-to-audio' \\\n--header 'Authorization: Bearer ENTER-YOUR-SECRET-KEY' \\\n--form 'text=Hello Dify;user=abc-123;message_id=5ad4cb98-f0c7-4085-b384-88c403be6290`}>
  1167. ```bash {{ title: 'cURL' }}
  1168. curl --location --request POST '${props.appDetail.api_base_url}/text-to-audio' \
  1169. --header 'Authorization: Bearer ENTER-YOUR-SECRET-KEY' \
  1170. --form 'file=Hello Dify;user=abc-123;message_id=5ad4cb98-f0c7-4085-b384-88c403be6290'
  1171. ```
  1172. </CodeGroup>
  1173. <CodeGroup title="ヘッダー">
  1174. ```json {{ title: 'ヘッダー' }}
  1175. {
  1176. "Content-Type": "audio/wav"
  1177. }
  1178. ```
  1179. </CodeGroup>
  1180. </Col>
  1181. </Row>
  1182. ---
  1183. <Heading
  1184. url='/info'
  1185. method='GET'
  1186. title='アプリケーションの基本情報を取得'
  1187. name='#info'
  1188. />
  1189. <Row>
  1190. <Col>
  1191. このアプリケーションの基本情報を取得するために使用されます
  1192. ### Response
  1193. - `name` (string) アプリケーションの名前
  1194. - `description` (string) アプリケーションの説明
  1195. - `tags` (array[string]) アプリケーションのタグ
  1196. - `mode` (string) アプリケーションのモード
  1197. - `author_name` (string) 作者の名前
  1198. </Col>
  1199. <Col>
  1200. <CodeGroup title="Request" tag="GET" label="/info" targetCode={`curl -X GET '${props.appDetail.api_base_url}/info' \\\n-H 'Authorization: Bearer {api_key}'`}>
  1201. ```bash {{ title: 'cURL' }}
  1202. curl -X GET '${props.appDetail.api_base_url}/info' \
  1203. -H 'Authorization: Bearer {api_key}'
  1204. ```
  1205. </CodeGroup>
  1206. <CodeGroup title="Response">
  1207. ```json {{ title: 'Response' }}
  1208. {
  1209. "name": "My App",
  1210. "description": "This is my app.",
  1211. "tags": [
  1212. "tag1",
  1213. "tag2"
  1214. ],
  1215. "mode": "chat",
  1216. "author_name": "Dify"
  1217. }
  1218. ```
  1219. </CodeGroup>
  1220. </Col>
  1221. </Row>
  1222. ---
  1223. <Heading
  1224. url='/parameters'
  1225. method='GET'
  1226. title='アプリケーションのパラメータ情報を取得'
  1227. name='#parameters'
  1228. />
  1229. <Row>
  1230. <Col>
  1231. ページに入る際に、機能、入力パラメータ名、タイプ、デフォルト値などの情報を取得するために使用されます。
  1232. ### 応答
  1233. - `opening_statement` (string) 開始文
  1234. - `suggested_questions` (array[string]) 開始時の推奨質問のリスト
  1235. - `suggested_questions_after_answer` (object) 答えを有効にした後の質問を提案します。
  1236. - `enabled` (bool) 有効かどうか
  1237. - `speech_to_text` (object) 音声からテキストへ
  1238. - `enabled` (bool) 有効かどうか
  1239. - `text_to_speech` (object) テキストから音声へ
  1240. - `enabled` (bool) 有効かどうか
  1241. - `voice` (string) 音声タイプ
  1242. - `language` (string) 言語
  1243. - `autoPlay` (string) 自動再生
  1244. - `enabled` 有効
  1245. - `disabled` 無効
  1246. - `retriever_resource` (object) 引用と帰属
  1247. - `enabled` (bool) 有効かどうか
  1248. - `annotation_reply` (object) 注釈返信
  1249. - `enabled` (bool) 有効かどうか
  1250. - `user_input_form` (array[object]) ユーザー入力フォームの構成
  1251. - `text-input` (object) テキスト入力コントロール
  1252. - `label` (string) 変数表示ラベル名
  1253. - `variable` (string) 変数ID
  1254. - `required` (bool) 必須かどうか
  1255. - `default` (string) デフォルト値
  1256. - `paragraph` (object) 段落テキスト入力コントロール
  1257. - `label` (string) 変数表示ラベル名
  1258. - `variable` (string) 変数ID
  1259. - `required` (bool) 必須かどうか
  1260. - `default` (string) デフォルト値
  1261. - `select` (object) ドロップダウンコントロール
  1262. - `label` (string) 変数表示ラベル名
  1263. - `variable` (string) 変数ID
  1264. - `required` (bool) 必須かどうか
  1265. - `default` (string) デフォルト値
  1266. - `options` (array[string]) オプション値
  1267. - `file_upload` (object) ファイルアップロード設定
  1268. - `document` (object) ドキュメント設定
  1269. 現在サポートされているドキュメントタイプ:`txt`, `md`, `markdown`, `pdf`, `html`, `xlsx`, `xls`, `docx`, `csv`, `eml`, `msg`, `pptx`, `ppt`, `xml`, `epub`。
  1270. - `enabled` (bool) 有効かどうか
  1271. - `number_limits` (int) ドキュメント数の上限。デフォルトは 3
  1272. - `transfer_methods` (array[string]) 転送方法リスト:`remote_url`, `local_file`。いずれかを選択する必要があります。
  1273. - `image` (object) 画像設定
  1274. 現在サポートされている画像タイプ:`png`, `jpg`, `jpeg`, `webp`, `gif`。
  1275. - `enabled` (bool) 有効かどうか
  1276. - `number_limits` (int) 画像数の上限。デフォルトは 3
  1277. - `transfer_methods` (array[string]) 転送方法リスト:`remote_url`, `local_file`。いずれかを選択する必要があります。
  1278. - `audio` (object) オーディオ設定
  1279. 現在サポートされているオーディオタイプ:`mp3`, `m4a`, `wav`, `webm`, `amr`。
  1280. - `enabled` (bool) 有効かどうか
  1281. - `number_limits` (int) オーディオ数の上限。デフォルトは 3
  1282. - `transfer_methods` (array[string]) 転送方法リスト:`remote_url`, `local_file`。いずれかを選択する必要があります。
  1283. - `video` (object) ビデオ設定
  1284. 現在サポートされているビデオタイプ:`mp4`, `mov`, `mpeg`, `mpga`。
  1285. - `enabled` (bool) 有効かどうか
  1286. - `number_limits` (int) ビデオ数の上限。デフォルトは 3
  1287. - `transfer_methods` (array[string]) 転送方法リスト:`remote_url`, `local_file`。いずれかを選択する必要があります。
  1288. - `custom` (object) カスタム設定
  1289. - `enabled` (bool) 有効かどうか
  1290. - `number_limits` (int) カスタム数の上限。デフォルトは 3
  1291. - `transfer_methods` (array[string]) 転送方法リスト:`remote_url`, `local_file`。いずれかを選択する必要があります。
  1292. - `system_parameters` (object) システムパラメータ
  1293. - `file_size_limit` (int) ドキュメントアップロードサイズ制限(MB)
  1294. - `image_file_size_limit` (int) 画像ファイルアップロードサイズ制限(MB)
  1295. - `audio_file_size_limit` (int) オーディオファイルアップロードサイズ制限(MB)
  1296. - `video_file_size_limit` (int) ビデオファイルアップロードサイズ制限(MB)
  1297. </Col>
  1298. <Col sticky>
  1299. <CodeGroup title="リクエスト" tag="GET" label="/parameters" targetCode={` curl -X GET '${props.appDetail.api_base_url}/parameters'`}>
  1300. ```bash {{ title: 'cURL' }}
  1301. curl -X GET '${props.appDetail.api_base_url}/parameters' \
  1302. --header 'Authorization: Bearer {api_key}'
  1303. ```
  1304. </CodeGroup>
  1305. <CodeGroup title="応答">
  1306. ```json {{ title: '応答' }}
  1307. {
  1308. "opening_statement": "こんにちは!",
  1309. "suggested_questions_after_answer": {
  1310. "enabled": true
  1311. },
  1312. "speech_to_text": {
  1313. "enabled": true
  1314. },
  1315. "text_to_speech": {
  1316. "enabled": true,
  1317. "voice": "sambert-zhinan-v1",
  1318. "language": "zh-Hans",
  1319. "autoPlay": "disabled"
  1320. },
  1321. "retriever_resource": {
  1322. "enabled": true
  1323. },
  1324. "annotation_reply": {
  1325. "enabled": true
  1326. },
  1327. "user_input_form": [
  1328. {
  1329. "paragraph": {
  1330. "label": "クエリ",
  1331. "variable": "query",
  1332. "required": true,
  1333. "default": ""
  1334. }
  1335. }
  1336. ],
  1337. "file_upload": {
  1338. "image": {
  1339. "enabled": false,
  1340. "number_limits": 3,
  1341. "detail": "high",
  1342. "transfer_methods": [
  1343. "remote_url",
  1344. "local_file"
  1345. ]
  1346. }
  1347. },
  1348. "system_parameters": {
  1349. "file_size_limit": 15,
  1350. "image_file_size_limit": 10,
  1351. "audio_file_size_limit": 50,
  1352. "video_file_size_limit": 100
  1353. }
  1354. }
  1355. ```
  1356. </CodeGroup>
  1357. </Col>
  1358. </Row>
  1359. ---
  1360. <Heading
  1361. url='/meta'
  1362. method='GET'
  1363. title='アプリケーションのメタ情報を取得'
  1364. name='#meta'
  1365. />
  1366. <Row>
  1367. <Col>
  1368. このアプリケーションのツールのアイコンを取得するために使用されます
  1369. ### 応答
  1370. - `tool_icons`(object[string]) ツールアイコン
  1371. - `tool_name` (string)
  1372. - `icon` (object|string)
  1373. - (object) アイコンオブジェクト
  1374. - `background` (string) 背景色(16 進数形式)
  1375. - `content`(string) 絵文字
  1376. - (string) アイコンの URL
  1377. </Col>
  1378. <Col>
  1379. <CodeGroup title="リクエスト" tag="GET" label="/meta" targetCode={`curl -X GET '${props.appDetail.api_base_url}/meta' \\\n-H 'Authorization: Bearer {api_key}'`}>
  1380. ```bash {{ title: 'cURL' }}
  1381. curl -X GET '${props.appDetail.api_base_url}/meta' \
  1382. -H 'Authorization: Bearer {api_key}'
  1383. ```
  1384. </CodeGroup>
  1385. <CodeGroup title="応答">
  1386. ```json {{ title: '応答' }}
  1387. {
  1388. "tool_icons": {
  1389. "dalle2": "https://cloud.dify.ai/console/api/workspaces/current/tool-provider/builtin/dalle/icon",
  1390. "api_tool": {
  1391. "background": "#252525",
  1392. "content": "\ud83d\ude01"
  1393. }
  1394. }
  1395. }
  1396. ```
  1397. </CodeGroup>
  1398. </Col>
  1399. </Row>
  1400. ---
  1401. <Heading
  1402. url='/site'
  1403. method='GET'
  1404. title='アプリのWebApp設定を取得'
  1405. name='#site'
  1406. />
  1407. <Row>
  1408. <Col>
  1409. アプリの WebApp 設定を取得するために使用します。
  1410. ### 応答
  1411. - `title` (string) WebApp 名
  1412. - `chat_color_theme` (string) チャットの色テーマ、16 進数形式
  1413. - `chat_color_theme_inverted` (bool) チャットの色テーマを反転するかどうか
  1414. - `icon_type` (string) アイコンタイプ、`emoji`-絵文字、`image`-画像
  1415. - `icon` (string) アイコン。`emoji`タイプの場合は絵文字、`image`タイプの場合は画像 URL
  1416. - `icon_background` (string) 16 進数形式の背景色
  1417. - `icon_url` (string) アイコンの URL
  1418. - `description` (string) 説明
  1419. - `copyright` (string) 著作権情報
  1420. - `privacy_policy` (string) プライバシーポリシーのリンク
  1421. - `custom_disclaimer` (string) カスタム免責事項
  1422. - `default_language` (string) デフォルト言語
  1423. - `show_workflow_steps` (bool) ワークフローの詳細を表示するかどうか
  1424. - `use_icon_as_answer_icon` (bool) WebApp のアイコンをチャット内の🤖に置き換えるかどうか
  1425. </Col>
  1426. <Col>
  1427. <CodeGroup title="Request" tag="POST" label="/meta" targetCode={`curl -X GET '${props.appDetail.api_base_url}/site' \\\n-H 'Authorization: Bearer {api_key}'`}>
  1428. ```bash {{ title: 'cURL' }}
  1429. curl -X GET '${props.appDetail.api_base_url}/site' \
  1430. -H 'Authorization: Bearer {api_key}'
  1431. ```
  1432. </CodeGroup>
  1433. <CodeGroup title="Response">
  1434. ```json {{ title: 'Response' }}
  1435. {
  1436. "title": "My App",
  1437. "chat_color_theme": "#ff4a4a",
  1438. "chat_color_theme_inverted": false,
  1439. "icon_type": "emoji",
  1440. "icon": "😄",
  1441. "icon_background": "#FFEAD5",
  1442. "icon_url": null,
  1443. "description": "This is my app.",
  1444. "copyright": "all rights reserved",
  1445. "privacy_policy": "",
  1446. "custom_disclaimer": "All generated by AI",
  1447. "default_language": "en-US",
  1448. "show_workflow_steps": false,
  1449. "use_icon_as_answer_icon": false,
  1450. }
  1451. ```
  1452. </CodeGroup>
  1453. </Col>
  1454. </Row>
  1455. ___