Cyclium.Test.SynthesizerCase (Cyclium v0.1.12)

Copy Markdown View Source

Test helpers for verifying synthesizer contract compliance and a FakeSynthesizer for use in strategy tests.

Usage

defmodule MyApp.Synthesizers.ProcurementTest do
  use ExUnit.Case, async: true
  use Cyclium.Test.SynthesizerCase

  test "synthesizer returns valid response" do
    prompt_ctx = %{system: "You are a helpful assistant", messages: []}
    episode_ctx = Cyclium.Test.StrategyCase.build_episode_ctx()

    assert_valid_synthesize(MySynthesizer, prompt_ctx, episode_ctx)
  end
end

FakeSynthesizer

For strategy tests that need a controllable synthesizer:

# In test setup
Cyclium.Test.FakeSynthesizer.start_link()
Cyclium.Test.FakeSynthesizer.set_response(%{"answer" => "42"})

# Strategy calls synthesize/2 and gets the canned response

Summary

Functions

Assert that synthesizer.estimate_tokens/1 returns a non-negative integer.

Assert that synthesizer.synthesize/2 returns a valid response shape.

Functions

assert_valid_estimate_tokens(synthesizer, prompt_ctx)

(macro)

Assert that synthesizer.estimate_tokens/1 returns a non-negative integer.

assert_valid_synthesize(synthesizer, prompt_ctx, episode_ctx)

(macro)

Assert that synthesizer.synthesize/2 returns a valid response shape.