Skip to content

Commit 79acef9

Browse files
committed
Merge branch 'dmdimitrov/chat-ai-component' of https://github.com/IgniteUI/igniteui-webcomponents into dmdimitrov/chat-ai-component
2 parents d49e099 + b0f89fe commit 79acef9

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

stories/chat.stories.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ And some sample html:
9696
},
9797
];
9898

99-
const draftMessage = { text: 'Hi' };
99+
// const draftMessage = { text: 'Hi' };
100100

101101
const userMessages: any[] = [];
102102

@@ -146,7 +146,11 @@ const _customRenderer = {
146146
const ai_chat_options = {
147147
headerText: 'Chat',
148148
inputPlaceholder: 'Type your message here...',
149-
suggestions: ['Hello', 'Hi', 'Generate an image of a pig!'],
149+
suggestions: [
150+
'Hello',
151+
'What is triskaidekaphobia?',
152+
'Show me very short sample typescript code',
153+
],
150154
templates: {
151155
// messageActionsTemplate: messageActionsTemplate,
152156
// typingIndicatorTemplate: _typingIndicatorTemplate,
@@ -365,7 +369,7 @@ async function handleAIMessageSend(e: CustomEvent) {
365369

366370
if (newMessage.text.includes('image')) {
367371
response = await ai.models.generateContent({
368-
model: 'gemini-2.5-flash-preview-image-generation',
372+
model: 'gemini-2.0-flash-preview-image-generation',
369373
contents: userMessages,
370374
config: {
371375
responseModalities: [Modality.TEXT, Modality.IMAGE],
@@ -422,6 +426,7 @@ async function handleAIMessageSend(e: CustomEvent) {
422426
};
423427
chat.messages = [...chat.messages];
424428
}
429+
chat.options = { ...ai_chat_options, suggestions: [], isTyping: false };
425430

426431
const messagesForSuggestions = [
427432
...chat.messages,
@@ -441,15 +446,14 @@ async function handleAIMessageSend(e: CustomEvent) {
441446
const matches: IterableIterator<RegExpMatchArray> =
442447
responseText.matchAll(regex);
443448

444-
const suggestions: string[] = Array.from(
449+
const suggestionsFromResponse: string[] = Array.from(
445450
matches,
446451
(match: RegExpMatchArray) => match[1]
447452
);
448453

449454
chat.options = {
450455
...ai_chat_options,
451-
suggestions: suggestions,
452-
isTyping: false,
456+
suggestions: suggestionsFromResponse,
453457
};
454458
}
455459
}
@@ -492,7 +496,6 @@ export const AI: Story = {
492496
render: () => html`
493497
<igc-chat
494498
style="--igc-chat-height: calc(100vh - 32px);"
495-
.draftMessage=${draftMessage}
496499
.options=${ai_chat_options}
497500
@igcMessageCreated=${handleAIMessageSend}
498501
>

0 commit comments

Comments
 (0)