Skip to content

Commit 4f21e68

Browse files
committed
04-solution
1 parent c640a81 commit 4f21e68

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

app/src/app/chat/chat-panel.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { Component, effect, ElementRef, inject, viewChild } from '@angular/core';
22
import { MatProgressBarModule } from '@angular/material/progress-bar';
33
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';
56
import { SmartHome } from '../smart-home';
67
import { Squircle } from '../squircle';
78
import { ChatLayout } from './chat-layout';
@@ -145,9 +146,24 @@ export class ChatPanelComponent {
145146
data: s.streaming.string('The markdown content'),
146147
},
147148
}),
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+
}),
148156
],
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+
]
151167
});
152168

153169
sendMessage(message: string) {

0 commit comments

Comments
 (0)