Skip to content

Commit e227ce8

Browse files
committed
ai chat improvements
1 parent bfaabc3 commit e227ce8

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

app/api/chat/route.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ const STOP_WORDS = new Set([
1616
'this','that','these','those','my','your','his','her','its','our','their',
1717
'about','other','another','also','too','more','any','some','just','even',
1818
'still','like','else','same','different','similar','related','using','use',
19+
'cool','great','awesome','nice','good','bad','okay','ok','yes','no','sure',
20+
'hey','hi','hello','thanks','thank','please','help','tell','show','explain',
21+
'want','need','trying','try','get','make','know','think','see','look','find',
22+
'works','working','work','thing','things','way','ways','go','going','got',
1923
]);
2024

2125
function buildSearchQuery(text: string): string {
@@ -35,6 +39,7 @@ async function runSearch(query: string, maxPages = 8) {
3539
indexName: process.env.NEXT_PUBLIC_ALGOLIA_INDEX!,
3640
query: searchQuery,
3741
hitsPerPage: 60,
42+
removeWordsIfNoResults: 'allOptional',
3843
},
3944
],
4045
});

components/ai/search.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ const roleName: Record<string, string> = {
238238
};
239239

240240
function Message({ message, ...props }: { message: UIMessage } & ComponentProps<'div'>) {
241+
const { setOpen } = useAISearchContext();
241242
let markdown = '';
242243
const searchCalls: UIToolInvocation<SearchTool>[] = [];
243244

@@ -266,7 +267,12 @@ function Message({ message, ...props }: { message: UIMessage } & ComponentProps<
266267
>
267268
{roleName[message.role] ?? 'unknown'}
268269
</p>
269-
<div className="prose text-sm">
270+
<div
271+
className="prose text-sm"
272+
onClick={(e) => {
273+
if ((e.target as HTMLElement).closest('a')) setOpen(false);
274+
}}
275+
>
270276
<Markdown text={markdown} />
271277
</div>
272278

@@ -355,7 +361,7 @@ export function AISearchPanel() {
355361
<Presence present={open}>
356362
<div
357363
className={cn(
358-
'fixed top-0 end-0 z-30 h-dvh overflow-hidden bg-fd-card text-fd-card-foreground border-s shadow-xl w-full sm:w-150 2xl:w-172.5',
364+
'fixed top-0 end-0 z-50 h-dvh overflow-hidden bg-fd-card text-fd-card-foreground border-s shadow-xl w-full sm:w-150 2xl:w-172.5',
359365
open
360366
? 'animate-[ask-ai-open_200ms]'
361367
: 'animate-[ask-ai-close_200ms]',

0 commit comments

Comments
 (0)