| | |
| | | |
| | | ### ChatCompletionResponse |
| | | 完全なアプリ結果を返します。`Content-Type`は`application/json`です。 |
| | | - `event` (string) イベントタイプ、固定で `message` |
| | | - `task_id` (string) タスクID、リクエスト追跡と以下のStop Generate APIに使用 |
| | | - `id` (string) ユニークID |
| | | - `message_id` (string) 一意のメッセージID |
| | | - `conversation_id` (string) 会話ID |
| | | - `mode` (string) アプリモード、`chat`として固定 |
| | |
| | | ```json {{ title: '応答' }} |
| | | { |
| | | "event": "message", |
| | | "task_id": "c3800678-a077-43df-a102-53f23ed20b88", |
| | | "id": "9da23599-e713-473b-982c-4328d4f5c78a", |
| | | "message_id": "9da23599-e713-473b-982c-4328d4f5c78a", |
| | | "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", |
| | | "mode": "chat", |
| | |
| | | data: {"event": "message", "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": "'m", "created_at": 1679586595} |
| | | data: {"event": "message", "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " glad", "created_at": 1679586595} |
| | | data: {"event": "message", "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " to", "created_at": 1679586595} |
| | | data: {"event": "message", "message_id" : "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " meet", "created_at": 1679586595} |
| | | data: {"event": "message", "message_id" : "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " you", "created_at": 1679586595} |
| | | data: {"event": "message", "message_id": : "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " meet", "created_at": 1679586595} |
| | | data: {"event": "message", "message_id": : "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " you", "created_at": 1679586595} |
| | | 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\""}]}} |
| | | 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"} |
| | | 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": ""} |
| | |
| | | </Row> |
| | | |
| | | --- |
| | | |
| | | <Heading |
| | | url='/app/feedbacks' |
| | | method='GET' |
| | | title='アプリのメッセージの「いいね」とフィードバックを取得' |
| | | name='#app-feedbacks' |
| | | /> |
| | | <Row> |
| | | <Col> |
| | | アプリのエンドユーザーからのフィードバックや「いいね」を取得します。 |
| | | |
| | | ### クエリ |
| | | <Properties> |
| | | <Property name='page' type='string' key='page'> |
| | | (任意)ページ番号。デフォルト値:1 |
| | | </Property> |
| | | </Properties> |
| | | |
| | | <Properties> |
| | | <Property name='limit' type='string' key='limit'> |
| | | (任意)1ページあたりの件数。デフォルト値:20 |
| | | </Property> |
| | | </Properties> |
| | | |
| | | ### レスポンス |
| | | - `data` (リスト) このアプリの「いいね」とフィードバックの一覧を返します。 |
| | | </Col> |
| | | <Col sticky> |
| | | |
| | | <CodeGroup title="Request" tag="GET" label="/app/feedbacks" targetCode={`curl -X GET '${props.appDetail.api_base_url}/app/feedbacks?page=1&limit=20'`}> |
| | | |
| | | ```bash {{ title: 'cURL' }} |
| | | curl -X GET '${props.appDetail.api_base_url}/app/feedbacks?page=1&limit=20' \ |
| | | --header 'Authorization: Bearer {api_key}' \ |
| | | --header 'Content-Type: application/json' |
| | | ``` |
| | | |
| | | </CodeGroup> |
| | | |
| | | <CodeGroup title="Response"> |
| | | ```json {{ title: 'Response' }} |
| | | { |
| | | "data": [ |
| | | { |
| | | "id": "8c0fbed8-e2f9-49ff-9f0e-15a35bdd0e25", |
| | | "app_id": "f252d396-fe48-450e-94ec-e184218e7346", |
| | | "conversation_id": "2397604b-9deb-430e-b285-4726e51fd62d", |
| | | "message_id": "709c0b0f-0a96-4a4e-91a4-ec0889937b11", |
| | | "rating": "like", |
| | | "content": "message feedback information-3", |
| | | "from_source": "user", |
| | | "from_end_user_id": "74286412-9a1a-42c1-929c-01edb1d381d5", |
| | | "from_account_id": null, |
| | | "created_at": "2025-04-24T09:24:38", |
| | | "updated_at": "2025-04-24T09:24:38" |
| | | } |
| | | ] |
| | | } |
| | | ``` |
| | | </CodeGroup> |
| | | </Col> |
| | | </Row> |
| | | --- |
| | | |
| | | |
| | | <Heading |
| | | url='/messages/{message_id}/suggested' |
| | |
| | | </CodeGroup> |
| | | |
| | | <CodeGroup title="応答"> |
| | | ```text {{ title: '応答' }} |
| | | 204 No Content |
| | | ```json {{ title: '応答' }} |
| | | { |
| | | "result": "success" |
| | | } |
| | | ``` |
| | | </CodeGroup> |
| | | </Col> |
| | |
| | | --- |
| | | |
| | | <Heading |
| | | url='/conversations/:conversation_id/variables' |
| | | method='GET' |
| | | title='会話変数の取得' |
| | | name='#conversation-variables' |
| | | /> |
| | | <Row> |
| | | <Col> |
| | | 特定の会話から変数を取得します。このエンドポイントは、会話中に取得された構造化データを抽出するのに役立ちます。 |
| | | |
| | | ### パスパラメータ |
| | | |
| | | <Properties> |
| | | <Property name='conversation_id' type='string' key='conversation_id'> |
| | | 変数を取得する会話のID。 |
| | | </Property> |
| | | </Properties> |
| | | |
| | | ### クエリパラメータ |
| | | |
| | | <Properties> |
| | | <Property name='user' type='string' key='user'> |
| | | ユーザー識別子。開発者によって定義されたルールに従い、アプリケーション内で一意である必要があります。 |
| | | </Property> |
| | | <Property name='last_id' type='string' key='last_id'> |
| | | (Optional)現在のページの最後の記録のID、デフォルトはnullです。 |
| | | </Property> |
| | | <Property name='limit' type='int' key='limit'> |
| | | (Optional)1回のリクエストで返す記録の数、デフォルトは最新の20件です。最大100、最小1。 |
| | | </Property> |
| | | </Properties> |
| | | |
| | | ### レスポンス |
| | | |
| | | - `limit` (int) ページごとのアイテム数 |
| | | - `has_more` (bool) さらにアイテムがあるかどうか |
| | | - `data` (array[object]) 変数のリスト |
| | | - `id` (string) 変数ID |
| | | - `name` (string) 変数名 |
| | | - `value_type` (string) 変数タイプ(文字列、数値、真偽値など) |
| | | - `value` (string) 変数値 |
| | | - `description` (string) 変数の説明 |
| | | - `created_at` (int) 作成タイムスタンプ |
| | | - `updated_at` (int) 最終更新タイムスタンプ |
| | | |
| | | ### エラー |
| | | - 404, `conversation_not_exists`, 会話が見つかりません |
| | | |
| | | </Col> |
| | | <Col sticky> |
| | | |
| | | <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}'`}> |
| | | |
| | | ```bash {{ title: 'cURL' }} |
| | | curl -X GET '${props.appDetail.api_base_url}/conversations/{conversation_id}/variables?user=abc-123' \ |
| | | --header 'Authorization: Bearer {api_key}' |
| | | ``` |
| | | |
| | | </CodeGroup> |
| | | |
| | | <CodeGroup title="Request with variable name filter"> |
| | | ```bash {{ title: 'cURL' }} |
| | | curl -X GET '${props.appDetail.api_base_url}/conversations/{conversation_id}/variables?user=abc-123&variable_name=customer_name' \ |
| | | --header 'Authorization: Bearer {api_key}' |
| | | ``` |
| | | </CodeGroup> |
| | | |
| | | <CodeGroup title="Response"> |
| | | ```json {{ title: 'Response' }} |
| | | { |
| | | "limit": 100, |
| | | "has_more": false, |
| | | "data": [ |
| | | { |
| | | "id": "variable-uuid-1", |
| | | "name": "customer_name", |
| | | "value_type": "string", |
| | | "value": "John Doe", |
| | | "description": "会話から抽出された顧客名", |
| | | "created_at": 1650000000000, |
| | | "updated_at": 1650000000000 |
| | | }, |
| | | { |
| | | "id": "variable-uuid-2", |
| | | "name": "order_details", |
| | | "value_type": "json", |
| | | "value": "{\"product\":\"Widget\",\"quantity\":5,\"price\":19.99}", |
| | | "description": "顧客の注文詳細", |
| | | "created_at": 1650000000000, |
| | | "updated_at": 1650000000000 |
| | | } |
| | | ] |
| | | } |
| | | ``` |
| | | </CodeGroup> |
| | | </Col> |
| | | </Row> |
| | | |
| | | --- |
| | | |
| | | <Heading |
| | | url='/audio-to-text' |
| | | method='POST' |
| | | title='音声からテキストへ' |
| | |
| | | </CodeGroup> |
| | | |
| | | <CodeGroup title="応答"> |
| | | ```json {{ title: '応答' }} |
| | | ```json {{ text: 'hello' }} |
| | | { |
| | | "text": "" |
| | | } |
| | |
| | | ### リクエストボディ |
| | | |
| | | <Properties> |
| | | <Property name='message_id' type='str' key='message_id'> |
| | | <Property name='message_id' type='str' key='text'> |
| | | Difyによって生成されたテキストメッセージの場合、生成されたメッセージIDを直接渡します。バックエンドはメッセージIDを使用して対応する内容を検索し、音声情報を直接合成します。message_idとtextが同時に提供される場合、message_idが優先されます。 |
| | | </Property> |
| | | <Property name='text' type='str' key='text'> |
| | |
| | | </CodeGroup> |
| | | </Col> |
| | | </Row> |
| | | |
| | | --- |
| | | |
| | | <Heading |
| | | url='/site' |
| | | method='GET' |
| | | title='アプリのWebApp設定を取得' |
| | | name='#site' |
| | | /> |
| | | <Row> |
| | | <Col> |
| | | アプリのWebApp設定を取得するために使用します。 |
| | | ### 応答 |
| | | - `title` (string) WebApp名 |
| | | - `chat_color_theme` (string) チャットの色テーマ、16進数形式 |
| | | - `chat_color_theme_inverted` (bool) チャットの色テーマを反転するかどうか |
| | | - `icon_type` (string) アイコンタイプ、`emoji`-絵文字、`image`-画像 |
| | | - `icon` (string) アイコン。`emoji`タイプの場合は絵文字、`image`タイプの場合は画像URL |
| | | - `icon_background` (string) 16進数形式の背景色 |
| | | - `icon_url` (string) アイコンのURL |
| | | - `description` (string) 説明 |
| | | - `copyright` (string) 著作権情報 |
| | | - `privacy_policy` (string) プライバシーポリシーのリンク |
| | | - `custom_disclaimer` (string) カスタム免責事項 |
| | | - `default_language` (string) デフォルト言語 |
| | | - `show_workflow_steps` (bool) ワークフローの詳細を表示するかどうか |
| | | - `use_icon_as_answer_icon` (bool) WebAppのアイコンをチャット内の🤖に置き換えるかどうか |
| | | </Col> |
| | | <Col> |
| | | <CodeGroup title="Request" tag="POST" label="/meta" targetCode={`curl -X GET '${props.appDetail.api_base_url}/site' \\\n-H 'Authorization: Bearer {api_key}'`}> |
| | | ```bash {{ title: 'cURL' }} |
| | | curl -X GET '${props.appDetail.api_base_url}/site' \ |
| | | -H 'Authorization: Bearer {api_key}' |
| | | ``` |
| | | |
| | | </CodeGroup> |
| | | |
| | | <CodeGroup title="Response"> |
| | | ```json {{ title: 'Response' }} |
| | | { |
| | | "title": "My App", |
| | | "chat_color_theme": "#ff4a4a", |
| | | "chat_color_theme_inverted": false, |
| | | "icon_type": "emoji", |
| | | "icon": "😄", |
| | | "icon_background": "#FFEAD5", |
| | | "icon_url": null, |
| | | "description": "This is my app.", |
| | | "copyright": "all rights reserved", |
| | | "privacy_policy": "", |
| | | "custom_disclaimer": "All generated by AI", |
| | | "default_language": "en-US", |
| | | "show_workflow_steps": false, |
| | | "use_icon_as_answer_icon": false, |
| | | } |
| | | ``` |
| | | </CodeGroup> |
| | | </Col> |
| | | </Row> |
| | | ___ |