[PR #2004] [MERGED] feat: add user toggleable web search #7655

Closed
opened 2025-11-11 17:32:31 -06:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/2004
Author: @cheahjs
Created: 5/6/2024
Status: Merged
Merged: 5/27/2024
Merged by: @tjbck

Base: websearchHead: feat/backend-web-search


📝 Commits (10+)

  • 501ff7a feat: backend implementation of various search APIs
  • 99e4edd feat: add websearch endpoint to RAG API
  • 83f086c fix: do not return raw search exception due to API keys in URLs
  • 8b3e370 fix: run formatter
  • 635951b Merge branch 'dev' into feat/backend-web-search
  • fb80691 feat: add WEB_SEARCH_RESULT_COUNT to control max number of results
  • 14a902f feat: add web search toggle on chat
  • 619c2f9 fix: toggle style
  • 2660a6e feat: prototype frontend web search integration
  • 77928ae Merge branch 'dev' of https://github.com/open-webui/open-webui into feat/web-search-toggle

📊 Changes

57 files changed (+3474 additions, -60 deletions)

View changed files

📝 backend/apps/rag/main.py (+72 -17)
backend/apps/rag/search/brave.py (+37 -0)
backend/apps/rag/search/google_pse.py (+45 -0)
backend/apps/rag/search/main.py (+9 -0)
backend/apps/rag/search/searxng.py (+44 -0)
backend/apps/rag/search/serper.py (+39 -0)
backend/apps/rag/search/serpstack.py (+43 -0)
backend/apps/rag/search/testdata/brave.json (+998 -0)
backend/apps/rag/search/testdata/google_pse.json (+442 -0)
backend/apps/rag/search/testdata/searxng.json (+476 -0)
backend/apps/rag/search/testdata/serper.json (+190 -0)
backend/apps/rag/search/testdata/serpstack.json (+276 -0)
📝 backend/apps/rag/utils.py (+43 -1)
📝 backend/config.py (+19 -0)
📝 backend/constants.py (+4 -0)
📝 backend/main.py (+3 -1)
📝 src/lib/apis/openai/index.ts (+117 -0)
📝 src/lib/apis/rag/index.ts (+32 -0)
📝 src/lib/components/chat/Chat.svelte (+76 -4)
📝 src/lib/components/chat/MessageInput.svelte (+72 -0)

...and 37 more files

📄 Description

Pull Request Checklist

  • Description: Briefly describe the changes in this pull request.
  • Changelog: Ensure a changelog entry following the format of Keep a Changelog is added at the bottom of the PR description.
  • Documentation: Have you updated relevant documentation Open WebUI Docs, or other documentation sources?
  • Dependencies: Are there any new dependencies? Have you updated the dependency versions in the documentation?
  • Testing: Have you written and run sufficient tests for the changes?
  • Code Review: Have you self-reviewed your code and addressed any coding standard issues?

Description

Adds the ability to perform web searches via the RAG API (rag/api/v1/websearch) using the following search providers:

  1. SearXNG, configured with SEARXNG_QUERY_URL, eg SEARXNG_QUERY_URL=https://search.projectsegfau.lt/search?q=<query>
  2. Google Programmatic Search Engine, configured with GOOGLE_PSE_API_KEY and GOOGLE_PSE_ENGINE_ID
  3. Brave Search, configured with BRAVE_SEARCH_API_KEY
  4. serpstack - Google proxy, configured with SERPSTACK_API_KEY (and an optional SERPSTACK_HTTPS=false, since the free tier doesn't allow for HTTPS connections)
  5. serper - Google proxy, configured with SERPER_API_KEY.

Users can configure how many of the top search results to crawl with RAG_WEB_SEARCH_RESULT_COUNT, and RAG_WEB_SEARCH_CONCURRENT_REQUESTS controls the number of concurrent requests made to crawl the search results.

Users can toggle web search on or off on the UI, which causes the frontend to use a prompt to generate a search query, calling the RAG API to search for that query, and then injecting the results of that as a RAG document.

Implements #586


Changelog Entry

Added

  • 🔍Web Search for RAG: You can now perform web searches when chatting using providers like SearXNG, Google PSE, Brave Search, serpstack, and serper.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/open-webui/open-webui/pull/2004 **Author:** [@cheahjs](https://github.com/cheahjs) **Created:** 5/6/2024 **Status:** ✅ Merged **Merged:** 5/27/2024 **Merged by:** [@tjbck](https://github.com/tjbck) **Base:** `websearch` ← **Head:** `feat/backend-web-search` --- ### 📝 Commits (10+) - [`501ff7a`](https://github.com/open-webui/open-webui/commit/501ff7a98bb874007ea1645d9fa371f75ae81f1a) feat: backend implementation of various search APIs - [`99e4edd`](https://github.com/open-webui/open-webui/commit/99e4edd3645bd513456a6664b7810f7780b28bc5) feat: add websearch endpoint to RAG API - [`83f086c`](https://github.com/open-webui/open-webui/commit/83f086ccdddc31ae10c7c298bd8952da9959c629) fix: do not return raw search exception due to API keys in URLs - [`8b3e370`](https://github.com/open-webui/open-webui/commit/8b3e370a6eec353c931af76739bae2506238d726) fix: run formatter - [`635951b`](https://github.com/open-webui/open-webui/commit/635951b55c0868bd825f7e30a51c2d97bb4052a0) Merge branch 'dev' into feat/backend-web-search - [`fb80691`](https://github.com/open-webui/open-webui/commit/fb8069123e49f703031be9d41e30bc85151b1a33) feat: add WEB_SEARCH_RESULT_COUNT to control max number of results - [`14a902f`](https://github.com/open-webui/open-webui/commit/14a902fcfae1226cf4c991cf923a90932727b6b2) feat: add web search toggle on chat - [`619c2f9`](https://github.com/open-webui/open-webui/commit/619c2f9c711b06afaeeb7f1cb40b85408c43951c) fix: toggle style - [`2660a6e`](https://github.com/open-webui/open-webui/commit/2660a6e5b88c5afe50bc370751e0f1d17bbdc4bb) feat: prototype frontend web search integration - [`77928ae`](https://github.com/open-webui/open-webui/commit/77928ae1417764f34438af8bd555dacb1b7c2901) Merge branch 'dev' of https://github.com/open-webui/open-webui into feat/web-search-toggle ### 📊 Changes **57 files changed** (+3474 additions, -60 deletions) <details> <summary>View changed files</summary> 📝 `backend/apps/rag/main.py` (+72 -17) ➕ `backend/apps/rag/search/brave.py` (+37 -0) ➕ `backend/apps/rag/search/google_pse.py` (+45 -0) ➕ `backend/apps/rag/search/main.py` (+9 -0) ➕ `backend/apps/rag/search/searxng.py` (+44 -0) ➕ `backend/apps/rag/search/serper.py` (+39 -0) ➕ `backend/apps/rag/search/serpstack.py` (+43 -0) ➕ `backend/apps/rag/search/testdata/brave.json` (+998 -0) ➕ `backend/apps/rag/search/testdata/google_pse.json` (+442 -0) ➕ `backend/apps/rag/search/testdata/searxng.json` (+476 -0) ➕ `backend/apps/rag/search/testdata/serper.json` (+190 -0) ➕ `backend/apps/rag/search/testdata/serpstack.json` (+276 -0) 📝 `backend/apps/rag/utils.py` (+43 -1) 📝 `backend/config.py` (+19 -0) 📝 `backend/constants.py` (+4 -0) 📝 `backend/main.py` (+3 -1) 📝 `src/lib/apis/openai/index.ts` (+117 -0) 📝 `src/lib/apis/rag/index.ts` (+32 -0) 📝 `src/lib/components/chat/Chat.svelte` (+76 -4) 📝 `src/lib/components/chat/MessageInput.svelte` (+72 -0) _...and 37 more files_ </details> ### 📄 Description ## Pull Request Checklist - [x] **Description:** Briefly describe the changes in this pull request. - [ ] **Changelog:** Ensure a changelog entry following the format of [Keep a Changelog](https://keepachangelog.com/) is added at the bottom of the PR description. - [ ] **Documentation:** Have you updated relevant documentation [Open WebUI Docs](https://github.com/open-webui/docs), or other documentation sources? - [ ] **Dependencies:** Are there any new dependencies? Have you updated the dependency versions in the documentation? - [x] **Testing:** Have you written and run sufficient tests for the changes? - [ ] **Code Review:** Have you self-reviewed your code and addressed any coding standard issues? --- ## Description Adds the ability to perform web searches via the RAG API (`rag/api/v1/websearch`) using the following search providers: 1. [SearXNG](https://searx.space/), configured with `SEARXNG_QUERY_URL`, eg `SEARXNG_QUERY_URL=https://search.projectsegfau.lt/search?q=<query>` 2. [Google Programmatic Search Engine](https://programmablesearchengine.google.com/about/), configured with `GOOGLE_PSE_API_KEY` and `GOOGLE_PSE_ENGINE_ID` 3. [Brave Search](https://brave.com/search/api/), configured with `BRAVE_SEARCH_API_KEY` 4. [serpstack](https://serpstack.com/) - Google proxy, configured with `SERPSTACK_API_KEY` (and an optional `SERPSTACK_HTTPS=false`, since the free tier doesn't allow for HTTPS connections) 5. [serper](https://serper.dev) - Google proxy, configured with `SERPER_API_KEY`. Users can configure how many of the top search results to crawl with `RAG_WEB_SEARCH_RESULT_COUNT`, and `RAG_WEB_SEARCH_CONCURRENT_REQUESTS` controls the number of concurrent requests made to crawl the search results. Users can toggle web search on or off on the UI, which causes the frontend to use a prompt to generate a search query, calling the RAG API to search for that query, and then injecting the results of that as a RAG document. Implements #586 --- ### Changelog Entry ### Added - **🔍Web Search for RAG**: You can now perform web searches when chatting using providers like SearXNG, Google PSE, Brave Search, serpstack, and serper. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2025-11-11 17:32:31 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#7655