1# @ohos.app.ability.InsightIntentDecorator (意图装饰器定义) 2 3<!--Kit: Ability Kit--> 4<!--Subsystem: Ability--> 5<!--Owner: @linjunjie6--> 6<!--Designer: @li-weifeng2--> 7<!--Tester: @lixueqing513--> 8<!--Adviser: @huipeizi--> 9 10InsightIntentDecorator模块提供了几类意图装饰器,用于装饰类或方法。开发者可以[使用装饰器开发意图](../../application-models/insight-intent-decorator-development.md), 将应用的功能定义为意图,并集成到智能问答、智能搜索、智能推荐等AI入口。 11 12- [@InsightIntentLink](#insightintentlink)装饰器:使用该装饰器装饰当前应用的uri链接,可以将该uri链接定义为意图,便于AI入口通过意图快速跳转到当前应用。该装饰器支持的参数参见[LinkIntentDecoratorInfo](#linkintentdecoratorinfo)。 13- [@InsightIntentPage](#insightintentpage)装饰器:使用该装饰器装饰当前应用的Page页面,可以将该Page页面定义为意图,便于AI入口通过意图快速跳转到当前Page页面。该装饰器支持的参数参见[PageIntentDecoratorInfo](#pageintentdecoratorinfo)。 14- [@InsightIntentFunction](#insightintentfunction)装饰器与[@InsightIntentFunctionMethod](#insightintentfunctionmethod)装饰器:两者必须组合使用。使用[@InsightIntentFunction](#insightintentfunction)装饰器来装饰类,同时使用[@InsightIntentFunctionMethod](#insightintentfunctionmethod)装饰器来装饰类中的静态函数,可以将对应的静态函数定义为意图,便于AI入口能够快速执行此函数。 15- [@InsightIntentEntry](#insightintententry)装饰器:使用该装饰器装饰一个继承自[InsightIntentEntryExecutor](./js-apis-app-ability-InsightIntentEntryExecutor.md)的类,实现意图操作并配置意图依赖的Ability组件,便于AI入口拉起依赖的Ability组件时,执行对应的意图操作。该装饰器支持的参数参见[EntryIntentDecoratorInfo](#entryintentdecoratorinfo)。 16- [@InsightIntentForm](#insightintentform)装饰器:使用该装饰器装饰[FormExtensionAbility](../apis-form-kit/js-apis-app-form-formExtensionAbility.md)并配置FormExtensionAbility绑定的卡片名称,便于AI入口通过意图添加卡片。该装饰器支持的参数参见[FormIntentDecoratorInfo](#formintentdecoratorinfo)。 17- [@InsightIntentEntity](#insightintententity)装饰器:使用该装饰器装饰一个继承自[IntentEntity](./js-apis-app-ability-insightIntent.md#intententity20)的类,可将该类定义为意图实体,用于传递意图调用时所需的参数。该装饰器支持的参数参见[IntentEntityDecoratorInfo](#intententitydecoratorinfo)。 18 19> **说明:** 20> 21> 本模块首批接口从API version 20开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 22> 23> 本模块接口仅可在Stage模型下使用。 24 25## 基本概念 26 27意图可以分为标准意图和自定义意图。 28 29系统会根据[IntentDecoratorInfo](#intentdecoratorinfo)中的schema与intentVersion字段,在标准意图列表查询是否存在匹配的意图。 30 31- 如果存在匹配的意图,则对应的意图为标准意图。 32- 如果不存在匹配的意图,则对应的意图为自定义意图。 33 34## 导入模块 35 36```ts 37import { InsightIntentLink, InsightIntentPage, InsightIntentFunctionMethod, InsightIntentFunction, InsightIntentEntry } from '@kit.AbilityKit'; 38``` 39 40## @InsightIntentLink 41 42使用该装饰器装饰当前应用的uri链接,可以将该uri链接定义为意图,便于AI入口通过定义的意图快速跳转到当前应用。该装饰器支持的参数参见[LinkIntentDecoratorInfo](#linkintentdecoratorinfo)。 43 44> **说明** 45> 46> uri链接格式需要符合[应用链接说明](../../application-models/app-uri-config.md)中的要求。 47 48**系统能力**:SystemCapability.Ability.AbilityRuntime.Core 49 50**原子化服务API**:从API version 20开始,该接口支持在原子化服务中使用。 51 52**示例:** 53 54以自定义意图为例:自定义意图的parameters需要传入标准的JSON Schema数据结构。 55 56```ts 57import { InsightIntentLink, LinkParamCategory } from '@kit.AbilityKit'; 58 59@InsightIntentLink({ 60 intentName: 'PlayMusic', 61 domain: 'MusicDomain', 62 intentVersion: '1.0.1', 63 displayName: '播放歌曲', 64 displayDescription: '播放音乐意图', 65 icon: $r('app.media.app_icon'), 66 llmDescription: '支持传递歌曲名称,播放音乐', 67 keywords: ['音乐播放', '播放歌曲', 'PlayMusic'], 68 uri: 'https://www.example.com/music/', 69 paramMappings: [{ 70 paramName: 'songName', 71 paramMappingName: 'music', 72 paramCategory: LinkParamCategory.LINK 73 }], 74 parameters: { 75 'schema': 'http://json-schema.org/draft-07/schema#', 76 'type': 'object', 77 'title': 'Song Schema', 78 'description': 'A schema for describing songs and their artists', 79 'properties': { 80 'songName': { 81 'type': 'string', 82 'description': 'The name of the song', 83 'minLength': 1 84 } 85 }, 86 'required': ['songName'], 87 'additionalProperties': false 88 }, 89 result: { 90 'type': 'object', 91 'propertyNames': { 92 'enum': [ 93 'code', 94 'result' 95 ] 96 }, 97 'required': [ 98 'code', 99 'result' 100 ], 101 'properties': { 102 'code': { 103 'description': '执行结果码', 104 'type': 'number' 105 }, 106 'result': {} 107 } 108 } 109}) 110export class ClassForLink { 111 private _playback: string = 'intention_test'; 112 113 public set playback(value: string) { 114 this._playback = value; 115 } 116 117 public get playback(): string { 118 return this._playback; 119 } 120 121 constructor(playback: string) { 122 this._playback = playback; 123 } 124 125 static Function1(playbackProgress: number, playback?: number): void { 126 console.log('Function1' + playbackProgress); 127 } 128} 129``` 130 131## IntentDecoratorInfo 132 133意图装饰器的通用属性,用于定义意图的基本信息(包括意图名称、意图版本号)。适用于本模块的所有装饰器。 134 135**系统能力**:SystemCapability.Ability.AbilityRuntime.Core 136 137**原子化服务API**:从API version 20开始,该接口支持在原子化服务中使用。 138 139**属性:** 140 141> **说明:** 142> 143> 如果根据schema与intentVersion字段,在标准意图列表存在匹配的标准意图,系统会将intentName、domain、llmDescription、keywords、parameters、result字段均设置为标准意图的相应字段值。 144 145| 名称 | 类型 | 只读 | 可选 | 说明 | 146| ------------------ | ----------------| ---------- | ---- | ------------------------------------------------------------ | 147| intentName | string | 否 | 否 | 表示意图名称,是意图的唯一标识。 | 148| domain | string | 否 | 否 | 表示意图垂域,用于将意图按垂直领域分类(例如:视频、音乐、游戏),取值范围参见[各垂域的智慧分发特性列表](https://developer.huawei.com/consumer/cn/doc/service/intents-ai-distribution-characteristic-0000001901922213#section2656133582215)中的垂域字段。 | 149| intentVersion | string | 否 | 否 | 表示意图版本号。当意图能力演进时,可通过版本号进行区分和管理。 | 150| displayName | string | 否 | 否 | 表示显示给用户的意图名称。 | 151| displayDescription | string | 否 | 是 | 表示显示给用户的意图描述。 | 152| schema | string | 否 | 是 | 表示接入的标准意图的名称。开发者[接入标准意图](../../application-models/insight-intent-definition.md#接入标准意图)时,需要配置该字段,[创建自定义意图](../../application-models/insight-intent-definition.md#创建自定义意图)时,无需配置该字段。标准意图列表参见[附录:标准意图接入规范](../../application-models/insight-intent-access-specifications.md)。 | 153| icon | ResourceStr | 否 | 是 | 表示意图图标,用于在AI入口显示。<br/>- 当取值为字符串类型时,表示图标读取网络资源。<br/>- 当取值为[Resource](../../reference/apis-localization-kit/js-apis-resource-manager.md)时,表示图标读取本地资源。 | 154| llmDescription | string | 否 | 是 | 表示意图的功能,用于大型语言模型理解该意图。 | 155| keywords | string[] | 否 | 是 | 表示意图的搜索关键字。 | 156| parameters | Record<string, Object>| 否 | 是 | 表示意图参数的数据格式声明,用于意图调用时定义入参的数据格式。取值参见[各垂域意图Schema](https://developer.huawei.com/consumer/cn/doc/service/intents-schema-0000001901962713) | 157| result | Record<string, Object> | 否 | 是 | 表示意图调用返回结果的数据格式声明,用于定义意图调用返回结果的数据格式。 | 158 159## LinkIntentDecoratorInfo 160 161LinkIntentDecoratorInfo继承自[IntentDecoratorInfo](#intentdecoratorinfo),用于描述[@InsightIntentLink](#insightintentlink)装饰器支持的参数,例如应用间跳转需要的uri信息。 162 163**系统能力**:SystemCapability.Ability.AbilityRuntime.Core 164 165**原子化服务API**:从API version 20开始,该接口支持在原子化服务中使用。 166 167**属性:** 168 169| 名称 | 类型 | 只读 | 可选 | 说明 | 170| ----------- | -----------------| ------ | ---- | ------------------------------------------------------------ | 171| uri | string | 否 | 否 | 表示意图的uri信息。 | 172| paramMappings | [LinkIntentParamMapping](#linkintentparammapping)[] | 否 | 是 | 意图参数和uri信息的映射。 | 173 174## LinkIntentParamMapping 175 176LinkIntentParamMapping是[@InsightIntentLink](#insightintentlink)装饰器的意图参数和uri信息的映射。 177 178**系统能力**:SystemCapability.Ability.AbilityRuntime.Core 179 180**原子化服务API**:从API version 20开始,该接口支持在原子化服务中使用。 181 182**属性:** 183 184| 名称 | 类型 | 只读 | 可选 | 说明 | 185| ---------------- | ------ | ----| ---- | -------------------------------------- | 186| paramName | string | 否 | 否 | 表示意图参数的名称。 | 187| paramMappingName | string | 否 | 是 | 表示意图参数映射名称。 | 188| paramCategory | [LinkParamCategory](#linkparamcategory) | 否 | 是 | 表示意图参数类别。<br/>若意图参数类别取值为[LINK](#linkparamcategory),系统获取paramName字段对应的意图参数映射名称,并将该意图参数映射名称拼接到uri链接的末尾(以键值对的形式key=value,key为意图参数映射名称,value为意图参数值)。<br/>若意图参数类别为[WANT](#linkparamcategory),系统获取paramName字段对应的意图参数映射名称,并将该意图参数映射名称及取值通过[Want](./js-apis-app-ability-want.md)的parameters字段进行传递。 | 189 190## LinkParamCategory 191 192[@InsightIntentLink](#insightintentlink)装饰器的意图参数类别,用于定义意图参数的传递形式。 193 194**系统能力**:SystemCapability.Ability.AbilityRuntime.Core 195 196**原子化服务API**:从API version 20开始,该接口支持在原子化服务中使用。 197 198| 名称 | 值 | 说明 | 199| -------- | -------- | -------- | 200| LINK | 'link' | 表示意图参数类别为'link'。意图参数将被拼接到uri链接的末尾,以uri链接的形式传给应用。 | 201| WANT | 'want' | 表示意图参数类别为'want'。意图参数将通过[Want](./js-apis-app-ability-want.md)的parameters字段传给应用。 | 202 203## @InsightIntentPage 204 205使用该装饰器装饰当前应用的页面,可以将页面定义为意图,便于AI入口通过意图快速跳转到指定页面。该装饰器支持的参数参见[PageIntentDecoratorInfo](#pageintentdecoratorinfo)。 206 207> **说明** 208> 209> 该装饰器仅支持装饰struct页面。 210 211**系统能力**:SystemCapability.Ability.AbilityRuntime.Core 212 213**原子化服务API**:从API version 20开始,该接口支持在原子化服务中使用。 214 215**示例:** 216 217```ts 218import { InsightIntentPage } from '@kit.AbilityKit'; 219 220@Entry 221@Component 222@InsightIntentPage({ 223 intentName: 'SearchMusic', 224 domain: 'MusicDomain', 225 intentVersion: '1.0.1', 226 displayName: '搜索歌曲', 227 displayDescription: '搜索歌曲意图', 228 schema: 'SearchMusic', 229 uiAbility: 'Entry', 230 pagePath: './ets/pages/Index', 231 navigationId: '1', 232 navDestinationName: 'PageOne', 233}) 234struct Index { 235 @State message: string = 'Hello World'; 236 237 build() { 238 RelativeContainer() { 239 Text(this.message) 240 .id('HelloWorld') 241 .fontSize(50) 242 .fontWeight(FontWeight.Bold) 243 .alignRules({ 244 center: { anchor: '__container__', align: VerticalAlign.Center }, 245 middle: { anchor: '__container__', align: HorizontalAlign.Center } 246 }) 247 } 248 .height('100%') 249 .width('100%') 250 } 251} 252``` 253 254## PageIntentDecoratorInfo 255 256PageIntentDecoratorInfo继承自[IntentDecoratorInfo](#intentdecoratorinfo),用于描述[@InsightIntentPage](#insightintentpage)装饰器支持的参数,例如目标页面的[NavDestination](../apis-arkui/arkui-ts/ts-basic-components-navigation.md#navdestination10)名称。 257 258**系统能力**:SystemCapability.Ability.AbilityRuntime.Core 259 260**原子化服务API**:从API version 20开始,该接口支持在原子化服务中使用。 261 262**属性:** 263 264| 名称 | 类型 | 只读 | 可选 | 说明 | 265| ------------------ | -------------| --------- | ---- | ------------------------------------------------------------ | 266| uiAbility | string | 否 | 是 | 表示与意图绑定的UIAbility名称。 | 267| pagePath | string | 否 | 否 | 表示与意图绑定的页面路径,该页面需要是一个实际存在的文件。 | 268| navigationId | string | 否 | 是 | 表示与意图绑定的[Navigation组件](../apis-arkui/arkui-ts/ts-basic-components-navigation.md#属性)的id属性。 | 269| navDestinationName | string | 否 | 是 | 表示与意图绑定[NavDestination组件](../apis-arkui/arkui-ts/ts-basic-components-navigation.md#navdestination10)的名称。 | 270 271## @InsightIntentFunction 272 273该装饰器与[@InsightIntentFunctionMethod](#insightintentfunctionmethod)装饰器必须组合使用。 274 275使用该装饰器来装饰类,同时使用[@InsightIntentFunctionMethod](#insightintentfunctionmethod)装饰器来装饰类中的静态函数,可以将对应的静态函数定义为意图,便于AI入口能够快速执行此函数。 276 277**系统能力**:SystemCapability.Ability.AbilityRuntime.Core 278 279**原子化服务API**:从API version 20开始,该接口支持在原子化服务中使用。 280 281## @InsightIntentFunctionMethod 282 283该装饰器与[@InsightIntentFunction](#insightintentfunction)装饰器必须组合使用。 284 285使用该装饰器来装饰类中的静态函数,同时使用[@InsightIntentFunction](#insightintentfunction)装饰器来装饰静态函数所属的类,可以将对应的静态函数定义为意图,便于AI入口能够快速执行此函数。 286 287> **说明** 288> 289> 静态方法所在的类需要通过export导出。 290> 291> 函数的参数名称、参数类型需要与意图定义的参数名称、参数类型保持一致。 292 293**系统能力**:SystemCapability.Ability.AbilityRuntime.Core 294 295**原子化服务API**:从API version 20开始,该接口支持在原子化服务中使用。 296 297**示例:** 298 299```ts 300import { InsightIntentFunction, InsightIntentFunctionMethod } from '@kit.AbilityKit'; 301 302@InsightIntentFunction() 303export class ClassForFuncDemo { 304 @InsightIntentFunctionMethod({ 305 intentName: 'GetWeather', 306 domain: 'LifeDomain', 307 intentVersion: '1.0.1', 308 displayName: '查询天气', 309 displayDescription: '显示天气信息', 310 icon: $r('app.media.app_icon'), 311 llmDescription: 'Get weather of an location', 312 parameters: { 313 'schema': 'http://json-schema.org/draft-07/schema#', 314 'type': 'object', 315 'title': 'Weather Schema', 316 'description': 'A schema for get weather of an location', 317 'properties': { 318 'location': { 319 'type': 'string', 320 'description': 'The city and state, e.g. Hangzhou', 321 'minLength': 1 322 } 323 }, 324 'required': ['location'], 325 'additionalProperties': false 326 } 327}) 328 static getWeather(location: string): string { 329 console.log('location' + location); 330 return 'The current temperature in Hangzhou is 24℃'; 331 } 332} 333``` 334 335## FunctionIntentDecoratorInfo 336 337[@InsightIntentFunctionMethod](#insightintentfunctionmethod)装饰器的参数类型,当前全部属性均继承自[IntentDecoratorInfo](#intentdecoratorinfo)。 338 339**系统能力**:SystemCapability.Ability.AbilityRuntime.Core 340 341**原子化服务API**:从API version 20开始,该接口支持在原子化服务中使用。 342 343## @InsightIntentEntry 344 345使用该装饰器装饰一个继承自[InsightIntentEntryExecutor](./js-apis-app-ability-InsightIntentEntryExecutor.md)的类,实现意图操作并配置意图依赖的Ability组件,便于AI入口拉起依赖的Ability组件时,执行对应的意图操作。该装饰器支持的参数参见[EntryIntentDecoratorInfo](#entryintentdecoratorinfo)。 346 347> **说明** 348> 349> - 如果使用该装饰器接入标注意图,必须实现标准意图Json Schema中定义的所有必选参数且类型匹配。 350> - 如果创建自定义意图,必须实现parameters字段中定义的所有必选参数且类型匹配。 351> - 被装饰的类需要使用export default导出。类的属性仅支持基础类型或意图实体,返回值仅支持意图实体。 352 353**系统能力**:SystemCapability.Ability.AbilityRuntime.Core 354 355**原子化服务API**:从API version 20开始,该接口支持在原子化服务中使用。 356 357**示例:** 358 359```ts 360import { insightIntent, InsightIntentEntry, InsightIntentEntryExecutor } from '@kit.AbilityKit'; 361import { hilog } from '@kit.PerformanceAnalysisKit'; 362 363const LOG_TAG: string = 'testTag-EntryIntent'; 364 365// 使用@InsightIntentEntry装饰器定义意图 366@InsightIntentEntry({ 367 intentName: 'PlayMusic', 368 domain: 'MusicDomain', 369 intentVersion: '1.0.1', 370 displayName: '播放歌曲', 371 displayDescription: '播放音乐意图', 372 icon: $r('app.media.app_icon'), 373 llmDescription: '支持传递歌曲名称,播放音乐', 374 keywords: ['音乐播放', '播放歌曲', 'PlayMusic'], 375 abilityName: 'EntryAbility', 376 executeMode: [insightIntent.ExecuteMode.UI_ABILITY_FOREGROUND], 377 parameters: { 378 'schema': 'http://json-schema.org/draft-07/schema#', 379 'type': 'object', 380 'title': 'Song Schema', 381 'description': 'A schema for describing songs and their artists', 382 'properties': { 383 'songName': { 384 'type': 'string', 385 'description': 'The name of the song', 386 'minLength': 1 387 } 388 }, 389 'required': ['songName'] 390 } 391}) 392export default class PlayMusicDemo extends InsightIntentEntryExecutor<string> { 393 songName: string = ''; 394 395 onExecute(): Promise<insightIntent.IntentResult<string>> { 396 hilog.info(0x0000, LOG_TAG, 'PlayMusicDemo executeMode %{public}s', JSON.stringify(this.executeMode)); 397 hilog.info(0x0000, LOG_TAG, '%{public}s', JSON.stringify(this)); 398 let storage = new LocalStorage(); 399 storage.setOrCreate('songName', this.songName); 400 // 根据executeMode参数的不同情况,提供不同拉起PlayMusicPage页面的方式。 401 if (this.executeMode == insightIntent.ExecuteMode.UI_ABILITY_FOREGROUND) { 402 this.windowStage?.loadContent('pages/PlayMusicPage', storage); 403 } else if (this.executeMode == insightIntent.ExecuteMode.UI_EXTENSION_ABILITY) { 404 this.uiExtensionSession?.loadContent('pages/PlayMusicPage', storage); 405 } 406 // 定义意图的执行结果 407 let result: insightIntent.IntentResult<string> = { 408 code: 123, 409 result: 'result' 410 } 411 hilog.info(0x0000, LOG_TAG, 'PlayMusicDemo return %{public}s', JSON.stringify(result)); 412 // 以Promise的方式返回意图执行结果 413 return Promise.reject(result); 414 } 415} 416``` 417 418## EntryIntentDecoratorInfo 419 420EntryIntentDecoratorInfo继承自[IntentDecoratorInfo](#intentdecoratorinfo),用于描述[@InsightIntentEntry](#insightintententry)装饰器支持的参数。 421 422**系统能力**:SystemCapability.Ability.AbilityRuntime.Core 423 424**原子化服务API**:从API version 20开始,该接口支持在原子化服务中使用。 425 426**属性:** 427 428| 名称 | 类型 | 只读 | 可选 | 说明 | 429| ------------------ | -------------| --------- | ---- | ------------------------------------------------------------ | 430| abilityName | string | 否 | 否 | 表示与意图绑定的Ability名称。 | 431| executeMode | [insightIntent.ExecuteMode](./js-apis-app-ability-insightIntent.md#executemode)[]| 否 | 否 | 表示意图调用执行模式。即拉起绑定的Ability时支持的执行模式。 | 432 433## @InsightIntentForm 434 435使用该装饰器装饰[FormExtensionAbility](../apis-form-kit/js-apis-app-form-formExtensionAbility.md)并配置FormExtensionAbility绑定的卡片名称,便于AI入口通过意图添加卡片。该装饰器支持的参数参见[FormIntentDecoratorInfo](#formintentdecoratorinfo)。 436 437> **说明** 438> 439> 卡片名称定义的要求参见[卡片配置](../../form/arkts-ui-widget-configuration.md#卡片配置)。 440 441**系统能力**:SystemCapability.Ability.AbilityRuntime.Core 442 443**原子化服务API**:从API version 20开始,该接口支持在原子化服务中使用。 444 445**示例:** 446 447```ts 448import { formBindingData, FormExtensionAbility, formInfo } from '@kit.FormKit'; 449import { insightIntent, Want, InsightIntentForm } from '@kit.AbilityKit'; 450 451// 使用@InsightIntentForm装饰器将该FormExtensionAbility名为widget的卡片定义为意图 452@InsightIntentForm({ 453 intentName: 'PlayMusic', 454 domain: 'MusicDomain', 455 intentVersion: '1.0.1', 456 displayName: '播放歌曲', 457 displayDescription: '播放音乐意图', 458 icon: $r('app.media.app_icon'), 459 llmDescription: '支持传递歌曲名称,播放音乐', 460 keywords: ['音乐播放', '播放歌曲', 'PlayMusic'], 461 parameters: { 462 '$schema': 'http://json-schema.org/draft-07/schema#', 463 'type': 'object', 464 'title': 'Song Schema', 465 'description': 'A schema for describing songs and their artists', 466 'properties': { 467 'songName': { 468 'type': 'string', 469 'description': 'The name of the song', 470 'minLength': 1 471 }, 472 'artist': { 473 'type': 'object', 474 'description': 'Information about the artist', 475 'properties': { 476 'country': { 477 'type': 'string', 478 'description': 'The artist\'s country of origin', 479 'default': 'zh' 480 }, 481 'city': { 482 'type': 'object', 483 'description': 'The artist\' city of origin' 484 }, 485 'name': { 486 'type': 'string', 487 'description': 'The name of the artist', 488 'minLength': 1 489 } 490 }, 491 'required': ['name'] 492 } 493 }, 494 'required': ['songName'] 495 }, 496 formName: 'widget' 497}) 498export default class EntryFormAbility extends FormExtensionAbility { 499 songName: string = ''; 500 501 onAddForm(want: Want) { 502 // 该方法被调用时,将返回FormBindingData对象 503 let formData = ''; 504 return formBindingData.createFormBindingData(formData); 505 } 506} 507``` 508 509## FormIntentDecoratorInfo 510 511FormIntentDecoratorInfo继承自[IntentDecoratorInfo](#intentdecoratorinfo),用于描述[@InsightIntentForm](#insightintentform)装饰器支持的参数。 512 513**系统能力**:SystemCapability.Ability.AbilityRuntime.Core 514 515**原子化服务API**:从API version 20开始,该接口支持在原子化服务中使用。 516 517**属性:** 518 519| 名称 | 类型 | 只读 | 可选 | 说明 | 520| ------------------ | -------------| --------- | ---- | ------------------------------------------------------------ | 521| formName | string | 否 | 否 | 表示FormExtensionAbility绑定的卡片名称。 | 522 523## @InsightIntentEntity 524 525使用该装饰器装饰一个继承自[IntentEntity](./js-apis-app-ability-insightIntent.md#intententity20)的类,可将该类定义为意图实体,用于传递意图调用时所需的参数。该装饰器支持的参数参见[IntentEntityDecoratorInfo](#intententitydecoratorinfo)。 526 527**系统能力**:SystemCapability.Ability.AbilityRuntime.Core 528 529**原子化服务API**:从API version 20开始,该接口支持在原子化服务中使用。 530 531**示例:** 532 533```ts 534import { insightIntent, InsightIntentEntity } from '@kit.AbilityKit'; 535 536@InsightIntentEntity({ 537 entityCategory: 'artist entity category', 538 parameters: { 539 '$id': '/schemas/ArtistClassDef', 540 'type': 'object', 541 'description': 'Information about the artist', 542 'properties': { 543 'country': { 544 'type': 'string', 545 'description': 'The artist\'s country of origin', 546 'default': 'zh' 547 }, 548 'city': { 549 'type': 'string', 550 'description': 'The artist\'s city of origin' 551 }, 552 'name': { 553 'type': 'string', 554 'description': 'The name of the artist', 555 'minLength': 1 556 } 557 }, 558 'required': ['name'] 559 } 560}) 561export class ArtistClassDef implements insightIntent.IntentEntity { 562 entityId: string = 'id'; 563 name: string = ''; 564} 565``` 566 567## IntentEntityDecoratorInfo 568 569用于描述[@InsightIntentEntity](#insightintententity)装饰器支持的参数。 570 571**系统能力**:SystemCapability.Ability.AbilityRuntime.Core 572 573**原子化服务API**:从API version 20开始,该接口支持在原子化服务中使用。 574 575**属性:** 576 577| 名称 | 类型 | 只读 | 可选 | 说明 | 578| ------------------ | -------------| --------- | ---- | ------------------------------------------------------------ | 579| entityCategory | string | 否 | 否 | 表示意图实体类别。可以基于意图实体类别对意图实体进行归类 | 580| parameters | Record<string, Object> | 否 | 是 | 表示意图实体的数据格式声明。用于定义意图实体的数据格式。 | 581