web_search_helper.api module
FastAPI HTTP surface (optional [api] extra), and the /gui page.
The production server is search.php; this app is the suite’s HTTP door to
the same engine, for agents, scripts and local testing without PHP. Every
route has an explicit operation_id: web_search_helper.mcp_server
exposes exactly those as MCP tools, so a route renamed here renames its tool.
POST /queryspeakssearch.php’s protocol ({lang, q, v?}), so the page’sweb-search.jscan point at it;/guidoes exactly that.POST /searchtakes a plain question and embeds it server-side, for callers without a browser model.GET /healthanswers without reading anything (the container’s probe);GET /indexeslists the indexes served;POST /calibratemeasures thresholds (never writes);POST /check-onlineaudits a deployed site.
Indexes are read from WSH_DATA_DIR (default ./search-data), one
<lang>.php per language, as search.php reads them.
Run it with:
pip install 'web-search-helper[api,embed]'
WSH_DATA_DIR=site/search-data uvicorn web_search_helper.api:app --port 8040
Author: Warith Harchaoui <warithmetics@deraison.ai>
- class web_search_helper.api.CalibrateRequest(*, lang, inside, outside)[source]
Bases:
BaseModel- model_config = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class web_search_helper.api.CheckOnlineRequest(*, base_url, langs, question='test', data_dir='search-data')[source]
Bases:
BaseModel- model_config = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class web_search_helper.api.QueryRequest(*, lang, q, v=None)[source]
Bases:
BaseModel- model_config = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class web_search_helper.api.SearchRequest(*, lang, question, words_only=False, explain=False)[source]
Bases:
BaseModel- model_config = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- web_search_helper.api.main(argv=None)[source]
Console entry point (
web-search-helper-api): serve the HTTP API and/gui.A click command, so
--helpanswers instead of starting the server. Loopback by default;--host 0.0.0.0(orWSH_HOST) for a container. The port also readsPORT, as it did before the options existed.