[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

@@ -1011,6 +1011,121 @@ Chat applications support session persistence, allowing previous chat history to
---
<Heading
url='/conversations/:conversation_id/variables/:variable_id'
method='PUT'
title='Update Conversation Variable'
name='#update-conversation-variable'
/>
<Row>
<Col>
Update the value of a specific conversation variable. This endpoint allows you to modify the value of a variable that was captured during the conversation while preserving its name, type, and description.
### Path Parameters
<Properties>
<Property name='conversation_id' type='string' key='conversation_id'>
The ID of the conversation containing the variable to update.
</Property>
<Property name='variable_id' type='string' key='variable_id'>
The ID of the variable to update.
</Property>
</Properties>
### Request Body
<Properties>
<Property name='value' type='any' key='value'>
The new value for the variable. Must match the variable's expected type (string, number, object, etc.).
</Property>
<Property name='user' type='string' key='user'>
The user identifier, defined by the developer, must ensure uniqueness within the application.
</Property>
</Properties>
### Response
Returns the updated variable object with:
- `id` (string) Variable ID
- `name` (string) Variable name
- `value_type` (string) Variable type (string, number, object, etc.)
- `value` (any) Updated variable value
- `description` (string) Variable description
- `created_at` (int) Creation timestamp
- `updated_at` (int) Last update timestamp
### Errors
- 400, `Type mismatch: variable expects {expected_type}, but got {actual_type} type`, Value type doesn't match variable's expected type
- 404, `conversation_not_exists`, Conversation not found
- 404, `conversation_variable_not_exists`, Variable not found
</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="Update with different value types">
```bash {{ title: 'String Value' }}
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": "New string value",
"user": "abc-123"
}'
```
```bash {{ title: 'Number Value' }}
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: 'Object Value' }}
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": "Customer name extracted from the conversation",
"created_at": 1650000000000,
"updated_at": 1650000001000
}
```
</CodeGroup>
</Col>
</Row>
---
<Heading
url='/audio-to-text'
method='POST'

View File

@@ -1011,6 +1011,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'

View File

@@ -1049,6 +1049,121 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx'
---
<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'

View File

@@ -1045,6 +1045,121 @@ Chat applications support session persistence, allowing previous chat history to
---
<Heading
url='/conversations/:conversation_id/variables/:variable_id'
method='PUT'
title='Update Conversation Variable'
name='#update-conversation-variable'
/>
<Row>
<Col>
Update the value of a specific conversation variable. This endpoint allows you to modify the value of a variable that was captured during the conversation while preserving its name, type, and description.
### Path Parameters
<Properties>
<Property name='conversation_id' type='string' key='conversation_id'>
The ID of the conversation containing the variable to update.
</Property>
<Property name='variable_id' type='string' key='variable_id'>
The ID of the variable to update.
</Property>
</Properties>
### Request Body
<Properties>
<Property name='value' type='any' key='value'>
The new value for the variable. Must match the variable's expected type (string, number, object, etc.).
</Property>
<Property name='user' type='string' key='user'>
The user identifier, defined by the developer, must ensure uniqueness within the application.
</Property>
</Properties>
### Response
Returns the updated variable object with:
- `id` (string) Variable ID
- `name` (string) Variable name
- `value_type` (string) Variable type (string, number, object, etc.)
- `value` (any) Updated variable value
- `description` (string) Variable description
- `created_at` (int) Creation timestamp
- `updated_at` (int) Last update timestamp
### Errors
- 400, `Type mismatch: variable expects {expected_type}, but got {actual_type} type`, Value type doesn't match variable's expected type
- 404, `conversation_not_exists`, Conversation not found
- 404, `conversation_variable_not_exists`, Variable not found
</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="Update with different value types">
```bash {{ title: 'String Value' }}
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": "New string value",
"user": "abc-123"
}'
```
```bash {{ title: 'Number Value' }}
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: 'Object Value' }}
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": "Customer name extracted from the conversation",
"created_at": 1650000000000,
"updated_at": 1650000001000
}
```
</CodeGroup>
</Col>
</Row>
---
<Heading
url='/audio-to-text'
method='POST'

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'

View File

@@ -1060,6 +1060,121 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx'
---
<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'