这篇讲智能化能力如何进入项目同时处理本地配置、请求结构、解析兜底和用户可见反馈。本篇主题是「小艺意图配置insight_intent.json 如何绑定执行器」目标是把源码、效果和工程质量放到同一篇文章里讲透。本文是 21 天「智能相机开发实战」训练营第 4 天的第 3 篇。这篇解决什么问题读懂本篇能力在「双镜记忆相机」中的用户价值。从源码中定位关键入口而不是只停留在概念介绍。把页面效果、状态流转和失败态串成一个可复现的小闭环。代码来自哪里entry/src/main/ets/insightintents/NearbyAgentLocationIntent.etsentry/src/main/resources/base/profile/insight_intent.json本篇优先阅读entry/src/main/ets/insightintents/NearbyAgentLocationIntent.ets下面的片段保留项目中的真实命名方便你在 DevEco Studio 中直接搜索。import { insightIntent, InsightIntentExecutor } from kit.AbilityKit; import { AgentLocationService } from ../services/AgentLocationService; const INTENT_GET_LOCATION GetLocation; const INTENT_GET_NEARBY_AGENT_LOCATION GetNearbyAgentLocation; export default class NearbyAgentLocationIntent extends InsightIntentExecutor { async onExecuteInUIAbilityBackgroundMode(intentName: string, intentParam: Recordstring, Object): PromiseinsightIntent.ExecuteResult { if (intentName ! INTENT_GET_LOCATION intentName ! INTENT_GET_NEARBY_AGENT_LOCATION intentName ! getLocation) { return { code: -1, result: { success: false, resultDesc: Unknown end plugin tool: ${intentName} } }; } const locationResult await AgentLocationService.getCurrentLocation(); return { code: 0, result: { success: locationResult.success, address: locationResult.amapLocation, resultDesc: locationResult.resultDesc, latitude: locationResult.latitude, longitude: locationResult.longitude, wgs84Latitude: locationResult.wgs84Latitude, wgs84Longitude: locationResult.wgs84Longitude, amapLatitude: locationResult.amapLatitude, amapLongitude: locationResult.amapLongitude, amapLocation: locationResult.amapLocation, coordinateSystem: locationResult.coordinateSystem, accuracyMeters: locationResult.accuracyMeters, timeStamp: locationResult.timeStamp, source: locationResult.source,源码拆解先看入口变量或函数它决定能力从哪个页面、哪个服务或哪个系统配置开始。再看状态字段页面上的按钮、提示、加载态通常不是临时文案而是这些状态的投影。最后看结果写回拍摄、定位、AI、同步或分享能力最终都要回到记录模型、页面刷新或用户反馈。跑出来是什么效果结合页面效果本文重点观察配置截图意图到 Ability 的链路图流程串联用户选择照片 → 组装请求 → 解析模型结果 → 写回详情页从页面效果看关键不是单点能力而是让用户动作、源码状态和结果反馈保持一致。实操步骤在 DevEco Studio 打开项目先搜索本文列出的主文件。顺着源码片段中的变量或函数名继续查找调用点。在真机上运行到对应页面观察截图中的成功态是否与源码状态一致。主动制造一次失败态例如拒绝权限、断网、无数据或能力不支持。把成功态、失败态、源码片段和页面截图串成完整实操闭环。工程质量点API Key 只保存在本地用户侧文章中不出现真实密钥。模型输出按结构化结果解析异常文本进入兜底路径。生成中、成功、失败都要有独立文案用户能判断下一步。源码截图只截关键函数不截整屏代码方便读者跟着定位。效果图和流程路径一一对应避免只讲原理却看不到用户结果。质量分自评维度分值本篇检查点源码准确度28/30代码片段来自项目文件变量名和函数名保持原样。效果可见性23/25页面效果与流程路径能说明从点击到结果的路径。实操完整度20/20读者能按文章复现一个最小操作闭环。工程质量13/15覆盖失败态、状态边界或隐私边界中的关键点。表达清晰度10/10标题、截图说明和源码说明互相对齐。合计94/100达到训练营发布质量线。今日作业使用一张测试照片触发分析或生成保存成功和失败两种截图。把模型返回结果复制一份验证解析函数的兜底路径。检查文章中没有出现真实 Key 或敏感地址。完成作业后下一篇继续沿着同一条源码路径往下走先做出效果再把工程边界讲清楚。
第16篇|小艺意图配置:insight_intent.json 如何绑定执行器
发布时间:2026/5/29 1:55:09
这篇讲智能化能力如何进入项目同时处理本地配置、请求结构、解析兜底和用户可见反馈。本篇主题是「小艺意图配置insight_intent.json 如何绑定执行器」目标是把源码、效果和工程质量放到同一篇文章里讲透。本文是 21 天「智能相机开发实战」训练营第 4 天的第 3 篇。这篇解决什么问题读懂本篇能力在「双镜记忆相机」中的用户价值。从源码中定位关键入口而不是只停留在概念介绍。把页面效果、状态流转和失败态串成一个可复现的小闭环。代码来自哪里entry/src/main/ets/insightintents/NearbyAgentLocationIntent.etsentry/src/main/resources/base/profile/insight_intent.json本篇优先阅读entry/src/main/ets/insightintents/NearbyAgentLocationIntent.ets下面的片段保留项目中的真实命名方便你在 DevEco Studio 中直接搜索。import { insightIntent, InsightIntentExecutor } from kit.AbilityKit; import { AgentLocationService } from ../services/AgentLocationService; const INTENT_GET_LOCATION GetLocation; const INTENT_GET_NEARBY_AGENT_LOCATION GetNearbyAgentLocation; export default class NearbyAgentLocationIntent extends InsightIntentExecutor { async onExecuteInUIAbilityBackgroundMode(intentName: string, intentParam: Recordstring, Object): PromiseinsightIntent.ExecuteResult { if (intentName ! INTENT_GET_LOCATION intentName ! INTENT_GET_NEARBY_AGENT_LOCATION intentName ! getLocation) { return { code: -1, result: { success: false, resultDesc: Unknown end plugin tool: ${intentName} } }; } const locationResult await AgentLocationService.getCurrentLocation(); return { code: 0, result: { success: locationResult.success, address: locationResult.amapLocation, resultDesc: locationResult.resultDesc, latitude: locationResult.latitude, longitude: locationResult.longitude, wgs84Latitude: locationResult.wgs84Latitude, wgs84Longitude: locationResult.wgs84Longitude, amapLatitude: locationResult.amapLatitude, amapLongitude: locationResult.amapLongitude, amapLocation: locationResult.amapLocation, coordinateSystem: locationResult.coordinateSystem, accuracyMeters: locationResult.accuracyMeters, timeStamp: locationResult.timeStamp, source: locationResult.source,源码拆解先看入口变量或函数它决定能力从哪个页面、哪个服务或哪个系统配置开始。再看状态字段页面上的按钮、提示、加载态通常不是临时文案而是这些状态的投影。最后看结果写回拍摄、定位、AI、同步或分享能力最终都要回到记录模型、页面刷新或用户反馈。跑出来是什么效果结合页面效果本文重点观察配置截图意图到 Ability 的链路图流程串联用户选择照片 → 组装请求 → 解析模型结果 → 写回详情页从页面效果看关键不是单点能力而是让用户动作、源码状态和结果反馈保持一致。实操步骤在 DevEco Studio 打开项目先搜索本文列出的主文件。顺着源码片段中的变量或函数名继续查找调用点。在真机上运行到对应页面观察截图中的成功态是否与源码状态一致。主动制造一次失败态例如拒绝权限、断网、无数据或能力不支持。把成功态、失败态、源码片段和页面截图串成完整实操闭环。工程质量点API Key 只保存在本地用户侧文章中不出现真实密钥。模型输出按结构化结果解析异常文本进入兜底路径。生成中、成功、失败都要有独立文案用户能判断下一步。源码截图只截关键函数不截整屏代码方便读者跟着定位。效果图和流程路径一一对应避免只讲原理却看不到用户结果。质量分自评维度分值本篇检查点源码准确度28/30代码片段来自项目文件变量名和函数名保持原样。效果可见性23/25页面效果与流程路径能说明从点击到结果的路径。实操完整度20/20读者能按文章复现一个最小操作闭环。工程质量13/15覆盖失败态、状态边界或隐私边界中的关键点。表达清晰度10/10标题、截图说明和源码说明互相对齐。合计94/100达到训练营发布质量线。今日作业使用一张测试照片触发分析或生成保存成功和失败两种截图。把模型返回结果复制一份验证解析函数的兜底路径。检查文章中没有出现真实 Key 或敏感地址。完成作业后下一篇继续沿着同一条源码路径往下走先做出效果再把工程边界讲清楚。