Skip to content

feat(chat): add Querit web search provider - #17813

Merged
wangq8 merged 4 commits into
infiniflow:mainfrom
QueritOps:agent/querit-web-search
Aug 5, 2026
Merged

wangq8 merged 4 commits into
infiniflow:mainfrom
QueritOps:agent/querit-web-search

Conversation

@ethan7zhanghx

Copy link
Copy Markdown
Contributor

Summary

Add Querit as a built-in Web Search provider for RAGFlow Chat.

This change also refactors the existing Tavily-only Chat search path behind provider-neutral dispatch in the Python and Go runtimes, so Chat settings and runtime call sites can select the configured provider without changing existing Tavily behavior.

What changed

  • Added provider-neutral Web Search resolution and dispatch to the Python and Go Chat runtimes.
  • Added a Querit connector using POST https://api.querit.ai/v1/search with Bearer authentication.
  • Normalized Querit title, url, and snippet values into the reference format already consumed by RAGFlow Chat.
  • Routed the existing Chat Web Search call sites through the shared provider interface.
  • Replaced the Tavily-only Chat field with a Web Search provider selector for Tavily and Querit.
  • Sorted provider options alphabetically by display name and added provider logos.
  • Added provider-specific BYOK fields and kept Tavily and Querit credentials isolated.
  • Added a provider-neutral Chat capability flag while retaining the existing Tavily flag for compatibility.
  • Documented web_search_provider and querit_api_key in the HTTP API reference.
  • Added focused Python, Go, and frontend tests for provider resolution, request mapping, response normalization, legacy settings, credential isolation, malformed responses, and missing or whitespace-only keys.

Configuration and compatibility

  • New Chats without Web Search configuration remain unselected until a provider is chosen.
  • Existing Chats with a non-empty tavily_api_key and no provider field continue to use Tavily.
  • Querit is selected only when web_search_provider is set to querit.
  • Each provider requires its own non-empty API key; selecting one provider never falls back to the other provider's stored key.
  • Existing Tavily request parameters and normalized results remain unchanged.
  • Shared Chat pages continue to support the existing Tavily capability flag in addition to the provider-neutral flag.

Querit request behavior

  • Sends the Chat query as query.
  • Requests up to 6 results with chunksPerDoc=1.
  • Uses the selected Chat's querit_api_key as a Bearer token.
  • Converts Querit results to RAGFlow references with title, URL, content, and score fields.
  • Preserves the existing Chat Web Search failure behavior; invalid credentials or malformed responses do not expose the API key to the caller.

Querit API keys can be created at https://www.querit.ai/en/dashboard/api-keys.

Scope

This PR provides the unified Web Search provider interface, Querit connector, Chat configuration, and compatibility behavior.

It does not change reasoning-mode scheduling or gating, Agent Canvas tools, MCP configuration, managed credentials, custom provider endpoints, or credential hosting.

Testing

  • Focused frontend provider-selection tests: 8 passed.
  • Production frontend build: 14,288 modules transformed.
  • Live Querit official SDK check: 5 structured results.
  • Live RAGFlow Querit connector check: 6 normalized results.
  • Live Naive + Internet enabled Chat request: HTTP 200, matching [Querit]Q / [Querit]R runtime entries, inline citations, and source cards.
  • Recent-information query ranked official RAGFlow sources first.
  • Invalid-credential check returned an empty result without propagating the exception or exposing the credential.
  • Changed-file formatting and git diff --check passed.
  • Retained logs and screenshots were scanned for complete Querit and LLM API keys; no matches were found.
  • Full upstream CI matrix pending.

Screenshots

Web Search provider selector

Web Search provider selector

Querit configuration

Querit configuration

Chat request with Internet enabled

Chat request with Internet enabled

Chat response

Chat response

Citations and source cards

Chat citations and source cards

@dosubot dosubot Bot added size:XL This PR changes 500-999 lines, ignoring generated files. 💞 feature Feature request, pull request that fullfill a new feature. labels Aug 4, 2026
@coderabbitai

