Module: Ace::TestSupport::Fixtures::HTTPMocks::LLMResponses
- Defined in:
- lib/ace/test_support/fixtures/http_mocks.rb
Overview
Common LLM API response fixtures
Class Method Summary collapse
-
.chat_completion(content: "Hello! How can I assist you today?", model: "test-model", input_tokens: 10, output_tokens: 20) ⇒ Hash
Standard successful chat completion response (OpenAI-compatible format).
-
.chat_completion_without_model(content: "Hello! How can I assist you today?", input_tokens: 10, output_tokens: 20) ⇒ Hash
Response with missing model field.
-
.chat_completion_without_usage(content: "Hello! How can I assist you today?", model: "test-model") ⇒ Hash
Response with missing usage field.
-
.empty_choices(model: "test-model") ⇒ Hash
Response with empty choices.
-
.nil_content(model: "test-model") ⇒ Hash
Response with nil content.
Class Method Details
.chat_completion(content: "Hello! How can I assist you today?", model: "test-model", input_tokens: 10, output_tokens: 20) ⇒ Hash
Standard successful chat completion response (OpenAI-compatible format)
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/ace/test_support/fixtures/http_mocks.rb', line 90 def self.chat_completion( content: "Hello! How can I assist you today?", model: "test-model", input_tokens: 10, output_tokens: 20 ) { "id" => "chatcmpl-test#{SecureRandom.hex(4)}", "object" => "chat.completion", "created" => Time.now.to_i, "model" => model, "choices" => [ { "index" => 0, "message" => { "role" => "assistant", "content" => content }, "finish_reason" => "stop" } ], "usage" => { "prompt_tokens" => input_tokens, "completion_tokens" => output_tokens, "total_tokens" => input_tokens + output_tokens } } end |
.chat_completion_without_model(content: "Hello! How can I assist you today?", input_tokens: 10, output_tokens: 20) ⇒ Hash
Response with missing model field
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
# File 'lib/ace/test_support/fixtures/http_mocks.rb', line 150 def self.chat_completion_without_model( content: "Hello! How can I assist you today?", input_tokens: 10, output_tokens: 20 ) { "id" => "chatcmpl-test#{SecureRandom.hex(4)}", "object" => "chat.completion", "created" => Time.now.to_i, "choices" => [ { "index" => 0, "message" => { "role" => "assistant", "content" => content }, "finish_reason" => "stop" } ], "usage" => { "prompt_tokens" => input_tokens, "completion_tokens" => output_tokens, "total_tokens" => input_tokens + output_tokens } } end |
.chat_completion_without_usage(content: "Hello! How can I assist you today?", model: "test-model") ⇒ Hash
Response with missing usage field
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/ace/test_support/fixtures/http_mocks.rb', line 123 def self.chat_completion_without_usage( content: "Hello! How can I assist you today?", model: "test-model" ) { "id" => "chatcmpl-test#{SecureRandom.hex(4)}", "object" => "chat.completion", "created" => Time.now.to_i, "model" => model, "choices" => [ { "index" => 0, "message" => { "role" => "assistant", "content" => content }, "finish_reason" => "stop" } ] } end |
.empty_choices(model: "test-model") ⇒ Hash
Response with empty choices
179 180 181 182 183 184 185 186 187 |
# File 'lib/ace/test_support/fixtures/http_mocks.rb', line 179 def self.empty_choices(model: "test-model") { "id" => "chatcmpl-test#{SecureRandom.hex(4)}", "object" => "chat.completion", "created" => Time.now.to_i, "model" => model, "choices" => [] } end |
.nil_content(model: "test-model") ⇒ Hash
Response with nil content
191 192 193 194 195 196 197 |
# File 'lib/ace/test_support/fixtures/http_mocks.rb', line 191 def self.nil_content(model: "test-model") { "id" => "chatcmpl-test", "choices" => [{"message" => {"content" => nil}, "finish_reason" => "stop"}], "model" => model } end |