Add Brave LLM Context endpoint as opt-in web search mode
Brave's /res/v1/llm/context returns pre-extracted text chunks optimized for LLM consumption instead of URLs + short snippets. Enable with BRAVE_LLM_CONTEXT=1 env var; same API key and pricing. - Add _search_llm_context() and _normalize_llm_context() to brave_search.py - Wire opt-in flag through _search_web() in last30days.py - Update module docstring (free tier eliminated Feb 2026) - Add 23 tests covering normalization, filtering, date parsing
This commit is contained in:
@@ -632,8 +632,10 @@ def _search_web(
|
||||
topic, from_date, to_date, config["PARALLEL_API_KEY"], depth=depth,
|
||||
)
|
||||
elif backend == "brave":
|
||||
use_llm_ctx = os.environ.get("BRAVE_LLM_CONTEXT", "").strip() == "1"
|
||||
raw_results = brave_search.search_web(
|
||||
topic, from_date, to_date, config["BRAVE_API_KEY"], depth=depth,
|
||||
topic, from_date, to_date, config["BRAVE_API_KEY"],
|
||||
depth=depth, use_llm_context=use_llm_ctx,
|
||||
)
|
||||
elif backend == "openrouter":
|
||||
raw_results = openrouter_search.search_web(
|
||||
|
||||
Reference in New Issue
Block a user