mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 18:40:44 +00:00
fix(web-search): fix empty snippets in Brave LLM Context mode
Brave's /res/v1/llm/context endpoint returns snippets as plain strings,
not { text: string } objects. The existing code applied .map(s => s.text)
which accessed .text on strings (returning undefined), causing all
snippets to be filtered out.
Update the type definition and snippet extraction to handle plain strings
directly.
Fixes #41370
This commit is contained in:
@@ -272,8 +272,7 @@ type BraveSearchResponse = {
|
||||
};
|
||||
};
|
||||
|
||||
type BraveLlmContextSnippet = { text: string };
|
||||
type BraveLlmContextResult = { url: string; title: string; snippets: BraveLlmContextSnippet[] };
|
||||
type BraveLlmContextResult = { url: string; title: string; snippets: string[] };
|
||||
type BraveLlmContextResponse = {
|
||||
grounding: { generic?: BraveLlmContextResult[] };
|
||||
sources?: { url?: string; hostname?: string; date?: string }[];
|
||||
@@ -1481,7 +1480,7 @@ async function runBraveLlmContextSearch(params: {
|
||||
const mapped = genericResults.map((entry) => ({
|
||||
url: entry.url ?? "",
|
||||
title: entry.title ?? "",
|
||||
snippets: (entry.snippets ?? []).map((s) => s.text ?? "").filter(Boolean),
|
||||
snippets: (entry.snippets ?? []).filter((s) => typeof s === "string" && s.length > 0),
|
||||
siteName: resolveSiteName(entry.url) || undefined,
|
||||
}));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user