Skip to content

Commit fcb6013

Browse files
v31.6.0 (#137)
1 parent 97251b0 commit fcb6013

File tree

4 files changed

+66
-3
lines changed

4 files changed

+66
-3
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ from solana_agent import SolanaAgent
164164
config = {
165165
"openai": {
166166
"api_key": "your-openai-api-key",
167+
"model": "gpt-4.1", # Optional, defaults to gpt-4.1
167168
},
168169
"agents": [
169170
{

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "solana-agent"
3-
version = "31.5.0"
3+
version = "31.6.0"
44
description = "AI Agents for Solana"
55
authors = ["Bevan Hunt <bevan@bevanhunt.com>"]
66
license = "MIT"

solana_agent/factories/agent_factory.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,11 @@ def create_from_config(config: Dict[str, Any]) -> QueryService: # pragma: no co
125125
elif "openai" in config and "api_key" in config["openai"]:
126126
llm_api_key = config["openai"]["api_key"]
127127
llm_base_url = None # Use default OpenAI endpoint
128-
llm_model = None # Will use OpenAI adapter defaults
129-
logger.info("Using OpenAI as LLM provider")
128+
llm_model = config["openai"].get("model") # Optional model override
129+
if llm_model:
130+
logger.info(f"Using OpenAI as LLM provider with model: {llm_model}")
131+
else:
132+
logger.info("Using OpenAI as LLM provider")
130133
else:
131134
raise ValueError(
132135
"Either OpenAI, Grok, or Groq API key is required in config."

tests/unit/factories/test_agent_factory.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,24 @@ def groq_with_logfire_config(groq_config):
250250
return config
251251

252252

253+
@pytest.fixture
254+
def openai_with_model_config():
255+
"""Config with OpenAI and a custom model specified."""
256+
return {
257+
"openai": {
258+
"api_key": "test-openai-key",
259+
"model": "gpt-4.1-mini",
260+
},
261+
"agents": [
262+
{
263+
"name": "test_agent",
264+
"instructions": "You are a test agent.",
265+
"specialization": "Testing",
266+
}
267+
],
268+
}
269+
270+
253271
@pytest.fixture
254272
def invalid_logfire_config_missing_key(base_config):
255273
"""Config with logfire section missing api_key."""
@@ -1855,3 +1873,44 @@ def test_create_groq_without_logfire(
18551873
mock_routing_service.assert_called_once()
18561874
mock_query_service.assert_called_once()
18571875
assert result == mock_query_instance
1876+
1877+
@patch("solana_agent.factories.agent_factory.MongoDBAdapter")
1878+
@patch("solana_agent.factories.agent_factory.OpenAIAdapter")
1879+
@patch("solana_agent.factories.agent_factory.AgentService")
1880+
@patch("solana_agent.factories.agent_factory.RoutingService")
1881+
@patch("solana_agent.factories.agent_factory.QueryService")
1882+
def test_create_openai_with_model(
1883+
self,
1884+
mock_query_service,
1885+
mock_routing_service,
1886+
mock_agent_service,
1887+
mock_openai_adapter,
1888+
mock_mongo_adapter,
1889+
openai_with_model_config,
1890+
):
1891+
"""Test creating services with OpenAI and a custom model specified."""
1892+
# Setup mocks
1893+
mock_openai_instance = MagicMock()
1894+
mock_openai_adapter.return_value = mock_openai_instance
1895+
mock_agent_instance = MagicMock()
1896+
mock_agent_service.return_value = mock_agent_instance
1897+
mock_agent_instance.tool_registry.list_all_tools.return_value = []
1898+
mock_routing_instance = MagicMock()
1899+
mock_routing_service.return_value = mock_routing_instance
1900+
mock_query_instance = MagicMock()
1901+
mock_query_service.return_value = mock_query_instance
1902+
1903+
# Call the factory
1904+
result = SolanaAgentFactory.create_from_config(openai_with_model_config)
1905+
1906+
# Verify OpenAIAdapter was called with OpenAI config and custom model
1907+
mock_openai_adapter.assert_called_once_with(
1908+
api_key="test-openai-key",
1909+
base_url=None,
1910+
model="gpt-4.1-mini",
1911+
)
1912+
# Verify other services were called
1913+
mock_agent_service.assert_called_once()
1914+
mock_routing_service.assert_called_once()
1915+
mock_query_service.assert_called_once()
1916+
assert result == mock_query_instance

0 commit comments

Comments
 (0)