coderabbitai Bot commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 888e8b4f-c11d-4efa-abb4-7fb8bee2db32

📥 Commits

Reviewing files that changed from the base of the PR and between 6cfe159 and c84fcd6.

📒 Files selected for processing (1)
  • test/testcases/test_http_api/test_session_management/test_session_sdk_routes_unit.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • test/testcases/test_http_api/test_session_management/test_session_sdk_routes_unit.py

📝 Walkthrough

Walkthrough

This PR adds Querit as a web-search provider alongside Tavily. Backend services, RAG flows, API metadata, and frontend settings now use provider-neutral configuration. Querit responses are validated and converted into RAG chunks and document aggregates.

Changes

Web search provider integration

Layer / File(s) Summary
Provider contracts and resolution
internal/service/web_search_provider.go, rag/utils/web_search_conn.py, internal/service/web_search_provider_test.go, test/unit_test/rag/utils/test_web_search_conn.py
Provider selection supports Tavily and Querit. Configuration validates provider names and API keys.
Querit retrieval and normalization
internal/service/web_search_provider.go, rag/utils/querit_conn.py, internal/service/web_search_provider_test.go, test/unit_test/rag/utils/test_querit_conn.py
Querit requests use authentication and result limits. Responses are validated and converted into normalized search results, RAG chunks, and document aggregates.
Provider-neutral retrieval wiring
api/db/services/dialog_service.py, internal/service/chat_pipeline.go, internal/service/deep_researcher.go, rag/advanced_rag/...
Retrieval paths resolve the configured provider instead of reading Tavily settings directly. Existing result merging and failure handling remain in place.
API availability metadata
api/apps/restful_apis/bot_api.py, internal/handler/bot.go, internal/service/bot.go, docs/references/http_api_reference.md, internal/handler/bot_test.go, test/testcases/test_http_api/...
Chatbot metadata retains has_tavily_key and adds has_web_search_provider. API documentation includes Querit configuration fields.
Frontend provider configuration
web/src/components/web-search-form-field.tsx, web/src/pages/next-chats/chat/app-settings/*, web/src/pages/next-chats/chat/web-search-api-key.ts, web/src/pages/next-chats/chat/use-show-internet.*, web/src/interfaces/database/chat.ts, web/src/constants/chat.ts, web/src/locales/*, web/src/pages/next-chats/share/index.tsx
Chat settings support provider selection, provider-specific API keys, validation, localization, legacy Tavily inference, and provider-neutral availability checks.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ChatSettings
  participant ChatPipelineService
  participant WebSearchProvider
  participant Querit
  participant RAGResults
  ChatSettings->>ChatPipelineService: send provider configuration
  ChatPipelineService->>WebSearchProvider: resolve provider and API key
  WebSearchProvider->>Querit: create client or dispatch request
  Querit->>RAGResults: return normalized chunks and document aggregates
Loading

Possibly related PRs

Suggested labels: 🌈 python, 🧰 typescript, 🧪 test

Poem

A rabbit selects a search provider,
Tavily and Querit run beside her.
Chunks return in a tidy stream,
Settings match the chosen scheme.
“Search is ready!” the rabbit sings. 🐰

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 15.69% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely identifies the primary change: adding Querit as a Chat web search provider.
Description check ✅ Passed The description includes a clear summary, detailed changes, compatibility behavior, testing results, screenshots, and scope limitations.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@yingfeng yingfeng added the ci Continue Integration label Aug 4, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (5)
api/apps/restful_apis/bot_api.py (1)

145-152: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Log the new availability resolution.

Add a debug log after resolving has_web_search. Record only the dialog ID and availability value. Do not log prompt configuration or API keys. As per coding guidelines, “Add logging for new flows.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@api/apps/restful_apis/bot_api.py` around lines 145 - 152, After resolving
has_web_search in the dialog response flow, add a debug log that records only
the dialog ID and the resolved availability value. Keep prompt configuration and
API keys out of the log, and leave the existing get_result response unchanged.

Source: Coding guidelines

test/testcases/test_http_api/test_session_management/test_session_sdk_routes_unit.py (1)

1654-1671: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Test the Querit response path.

This fixture only uses tavily_api_key. It cannot detect a regression where has_web_search_provider fails for an explicitly selected Querit provider. Add an owned-dialog fixture with Querit selected and a Querit key, then assert that has_web_search_provider is true. As per coding guidelines, “Preserve still-valid behavior with focused tests.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@test/testcases/test_http_api/test_session_management/test_session_sdk_routes_unit.py`
around lines 1654 - 1671, The happy-path test around chatbots_inputs currently
covers only Tavily; add a focused owned-dialog fixture or case with Querit
explicitly selected and its key configured in prompt_config, then invoke
chatbots_inputs through the existing _run setup and assert the returned
data["has_web_search_provider"] is true. Preserve the existing Tavily assertions
and test structure.

Source: Coding guidelines

web/src/components/web-search-form-field.tsx (2)

22-65: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Rename the top-level constants to PascalCase.

Rename providerOptions and providerKeyConfig to PascalCase names. This keeps module constants consistent with the frontend naming rule.

As per coding guidelines, “Use PascalCase for React component names and top-level constants.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@web/src/components/web-search-form-field.tsx` around lines 22 - 65, Rename
the top-level constants providerOptions and providerKeyConfig to PascalCase
names, such as ProviderOptions and ProviderKeyConfig, and update every reference
to them in the component without changing their values or behavior.

Source: Coding guidelines


5-5: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use useTranslation in this component.

Replace useTranslate('chat') with useTranslation. Update the translation keys to use the same namespace convention as the adjacent chat settings components.

As per coding guidelines, “Prefer useTranslation from react-i18next over project-wrapped utilities such as useTranslate.”

Also applies to: 69-69

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@web/src/components/web-search-form-field.tsx` at line 5, Update the
web-search form component to use react-i18next’s useTranslation instead of the
project-wrapped useTranslate, and adjust its translation key references to match
the namespace convention used by adjacent chat settings components.

Source: Coding guidelines

internal/service/chat_pipeline.go (1)

775-778: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Update the Phase 9 comment to describe provider-neutral search.

Line 615 still says “Tavily web search,” but these lines resolve and dispatch the configured provider. Replace that reference with “web search provider.”

As per coding guidelines, Go comments must align with the current runtime path rather than migration history.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/service/chat_pipeline.go` around lines 775 - 778, Update the Phase 9
comment near the web-search flow to replace the provider-specific “Tavily web
search” wording with “web search provider,” matching the provider resolution
performed by resolveWebSearchProvider and retrieveWebSearch.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/references/http_api_reference.md`:
- Around line 3035-3037: Update the web_search_provider and querit_api_key
documentation to explicitly state that clients using querit_api_key must set
web_search_provider to "querit", while preserving the existing default of
"tavily" when the provider is omitted.

In `@internal/service/web_search_provider_test.go`:
- Around line 142-144: In the request handler’s JSON decode error path, replace
t.Fatalf with t.Errorf and return immediately so the handler goroutine exits
safely. Update the main test flow to detect an unrecoverable decode failure and
fail the test goroutine separately, preserving the existing request validation
behavior.

In `@rag/utils/web_search_conn.py`:
- Around line 47-52: Update create_web_search_provider to add debug-level
logging for each provider-resolution outcome: disabled or invalid configuration,
Querit selection, and Tavily selection. Log only the provider and resolution
status; do not include API keys or prompt content.

---

Nitpick comments:
In `@api/apps/restful_apis/bot_api.py`:
- Around line 145-152: After resolving has_web_search in the dialog response
flow, add a debug log that records only the dialog ID and the resolved
availability value. Keep prompt configuration and API keys out of the log, and
leave the existing get_result response unchanged.

In `@internal/service/chat_pipeline.go`:
- Around line 775-778: Update the Phase 9 comment near the web-search flow to
replace the provider-specific “Tavily web search” wording with “web search
provider,” matching the provider resolution performed by
resolveWebSearchProvider and retrieveWebSearch.

In
`@test/testcases/test_http_api/test_session_management/test_session_sdk_routes_unit.py`:
- Around line 1654-1671: The happy-path test around chatbots_inputs currently
covers only Tavily; add a focused owned-dialog fixture or case with Querit
explicitly selected and its key configured in prompt_config, then invoke
chatbots_inputs through the existing _run setup and assert the returned
data["has_web_search_provider"] is true. Preserve the existing Tavily assertions
and test structure.

In `@web/src/components/web-search-form-field.tsx`:
- Around line 22-65: Rename the top-level constants providerOptions and
providerKeyConfig to PascalCase names, such as ProviderOptions and
ProviderKeyConfig, and update every reference to them in the component without
changing their values or behavior.
- Line 5: Update the web-search form component to use react-i18next’s
useTranslation instead of the project-wrapped useTranslate, and adjust its
translation key references to match the namespace convention used by adjacent
chat settings components.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 6bd40b4e-95f2-4e23-b62d-7ecf5b7245cc

📥 Commits

Reviewing files that changed from the base of the PR and between 744b3ea and d859aea.

⛔ Files ignored due to path filters (1)
  • web/src/assets/querit.png is excluded by !**/*.png
