Brained Search Langsearch OR

tool

Smart LangSearch Search, OpenRouter version (The langsearch API is free)

cernunnos
@cernunnos
·
a year ago
9
0
1.4K
Updated a year ago
Created Dec 6, 2025
brained_search_langsearch_or.py
Python · 897 lines
"""
title: Smart Search LangSearch with Jina Scraper
author: Lug
author_url: https://brainedai.netlify.app
description: An advanced search tool that uses 2 LLMs to perform URL selection, and content extraction. Returns only the most relevant information.
required_open_webui_version: 0.6.0
requirements: ddgs, aiohttp, asyncio, requests
version: 0.9.3
license: MIT
"""

import json

Version 0.9.3, it can scrape arxiv paper (HTML or PDF), and other improvements.

A tool specially designed for BDS agent, but work well for any agent.

This tool works in four steps:
Step 1: performs a search with LangSearch API (free).
Step 2: LLM 1 selects a defined number of URLs from those in the search response based on “long_query” if it exists, otherwise based on “query”.
Step 3: The selected URLs are scraped by a cloud scraper (Jina)
Step 4: The pages scraped are sent to LLM 2, which selects the interesting information based on “long_query”.

The default LLM 2 is fast and free, but if you are doing scientific or complicated research, I recommend using an LLM such as Deepseek V3.2 or Kimi K2 Thinking.

Jina scraper without Jina API key scrapes 2 URLs at the same time. With Jina API key, it scrapes 5 URLs at the same time.

The main function of this tool is: smart_search

Important:
You need to have API key for OpenRouter and LangSearch, Langsearch is free, LLM 2 is free but LLM 1 cost 0.0002 if you want you can put a free LLM for LLM 1.
The minimum parameters to enter are the API keys for OpenRouter (for LLM 1 and for LLM 2) and for LangSearch.

A special version for OpenRouter that allows you to configure fallback models and prioritize providers using a list (provider IDs are separated by commas without spaces) or by enabling “Llm 2 Enable Throughput Sort.” If you enable this option, you disable the list of providers to prioritize and enable prioritization based on throughput, and you also enable the ability to disable providers that are too expensive.
https://openrouter.ai/docs/features/provider-routing


0