Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Principle:Langgenius Dify Feature Configuration

From Leeroopedia


Knowledge Sources
Domains Feature Toggle Patterns Progressive Enhancement
Last Updated 2026-02-08 00:00 GMT

Overview

Feature toggle patterns enable progressive capability enhancement in AI applications by allowing developers to activate or deactivate modular features independently without modifying core application logic.

Description

Dify applications support a set of optional, orthogonal features that can be independently enabled or disabled. Each feature follows a consistent pattern: a boolean enabled flag plus feature-specific configuration parameters. This design allows developers to progressively enhance their application's capabilities without risking regressions in existing functionality.

The supported feature toggles are:

Core Interaction Features:

  • More Like This (moreLikeThisConfig) -- Generates alternative responses to the same input, allowing end users to explore different outputs. Only available in completion mode.
  • Suggested Questions After Answer (suggestedQuestionsAfterAnswerConfig) -- Automatically generates follow-up question suggestions after each assistant response, encouraging continued engagement.

Voice Features:

  • Speech-to-Text (speechToTextConfig) -- Enables voice input, converting spoken language to text before sending to the LLM.
  • Text-to-Speech (textToSpeechConfig) -- Converts the assistant's text responses to spoken audio. Configurable with voice selection and language preference.

Quality and Safety Features:

  • Citation (citationConfig) -- When knowledge base (RAG) retrieval is active, displays source citations alongside the generated response, enabling end users to verify information provenance.
  • Moderation (moderationConfig) -- Applies content moderation rules to filter or flag inappropriate inputs and outputs. Supports multiple moderation providers and custom rule configurations.
  • Annotation Reply (annotationConfig) -- Enables a curated knowledge base of predefined question-answer pairs. When enabled, the system checks incoming queries against annotated responses using embedding similarity and returns the annotation if the similarity score exceeds a configurable threshold.

Usage

Configure features when:

  • Enhancing user experience with voice capabilities (speech-to-text, text-to-speech)
  • Adding safety guardrails (moderation, annotation)
  • Improving information transparency (citations)
  • Increasing engagement (suggested questions, more-like-this)

Theoretical Basis

The feature configuration system follows the Feature Toggle pattern (also known as Feature Flags), a well-established software engineering practice for controlling feature availability at runtime.

FUNCTION evaluate_features(response, feature_config):
    IF feature_config.citation.enabled AND has_retrieval_context:
        response = ATTACH_CITATIONS(response, retrieval_sources)

    IF feature_config.moderation.enabled:
        moderation_result = MODERATE(response, feature_config.moderation.config)
        IF moderation_result.flagged:
            response = APPLY_MODERATION_ACTION(response, moderation_result)

    IF feature_config.suggested_questions.enabled:
        suggestions = GENERATE_FOLLOWUPS(response, conversation_history)
        response.suggested_questions = suggestions

    IF feature_config.text_to_speech.enabled:
        audio = SYNTHESIZE_SPEECH(response.text, feature_config.tts.voice, feature_config.tts.language)
        response.audio = audio

    IF feature_config.annotation.enabled:
        annotation_match = SEARCH_ANNOTATIONS(user_input, feature_config.annotation.score_threshold)
        IF annotation_match:
            response = annotation_match.answer

    RETURN response

Design principles:

  • Independence -- Each feature toggle is orthogonal; enabling one does not affect others.
  • Safe defaults -- All features default to enabled: false, ensuring a minimal baseline configuration.
  • Gradual rollout -- Features can be activated one at a time, allowing developers to test each capability in isolation before combining them.

Related Pages

Implemented By

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment