LangchainPrompt.TestAssertions (LangchainPrompt v0.1.0)

Copy Markdown View Source

ExUnit helpers for asserting on LangchainPrompt.Adapters.Test calls.

Import this in your test files:

import LangchainPrompt.TestAssertions

Macros

Example

test "sends the right system prompt" do
  LangchainPrompt.execute(MyPrompt, assigns)

  assert_adapter_called(fn payload ->
    system_msg = hd(payload.messages)
    assert system_msg.role == :system
    assert system_msg.content =~ "summarise"
  end)
end

Summary

Functions

Asserts the test adapter was called, and optionally inspects the payload.

Asserts the test adapter was NOT called.

Functions

assert_adapter_called(filter \\ nil)

(macro)

Asserts the test adapter was called, and optionally inspects the payload.

When called with a function, the function receives a map with:

refute_adapter_called()

(macro)

Asserts the test adapter was NOT called.