📒 Files selected for processing (31)
  • api/apps/restful_apis/bot_api.py
  • api/db/services/dialog_service.py
  • docs/references/http_api_reference.md
  • internal/handler/bot.go
  • internal/handler/bot_test.go
  • internal/service/bot.go
  • internal/service/chat_pipeline.go
  • internal/service/deep_researcher.go
  • internal/service/web_search_provider.go
  • internal/service/web_search_provider_test.go
  • rag/advanced_rag/agentic_rag.py
  • rag/advanced_rag/harness/tools/search.py
  • rag/advanced_rag/tree_structured_query_decomposition_retrieval.py
  • rag/utils/querit_conn.py
  • rag/utils/web_search_conn.py
  • test/testcases/test_http_api/test_session_management/test_session_sdk_routes_unit.py
  • test/unit_test/rag/utils/test_querit_conn.py
  • test/unit_test/rag/utils/test_web_search_conn.py
  • web/src/components/tavily-form-field.tsx
  • web/src/components/web-search-form-field.tsx
  • web/src/constants/chat.ts
  • web/src/interfaces/database/chat.ts
  • web/src/locales/en.ts
  • web/src/locales/zh.ts
  • web/src/pages/next-chats/chat/app-settings/chat-prompt-engine.tsx
  • web/src/pages/next-chats/chat/app-settings/chat-settings.tsx
  • web/src/pages/next-chats/chat/app-settings/use-chat-setting-schema.tsx
  • web/src/pages/next-chats/chat/use-show-internet.test.ts
  • web/src/pages/next-chats/chat/use-show-internet.ts
  • web/src/pages/next-chats/chat/web-search-api-key.ts
  • web/src/pages/next-chats/share/index.tsx
