Module: LlmMock::Anthropic
- Defined in:
- lib/llm_mock_anthropic.rb,
lib/llm_mock_anthropic/version.rb
Overview
Fabricates Anthropic Ruby SDK response objects for tests, and serializes them to/from the plain hashes a cache stores.
‘LlmMock::Anthropic` is the namespace: the response structs and the builder helpers live here, and `LlmMock::Anthropic::Provider` is the object a consumer (e.g. deja) drives. Use `::Anthropic` for the SDK constant — bare `Anthropic` inside this module would resolve to here.
Defined Under Namespace
Classes: Message, Provider, Stream, TextBlock, ToolUseBlock
Constant Summary collapse
- VERSION =
"0.1.0"
Class Method Summary collapse
- .message(blocks) ⇒ Object
- .stream(text_chunks:, message:) ⇒ Object
-
.text(text) ⇒ Object
Ergonomic builders for canned responses — handy in specs that stub the client directly and return a scripted response.
- .tool_use(id:, name:, input:) ⇒ Object
Class Method Details
.message(blocks) ⇒ Object
38 39 40 |
# File 'lib/llm_mock_anthropic.rb', line 38 def self.(blocks) Message.new(blocks) end |
.stream(text_chunks:, message:) ⇒ Object
42 43 44 |
# File 'lib/llm_mock_anthropic.rb', line 42 def self.stream(text_chunks:, message:) Stream.new(text_chunks, ) end |
.text(text) ⇒ Object
30 31 32 |
# File 'lib/llm_mock_anthropic.rb', line 30 def self.text(text) TextBlock.new(:text, text) end |
.tool_use(id:, name:, input:) ⇒ Object
34 35 36 |
# File 'lib/llm_mock_anthropic.rb', line 34 def self.tool_use(id:, name:, input:) ToolUseBlock.new(:tool_use, id, name, input) end |