[Enhancement] Allow modify conversation variable via api (#23112)

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
Alex Chim
2025-08-01 09:34:56 +08:00
committed by GitHub
parent 1821726d4f
commit 8ab3fda5a8
9 changed files with 816 additions and 2 deletions

View File

@@ -1044,6 +1044,121 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from
---
<Heading
url='/conversations/:conversation_id/variables/:variable_id'
method='PUT'
title='会話変数の更新'
name='#update-conversation-variable'
/>
<Row>
<Col>
特定の会話変数の値を更新します。このエンドポイントは、名前、型、説明を保持しながら、会話中にキャプチャされた変数の値を変更することを可能にします。
### パスパラメータ
<Properties>
<Property name='conversation_id' type='string' key='conversation_id'>
更新する変数を含む会話のID。
</Property>
<Property name='variable_id' type='string' key='variable_id'>
更新する変数のID。
</Property>
</Properties>
### リクエストボディ
<Properties>
<Property name='value' type='any' key='value'>
変数の新しい値。変数の期待される型(文字列、数値、オブジェクトなど)と一致する必要があります。
</Property>
<Property name='user' type='string' key='user'>
ユーザー識別子。開発者によって定義されたルールに従い、アプリケーション内で一意である必要があります。
</Property>
</Properties>
### レスポンス
以下を含む更新された変数オブジェクトを返します:
- `id` (string) 変数ID
- `name` (string) 変数名
- `value_type` (string) 変数型(文字列、数値、オブジェクトなど)
- `value` (any) 更新された変数値
- `description` (string) 変数の説明
- `created_at` (int) 作成タイムスタンプ
- `updated_at` (int) 最終更新タイムスタンプ
### エラー
- 400, `Type mismatch: variable expects {expected_type}, but got {actual_type} type`, 値の型が変数の期待される型と一致しません
- 404, `conversation_not_exists`, 会話が見つかりません
- 404, `conversation_variable_not_exists`, 変数が見つかりません
</Col>
<Col sticky>
<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}'`}>
```bash {{ title: 'cURL' }}
curl -X PUT '${props.appDetail.api_base_url}/conversations/{conversation_id}/variables/{variable_id}' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {api_key}' \
--data-raw '{
"value": "Updated Value",
"user": "abc-123"
}'
```
</CodeGroup>
<CodeGroup title="異なる値型での更新">
```bash {{ title: '文字列値' }}
curl -X PUT '${props.appDetail.api_base_url}/conversations/{conversation_id}/variables/{variable_id}' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {api_key}' \
--data-raw '{
"value": "新しい文字列値",
"user": "abc-123"
}'
```
```bash {{ title: '数値' }}
curl -X PUT '${props.appDetail.api_base_url}/conversations/{conversation_id}/variables/{variable_id}' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {api_key}' \
--data-raw '{
"value": 42,
"user": "abc-123"
}'
```
```bash {{ title: 'オブジェクト値' }}
curl -X PUT '${props.appDetail.api_base_url}/conversations/{conversation_id}/variables/{variable_id}' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {api_key}' \
--data-raw '{
"value": {"product": "Widget", "quantity": 10, "price": 29.99},
"user": "abc-123"
}'
```
</CodeGroup>
<CodeGroup title="Response">
```json {{ title: 'Response' }}
{
"id": "variable-uuid-1",
"name": "customer_name",
"value_type": "string",
"value": "Updated Value",
"description": "会話から抽出された顧客名",
"created_at": 1650000000000,
"updated_at": 1650000001000
}
```
</CodeGroup>
</Col>
</Row>
---
<Heading
url='/audio-to-text'
method='POST'