Skip to content

An AI-powered search engine with a generative UI

Refactor researcher function to append answer section only when necessary

Yoshiki Miura0db3e862a0aa
diff --git a/lib/agents/researcher.tsx b/lib/agents/researcher.tsx
index 1c317a7a..ca3b7824 100644
--- a/lib/agents/researcher.tsx
+++ b/lib/agents/researcher.tsx
@@ -95,11 +95,6 @@ export async function researcher(
streamResults.done(JSON.stringify(searchResult))
- // Append the answer section if the specific model is not used
- if (!useSpecificModel) {
- uiStream.append(answerSection)
- }
-
return searchResult
}
}
@@ -126,6 +121,10 @@ export async function researcher(
toolCalls.push(delta)
break
case 'tool-result':
+ // Append the answer section if the specific model is not used
+ if (!useSpecificModel && toolResponses.length === 0) {
+ uiStream.append(answerSection)
+ }
toolResponses.push(delta)
break
case 'error':