Skip to content

Commit 7ffdd7a

Browse files
fix bug (#75)
* fix bug * fix error
1 parent 2bb4862 commit 7ffdd7a

2 files changed

Lines changed: 4 additions & 8 deletions

File tree

grafi/agents/react_agent.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,11 @@ class ReActAgent(Assistant):
4545
name: str = Field(default="ReActAgent")
4646
type: str = Field(default="ReActAgent")
4747
api_key: Optional[str] = Field(default_factory=lambda: os.getenv("OPENAI_API_KEY"))
48-
tavily_api_key: Optional[str] = Field(
49-
default_factory=lambda: os.getenv("TAVILY_API_KEY")
50-
)
5148
system_prompt: Optional[str] = Field(default=AGENT_SYSTEM_MESSAGE)
5249
function_call_tool: FunctionCallTool = Field(
5350
default=TavilyTool.builder()
5451
.name("TavilyTestTool")
55-
.api_key(tavily_api_key)
52+
.api_key(os.getenv("TAVILY_API_KEY"))
5653
.max_tokens(6000)
5754
.search_depth("advanced")
5855
.build()

tests/agents/test_react_agent.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,15 @@
66

77
import pytest
88

9+
# Set a dummy TAVILY_API_KEY to prevent initialization errors
10+
os.environ["TAVILY_API_KEY"] = "test-tavily-key"
11+
912
# Now import after setting the environment variable
1013
from grafi.agents.react_agent import ReActAgent
1114
from grafi.agents.react_agent import ReActAgentBuilder
1215
from grafi.tools.function_calls.impl.tavily_tool import TavilyTool
1316

1417

15-
# Set environment variable before any imports to prevent API key errors
16-
# os.environ["TAVILY_API_KEY"] = "mock-api-key-for-testing"
17-
18-
1918
@pytest.fixture(autouse=True)
2019
def mock_tavily_client():
2120
"""Automatically mock TavilyClient for all tests."""

0 commit comments

Comments
 (0)