---
name: "initializePanelAgentRoleBinding"
mode: "kit"
versionRequirements:
  - { name: "@tuya-miniapp/cloud-api", version: "1.0.6" }
---

## initializePanelAgentRoleBinding

> [VERSION] @tuya-miniapp/cloud-api >= 1.0.6

> 💡 接口依赖云能力，需在 [小程序开发者平台](https://platform.tuya.com/miniapp/)开发设置 - 云能力 进行授权配置。

### 方法签名

```typescript
initializePanelAgentRoleBinding(params: InitializePanelAgentRoleBindingParams)
```

### 描述

初始化角色和智能体绑定关系。

### 参数

`Params`

| 参数 | 类型 | 必填 | 默认值 | 描述 |
| --- | --- | --- | --- | --- |
| `params` | `InitializePanelAgentRoleBindingParams` | 是 | - | 请求体 |

### 返回值

类型: `Promise<PanelAgentRoleDetail>`

InitializePanelAgentRoleBindingResult（字段含义见类型定义与 minituya 返回参数）

### 引用对象

##### `interface` InitializePanelAgentRoleBindingParams

| 属性 | 类型 | 必填 | 描述 |
| --- | --- | --- | --- |
| `devId` | `string` | 是 | 设备ID |

##### `type` PanelAgentRoleDetail

| 属性 | 类型 | 描述 |
| --- | --- | --- |
| `roleId` | `string` | 角色id |
| `roleName` | `string` | 角色名称 |
| `roleDesc` | `string` | 角色描述 |
| `roleIntroduce` | `string` | 角色介绍 |
| `roleImgUrl` | `string` | 角色图像 |
| `useLangCode` | `string` | 角色使用语言code |
| `useLangName` | `string` | 角色使用语言名称 |
| `useTimbreId` | `string` | 角色使用音色 |
| `isUserCloneTimbre` | `boolean` | 是否是自定义克隆音色 |
| `useTimbreName` | `string` | 角色使用音色名称 |
| `useTimbreSupportLangs` | `string` | 角色支持的音色语言,多个用逗号分隔 |
| `useTimbreSupportLangList` | `string[]` | 角色支持的音色语言列表 |
| `useTimbreTags` | `string[]` | 角色标签 |
| `useLlmId` | `string` | 角色使用语言模型 |
| `useLlmName` | `string` | 角色使用语言模型名称 |
| `inBind` | `boolean` | 是否绑定 |
| `memoryInfo` | `string` | 记忆体 |
| `speed` | `number` | 音色速度 |
| `tone` | `number` | 音色语气 |
| `templateId` | `string` | 模板id |
| `bindRoleType` | `number` | 绑定角色类型 |
| `lastTextAnswer` | `string` | 最近的一次回复文本 |
| `llmSupportFuncTags` | `string` | 语言模型支持的函数标签，多个用逗号分隔 |


### 示例代码

#### 请求示例

```typescript
import { initializePanelAgentRoleBinding } from '@tuya-miniapp/cloud-api';

const params = {
  devId: 'your_device_id',
};

initializePanelAgentRoleBinding(params)
  .then(result => {
    console.log('初始化绑定关系结果:', result);
  })
  .catch(error => {
    console.error('初始化绑定关系失败:', error);
  });
```

#### 返回示例

```json
{
  "roleId": "role_initialized_001",
  "roleName": "初始化智能助手",
  "roleDesc": "系统初始化的默认智能助手",
  "roleIntroduce": "我是系统为您初始化的智能助手",
  "roleImgUrl": "https://example.com/default_avatar.jpg",
  "useLangCode": "zh-CN",
  "useLangName": "中文（简体）",
  "useTimbreId": "timbre_default_001",
  "isUserCloneTimbre": false,
  "useTimbreName": "默认音色",
  "useTimbreSupportLangs": "zh-CN",
  "useTimbreSupportLangList": ["zh-CN"],
  "useTimbreTags": ["默认", "初始"],
  "useLlmId": "1001",
  "useLlmName": "GPT-3.5-turbo",
  "inBind": true,
  "memoryInfo": "初始化记忆信息",
  "speed": 1.0,
  "tone": 0.5,
  "templateId": "default_template",
  "bindRoleType": 2,
  "lastTextAnswer": "您好，我是您的智能助手，很高兴为您服务！",
  "llmSupportFuncTags": "text"
}
```
