Skip to content

Commit b137bfa

Browse files
committed
Turn off RAG and Enable Fast Code by default
1 parent af32b0b commit b137bfa

File tree

6 files changed

+114
-25
lines changed

6 files changed

+114
-25
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3030
- **MCP Error Handling**: Auto-connect for `/mcp-tools`, detailed error messages with troubleshooting tips
3131

3232
### Changed
33+
- **Default Performance Settings**: Fast mode now enabled by default, RAG disabled by default for faster initial responses
3334
- `/mcp-tools` command now auto-connects to servers if not already connected
3435
- Improved MCP error messages and session management
36+
- Welcome screen displays performance settings (RAG/Fast Mode status) with contextual tips
37+
- Code generation completion messages now include tips to enable RAG for better quality when disabled
3538

3639
### Fixed
3740
- Fixed `/mcp-tools` command failing when server not connected

dspy_code/commands/interactive_command.py

Lines changed: 87 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -537,8 +537,8 @@ def _show_welcome(self):
537537
# Show RAG and Fast Mode status with humor
538538
try:
539539
rag_config = self.config_manager.config.codebase_rag
540-
rag_enabled = rag_config.enabled if rag_config else True
541-
fast_mode = rag_config.fast_mode if rag_config else False
540+
rag_enabled = rag_config.enabled if rag_config else False # Default to disabled
541+
fast_mode = rag_config.fast_mode if rag_config else True # Default to enabled
542542

543543
# RAG status
544544
if self.codebase_rag and self.codebase_rag.enabled:
@@ -564,26 +564,28 @@ def _show_welcome(self):
564564
console.print(f" {rag_status}")
565565
console.print(f" {fast_status}")
566566

567-
# Add humorous message about quality vs speed
567+
# Add message about quality vs speed
568568
if rag_enabled and not fast_mode:
569569
console.print()
570-
console.print("[dim]💡 Awesomeness takes time (but you can toggle anytime!)[/dim]")
570+
console.print("[dim]💡 RAG enabled - better code quality, slower responses[/dim]")
571571
console.print(
572572
"[dim] Use [cyan]/fast-mode on[/cyan] for faster responses or check [cyan]/status[/cyan] for details[/dim]"
573573
)
574574
elif not rag_enabled:
575575
console.print()
576-
console.print("[dim]💡 RAG disabled - faster startup, lower code quality[/dim]")
577576
console.print(
578-
"[dim] Use [cyan]/enable-rag[/cyan] to enable or check [cyan]/status[/cyan] for details[/dim]"
577+
"[dim]💡 Fast mode ON, RAG disabled - quick responses, lower code quality[/dim]"
578+
)
579+
console.print(
580+
"[dim] Use [cyan]/enable-rag[/cyan] and [cyan]/fast-mode off[/cyan] for better quality (slower)[/dim]"
579581
)
580582
elif fast_mode:
581583
console.print()
582584
console.print(
583585
"[dim]💡 Fast mode enabled - quick responses, slightly lower quality[/dim]"
584586
)
585587
console.print(
586-
"[dim] Use [cyan]/fast-mode off[/cyan] for better quality or check [cyan]/status[/cyan] for details[/dim]"
588+
"[dim] Use [cyan]/enable-rag[/cyan] and [cyan]/fast-mode off[/cyan] for better quality (slower)[/dim]"
587589
)
588590
except Exception as e:
589591
logger.debug(f"Error showing performance status: {e}")
@@ -1024,6 +1026,9 @@ def _handle_create_module(self, user_input: str):
10241026
console.print("[dim]✓ Code ready - use [cyan]/save <filename>[/cyan] to save it[/dim]")
10251027
console.print()
10261028

