Your lightweight open-source personal agent.
Python agent-frameworkai-agentai-agentschatbotchatopsdiscord-botllm-agentsllmslocal-llmmcpmodel-context-protocolmulti-agentopenai-compatibleopenclawpersonal-ai-assistantpythonself-hostedtelegram-bot-ai-assistantwebuiworkflow-automation
refactor: move search_usage to utils/searchusage, remove brave stub
Xubin Ren7ffd93f48dae
diff --git a/nanobot/command/builtin.py b/nanobot/command/builtin.pyindex 81623ebd5..8ead6a131 100644--- a/nanobot/command/builtin.py+++ b/nanobot/command/builtin.py@@ -64,7 +64,7 @@ async def cmd_status(ctx: CommandContext) -> OutboundMessage:# Fetch web search provider usage (best-effort, never blocks the response)search_usage_text: str | None = Nonetry:- from nanobot.agent.tools.search_usage import fetch_search_usage+ from nanobot.utils.searchusage import fetch_search_usageweb_cfg = getattr(getattr(loop, "config", None), "tools", None)web_cfg = getattr(web_cfg, "web", None) if web_cfg else Nonesearch_cfg = getattr(web_cfg, "search", None) if web_cfg else Nonediff --git a/nanobot/agent/tools/search_usage.py b/nanobot/utils/searchusage.pysimilarity index 89%rename from nanobot/agent/tools/search_usage.pyrename to nanobot/utils/searchusage.pyindex 70fecb8c6..3e0c86101 100644--- a/nanobot/agent/tools/search_usage.py+++ b/nanobot/utils/searchusage.py@@ -81,10 +81,8 @@ async def fetch_search_usage(if p == "tavily":return await _fetch_tavily_usage(api_key)- elif p == "brave":- return await _fetch_brave_usage(api_key)else:- # duckduckgo, searxng, jina, unknown — no usage API+ # brave, duckduckgo, searxng, jina, unknown — no usage APIreturn SearchUsageInfo(provider=p, supported=False)@@ -171,13 +169,3 @@ def _parse_tavily_usage(data: dict[str, Any]) -> SearchUsageInfo:)-# ----------------------------------------------------------------------------# Brave-# -----------------------------------------------------------------------------async def _fetch_brave_usage(api_key: str | None) -> SearchUsageInfo:- """- Brave Search does not have a public usage/quota endpoint.- Rate-limit headers are returned per-request, not queryable standalone.- """- return SearchUsageInfo(provider="brave", supported=False)diff --git a/tests/tools/test_search_usage.py b/tests/utils/test_searchusage.pysimilarity index 99%rename from tests/tools/test_search_usage.pyrename to tests/utils/test_searchusage.pyindex faec41dfa..dd8c62571 100644--- a/tests/tools/test_search_usage.py+++ b/tests/utils/test_searchusage.py@@ -5,7 +5,7 @@ from __future__ import annotationsimport pytestfrom unittest.mock import AsyncMock, MagicMock, patch-from nanobot.agent.tools.search_usage import (+from nanobot.utils.searchusage import (SearchUsageInfo,_parse_tavily_usage,fetch_search_usage,