Browse Source

AI Assistant: added installing IoT Hub devices from the chat (#16851)

* feat: AI chat words for installing an IoT Hub device in the chat: action lines for read_iot_hub_device and install_iot_hub_device, their Details as the hub item, the approval card's install facts (model, how it connects, profile, device, gateway, connector, dashboard, rule chain, converter, integration, kept entities) and the IoT Hub record on the device install's approval and line

* AI chat: an IoT Hub device install's Details header says it installed the device ('Installed ... from IoT Hub') instead of reading it
pull/16852/head
Vladyslav Prykhodko 5 days ago
committed by GitHub
parent
commit
ac7ebeb5d8
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 10
      ui-ngx/src/app/modules/home/components/ai/ai-action-detail.models.ts
  2. 5
      ui-ngx/src/app/modules/home/components/ai/ai-action-line.component.ts
  3. 4
      ui-ngx/src/app/modules/home/components/ai/ai-action.models.ts
  4. 4
      ui-ngx/src/app/modules/home/components/ai/ai-approval-card.component.ts
  5. 20
      ui-ngx/src/assets/locale/locale.constant-en_US.json

10
ui-ngx/src/app/modules/home/components/ai/ai-action-detail.models.ts

@ -1074,6 +1074,16 @@ function describe(tool: string, values: Values, result: unknown, names: AiDetail
description: str(item.description)}]}] : generic(result, 'result') description: str(item.description)}]}] : generic(result, 'result')
}; };
} }
case 'read_iot_hub_device':
case 'install_iot_hub_device': {
const item = isObject(result) && (str(result.name) ?? str(result.installed)) ? result : null;
const name = str(item?.name) ?? str(item?.installed);
return {
hood: text(tool === 'install_iot_hub_device' ? 'iot-hub-install' : 'iot-hub-read', {name: name ?? '…'}),
blocks: item && str(values.versionId) ? [{type: 'hub', rows: [{id: values.versionId, name, vendor: str(item.vendor),
description: str(item.description)}]}] : generic(result, 'result')
};
}
case 'search_entities': case 'search_entities':
return searchEntities(values, result, names); return searchEntities(values, result, names);
case 'read_entity': { case 'read_entity': {

5
ui-ngx/src/app/modules/home/components/ai/ai-action-line.component.ts

@ -16,7 +16,8 @@ import {
aiEntityKind, aiEntityKind,
aiActionDuration, aiActionDuration,
aiActionText, aiActionText,
aiActionWords aiActionWords,
HUB_INSTALL_TOOLS
} from '@home/components/ai/ai-action.models'; } from '@home/components/ai/ai-action.models';
@Component({ @Component({
@ -41,7 +42,7 @@ export class AiActionLineComponent {
hubVersionId = computed(() => { hubVersionId = computed(() => {
const action = this.action(); const action = this.action();
const id = action.tool === 'install_iot_hub_item' && action.status !== 'RUNNING' ? (action.arguments as {versionId?: unknown})?.versionId : null; const id = HUB_INSTALL_TOOLS.has(action.tool) && action.status !== 'RUNNING' ? (action.arguments as {versionId?: unknown})?.versionId : null;
return typeof id === 'string' && id ? id : null; return typeof id === 'string' && id ? id : null;
}); });

4
ui-ngx/src/app/modules/home/components/ai/ai-action.models.ts

@ -54,8 +54,10 @@ const TOOL_WORDS: Record<string, string> = {
search_iot_hub_devices: 'search-iot-hub', search_iot_hub_devices: 'search-iot-hub',
search_iot_hub: 'search-iot-hub', search_iot_hub: 'search-iot-hub',
read_iot_hub_item: 'read-iot-hub-item', read_iot_hub_item: 'read-iot-hub-item',
read_iot_hub_device: 'read-iot-hub-device',
list_installed_iot_hub_items: 'list-installed-iot-hub-items', list_installed_iot_hub_items: 'list-installed-iot-hub-items',
install_iot_hub_item: 'install-iot-hub-item', install_iot_hub_item: 'install-iot-hub-item',
install_iot_hub_device: 'install-iot-hub-device',
update_group_members: 'update-group-members', update_group_members: 'update-group-members',
change_owner: 'change-owner', change_owner: 'change-owner',
share_entity_group: 'share-group', share_entity_group: 'share-group',
@ -248,6 +250,8 @@ export const PROPOSE_PLAN_TOOL = 'propose_plan';
export const CITE_SOURCES_TOOL = 'cite_sources'; export const CITE_SOURCES_TOOL = 'cite_sources';
export const HUB_INSTALL_TOOLS: ReadonlySet<string> = new Set(['install_iot_hub_item', 'install_iot_hub_device']);
export interface AiSource { export interface AiSource {
url: string; url: string;
title: string; title: string;

4
ui-ngx/src/app/modules/home/components/ai/ai-approval-card.component.ts

@ -28,7 +28,7 @@ import {
ToolExecutionRequested, ToolExecutionRequested,
ToolExecutionResult ToolExecutionResult
} from '@shared/models/ai-chat.models'; } from '@shared/models/ai-chat.models';
import { AiAction } from '@home/components/ai/ai-action.models'; import { AiAction, HUB_INSTALL_TOOLS } from '@home/components/ai/ai-action.models';
import { EntityType, entityTypeTranslations } from '@shared/models/entity-type.models'; import { EntityType, entityTypeTranslations } from '@shared/models/entity-type.models';
import { MailTemplate, mailTemplateTranslations } from '@shared/models/settings.models'; import { MailTemplate, mailTemplateTranslations } from '@shared/models/settings.models';
@ -277,7 +277,7 @@ export class AiApprovalCardComponent implements OnChanges, AfterViewChecked {
} }
get hubVersionId(): string | null { get hubVersionId(): string | null {
const id = this.data?.tool === 'install_iot_hub_item' ? (this.data.arguments as {versionId?: unknown})?.versionId : null; const id = HUB_INSTALL_TOOLS.has(this.data?.tool) ? (this.data.arguments as {versionId?: unknown})?.versionId : null;
return typeof id === 'string' && id ? id : null; return typeof id === 'string' && id ? id : null;
} }

20
ui-ngx/src/assets/locale/locale.constant-en_US.json

@ -787,6 +787,7 @@
"iot-hub-browse": "Browsed IoT Hub", "iot-hub-browse": "Browsed IoT Hub",
"iot-hub-installed": "Listed the items installed from IoT Hub", "iot-hub-installed": "Listed the items installed from IoT Hub",
"iot-hub-read": "Read '{{name}}' in IoT Hub", "iot-hub-read": "Read '{{name}}' in IoT Hub",
"iot-hub-install": "Installed '{{name}}' from IoT Hub",
"search": "Searched {{what}}", "search": "Searched {{what}}",
"search-one": "Looked up {{entity}}", "search-one": "Looked up {{entity}}",
"search-related-from": "Searched {{what}} that {{entity}} points to", "search-related-from": "Searched {{what}} that {{entity}} points to",
@ -1456,6 +1457,10 @@
"run": "Reading the IoT Hub item", "run": "Reading the IoT Hub item",
"done": "Read the IoT Hub item" "done": "Read the IoT Hub item"
}, },
"read-iot-hub-device": {
"run": "Reading the device's IoT Hub package",
"done": "Read the device's IoT Hub package"
},
"list-installed-iot-hub-items": { "list-installed-iot-hub-items": {
"run": "Checking what is installed from IoT Hub", "run": "Checking what is installed from IoT Hub",
"done": "Checked what is installed from IoT Hub" "done": "Checked what is installed from IoT Hub"
@ -1464,6 +1469,10 @@
"run": "Installing from IoT Hub", "run": "Installing from IoT Hub",
"done": "Installed from IoT Hub" "done": "Installed from IoT Hub"
}, },
"install-iot-hub-device": {
"run": "Installing the device from IoT Hub",
"done": "Installed the device from IoT Hub"
},
"read-connection-settings": { "read-connection-settings": {
"run": "Looking up the connection settings", "run": "Looking up the connection settings",
"done": "Looked up the connection settings" "done": "Looked up the connection settings"
@ -2710,6 +2719,17 @@
"size": "Size", "size": "Size",
"defaultDashboard": "Default dashboard", "defaultDashboard": "Default dashboard",
"homeDashboard": "Home dashboard", "homeDashboard": "Home dashboard",
"hub-model": "Model",
"hub-connection": "Connects",
"hub-profile": "Device profile",
"hub-device": "Device",
"hub-gateway": "Gateway",
"hub-connector": "Connector",
"hub-dashboard": "Dashboard",
"hub-ruleChain": "Rule chain",
"hub-integration": "Integration",
"hub-converter": "Converter",
"hub-reused": "Kept as they are",
"email": "Email", "email": "Email",
"firstName": "First name", "firstName": "First name",
"lastName": "Last name", "lastName": "Last name",

Loading…
Cancel
Save