From b2649367c5b9c0309eb0fe42956d7c591f8f7c73 Mon Sep 17 00:00:00 2001 From: "coderabbitai[bot]" <136622811+coderabbitai[bot]@users.noreply.github.com> Date: Wed, 6 May 2026 17:27:43 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9D=20CodeRabbit=20Chat:=20Implement?= =?UTF-8?q?=20requested=20code=20changes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/actions.tsx | 9 +++++++-- components/empty-screen.tsx | 4 ++-- lib/agents/query-suggestor.tsx | 26 +++++++++++++++----------- 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/app/actions.tsx b/app/actions.tsx index e49684cc..a93a2892 100644 --- a/app/actions.tsx +++ b/app/actions.tsx @@ -28,6 +28,7 @@ import RetrieveSection from '@/components/retrieve-section' import { VideoSearchSection } from '@/components/video-search-section' import { MapQueryHandler } from '@/components/map/map-query-handler' import { getCurrentUserIdOnServer } from '@/lib/auth/get-current-user' +import { PartialRelated } from '@/lib/schema/related' // Define the type for related queries type RelatedQueries = { @@ -461,14 +462,18 @@ async function submit(formData?: FormData, skip?: boolean) { } if (!errorOccurred) { - const relatedQueries = await querySuggestor(uiStream, messages) + let relatedQueries: PartialRelated = {} + try { + relatedQueries = await querySuggestor(uiStream, messages) + } catch (err) { + console.error('querySuggestor failed, continuing without related queries:', err) + } uiStream.append(
) - aiState.done({ ...aiState.get(), messages: [ diff --git a/components/empty-screen.tsx b/components/empty-screen.tsx index e16fabc6..2c0f63e4 100644 --- a/components/empty-screen.tsx +++ b/components/empty-screen.tsx @@ -32,9 +32,9 @@ export function EmptyScreen({ className?: string; }) { return ( -
+
-
+
{exampleMessages.map((item) => { const Icon = item.icon; return ( diff --git a/lib/agents/query-suggestor.tsx b/lib/agents/query-suggestor.tsx index e54866be..6637977d 100644 --- a/lib/agents/query-suggestor.tsx +++ b/lib/agents/query-suggestor.tsx @@ -17,9 +17,10 @@ export async function querySuggestor( ) let finalRelatedQueries: PartialRelated = {} - const result = await streamObject({ - model: (await getModel(false, "auxiliary")) as LanguageModel, - system: `As a professional web researcher, your task is to generate a set of three queries that explore the subject matter more deeply, building upon the initial query and the information uncovered in its search results. + try { + const result = await streamObject({ + model: (await getModel(false, "auxiliary")) as LanguageModel, + system: `As a professional web researcher, your task is to generate a set of three queries that explore the subject matter more deeply, building upon the initial query and the information uncovered in its search results. For instance, if the original query was "Starship's third test flight key milestones", your output should follow this format: @@ -33,15 +34,18 @@ export async function querySuggestor( Aim to create queries that progressively delve into more specific aspects, implications, or adjacent topics related to the initial query. The goal is to anticipate the user's potential information needs and guide them towards a more comprehensive understanding of the subject matter. Please match the language of the response to the user's language.`, - messages, - schema: relatedSchema - }) - - for await (const obj of result.partialObjectStream) { - if (obj && typeof obj === 'object' && 'items' in obj) { - objectStream.update(obj as PartialRelated) - finalRelatedQueries = obj as PartialRelated + messages, + schema: relatedSchema + }) + + for await (const obj of result.partialObjectStream) { + if (obj && typeof obj === 'object' && 'items' in obj) { + objectStream.update(obj as PartialRelated) + finalRelatedQueries = obj as PartialRelated + } } + } catch (err) { + console.error('querySuggestor: model call failed, returning empty queries:', err) } objectStream.done()