active_harness 0.2.31 → 0.2.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 231f48053aa92c1172f16cf7b6d03b222eccc9a967092d78488718dafa006b2b
|
|
4
|
+
data.tar.gz: 1f4f83487faff2a5b6b5dad31e8c902718c6179a0fec1162425b62640454b2da
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 23b68426a66c24f9f1c5759b64a01cefd4293a5f94f11f1a30806447d55db1d85cc54d4de4a3a18b9254db32b5aeb63c502938adbe023cb4d03962dcc4d8247b
|
|
7
|
+
data.tar.gz: 93ca0e61a02ce50bb5beb10fbb4c98630ef0c90efc9642b3d1c8d74f666559cdebcc965b4f29bcda32c9b7ac5609c0a6ea49790d5f62384a2ecacbab941fd0b2
|
|
@@ -3,7 +3,7 @@ module ActiveHarness
|
|
|
3
3
|
private
|
|
4
4
|
|
|
5
5
|
# Builds a CostBreakdown for a single request from token usage and
|
|
6
|
-
# pricing data from ActiveHarness::
|
|
6
|
+
# pricing data from ActiveHarness::Pricing.
|
|
7
7
|
#
|
|
8
8
|
# Returns CostBreakdown (input, output, total in USD),
|
|
9
9
|
# or nil if usage is absent or the model is not found in the pricing registry.
|
data/lib/active_harness/agent.rb
CHANGED
|
@@ -10,28 +10,28 @@ module ActiveHarness
|
|
|
10
10
|
# by ActiveHarness (files present in lib/active_harness/providers/).
|
|
11
11
|
#
|
|
12
12
|
# Data source priority:
|
|
13
|
-
# 1. {project_root}/tmp/active_harness/
|
|
13
|
+
# 1. {project_root}/tmp/active_harness/pricing.json — fetched cache (refreshed once per day)
|
|
14
14
|
# 2. lib/active_harness/data/models.json — bundled fallback (ships with gem)
|
|
15
15
|
#
|
|
16
16
|
# Usage:
|
|
17
17
|
#
|
|
18
18
|
# # Fetch fresh data and save to tmp cache (also called automatically when stale)
|
|
19
|
-
# ActiveHarness::
|
|
19
|
+
# ActiveHarness::Pricing.update
|
|
20
20
|
#
|
|
21
21
|
# # All models (auto-updates cache if missing or older than 24h)
|
|
22
|
-
# ActiveHarness::
|
|
22
|
+
# ActiveHarness::Pricing.all
|
|
23
23
|
#
|
|
24
24
|
# # Single model by ID
|
|
25
|
-
# ActiveHarness::
|
|
25
|
+
# ActiveHarness::Pricing.find("gpt-4o")
|
|
26
26
|
#
|
|
27
27
|
# # By provider — method or bracket syntax
|
|
28
|
-
# ActiveHarness::
|
|
29
|
-
# ActiveHarness::
|
|
28
|
+
# ActiveHarness::Pricing.providers.openai
|
|
29
|
+
# ActiveHarness::Pricing.providers[:anthropic]
|
|
30
30
|
#
|
|
31
31
|
# # List providers that have data
|
|
32
|
-
# ActiveHarness::
|
|
32
|
+
# ActiveHarness::Pricing.providers.list
|
|
33
33
|
#
|
|
34
|
-
module
|
|
34
|
+
module Pricing
|
|
35
35
|
BUNDLED_DATA_FILE = File.expand_path("data/models.json", __dir__).freeze
|
|
36
36
|
MODELS_DEV_URL = "https://models.dev/api.json"
|
|
37
37
|
CACHE_TTL = 86_400 # 24 hours in seconds
|
|
@@ -54,7 +54,7 @@ module ActiveHarness
|
|
|
54
54
|
}.freeze
|
|
55
55
|
|
|
56
56
|
# Value object representing the pricing for a single model.
|
|
57
|
-
|
|
57
|
+
ModelPrice = Struct.new(
|
|
58
58
|
:id,
|
|
59
59
|
:name,
|
|
60
60
|
:provider,
|
|
@@ -89,31 +89,31 @@ module ActiveHarness
|
|
|
89
89
|
parts << "output=$#{output_per_million}/M" if output_per_million
|
|
90
90
|
parts << "ctx=#{context_window}" if context_window
|
|
91
91
|
parts << "cats=#{categories.join(',')}" if categories.any?
|
|
92
|
-
"#<
|
|
92
|
+
"#<ModelPrice #{parts.join(' ')}>"
|
|
93
93
|
end
|
|
94
94
|
end
|
|
95
95
|
|
|
96
96
|
# Proxy object that exposes providers as methods and via [].
|
|
97
97
|
class ProvidersProxy
|
|
98
98
|
def [](name)
|
|
99
|
-
ActiveHarness::
|
|
99
|
+
ActiveHarness::Pricing.for_provider(name.to_s)
|
|
100
100
|
end
|
|
101
101
|
|
|
102
102
|
def list
|
|
103
|
-
ActiveHarness::
|
|
103
|
+
ActiveHarness::Pricing.provider_names
|
|
104
104
|
end
|
|
105
105
|
|
|
106
106
|
def method_missing(name, *args, &block)
|
|
107
107
|
provider = name.to_s
|
|
108
|
-
if ActiveHarness::
|
|
109
|
-
ActiveHarness::
|
|
108
|
+
if ActiveHarness::Pricing.provider_names.include?(provider)
|
|
109
|
+
ActiveHarness::Pricing.for_provider(provider)
|
|
110
110
|
else
|
|
111
111
|
super
|
|
112
112
|
end
|
|
113
113
|
end
|
|
114
114
|
|
|
115
115
|
def respond_to_missing?(name, include_private = false)
|
|
116
|
-
ActiveHarness::
|
|
116
|
+
ActiveHarness::Pricing.provider_names.include?(name.to_s) || super
|
|
117
117
|
end
|
|
118
118
|
end
|
|
119
119
|
|
|
@@ -154,7 +154,7 @@ module ActiveHarness
|
|
|
154
154
|
end
|
|
155
155
|
|
|
156
156
|
# Fetches fresh pricing data from models.dev, filters to supported providers,
|
|
157
|
-
# and writes the result to {project_root}/tmp/active_harness/
|
|
157
|
+
# and writes the result to {project_root}/tmp/active_harness/pricing.json.
|
|
158
158
|
# Returns the number of models saved, or raises on HTTP failure.
|
|
159
159
|
def update
|
|
160
160
|
raw_api = fetch_models_dev
|
|
@@ -176,7 +176,7 @@ module ActiveHarness
|
|
|
176
176
|
|
|
177
177
|
# Path to the per-project cache file.
|
|
178
178
|
def cache_file
|
|
179
|
-
File.join(project_root, "tmp", "active_harness", "
|
|
179
|
+
File.join(project_root, "tmp", "active_harness", "pricing.json")
|
|
180
180
|
end
|
|
181
181
|
|
|
182
182
|
# Names of providers supported by ActiveHarness (derived from providers/ directory).
|
|
@@ -267,7 +267,7 @@ module ActiveHarness
|
|
|
267
267
|
|
|
268
268
|
def build_cost(raw)
|
|
269
269
|
standard = raw.dig(:pricing, :text_tokens, :standard) || {}
|
|
270
|
-
|
|
270
|
+
ModelPrice.new(
|
|
271
271
|
id: raw[:id],
|
|
272
272
|
name: raw[:name],
|
|
273
273
|
provider: raw[:provider],
|
|
@@ -3,7 +3,7 @@ require "json"
|
|
|
3
3
|
module ActiveHarness
|
|
4
4
|
# Value objects for structured result data.
|
|
5
5
|
|
|
6
|
-
# Pricing rates for a model (per-token, from
|
|
6
|
+
# Pricing rates for a model (per-token, from Pricing registry).
|
|
7
7
|
# nil when the model is not found in the pricing registry.
|
|
8
8
|
ModelPricing = Struct.new(:input, :output, keyword_init: true)
|
|
9
9
|
|
data/lib/active_harness.rb
CHANGED
|
@@ -21,7 +21,7 @@ require_relative "active_harness/providers/azure"
|
|
|
21
21
|
require_relative "active_harness/providers/bedrock"
|
|
22
22
|
require_relative "active_harness/providers/vertexai"
|
|
23
23
|
require_relative "active_harness/providers/custom"
|
|
24
|
-
require_relative "active_harness/
|
|
24
|
+
require_relative "active_harness/pricing"
|
|
25
25
|
require_relative "active_harness/memory"
|
|
26
26
|
require_relative "active_harness/agent"
|
|
27
27
|
require_relative "active_harness/tribunal"
|
|
@@ -30,7 +30,7 @@ require_relative "active_harness/pipeline"
|
|
|
30
30
|
require_relative "active_harness/railtie" if defined?(Rails::Railtie)
|
|
31
31
|
|
|
32
32
|
module ActiveHarness
|
|
33
|
-
VERSION = "0.2.
|
|
33
|
+
VERSION = "0.2.32"
|
|
34
34
|
|
|
35
35
|
class << self
|
|
36
36
|
# Configure ActiveHarness.
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: active_harness
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.32
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- the-teacher
|
|
@@ -43,7 +43,6 @@ files:
|
|
|
43
43
|
- lib/active_harness/configuration.rb
|
|
44
44
|
- lib/active_harness/core/errors.rb
|
|
45
45
|
- lib/active_harness/core/hooks.rb
|
|
46
|
-
- lib/active_harness/costs.rb
|
|
47
46
|
- lib/active_harness/data/models.json
|
|
48
47
|
- lib/active_harness/http/client.rb
|
|
49
48
|
- lib/active_harness/http/retry_policy.rb
|
|
@@ -57,6 +56,7 @@ files:
|
|
|
57
56
|
- lib/active_harness/pipeline/README.md
|
|
58
57
|
- lib/active_harness/pipeline/hooks.rb
|
|
59
58
|
- lib/active_harness/pipeline/step.rb
|
|
59
|
+
- lib/active_harness/pricing.rb
|
|
60
60
|
- lib/active_harness/providers/PROVIDER_CONTRACT.md
|
|
61
61
|
- lib/active_harness/providers/anthropic.rb
|
|
62
62
|
- lib/active_harness/providers/azure.rb
|