File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -886,13 +886,16 @@ def _expand_slash_commands(query: str) -> str:
886886 """Expande comandos como /investigate BRA ou /country:Brazil para prompts estruturados."""
887887 query_stripped = query .strip ()
888888
889- # 1. /investigate [ISO3 ]
889+ # 1. /investigate [CountryName or ISO ]
890890 investigate_pattern = (
891- r"^/(?:investigate_country_economy|investigate)\s+([A-Za-z]{2,3} )$"
891+ r"^/(?:investigate_country_economy|investigate)\s+([A-Za-z\s]+ )$"
892892 )
893893 inv_match = re .match (investigate_pattern , query_stripped , re .IGNORECASE )
894894 if inv_match :
895- country_code = inv_match .group (1 ).upper ()
895+ raw_country = inv_match .group (1 ).strip ().upper ()
896+ from ..wb_client .wdi_client import _ISO_NORMALIZATION
897+
898+ country_code = _ISO_NORMALIZATION .get (raw_country , raw_country )
896899 try :
897900 from mcp_src .anchor_mcp .main import investigate_country_economy
898901
Original file line number Diff line number Diff line change @@ -25,6 +25,16 @@ def test_expand_slash_commands():
2525 assert "country_code='BRA'" in expanded
2626
2727
28+ def test_expand_slash_commands_full_name ():
29+ """Verify that /investigate China is expanded and normalized to CHN."""
30+ query = "/investigate China"
31+ expanded = _expand_slash_commands (query )
32+ assert "CHN" in expanded
33+ assert "GDP" in expanded
34+ assert "search_documents" in expanded
35+ assert "country_code='CHN'" in expanded
36+
37+
2838def test_build_messages_with_context ():
2939 """Verify that document context is correctly injected into the user query."""
3040 user_query = "What is mentioned in the document?"
You can’t perform that action at this time.
0 commit comments