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 4 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')
};
}
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':
return searchEntities(values, result, names);
case 'read_entity': {

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

@ -16,7 +16,8 @@ import {
aiEntityKind,
aiActionDuration,
aiActionText,
aiActionWords
aiActionWords,
HUB_INSTALL_TOOLS
} from '@home/components/ai/ai-action.models';
@Component({
@ -41,7 +42,7 @@ export class AiActionLineComponent {
hubVersionId = computed(() => {
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;
});

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: 'search-iot-hub',
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',
install_iot_hub_item: 'install-iot-hub-item',
install_iot_hub_device: 'install-iot-hub-device',
update_group_members: 'update-group-members',
change_owner: 'change-owner',
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 HUB_INSTALL_TOOLS: ReadonlySet<string> = new Set(['install_iot_hub_item', 'install_iot_hub_device']);
export interface AiSource {
url: string;
title: string;

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

@ -28,7 +28,7 @@ import {
ToolExecutionRequested,
ToolExecutionResult
} 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 { MailTemplate, mailTemplateTranslations } from '@shared/models/settings.models';
@ -277,7 +277,7 @@ export class AiApprovalCardComponent implements OnChanges, AfterViewChecked {
}
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;
}

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

@ -787,6 +787,7 @@
"iot-hub-browse": "Browsed IoT Hub",
"iot-hub-installed": "Listed the items installed from IoT Hub",
"iot-hub-read": "Read '{{name}}' in IoT Hub",
"iot-hub-install": "Installed '{{name}}' from IoT Hub",
"search": "Searched {{what}}",
"search-one": "Looked up {{entity}}",
"search-related-from": "Searched {{what}} that {{entity}} points to",
@ -1456,6 +1457,10 @@
"run": "Reading 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": {
"run": "Checking what is installed from IoT Hub",
"done": "Checked what is installed from IoT Hub"
@ -1464,6 +1469,10 @@
"run": "Installing 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": {
"run": "Looking up the connection settings",
"done": "Looked up the connection settings"
@ -2710,6 +2719,17 @@
"size": "Size",
"defaultDashboard": "Default 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",
"firstName": "First name",
"lastName": "Last name",

Loading…
Cancel
Save