Skip to content

Commit 2853c65

Browse files
committed
Pass conversation to xai and openai llms in tests
1 parent b10c8d9 commit 2853c65

2 files changed

Lines changed: 14 additions & 9 deletions

File tree

plugins/openai/tests/test_openai_llm.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22

33
import pytest
44
from dotenv import load_dotenv
5-
from vision_agents.core.agents.conversation import Message
5+
from vision_agents.core.agents.conversation import InMemoryConversation, Message
66
from vision_agents.plugins.openai.openai_llm import OpenAILLM
7-
87
from vision_agents.testing import collect_simple_response
98

109
load_dotenv()
@@ -13,6 +12,7 @@
1312
@pytest.fixture
1413
async def llm():
1514
llm = OpenAILLM(model="gpt-4o")
15+
llm.set_conversation(InMemoryConversation("be friendly", []))
1616
yield llm
1717
await llm.close()
1818

plugins/xai/tests/test_xai_llm.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,35 @@
22

33
import pytest
44
from dotenv import load_dotenv
5+
from vision_agents.core.agents.conversation import InMemoryConversation
56
from vision_agents.plugins.xai.llm import XAILLM
67

78
from vision_agents.testing import collect_simple_response
89

910
load_dotenv()
1011

1112

13+
@pytest.fixture
14+
async def llm():
15+
llm = XAILLM(model="grok-4-latest", api_key=os.getenv("XAI_API_KEY"))
16+
llm.set_conversation(InMemoryConversation("be friendly", []))
17+
yield llm
18+
await llm.close()
19+
20+
1221
@pytest.mark.integration
1322
@pytest.mark.skipif(not os.getenv("XAI_API_KEY"), reason="XAI_API_KEY not set")
1423
class TestXAILLMIntegration:
1524
"""Test suite for XAILLM class with live API calls."""
1625

17-
async def test_simple_response(self):
18-
llm = XAILLM(model="grok-4-latest", api_key=os.getenv("XAI_API_KEY"))
26+
async def test_simple_response(self, llm: XAILLM):
1927
deltas, final = await collect_simple_response(
2028
llm.simple_response("Explain quantum computing in 1 paragraph")
2129
)
2230
assert deltas
2331
assert final.text
2432

25-
async def test_memory(self):
26-
llm = XAILLM(model="grok-4-latest", api_key=os.getenv("XAI_API_KEY"))
33+
async def test_memory(self, llm: XAILLM):
2734
await collect_simple_response(
2835
llm.simple_response(text="There are 2 dogs in the room")
2936
)
@@ -32,9 +39,7 @@ async def test_memory(self):
3239
)
3340
assert "8" in final.text or "eight" in final.text
3441

35-
async def test_tool_calling(self):
36-
llm = XAILLM(model="grok-4-latest", api_key=os.getenv("XAI_API_KEY"))
37-
42+
async def test_tool_calling(self, llm: XAILLM):
3843
@llm.register_function()
3944
async def get_weather(location: str) -> str:
4045
"""Get the weather for a location."""

0 commit comments

Comments
 (0)