dify/api/services/knowledge_fs
Jyong 0340784d57 feat(knowledge-fs): add automatic metadata filtering to retrieval node
Bring the LLM-driven "automatic" metadata filtering mode from the legacy
Knowledge Retrieval node to the KnowledgeFS retrieval node
(knowledge-retrieval-v2).

Backend:
- Accept `automatic` in `metadata_filtering_mode` and add
  `metadata_model_config` to the node entity.
- Add `automatic_metadata_filter.py`, which reuses the legacy metadata
  filter prompt templates, invokes the configured model, parses the JSON
  answer and normalises operators/values against the KnowledgeFS
  metadata catalog before building custom metadata conditions.
- Resolve the shared metadata catalog across the selected spaces through
  the new `list_metadata_fields` app execution capability (paginated),
  fail closed on missing/unavailable models and catalog admission errors,
  fail open on extraction errors, and expose the outcome via
  `metrics.metadata_filtering` and `llm_usage`.
- Inject the default extractor from the node factory.
- Fix an unescaped brace in the legacy completion prompt template that
  broke `.format()`.

Frontend:
- Offer disabled/automatic/manual modes, normalise unknown persisted
  modes to disabled, store the automatic model and completion params,
  render the model selector through the shared MetadataFilter, and
  require a model when saving in automatic mode.

Co-Authored-By: Claude Code <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WnUM1CdV5LpcxZEQ2vu9Xc
2026-09-02 02:55:12 -04:00
..
__init__.py Expand application capabilities and refactor core workflows 2026-07-22 05:09:09 -04:00
app_admission_service.py fix(workflow): stabilize KnowledgeFS retrieval access 2026-08-11 11:51:17 -04:00
app_binding_management.py Fix workflow binding sync session handling 2026-08-09 22:50:44 -04:00
app_execution_capability.py feat(knowledge-fs): add automatic metadata filtering to retrieval node 2026-09-02 02:55:12 -04:00
batch_capability.py Expand application capabilities and refactor core workflows 2026-07-22 05:09:09 -04:00
buffered_upload_admission.py perf(knowledge-fs): harden cross-format document ingestion 2026-08-31 07:48:35 -04:00
capability_broker.py refactor(knowledge_fs): replace credential service with dataset API key authorization. Remove the API token feature at the space level for knowledgeFs. 2026-08-26 15:40:18 +08:00
cleanup.py Expand application capabilities and refactor core workflows 2026-07-22 05:09:09 -04:00
control_plane_service.py fix(knowledge-fs): persist icon style selection (WTA-2068) 2026-08-17 17:31:25 +08:00
control_space_commands.py default KnowledgeFS external access on creation 2026-08-19 00:33:43 -04:00
control_space_lifecycle.py Expand application capabilities and refactor core workflows 2026-07-22 05:09:09 -04:00
control_space_management.py Expand application capabilities and refactor core workflows 2026-07-22 05:09:09 -04:00
cutover_runtime_gate.py feat(knowledge-fs): automate greenfield workspace cutover 2026-07-28 09:12:50 -04:00
cutover.py feat(knowledge-fs): automate greenfield workspace cutover 2026-07-28 09:12:50 -04:00
data_facade.py perf(knowledge-fs): harden cross-format document ingestion 2026-08-31 07:48:35 -04:00
download_service.py fix(knowledge-fs): align document download contracts 2026-08-12 11:43:32 +08:00
greenfield_initializer.py feat(knowledge-fs): automate greenfield workspace cutover 2026-07-28 09:12:50 -04:00
initial_source_preview_job.py feat(knowledge-fs): support datasource-driven source previews 2026-08-12 08:33:52 +08:00
initial_source_preview.py fix(knowledge-fs): disambiguate preview page types 2026-08-12 09:59:43 +08:00
lifecycle_port.py feat(dataset): support deferred New RAG model setup 2026-07-28 23:19:25 +08:00
lifecycle_readiness.py Expand application capabilities and refactor core workflows 2026-07-22 05:09:09 -04:00
lifecycle_remote_http.py feat(dataset): support deferred New RAG model setup 2026-07-28 23:19:25 +08:00
lifecycle_saga.py feat(dataset): support deferred New RAG model setup 2026-07-28 23:19:25 +08:00
membership_changes.py Expand application capabilities and refactor core workflows 2026-07-22 05:09:09 -04:00
object_storage.py feat(knowledge): stage document uploads before admission 2026-08-10 10:58:17 -04:00
observability.py Refactor frontend architecture and simplify implementation 2026-07-29 02:30:27 -04:00
orphan_reconciler.py Expand application capabilities and refactor core workflows 2026-07-22 05:09:09 -04:00
product_application_service.py fix(knowledge-fs): persist icon style selection (WTA-2068) 2026-08-17 17:31:25 +08:00
product_authorization.py feat(dataset): add New Knowledge space actions 2026-07-29 12:15:33 +08:00
product_dto.py fix(knowledge-fs): show task object titles 2026-09-02 01:43:16 -04:00
product_operations.py perf(knowledge-fs): harden cross-format document ingestion 2026-08-31 07:48:35 -04:00
product_remote_http.py feat(knowledge-fs): add profile-driven multimodal retrieval 2026-09-02 01:01:57 -04:00
product_remote.py feat(knowledge-fs): add profile-driven multimodal retrieval 2026-09-02 01:01:57 -04:00
product_service.py fix(knowledge-fs): persist icon style selection (WTA-2068) 2026-08-17 17:31:25 +08:00
query_images.py fix(knowledge-fs): align query image types 2026-09-02 14:06:14 +08:00
remote_images.py fix(knowledge-fs): persist document images across formats 2026-08-26 03:58:04 -04:00
remote_registry.py Expand application capabilities and refactor core workflows 2026-07-22 05:09:09 -04:00
revocation_commands.py Expand application capabilities and refactor core workflows 2026-07-22 05:09:09 -04:00
revocation_reconciler.py Expand application capabilities and refactor core workflows 2026-07-22 05:09:09 -04:00
runtime.py fix(knowledge-fs): align retrieval test timeout 2026-09-01 13:51:15 -04:00
service_api_authorization.py refactor(knowledge_fs): replace credential service with dataset API key authorization. Remove the API token feature at the space level for knowledgeFs. 2026-08-26 15:40:18 +08:00
source_import_commit_service.py feat(knowledge-fs): enhance source update payload with selection and sync policy validation 2026-08-30 23:58:27 +08:00
space_tag_service.py feat(knowledge-fs): update space tag management and improve type annotations 2026-08-13 11:14:52 +08:00
staged_upload_service.py feat(knowledge_fs): expand supported document upload formats 2026-08-25 19:58:15 +08:00