mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-25 00:51:20 +00:00
fix: allow self-hosted Firecrawl without API key + add self-hosting docs
On top of PR #460: self-hosted Firecrawl instances don't require an API key (USE_DB_AUTHENTICATION=false), so don't force users to set a dummy FIRECRAWL_API_KEY when FIRECRAWL_API_URL is set. Also adds a proper self-hosting section to the configuration docs explaining what you get, what you lose, and how to set it up (Docker stack, tradeoffs vs cloud). Added 2 more tests (URL-only without key, neither-set raises).
This commit is contained in:
parent
a41ba57a7a
commit
363633e2ba
4 changed files with 78 additions and 19 deletions
|
|
@ -14,16 +14,15 @@ class TestFirecrawlClientConfig:
|
|||
|
||||
tools.web_tools._firecrawl_client = None
|
||||
|
||||
def _clear_firecrawl_env(self):
|
||||
"""Remove Firecrawl env vars so tests start clean."""
|
||||
for key in ("FIRECRAWL_API_KEY", "FIRECRAWL_API_URL"):
|
||||
os.environ.pop(key, None)
|
||||
|
||||
def test_client_with_api_key_only(self):
|
||||
"""Test client initialization with only API key (no custom URL)."""
|
||||
env_vars = {"FIRECRAWL_API_KEY": "test-key"}
|
||||
env_vars.pop("FIRECRAWL_API_URL", None)
|
||||
|
||||
with patch.dict(os.environ, env_vars, clear=False):
|
||||
# Remove FIRECRAWL_API_URL from env if it exists
|
||||
if "FIRECRAWL_API_URL" in os.environ:
|
||||
del os.environ["FIRECRAWL_API_URL"]
|
||||
|
||||
"""Test client initialization with only API key (cloud mode)."""
|
||||
self._clear_firecrawl_env()
|
||||
with patch.dict(os.environ, {"FIRECRAWL_API_KEY": "test-key"}, clear=False):
|
||||
with patch("tools.web_tools.Firecrawl") as mock_firecrawl:
|
||||
from tools.web_tools import _get_firecrawl_client
|
||||
|
||||
|
|
@ -32,6 +31,7 @@ class TestFirecrawlClientConfig:
|
|||
|
||||
def test_client_with_api_key_and_url(self):
|
||||
"""Test client initialization with API key and custom URL."""
|
||||
self._clear_firecrawl_env()
|
||||
with patch.dict(
|
||||
os.environ,
|
||||
{
|
||||
|
|
@ -47,3 +47,28 @@ class TestFirecrawlClientConfig:
|
|||
mock_firecrawl.assert_called_once_with(
|
||||
api_key="test-key", api_url="http://localhost:3002"
|
||||
)
|
||||
|
||||
def test_client_with_url_only_no_key(self):
|
||||
"""Self-hosted mode: URL without API key should work."""
|
||||
self._clear_firecrawl_env()
|
||||
with patch.dict(
|
||||
os.environ,
|
||||
{"FIRECRAWL_API_URL": "http://localhost:3002"},
|
||||
clear=False,
|
||||
):
|
||||
with patch("tools.web_tools.Firecrawl") as mock_firecrawl:
|
||||
from tools.web_tools import _get_firecrawl_client
|
||||
|
||||
_get_firecrawl_client()
|
||||
mock_firecrawl.assert_called_once_with(
|
||||
api_url="http://localhost:3002"
|
||||
)
|
||||
|
||||
def test_no_key_no_url_raises(self):
|
||||
"""Neither key nor URL set should raise a clear error."""
|
||||
self._clear_firecrawl_env()
|
||||
with patch("tools.web_tools.Firecrawl"):
|
||||
from tools.web_tools import _get_firecrawl_client
|
||||
|
||||
with pytest.raises(ValueError, match="FIRECRAWL_API_KEY"):
|
||||
_get_firecrawl_client()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue