Skip to content

Refactor: explictly use keywords_similarity_weight - #20379

Merged
yuzhichang merged 1 commit into
infiniflow:mainfrom
wangq8:refactor/use-keyword-similarity-weight-as-major
Sep 29, 2026
Merged

yuzhichang merged 1 commit into
infiniflow:mainfrom
wangq8:refactor/use-keyword-similarity-weight-as-major

Conversation

@wangq8

@wangq8 wangq8 commented Sep 29, 2026 •

Copy link
Copy Markdown
Collaborator

Tested: pass

@wangq8
wangq8 requested a review from yuzhichang September 29, 2026 09:08
@coderabbitai

coderabbitai Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 257da375-aedb-4c29-88bb-034c150ee108

📥 Commits

Reviewing files that changed from the base of the PR and between 66fb8d0 and 4f222d3.

📒 Files selected for processing (24)
  • docs/references/http_api_reference.md
  • internal/handler/chat.go
  • internal/handler/dataset.go
  • internal/handler/dataset_search_test.go
  • internal/handler/searchbot.go
  • internal/service/chat.go
  • internal/service/chat_rest_update_test.go
  • internal/service/dataset_types.go
  • internal/service/search.go
  • internal/service/search_test.go
  • internal/service/similarity_weight.go
  • internal/service/similarity_weight_test.go
  • web/src/components/similarity-slider/index.tsx
  • web/src/interfaces/database/chat.ts
  • web/src/interfaces/request/knowledge.ts
  • web/src/pages/dataset/testing/testing-form.tsx
  • 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/hooks/use-create-chat.ts
  • web/src/pages/next-search/search-setting-hooks.ts
  • web/src/pages/next-search/search-setting.tsx
  • web/src/pages/next-searches/hooks.ts
  • web/src/services/knowledge-service.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

The change makes keywords_similarity_weight the primary setting for chat, search, and retrieval configuration. Backend services resolve the vector weight as its complement, validate supplied weight combinations, and return keyword weight in chat responses. Web forms and API documentation use the updated field.

Changes

Similarity Weight Configuration

Layer / File(s) Summary
Weight resolution and service updates
internal/service/similarity_weight.go, internal/service/similarity_weight_test.go, internal/service/chat.go, internal/service/chat_rest_update_test.go, internal/service/search.go, internal/service/search_test.go
Shared functions validate weight ranges and matching sums, derive the complementary vector weight, and normalize configuration maps. Chat and search service paths use this handling, with tests for derivation and validation.
Backend request and response paths
internal/service/dataset_types.go, internal/handler/dataset.go, internal/handler/dataset_search_test.go, internal/handler/searchbot.go, internal/handler/chat.go, docs/references/http_api_reference.md
Dataset and retrieval request paths accept and resolve keyword weight. Chat responses include keyword weight. The API reference describes the primary field, legacy fallback, and matching-sum requirement.
Web settings and retrieval forms
web/src/components/similarity-slider/index.tsx, web/src/interfaces/database/chat.ts, web/src/interfaces/request/knowledge.ts, web/src/pages/dataset/testing/testing-form.tsx, web/src/pages/next-chats/..., web/src/pages/next-search/..., web/src/pages/next-searches/hooks.ts, web/src/services/knowledge-service.ts
Web forms and request types use keyword similarity weight for chat settings, search settings, and retrieval testing. Existing vector weights are optional in chat and search configuration interfaces.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Feature

Suggested reviewers: jinhai-cn, euvre, cike8899

Merge Risk: ⚪ Minimal · up to 4f222

The change makes keyword similarity weight the primary setting and derives the vector weight from it. Inspected callers and request paths showed no reachable failure, so it appears ready to merge after normal checks.

Security Architecture Review

Security architecture risk: 🟡 Moderate · up to 4f222

Current-version requests validate and preserve the complementary weights, but a browser and server running different versions could save a setting that later produces a different retrieval weight. No new authorization bypass was established.

Retained concerns

  • Medium · architecture · inferred: During rollback or mixed-version operation, a keyword-only search-settings update can leave the legacy vector weight absent or stale. Retrieval can then use the old value; an inconsistent saved pair is not resolved when the new server returns.
Security review details

Security Blast Radius

  • inferred — The changed input affects retrieval weighting for search and dataset requests. The inspected searchbot path does not add dataset or document identifiers to the caller-controlled request scope.

Trust Boundaries and Controls

  • observed — Dataset-search validation resolves and checks caller-supplied weights before passing the vector value into the existing search-parameter validation.

Resilience and Maintainability Implications

  • inferred — Version-skewed writes can cause retrieval settings to drift without changing dataset authorization. Whether mixed client and server versions can operate together during deployment or rollback is not established.

Hardening Proposals

  • proposed — Keep the vector complement in client updates while rollback to a vector-only server remains possible, and verify retrieval after mixed-version writes and restoration.
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 13.64% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 22 functions across 23 files. (1 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The description only states “Tested: pass” and does not include the required Summary section or explain the purpose and background of the changes. Add a Summary section that briefly explains the migration to keywords_similarity_weight, the legacy role of vector_similarity_weight, and the purpose of the related backend, frontend, and documentation changes.
✅ Passed checks (3 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly identifies the main change: using keywords_similarity_weight explicitly. It is concise and related to the changeset, although “explictly” is misspelled.
Full details: Docstring Coverage

Explanation

Docstring coverage is 13.64% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 22 functions across 23 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI

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

A rabbit checks the weights at dawn
Keyword leads; the vector follows on
A slider hops to a new place
Both values settle into space
The docs now show the balanced pair
Soft paws leave tidy sums to spare

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

@yuzhichang
yuzhichang merged commit f88c1d1 into infiniflow:main Sep 29, 2026
1 check passed
@wangq8
wangq8 requested a review from cike8899 September 29, 2026 09:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants