LangchainPrompt.Adapters.Test (LangchainPrompt v0.1.0)

Copy Markdown View Source

In-process adapter for ExUnit tests.

Records every chat/2 call by sending a {:adapter_called, payload} message to the calling process (and any $callers). Use LangchainPrompt.TestAssertions to assert on these messages.

On-demand failure

Any message whose content is the string "FAIL_NOW" causes the adapter to return {:error, :adapter_did_fail_on_demand} without sending any message.

Shared process override

For async tests that spawn work in separate processes, set:

Application.put_env(:langchain_prompt, :test_process, self())

The adapter will send the :adapter_called message to that PID instead of walking $callers.

Mock response content

Pass mock_content: "custom response" in profile opts to control what the adapter returns.