Repository navigation
fix(knowledge): keep the indexing strategy and feature settings on a KB copy - #6233
Open
columbia11 wants to merge 1 commit into
Open
columbia11 wants to merge 1 commit into
columbia11 wants to merge 1 commit into
Conversation
…KB copy CopyKnowledgeBase created the destination from a field-by-field literal that left out IndexingStrategy, ExtractConfig, WikiConfig, QuestionGenerationConfig, AutoTagConfig and ASRConfig. The copy came up with the default vector+keyword strategy and wiki, graph, generated questions, auto-tagging and transcription switched off, whatever the source had. Take those settings from the same deep copy DuplicateKnowledgeBase uses.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
POST /api/v1/knowledge-bases/copywithout atarget_idcreates the destination knowledge base and copies the documents into it. The new knowledge base does not get the source's indexing strategy or its per-feature settings, so it indexes and processes documents differently from the knowledge base it was copied from, with nothing in the task result saying so.For a source with keyword search, wiki and graph enabled (vector off), the copy comes out as:
indexing_strategyextract_config(graph prompt, tags, node and relation types)wiki_configquestion_generation_configauto_tag_configasr_configDocuments uploaded to the copy afterwards get no graph extraction, no wiki pages, no generated questions, no auto-tagging and no transcription, and the extraction prompt and schema have to be re-entered by hand.
Cause
CopyKnowledgeBasebuilds the new knowledge base from a field-by-field literal. The literal predates these settings, and they were never added to it (VectorStoreID,StorageBackendIDandProfileConfigwere).EnsureDefaultsthen fills the emptyIndexingStrategywith the default.DuplicateKnowledgeBase(the settings-only copy the web UI uses) clones the whole configuration and is not affected.Change
The create branch of
CopyKnowledgeBasenow also setsIndexingStrategy,ASRConfig,ExtractConfig,WikiConfig,QuestionGenerationConfigandAutoTagConfig, taken from the same deep copyDuplicateKnowledgeBasestarts from (cloneKnowledgeBaseConfiguration).Copying into an existing
target_idis unchanged: that knowledge base keeps its own settings.Not changed, and worth knowing when reviewing: the copy task still transfers documents, chunks and index rows only. Wiki pages and graph data of the source are not copied and are not regenerated for the copied documents, before or after this PR. With this PR the copy has the wiki and graph settings, so documents added later are processed like in the source. That is the state a copy into an existing wiki- or graph-enabled knowledge base is already in today, so it is not a new one. Queueing wiki generation for the copied documents (the document move path does this) would be a separate change.
Type of Change
Related Issue
None found.
Testing
New test
TestCopyServiceCarriesIndexingStrategyAndFeatureSettingsininternal/application/service/knowledge_transfer_test.go: copy a source that has all six settings into a new destination and compare each one; the copy must also own itsExtractConfigrather than share the source's.With
main'sknowledgebase.goit fails on the first comparison:With the change it passes.
Commands, run in WSL (Ubuntu 24.04, Go 1.26.7, cgo on):
go test ./internal/application/service/ -count=1→ok.go vet ./internal/application/service/→ clean.gofmt -lon the two files → no output.golangci-lint run --new-from-patch=<git diff origin/main>on the package with golangci-lint v2.12.2 → 0 issues.git diff --check origin/main...HEAD→ clean.Not run:
make test/make lintfor the whole repository, and the endpoint was not called against a running server.Checklist
git diff --check origin/main...HEADpassesgolangci-lint run --new-from-rev=origin/main ./...) — run as--new-from-patchinternal/application/servicewebsite-docs/, Swagger annotations, etc.) — none neededScreenshots / Recordings
Not a UI change.