feat: Update web search agent to return top 12 results and enhance message box interactivity

This commit is contained in:
Willie Zutz 2025-06-24 00:10:25 -06:00
parent feec1cd608
commit 190153fbc2
4 changed files with 12 additions and 11 deletions

View file

@ -425,6 +425,7 @@ export const POST = async (req: Request) => {
}), }),
), ),
); );
writer.close();
cleanupCancelToken(message.messageId); cleanupCancelToken(message.messageId);
}); });

View file

@ -93,7 +93,7 @@ const MessageBox = ({
) : ( ) : (
<> <>
<div className="flex items-center"> <div className="flex items-center">
<h2 className="text-black dark:text-white font-medium text-3xl"> <h2 className="text-black dark:text-white font-medium text-3xl" onClick={startEditMessage}>
{message.content} {message.content}
</h2> </h2>
<button <button

View file

@ -15,13 +15,13 @@ const OptimizationModes = [
'Prioritize speed and get the quickest possible answer. Minimum effort retrieving web content.', 'Prioritize speed and get the quickest possible answer. Minimum effort retrieving web content.',
icon: <Zap size={20} className="text-[#FF9800]" />, icon: <Zap size={20} className="text-[#FF9800]" />,
}, },
{ // {
key: 'balanced', // key: 'balanced',
title: 'Balanced', // title: 'Balanced',
description: // description:
'Find the right balance between speed and accuracy. Medium effort retrieving web content.', // 'Find the right balance between speed and accuracy. Medium effort retrieving web content.',
icon: <Sliders size={20} className="text-[#4CAF50]" />, // icon: <Sliders size={20} className="text-[#4CAF50]" />,
}, // },
// { // {
// key: 'quality', // key: 'quality',
// title: 'Quality', // title: 'Quality',

View file

@ -175,10 +175,10 @@ export class WebSearchAgent {
}), }),
); );
// Sort by relevance score and take top 8 results // Sort by relevance score and take top 12 results
const previewContents: PreviewContent[] = resultsWithSimilarity const previewContents: PreviewContent[] = resultsWithSimilarity
.sort((a, b) => b.similarity - a.similarity) .sort((a, b) => b.similarity - a.similarity)
.slice(0, 8) .slice(0, 12)
.map(({ result }) => ({ .map(({ result }) => ({
title: result.title || 'Untitled', title: result.title || 'Untitled',
snippet: result.content || '', snippet: result.content || '',
@ -301,7 +301,7 @@ export class WebSearchAgent {
// Summarize the top 2 search results // Summarize the top 2 search results
for (const result of resultsWithSimilarity for (const result of resultsWithSimilarity
.slice(0, 8) .slice(0, 12)
.map((r) => r.result)) { .map((r) => r.result)) {
if (this.signal.aborted) { if (this.signal.aborted) {
console.warn('Search operation aborted by signal'); console.warn('Search operation aborted by signal');