Skip to content

Commit 7039845

Browse files
authored
feat(letsgo): add nimble-search to letsgo auto-detection (#6080)
Add remote::nimble-search to the web search provider priority list so it is auto-detected when NIMBLE_API_KEY is set. Update the corresponding unit tests to cover the new provider. Signed-off-by: Matthew Farrellee <matt@cs.wisc.edu>
1 parent 7bbfa12 commit 7039845

2 files changed

Lines changed: 15 additions & 5 deletions

File tree

src/ogx/cli/stack/lets_go.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ def _add_file_search_and_responses(run_config: StackConfig) -> None:
248248
("remote::brave-search", "brave-search"),
249249
("remote::tavily-search", "tavily-search"),
250250
("remote::bing-search", "bing-search"),
251+
("remote::nimble-search", "nimble-search"),
251252
]
252253
tool_runtime_registry = get_provider_registry().get(Api.tool_runtime, {})
253254
existing_web_search: set[str] = {

tests/unit/cli/test_stack_lets_go.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,7 @@ def test_uses_brave_when_brave_key_is_set(self, monkeypatch: pytest.MonkeyPatch)
557557
monkeypatch.setenv("BRAVE_SEARCH_API_KEY", "brave-key")
558558
monkeypatch.delenv("TAVILY_SEARCH_API_KEY", raising=False)
559559
monkeypatch.delenv("BING_API_KEY", raising=False)
560+
monkeypatch.delenv("NIMBLE_API_KEY", raising=False)
560561

561562
with patch("ogx.cli.stack.lets_go.cprint") as mock_cprint:
562563
_add_file_search_and_responses(
@@ -571,13 +572,14 @@ def test_uses_brave_when_brave_key_is_set(self, monkeypatch: pytest.MonkeyPatch)
571572

572573
web_search_providers = [
573574
p
574-
for p in ["brave-search", "tavily-search", "bing-search"]
575+
for p in ["brave-search", "tavily-search", "bing-search", "nimble-search"]
575576
if any(p in str(call) for call in mock_cprint.call_args_list)
576577
]
577578
# Only brave should be added (env var set)
578579
assert "brave-search" in web_search_providers
579580
assert "tavily-search" not in web_search_providers
580581
assert "bing-search" not in web_search_providers
582+
assert "nimble-search" not in web_search_providers
581583

582584
def test_falls_back_to_tavily_when_only_tavily_key_set(self, monkeypatch: pytest.MonkeyPatch):
583585
from ogx.cli.stack.lets_go import _add_file_search_and_responses
@@ -586,6 +588,7 @@ def test_falls_back_to_tavily_when_only_tavily_key_set(self, monkeypatch: pytest
586588
monkeypatch.delenv("BRAVE_SEARCH_API_KEY", raising=False)
587589
monkeypatch.setenv("TAVILY_SEARCH_API_KEY", "tavily-key")
588590
monkeypatch.delenv("BING_API_KEY", raising=False)
591+
monkeypatch.delenv("NIMBLE_API_KEY", raising=False)
589592

590593
with patch("ogx.cli.stack.lets_go.cprint") as mock_cprint:
591594
_add_file_search_and_responses(
@@ -606,6 +609,8 @@ def test_falls_back_to_tavily_when_only_tavily_key_set(self, monkeypatch: pytest
606609
provider_ids_in_calls.add("tavily-search")
607610
if "bing-search" in str(call):
608611
provider_ids_in_calls.add("bing-search")
612+
if "nimble-search" in str(call):
613+
provider_ids_in_calls.add("nimble-search")
609614

610615
# Only tavily is added since only its env var is set
611616
assert provider_ids_in_calls == {"tavily-search"}
@@ -617,6 +622,7 @@ def test_selects_first_with_api_key(self, monkeypatch: pytest.MonkeyPatch):
617622
monkeypatch.setenv("BRAVE_SEARCH_API_KEY", "brave-key")
618623
monkeypatch.setenv("TAVILY_SEARCH_API_KEY", "tavily-key")
619624
monkeypatch.setenv("BING_API_KEY", "bing-key")
625+
monkeypatch.setenv("NIMBLE_API_KEY", "nimble-key")
620626

621627
with patch("ogx.cli.stack.lets_go.cprint") as mock_cprint:
622628
_add_file_search_and_responses(
@@ -637,16 +643,18 @@ def test_selects_first_with_api_key(self, monkeypatch: pytest.MonkeyPatch):
637643
provider_ids_in_calls.add("tavily-search")
638644
if "bing-search" in str(call):
639645
provider_ids_in_calls.add("bing-search")
646+
if "nimble-search" in str(call):
647+
provider_ids_in_calls.add("nimble-search")
640648

641-
# All three have keys, all three should be added
642-
assert provider_ids_in_calls == {"brave-search", "tavily-search", "bing-search"}
649+
# All four have keys, all four should be added
650+
assert provider_ids_in_calls == {"brave-search", "tavily-search", "bing-search", "nimble-search"}
643651

644652
def test_no_web_search_when_no_key_set(self, monkeypatch: pytest.MonkeyPatch):
645653
from ogx.cli.stack.lets_go import _add_file_search_and_responses
646654
from ogx.core.datatypes import StackConfig
647655

648656
# Clear env vars to ensure no keys are set
649-
for var in ("BRAVE_SEARCH_API_KEY", "TAVILY_SEARCH_API_KEY", "BING_API_KEY"):
657+
for var in ("BRAVE_SEARCH_API_KEY", "TAVILY_SEARCH_API_KEY", "BING_API_KEY", "NIMBLE_API_KEY"):
650658
monkeypatch.delenv(var, raising=False)
651659

652660
with patch("ogx.cli.stack.lets_go.cprint") as mock_cprint:
@@ -668,7 +676,7 @@ def test_duplicate_providers_when_already_configured(self, monkeypatch: pytest.M
668676
from ogx.cli.stack.lets_go import _add_file_search_and_responses
669677
from ogx.core.datatypes import Provider, StackConfig
670678

671-
for var in ("BRAVE_SEARCH_API_KEY", "TAVILY_SEARCH_API_KEY", "BING_API_KEY"):
679+
for var in ("BRAVE_SEARCH_API_KEY", "TAVILY_SEARCH_API_KEY", "BING_API_KEY", "NIMBLE_API_KEY"):
672680
monkeypatch.delenv(var, raising=False)
673681

674682
initial_providers = [
@@ -690,6 +698,7 @@ def test_duplicate_providers_when_already_configured(self, monkeypatch: pytest.M
690698
"remote::brave-search",
691699
"remote::tavily-search",
692700
"remote::bing-search",
701+
"remote::nimble-search",
693702
}
694703
web_search_providers = [p for p in config.providers["tool_runtime"] if p.provider_type in web_search_types]
695704
assert len(web_search_providers) == 1

0 commit comments

Comments
 (0)