ADK.Model.Mock (adk_ex v1.1.0)

Copy Markdown View Source

Mock model for testing without real API calls.

Configured with a list of responses (either LlmResponse structs or functions that take an LlmRequest and return an LlmResponse). Returns them in sequence via an internal Agent process for statefulness. Falls back to a default text response if the list is exhausted.

Summary

Functions

Creates a new Mock model with an internal Agent for stateful response tracking.

Pops the next response from the model, returning {response, updated_model}.

Types

response_entry()

@type response_entry() :: ADK.Model.LlmResponse.t() | response_fn()

response_fn()

@type response_fn() :: (ADK.Model.LlmRequest.t() -> ADK.Model.LlmResponse.t())

t()

@type t() :: %ADK.Model.Mock{
  model_name: String.t(),
  pid: pid() | nil,
  responses: [response_entry()]
}

Functions

new(opts \\ [])

@spec new(keyword()) :: t()

Creates a new Mock model with an internal Agent for stateful response tracking.

pop_response(model, request)

@spec pop_response(t(), ADK.Model.LlmRequest.t()) :: {ADK.Model.LlmResponse.t(), t()}

Pops the next response from the model, returning {response, updated_model}.

Useful for tests that need to track consumed responses.