mirror of
https://github.com/langgenius/dify.git
synced 2026-09-05 00:31:19 +08:00
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 |
||
|---|---|---|
| .. | ||
| cleaner | ||
| data_post_processor | ||
| datasource | ||
| docstore | ||
| embedding | ||
| entities | ||
| extractor | ||
| index_processor | ||
| models | ||
| pipeline | ||
| rerank | ||
| retrieval | ||
| splitter | ||
| summary_index | ||
| __init__.py | ||