💤 Files with no reviewable changes (1)
  • web/src/components/tavily-form-field.tsx

Comment thread docs/references/http_api_reference.md Resolved
Comment thread rag/utils/web_search_conn.py Resolved
@codecov

codecov Bot commented Aug 4, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.65%. Comparing base (744b3ea) to head (c84fcd6).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #17813   +/-   ##
=======================================
  Coverage   90.65%   90.65%           
=======================================
  Files          10       10           
  Lines         717      717           
  Branches      118      118           
=======================================
  Hits          650      650           
  Misses         39       39           
  Partials       28       28           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
test/testcases/test_http_api/test_session_management/test_session_sdk_routes_unit.py (2)

1685-1688: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Assert the retained legacy availability field.

The endpoint returns both has_tavily_key and has_web_search_provider from the same availability value (api/apps/restful_apis/bot_api.py, Lines 130-155). This Querit case checks only the provider-neutral field. Add an assertion for res["data"]["has_tavily_key"] is True to protect the backward-compatible API contract.

Proposed assertion
     assert res["code"] == 0
+    assert res["data"]["has_tavily_key"] is True
     assert res["data"]["has_web_search_provider"] is True
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@test/testcases/test_http_api/test_session_management/test_session_sdk_routes_unit.py`
around lines 1685 - 1688, Add an assertion in the Querit case around
chatbots_inputs to verify res["data"]["has_tavily_key"] is True, while
preserving the existing has_web_search_provider assertion and response-code
check.

1673-1688: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add logging for the new Querit flow.

Add a concise info-level log that identifies the Querit provider and dialog ID. This will make failures in the new test flow easier to diagnose.

As per coding guidelines, **/*.py: Add logging for new flows.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@test/testcases/test_http_api/test_session_management/test_session_sdk_routes_unit.py`
around lines 1673 - 1688, Add a concise info-level log in the Querit flow
exercised by chatbots_inputs, including the Querit provider and dialog ID (such
as “dialog-querit”). Keep the existing response assertions and provider-neutral
flag behavior unchanged.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@test/testcases/test_http_api/test_session_management/test_session_sdk_routes_unit.py`:
- Around line 1674-1684: Add an llm_id attribute to the querit_dialog
SimpleNamespace fixture, using an appropriate test value or empty string, so
chatbots_inputs can access dialog.llm_id without raising AttributeError.

---

Nitpick comments:
In
`@test/testcases/test_http_api/test_session_management/test_session_sdk_routes_unit.py`:
- Around line 1685-1688: Add an assertion in the Querit case around
chatbots_inputs to verify res["data"]["has_tavily_key"] is True, while
preserving the existing has_web_search_provider assertion and response-code
check.
- Around line 1673-1688: Add a concise info-level log in the Querit flow
exercised by chatbots_inputs, including the Querit provider and dialog ID (such
as “dialog-querit”). Keep the existing response assertions and provider-neutral
flag behavior unchanged.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 410af6d9-b651-4cc7-b346-34e22c0304f7

📥 Commits

Reviewing files that changed from the base of the PR and between 4bc311b and 6cfe159.

📒 Files selected for processing (5)
  • docs/references/http_api_reference.md
  • internal/service/chat_pipeline.go
  • internal/service/web_search_provider_test.go
  • rag/utils/web_search_conn.py
  • test/testcases/test_http_api/test_session_management/test_session_sdk_routes_unit.py
🚧 Files skipped from review as they are similar to previous changes (4)
  • docs/references/http_api_reference.md
  • internal/service/chat_pipeline.go
  • rag/utils/web_search_conn.py
  • internal/service/web_search_provider_test.go

@wangq8
wangq8 merged commit bdcd8aa into infiniflow:main Aug 5, 2026
5 checks passed
JinHai-CN pushed a commit that referenced this pull request Aug 20, 2026
### Summary

Adds You.com as a built-in Web Search provider for RAGFlow Chat,
alongside Tavily and Querit, using the provider-neutral dispatch #17813
put in place. No changes to existing Tavily or Querit behaviour.

You.com runs its own web index and returns several extracted passages
per result rather than a single meta description, so retrieved chunks
arrive with usable context.

---------

Co-authored-by: Brian Sparker <[email protected]>
Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
mill413 pushed a commit to mill413/ragflow that referenced this pull request Sep 3, 2026
mill413 pushed a commit to mill413/ragflow that referenced this pull request Sep 3, 2026
Adds You.com as a built-in Web Search provider for RAGFlow Chat,
alongside Tavily and Querit, using the provider-neutral dispatch infiniflow#17813
put in place. No changes to existing Tavily or Querit behaviour.

You.com runs its own web index and returns several extracted passages
per result rather than a single meta description, so retrieved chunks
arrive with usable context.

---------

Co-authored-by: Brian Sparker <[email protected]>
Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continue Integration 💞 feature Feature request, pull request that fullfill a new feature. size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants