Ragex. AI. Features. Config
(Ragex v0.14.1)
View Source
Configuration management for AI-enhanced features.
Provides a centralized configuration system for optional AI integrations throughout Ragex. Each feature can be individually enabled/disabled, and there's a master switch to control all AI features at once.
Configuration
# config/runtime.exs
config :ragex, :ai,
enabled: true, # Master switch - disables ALL AI features if false
providers: [:deepseek_r1, :openai],
default_provider: :deepseek_r1,
fallback_enabled: true
config :ragex, :ai_features,
# Editor features
validation_error_explanation: true,
refactor_preview_commentary: true,
commit_message_generation: true,
# Analysis features
dead_code_refinement: true,
duplication_semantic_analysis: true,
dependency_insights: true,
test_suggestions: false,
complexity_explanation: trueUsage
# Check if a feature is enabled
if Config.enabled?(:validation_error_explanation) do
# Use AI enhancement
else
# Fallback to non-AI behavior
end
# Check with per-call override
if Config.enabled?(:refactor_preview_commentary, ai_preview: false) do
# This will be false due to override
end
# Get feature-specific configuration
config = Config.get_feature_config(:validation_error_explanation)
Summary
Functions
Check if AI features are enabled globally.
Check if a specific AI feature is enabled.
Get the configuration map for a specific feature.
List all available AI features.
Get status of all AI features.
Types
@type feature() ::
:validation_error_explanation
| :refactor_preview_commentary
| :commit_message_generation
| :dead_code_refinement
| :duplication_semantic_analysis
| :dependency_insights
| :test_suggestions
| :complexity_explanation
@type override() :: boolean() | :force
Functions
@spec ai_enabled?() :: boolean()
Check if AI features are enabled globally.
Returns false if the master :ai, enabled flag is false, regardless of
individual feature flags.
Examples
iex> Config.ai_enabled?()
true
Check if a specific AI feature is enabled.
Respects the master AI switch and individual feature flags. Can be overridden with per-call options.
Parameters
feature- Feature identifier atomopts- Keyword list with optional overrides::ai_<feature>- Override for specific feature (e.g.,:ai_preview):force_ai- Force enable regardless of config (for testing)
Returns
trueif feature should be usedfalseif feature should be skipped
Examples
# Check global + feature config
Config.enabled?(:validation_error_explanation)
# With per-call override (disable)
Config.enabled?(:refactor_preview_commentary, ai_preview: false)
# With per-call override (force enable)
Config.enabled?(:test_suggestions, force_ai: true)
Get the configuration map for a specific feature.
Returns feature-specific settings like timeout, cache TTL, model preferences, etc.
Parameters
feature- Feature identifier atom
Returns
- Map of feature configuration options
Examples
iex> Config.get_feature_config(:validation_error_explanation)
%{
enabled: true,
timeout: 5000,
cache_ttl: 604_800, # 7 days
temperature: 0.7
}
@spec list_features() :: [feature()]
List all available AI features.
Returns
- List of feature atoms
Examples
iex> Config.list_features()
[:validation_error_explanation, :refactor_preview_commentary, ...]
Get status of all AI features.
Returns a map showing which features are currently enabled.
Returns
- Map of feature => enabled status
Examples
iex> Config.status()
%{
validation_error_explanation: true,
refactor_preview_commentary: true,
test_suggestions: false,
...
}