Testing
Fake components to help you test your AI powered system
Setup
use NeuronAI\Chat\Messages\Stream\AssistantMessage;
use NeuronAI\Testing\FakeAIProvider;
$provider = new FakeAIProvider(
new AssistantMessage('Hello! How can I help you?')
);
$agent = MyAgent::make()->setAiProvider($provider);$provider = new FakeAIProvider(
new AssistantMessage('First response'),
new AssistantMessage('Second response'),
);Chat
public function test_agent_responds(): void
{
$provider = new FakeAIProvider(
new AssistantMessage('The capital of France is Paris.')
);
$agent = MyAgent::make()->setAiProvider($provider);
$message = $agent->chat(new UserMessage('What is the capital of France?'))->getMessage();
$this->assertSame('The capital of France is Paris.', $message->getContent());
$provider->assertCallCount(1);
}Streaming
Structured Output
Tool Calls
Assertions
Inspecting Requests
RAG
Last updated