mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-25 00:51:20 +00:00
feat(tools): add support for self-hosted firecrawl
Adds optional FIRECRAWL_API_URL environment variable to support self-hosted Firecrawl deployments alongside the cloud service. - Add FIRECRAWL_API_URL to optional env vars in hermes_cli/config.py - Update _get_firecrawl_client() in tools/web_tools.py to accept custom API URL - Add tests for client initialization with/without URL - Document new env var in installation and config guides
This commit is contained in:
parent
21d61bdd71
commit
d7d10b14cd
7 changed files with 68 additions and 2 deletions
49
tests/tools/test_web_tools_config.py
Normal file
49
tests/tools/test_web_tools_config.py
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
"""Tests for Firecrawl client configuration."""
|
||||
|
||||
import os
|
||||
import pytest
|
||||
from unittest.mock import patch, MagicMock
|
||||
|
||||
|
||||
class TestFirecrawlClientConfig:
|
||||
"""Test suite for Firecrawl client initialization with API URL support."""
|
||||
|
||||
def teardown_method(self):
|
||||
"""Reset client between tests."""
|
||||
import tools.web_tools
|
||||
|
||||
tools.web_tools._firecrawl_client = 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"]
|
||||
|
||||
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_key="test-key")
|
||||
|
||||
def test_client_with_api_key_and_url(self):
|
||||
"""Test client initialization with API key and custom URL."""
|
||||
with patch.dict(
|
||||
os.environ,
|
||||
{
|
||||
"FIRECRAWL_API_KEY": "test-key",
|
||||
"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_key="test-key", api_url="http://localhost:3002"
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue