active_harness 0.2.17 → 0.2.19
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: 9562f506c8c0b6a219b085fc33a123a39538f368d5fa0255400cc5632b3395f2
|
|
4
|
+
data.tar.gz: c23b9fddc6356c71b37495fce0654d1777314d96ca43001b41c1e97f3b59c8d8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6def9d9a139113f948c7da6acd1ed0f99e88257c273b3434d236829b700d156e6feeda60ac7fbadef183840ca76e9e12b08b70f40b9d2bdb634f14a4cee19ce7
|
|
7
|
+
data.tar.gz: 76e1a91a7cbd321e56900562b9c471d7313a0553d2a72764000768e7e7c4fcdd0ecc09d321ebb95f3cc43335f66ad81d11d7d354fdc8204bab48d404a969710c
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
module ActiveHarness
|
|
2
2
|
class Agent
|
|
3
3
|
# -------------------------------------------------------------------------
|
|
4
|
-
#
|
|
4
|
+
# Custom LLM backend DSL
|
|
5
5
|
#
|
|
6
|
-
# Allows an agent to delegate HTTP calls to
|
|
7
|
-
# ActiveHarness's built-in Net::HTTP providers.
|
|
6
|
+
# Allows an agent to delegate HTTP calls to any LLM client (e.g. `ruby_llm`)
|
|
7
|
+
# instead of ActiveHarness's built-in Net::HTTP providers.
|
|
8
8
|
#
|
|
9
9
|
# Usage:
|
|
10
10
|
#
|
|
11
|
-
#
|
|
11
|
+
# custom_llm_backend do |params|
|
|
12
12
|
# RubyLLM.chat(
|
|
13
13
|
# model: params.model,
|
|
14
14
|
# provider: params.provider,
|
|
@@ -27,23 +27,23 @@ module ActiveHarness
|
|
|
27
27
|
# - streaming via stream: lambda
|
|
28
28
|
# -------------------------------------------------------------------------
|
|
29
29
|
|
|
30
|
-
# Passed to the
|
|
30
|
+
# Passed to the custom_llm_backend block for each model attempt.
|
|
31
31
|
BackendParams = Struct.new(:model, :provider, :temperature, keyword_init: true)
|
|
32
32
|
|
|
33
33
|
class << self
|
|
34
|
-
# Define the
|
|
35
|
-
def
|
|
36
|
-
agent_config[:
|
|
34
|
+
# Define the custom LLM backend block for this agent class.
|
|
35
|
+
def custom_llm_backend(&block)
|
|
36
|
+
agent_config[:custom_llm_backend] = block
|
|
37
37
|
end
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
private
|
|
41
41
|
|
|
42
|
-
# Called from attempt_model when
|
|
43
|
-
def
|
|
42
|
+
# Called from attempt_model when custom_llm_backend is configured.
|
|
43
|
+
def attempt_via_custom_llm(entry, system_prompt)
|
|
44
44
|
require "ruby_llm"
|
|
45
45
|
|
|
46
|
-
backend = @config[:
|
|
46
|
+
backend = @config[:custom_llm_backend]
|
|
47
47
|
|
|
48
48
|
params = BackendParams.new(
|
|
49
49
|
model: entry[:model],
|
|
@@ -60,7 +60,7 @@ module ActiveHarness
|
|
|
60
60
|
response = chat.ask(@input)
|
|
61
61
|
end
|
|
62
62
|
|
|
63
|
-
{ content: response.content, usage:
|
|
63
|
+
{ content: response.content, usage: custom_llm_usage(response) }
|
|
64
64
|
rescue ::RubyLLM::UnauthorizedError => e
|
|
65
65
|
raise Errors::InvalidApiKeyError, e.message
|
|
66
66
|
rescue ::RubyLLM::RateLimitError, ::RubyLLM::OverloadedError => e
|
|
@@ -76,7 +76,7 @@ module ActiveHarness
|
|
|
76
76
|
"The `ruby_llm` gem is required. Add `gem \"ruby_llm\"` to your Gemfile."
|
|
77
77
|
end
|
|
78
78
|
|
|
79
|
-
def
|
|
79
|
+
def custom_llm_usage(response)
|
|
80
80
|
t = response.tokens
|
|
81
81
|
return nil unless t
|
|
82
82
|
|
|
@@ -41,7 +41,7 @@ module ActiveHarness
|
|
|
41
41
|
private
|
|
42
42
|
|
|
43
43
|
def attempt_model(entry, system_prompt)
|
|
44
|
-
return
|
|
44
|
+
return attempt_via_custom_llm(entry, system_prompt) if @config[:custom_llm_backend]
|
|
45
45
|
|
|
46
46
|
provider = resolve_provider(entry[:provider])
|
|
47
47
|
messages = build_messages(system_prompt, @input)
|
data/lib/active_harness/agent.rb
CHANGED
|
@@ -170,6 +170,6 @@ require_relative "agent/hooks"
|
|
|
170
170
|
require_relative "agent/models"
|
|
171
171
|
require_relative "agent/providers"
|
|
172
172
|
require_relative "agent/output_parser"
|
|
173
|
-
require_relative "agent/
|
|
173
|
+
require_relative "agent/custom_llm_backend"
|
|
174
174
|
require_relative "agent/cost"
|
|
175
175
|
|
data/lib/active_harness.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
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.19
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- the-teacher
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-05-
|
|
11
|
+
date: 2026-05-27 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: concurrent-ruby
|
|
@@ -34,12 +34,12 @@ files:
|
|
|
34
34
|
- lib/active_harness.rb
|
|
35
35
|
- lib/active_harness/agent.rb
|
|
36
36
|
- lib/active_harness/agent/cost.rb
|
|
37
|
+
- lib/active_harness/agent/custom_llm_backend.rb
|
|
37
38
|
- lib/active_harness/agent/hooks.rb
|
|
38
39
|
- lib/active_harness/agent/models.rb
|
|
39
40
|
- lib/active_harness/agent/output_parser.rb
|
|
40
41
|
- lib/active_harness/agent/prompt.rb
|
|
41
42
|
- lib/active_harness/agent/providers.rb
|
|
42
|
-
- lib/active_harness/agent/ruby_llm_backend.rb
|
|
43
43
|
- lib/active_harness/configuration.rb
|
|
44
44
|
- lib/active_harness/core/errors.rb
|
|
45
45
|
- lib/active_harness/costs.rb
|