|
1 | 1 | import { Component, effect, ElementRef, inject, viewChild } from '@angular/core'; |
2 | 2 | import { MatProgressBarModule } from '@angular/material/progress-bar'; |
3 | 3 | import { prompt, s } from '@hashbrownai/core'; |
4 | | -import { exposeComponent, RenderMessageComponent, uiChatResource } from '@hashbrownai/angular'; |
| 4 | +import { createTool, exposeComponent, RenderMessageComponent, uiChatResource } from '@hashbrownai/angular'; |
| 5 | +import { LightCard } from '../lights/light-card'; |
5 | 6 | import { SmartHome } from '../smart-home'; |
6 | 7 | import { Squircle } from '../squircle'; |
7 | 8 | import { ChatLayout } from './chat-layout'; |
@@ -145,9 +146,24 @@ export class ChatPanelComponent { |
145 | 146 | data: s.streaming.string('The markdown content'), |
146 | 147 | }, |
147 | 148 | }), |
| 149 | + exposeComponent(LightCard, { |
| 150 | + description: `This option shows a light to the user, with a dimmer for them to control the light. |
| 151 | + Always prefer this option over printing a light's name. Always prefer putting these in a list.`, |
| 152 | + input: { |
| 153 | + lightId: s.string('The id of the light'), |
| 154 | + }, |
| 155 | + }), |
148 | 156 | ], |
149 | | - // 1. Add tools array. |
150 | | - // 2. Use the `createTool()` function to define a `getLights` tool. |
| 157 | + tools: [ |
| 158 | + createTool({ |
| 159 | + name: 'getLights', |
| 160 | + description: 'Get the current lights', |
| 161 | + handler: () => { |
| 162 | + const smartHome = inject(SmartHome); |
| 163 | + return smartHome.fetchLights(); |
| 164 | + }, |
| 165 | + }) |
| 166 | + ] |
151 | 167 | }); |
152 | 168 |
|
153 | 169 | sendMessage(message: string) { |
|
0 commit comments