dify/api/tests/unit_tests/core
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
..
agent feat(api): track credit usage contexts (#41181) 2026-08-25 10:21:32 +00:00
app Merge remote-tracking branch 'origin/main' into deploy/konwledge 2026-09-01 09:45:49 +08:00
base fix(tts): propagate and validate actual audio MIME (#41043) 2026-08-24 03:38:09 +00:00
callback_handler test: enforce centralized config overrides (#40869) 2026-08-29 14:05:35 +00:00
datasource test: centralize core and service config overrides (#40868) 2026-08-29 14:05:34 +00:00
entities test: centralize core and service config overrides (#40868) 2026-08-29 14:05:34 +00:00
extension test: centralize core and service config overrides (#40868) 2026-08-29 14:05:34 +00:00
external_data_tool
file test: centralize app and account config overrides (#40860) 2026-08-25 06:19:35 +00:00
helper refactor(api): decouple system features and web adapters (#40772) 2026-09-01 11:50:52 +00:00
llm_generator refactor: pass db.session explicitly in instruction_modify_workflow (#37403) (#40827) 2026-08-30 00:48:00 +00:00
logging fix(api): restore deadlock-safe identity logging 2026-08-14 11:21:46 +08:00
mcp fix(workflow): block manual runs for trigger workflows (#41519) 2026-08-31 09:30:52 +00:00
memory test: migrate telemetry and core entity ORM models to SQLite (#40574) 2026-08-18 12:25:42 +00:00
model_runtime
moderation feat(api): track credit usage contexts (#41181) 2026-08-25 10:21:32 +00:00
ops Merge remote-tracking branch 'origin/main' into deploy/konwledge 2026-09-01 09:45:49 +08:00
plugin feat(knowledge-fs): add profile-driven multimodal retrieval 2026-09-02 01:01:57 -04:00
prompt test: enforce centralized config overrides (#40869) 2026-08-29 14:05:35 +00:00
rag Merge remote-tracking branch 'origin/main' into deploy/konwledge 2026-09-02 10:31:10 +08:00
repositories test: centralize enterprise config overrides (#40853) 2026-08-18 12:01:01 +00:00
schemas
telemetry fix: add missing metrics back and enhance typing (#40935) 2026-08-21 09:46:45 +00:00
tools Merge remote-tracking branch 'origin/main' into deploy/konwledge 2026-09-01 09:45:49 +08:00
trigger test: migrate trigger and webhook sessions and ORM models to SQLite (#40594) 2026-08-24 04:01:02 +00:00
variables feat(workflow): support human input in loop and iteration (#39243) 2026-08-03 02:24:18 +00:00
workflow feat(knowledge-fs): add automatic metadata filtering to retrieval node 2026-09-02 02:55:12 -04:00
__init__.py
test_file.py
test_model_context.py feat(api): track credit usage contexts (#41181) 2026-08-25 10:21:32 +00:00
test_model_manager.py feat(api): track credit usage contexts (#41181) 2026-08-25 10:21:32 +00:00
test_provider_configuration.py
test_provider_manager.py test: enforce centralized config overrides (#40869) 2026-08-29 14:05:35 +00:00
test_trigger_debug_event_selectors.py