1029+
# Show RAG tip if disabled
1030+
self._show_rag_tip_if_needed()
1031+
10271032
show_next_steps(
10281033
[
10291034
"Type [cyan]/save <filename>[/cyan] to save this code",
@@ -1095,6 +1100,9 @@ def _handle_create_program(self, user_input: str):
10951100
console.print("[dim]✓ Code ready - use [cyan]/save <filename>[/cyan] to save it[/dim]")
10961101
console.print()
10971102

1103+
# Show RAG tip if disabled
1104+
self._show_rag_tip_if_needed()
1105+
10981106
show_next_steps(
10991107
[
11001108
"Type [cyan]/save <filename>[/cyan] to save this code",
@@ -1814,6 +1822,10 @@ def _handle_general_query(self, user_input: str):
18141822
self.current_context["type"] = "module"
18151823
show_code_panel(code, "Generated DSPy Code", "python")
18161824
show_success_message("Code generated!")
1825+
1826+
# Show RAG tip if disabled
1827+
self._show_rag_tip_if_needed()
1828+
18171829
show_next_steps(
18181830
[
18191831
"Type [cyan]/save <filename>[/cyan] to save this code",
@@ -2037,9 +2049,38 @@ def _is_fast_mode(self) -> bool:
20372049
"""Check if fast mode is enabled."""
20382050
try:
20392051
rag_config = self.config_manager.config.codebase_rag
2040-
return rag_config.fast_mode if rag_config else False
2052+
return rag_config.fast_mode if rag_config else True # Default to enabled
20412053
except:
2042-
return False
2054+
return True # Default to enabled
2055+
2056+
def _show_rag_tip_if_needed(self):
2057+
"""Show tip to enable RAG if it's disabled."""
2058+
# Only show once per session
2059+
if hasattr(self, "_rag_tip_shown"):
2060+
return
2061+
2062+
try:
2063+
rag_config = self.config_manager.config.codebase_rag
2064+
rag_enabled = rag_config.enabled if rag_config else False
2065+
fast_mode = rag_config.fast_mode if rag_config else True
2066+
2067+
# Only show if RAG is disabled
2068+
if rag_enabled:
2069+
return
2070+
2071+
console.print()
2072+
console.print(
2073+
"[yellow]💡 Tip:[/yellow] Want better code quality? "
2074+
"[cyan]/enable-rag[/cyan] and [cyan]/fast-mode off[/cyan] "
2075+
"(slower but more accurate)"
2076+
)
2077+
console.print("[dim] Current: Fast mode ON, RAG OFF - quick responses[/dim]")
2078+
console.print("[dim] Better: RAG ON, Fast mode OFF - slower but higher quality[/dim]")
2079+
console.print()
2080+
2081+
self._rag_tip_shown = True
2082+
except Exception:
2083+
pass
20432084

20442085
def _show_performance_tip_if_needed(self, generation_time: float):
20452086
"""Show performance tip after slow response."""
@@ -3507,6 +3548,43 @@ def _show_welcome_screen(console, context, config_manager):
35073548
console.print(Align.center(model_info))
35083549
console.print()
35093550

3551+
# Show RAG and Fast Mode status
3552+
try:
3553+
if config_manager:
3554+
rag_config = config_manager.config.codebase_rag
3555+
rag_enabled = rag_config.enabled if rag_config else False # Default to disabled
3556+
fast_mode = rag_config.fast_mode if rag_config else True # Default to enabled
3557+
3558+
# Performance status using Rich Text properly
3559+
perf_text = Text()
3560+
perf_text.append("⚡ Performance: ", style="dim")
3561+
perf_text.append("RAG ", style="dim")
3562+
if rag_enabled:
3563+
perf_text.append("ON", style="bold green")
3564+
else:
3565+
perf_text.append("OFF", style="bold red")
3566+
perf_text.append(" | Fast Mode ", style="dim")
3567+
if fast_mode:
3568+
perf_text.append("ON", style="bold green")
3569+
else:
3570+
perf_text.append("OFF", style="bold yellow")
3571+
console.print(Align.center(perf_text))
3572+
console.print()
3573+
3574+
# Show tip based on current settings
3575+
if not rag_enabled:
3576+
tip_text = Text()
3577+
tip_text.append("💡 ", style="yellow")
3578+
tip_text.append("Quick responses | ", style="dim")
3579+
tip_text.append("Enable RAG for better quality: ", style="dim")
3580+
tip_text.append("/enable-rag", style="cyan")
3581+
tip_text.append(" + ", style="dim")
3582+
tip_text.append("/fast-mode off", style="cyan")
3583+
console.print(Align.center(tip_text))
3584+
console.print()
3585+
except Exception:
3586+
pass
3587+
35103588
# Minimal help
35113589
console.print("[dim]Type /help for commands or describe what you want to build[/dim]")
35123590
console.print()

dspy_code/commands/slash_commands.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -673,8 +673,8 @@ def cmd_status(self, args: list):
673673
# Performance Settings
674674
try:
675675
rag_config = self.config_manager.config.codebase_rag
676-
rag_enabled = rag_config.enabled if rag_config else True
677-
fast_mode = rag_config.fast_mode if rag_config else False
676+
rag_enabled = rag_config.enabled if rag_config else False # Default to disabled
677+
fast_mode = rag_config.fast_mode if rag_config else True # Default to enabled
678678

679679
console.print("[bold]⚡ Performance Settings:[/bold]")
680680

@@ -699,20 +699,24 @@ def cmd_status(self, args: list):
699699
# Show tips based on current settings
700700
if rag_enabled and not fast_mode:
701701
console.print()
702-
console.print("[dim]💡 Awesomeness takes time (but you can toggle anytime!)[/dim]")
703-
console.print(
704-
"[dim] Use [cyan]/fast-mode on[/cyan] for faster responses (0.5-1s)[/dim]"
705-
)
702+
console.print("[dim]💡 RAG enabled - better code quality, slower responses[/dim]")
703+
console.print("[dim] Use [cyan]/fast-mode on[/cyan] for faster responses[/dim]")
706704
elif not rag_enabled:
707705
console.print()
708-
console.print("[dim]💡 RAG disabled - faster startup, lower code quality[/dim]")
709-
console.print("[dim] Use [cyan]/enable-rag[/cyan] for better code quality[/dim]")
706+
console.print(
707+
"[dim]💡 Fast mode ON, RAG disabled - quick responses, lower code quality[/dim]"
708+
)
709+
console.print(
710+
"[dim] Use [cyan]/enable-rag[/cyan] and [cyan]/fast-mode off[/cyan] for better quality (slower)[/dim]"
711+
)
710712
elif fast_mode:
711713
console.print()
712714
console.print(
713715
"[dim]💡 Fast mode enabled - quick responses, slightly lower quality[/dim]"
714716
)
715-
console.print("[dim] Use [cyan]/fast-mode off[/cyan] for better quality[/dim]")
717+
console.print(
718+
"[dim] Use [cyan]/enable-rag[/cyan] and [cyan]/fast-mode off[/cyan] for better quality (slower)[/dim]"
719+
)
716720

717721
except Exception as e:
718722
logger.debug(f"Error showing performance settings: {e}")
@@ -3116,7 +3120,7 @@ def cmd_fast_mode(self, args: list):
31163120
# Show status
31173121
try:
31183122
rag_config = self.config_manager.config.codebase_rag
3119-
is_fast = rag_config.fast_mode if rag_config else False
3123+
is_fast = rag_config.fast_mode if rag_config else True # Default to enabled
31203124
status = "enabled" if is_fast else "disabled"
31213125
console.print()
31223126
console.print(f"[cyan]Fast mode:[/cyan] {status}")

dspy_code/core/config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ class GepaConfig:
4242
class CodebaseRAGConfig:
4343
"""Configuration for codebase RAG system."""
4444

45-
enabled: bool = True
45+
enabled: bool = False # Disabled by default for faster responses
4646
# Performance options
47-
fast_mode: bool = False # Skip RAG context building for faster responses
47+
fast_mode: bool = True # Enabled by default for faster responses
4848
skip_pattern_searches: bool = False # Skip additional pattern-specific searches
4949
codebases: list[str] = field(default_factory=lambda: ["dspy-code", "dspy", "gepa"])
5050
cache_dir: str | None = None # Defaults to .dspy_code/cache/codebase_index in CWD

dspy_code/rag/codebase_rag.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def __init__(self, config_manager: ConfigManager | None = None, cache_dir: Path
6969
def _is_enabled(self) -> bool:
7070
"""Check if RAG is enabled in config."""
7171
if not self.config_manager:
72-
return True # Default to enabled
72+
return False # Default to disabled for faster responses
7373

7474
try:
7575
if hasattr(self.config_manager.config, "codebase_rag"):
@@ -79,7 +79,7 @@ def _is_enabled(self) -> bool:
7979
except:
8080
pass
8181

82-
return True # Default to enabled
82+
return False # Default to disabled for faster responses
8383

8484
def search(self, query: str, top_k: int = 5, strategy: str = "hybrid") -> list[SearchResult]:
8585
"""Search for relevant code snippets.

dspy_code/templates/dspy_config_example.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,12 @@ caching:
261261
# This indexes source code from installed packages to provide better code examples
262262

263263
codebase_rag:
264-
# Enable/disable codebase RAG
265-
enabled: true
264+
# Enable/disable codebase RAG (disabled by default for faster responses)
265+
enabled: false
266+
267+
# Performance options
268+
# Fast mode: Skip RAG context building for faster responses (enabled by default)
269+
fast_mode: true
266270

267271
# Codebases to index
268272
# Options: dspy-code, dspy, gepa, mcp

0 commit comments

Comments
 (0)