summaryrefslogtreecommitdiffhomepage
path: root/spec/model_info_spec.rb
diff options
context:
space:
mode:
authorAdam Malczewski <[email protected]>2026-04-29 21:40:58 +0900
committerAdam Malczewski <[email protected]>2026-04-29 21:40:58 +0900
commit27af03cb3540539f065334c199fdb42c48776fc5 (patch)
tree9dcaecc59f4383d88933519b5b049793e772427b /spec/model_info_spec.rb
parent07277435c0688ad9f5fa682633b86b99ef5bb854 (diff)
downloaddispatch-adapter-interface-27af03cb3540539f065334c199fdb42c48776fc5.tar.gz
dispatch-adapter-interface-27af03cb3540539f065334c199fdb42c48776fc5.zip
update to support claude
Diffstat (limited to 'spec/model_info_spec.rb')
-rw-r--r--spec/model_info_spec.rb61
1 files changed, 61 insertions, 0 deletions
diff --git a/spec/model_info_spec.rb b/spec/model_info_spec.rb
new file mode 100644
index 0000000..25930f4
--- /dev/null
+++ b/spec/model_info_spec.rb
@@ -0,0 +1,61 @@
+# frozen_string_literal: true
+
+require "spec_helper"
+
+RSpec.describe Dispatch::Adapter::ModelInfo do
+ let(:base_kwargs) do
+ {
+ id: "gpt-4",
+ name: "GPT-4",
+ max_context_tokens: 8192,
+ supports_vision: false,
+ supports_tool_use: true,
+ supports_streaming: true
+ }
+ end
+
+ it "still works without pricing (existing shape unchanged)" do
+ info = described_class.new(**base_kwargs)
+ expect(info.id).to eq("gpt-4")
+ expect(info.name).to eq("GPT-4")
+ expect(info.max_context_tokens).to eq(8192)
+ expect(info.supports_vision).to be(false)
+ expect(info.supports_tool_use).to be(true)
+ expect(info.supports_streaming).to be(true)
+ expect(info.premium_request_multiplier).to be_nil
+ expect(info.pricing).to be_nil
+ end
+
+ it "accepts a ModelPricing and exposes it on #pricing" do
+ pricing = Dispatch::Adapter::ModelPricing.new(input_per_mtok: 3.0, output_per_mtok: 15.0)
+ info = described_class.new(**base_kwargs, pricing: pricing)
+ expect(info.pricing).to be_a(Dispatch::Adapter::ModelPricing)
+ expect(info.pricing.input_per_mtok).to eq(3.0)
+ expect(info.pricing.output_per_mtok).to eq(15.0)
+ end
+end
+
+RSpec.describe Dispatch::Adapter::ModelPricing do
+ it "requires input_per_mtok and output_per_mtok" do
+ pricing = described_class.new(input_per_mtok: 3.0, output_per_mtok: 15.0)
+ expect(pricing.input_per_mtok).to eq(3.0)
+ expect(pricing.output_per_mtok).to eq(15.0)
+ end
+
+ it "defaults cache_read_per_mtok and cache_write_per_mtok to 0.0" do
+ pricing = described_class.new(input_per_mtok: 1.0, output_per_mtok: 2.0)
+ expect(pricing.cache_read_per_mtok).to eq(0.0)
+ expect(pricing.cache_write_per_mtok).to eq(0.0)
+ end
+
+ it "accepts explicit cache pricing" do
+ pricing = described_class.new(
+ input_per_mtok: 3.0,
+ output_per_mtok: 15.0,
+ cache_read_per_mtok: 0.3,
+ cache_write_per_mtok: 3.75
+ )
+ expect(pricing.cache_read_per_mtok).to eq(0.3)
+ expect(pricing.cache_write_per_mtok).to eq(3.75)
+ end
+end