MCPcopy Create free account
hub / github.com/MiniMax-AI/Mini-Agent / test_wrapper_openai_provider

Function test_wrapper_openai_provider

tests/test_llm.py:61–103  ·  view source on GitHub ↗

Test LLM wrapper with OpenAI provider.

()

Source from the content-addressed store, hash-verified

59
60@pytest.mark.asyncio
61async def test_wrapper_openai_provider():
62 """Test LLM wrapper with OpenAI provider."""
63 print("\n=== Testing LLM Wrapper (OpenAI Provider) ===")
64
65 # Load config
66 config_path = Path("mini_agent/config/config.yaml")
67 with open(config_path, encoding="utf-8") as f:
68 config = yaml.safe_load(f)
69
70 # Create client with OpenAI provider
71 client = LLMClient(
72 api_key=config["api_key"],
73 provider=LLMProvider.OPENAI,
74 model=config.get("model"),
75 )
76
77 assert client.provider == LLMProvider.OPENAI
78
79 # Simple messages
80 messages = [
81 Message(role="system", content="You are a helpful assistant."),
82 Message(role="user", content="Say 'Hello, Mini Agent!' and nothing else."),
83 ]
84
85 try:
86 response = await client.generate(messages=messages)
87
88 print(f"Response: {response.content}")
89 print(f"Finish reason: {response.finish_reason}")
90
91 assert response.content, "Response content is empty"
92 assert "Hello" in response.content or "hello" in response.content, (
93 f"Response doesn't contain 'Hello': {response.content}"
94 )
95
96 print("✅ OpenAI provider test passed")
97 return True
98 except Exception as e:
99 print(f"❌ OpenAI provider test failed: {e}")
100 import traceback
101
102 traceback.print_exc()
103 return False
104
105
106@pytest.mark.asyncio

Callers 1

mainFunction · 0.85

Calls 4

generateMethod · 0.95
LLMClientClass · 0.90
MessageClass · 0.90
getMethod · 0.80

Tested by

no test coverage detected