Skip to content

Commit 0eca2df

Browse files
committed
Use slash commands only slash is forst character
1 parent 211af9c commit 0eca2df

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

dspy_code/commands/nl_command_router.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -502,10 +502,16 @@ def route(
502502

503503
user_input_lower = user_input.lower().strip()
504504

505+
# Check if user explicitly references a slash command (e.g., "/save", "/mcp-read")
506+
# We need to distinguish between actual commands (like "/save") and file paths (like "/tmp/city")
507+
# Slash commands typically appear as "/command" at word boundaries or standalone
508+
slash_command_pattern = r'\b/(?:save|run|validate|connect|mcp-|init|help|status|clear|exit|optimize|eval|explain|model|models|data|examples|adapters|retrievers|demo|session)'
509+
has_slash_command = re.search(slash_command_pattern, user_input_lower) is not None
510+
505511
# For now, we are conservative: only attempt NL routing when the
506-
# user *explicitly* references slash commands (\"/\"), otherwise
512+
# user *explicitly* references slash commands, otherwise
507513
# we treat the input as a normal LLM request.
508-
if "/" not in user_input_lower:
514+
if not has_slash_command:
509515
logger.debug(
510516
f"No explicit slash command reference in NL input, treating as normal LLM input: '{user_input}'"
511517
)

0 commit comments

Comments
 (0)