active_harness 0.2.8 → 0.2.9
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: 15017e6a42df89f5372596d3b75deb192117a680ad297196eda52111a8931a96
|
|
4
|
+
data.tar.gz: 135fdfb6b453c4c2bfaef6ff8ed7f022b2c3fb1b45923f2ed282701fd106864d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 253c875d86e0d52535ba46ef206679a8cd5920e10b0cc0bcc82fad743e4a7bed1d1a3a28c8063db72400f17f057070ae0ac8cf61e14a3fe5708a766d9fa3b00f
|
|
7
|
+
data.tar.gz: f7f5a376c825d3ee9ace72f0512cb55f835dc7bad6b4dc419517d14b42f100b78b4bff1e6bf70cc6e7a137624d0ccf91fa71286805e3408560d3eb4fff54b904
|
|
@@ -47,7 +47,7 @@ module ActiveHarness
|
|
|
47
47
|
messages = build_messages(system_prompt, @input)
|
|
48
48
|
opts = { model: entry[:model], messages: messages }
|
|
49
49
|
opts[:temperature] = entry[:temperature] if entry[:temperature]
|
|
50
|
-
opts[:stream] = @
|
|
50
|
+
opts[:stream] = @token_stream if @token_stream
|
|
51
51
|
opts[:name] = entry[:name] if entry[:name]
|
|
52
52
|
provider.call(**opts)
|
|
53
53
|
end
|
|
@@ -54,8 +54,8 @@ module ActiveHarness
|
|
|
54
54
|
chat = backend.call(params)
|
|
55
55
|
chat.with_instructions(system_prompt) if system_prompt
|
|
56
56
|
|
|
57
|
-
if @
|
|
58
|
-
response = chat.ask(@input) { |chunk| @
|
|
57
|
+
if @token_stream
|
|
58
|
+
response = chat.ask(@input) { |chunk| @token_stream.call(chunk.content) if chunk.content }
|
|
59
59
|
else
|
|
60
60
|
response = chat.ask(@input)
|
|
61
61
|
end
|
data/lib/active_harness/agent.rb
CHANGED
|
@@ -11,8 +11,8 @@ module ActiveHarness
|
|
|
11
11
|
# SupportAgent.call(input: "Hi")
|
|
12
12
|
# SupportAgent.call(input: "Hi", context: { user_id: 42 })
|
|
13
13
|
# SupportAgent.call(input: "Hi", memory: memory)
|
|
14
|
-
def call(input: nil, context: {}, models: nil, memory: nil, stream: nil)
|
|
15
|
-
new(input: input, context: context, models: models, memory: memory, stream: stream).call
|
|
14
|
+
def call(input: nil, context: {}, models: nil, memory: nil, stream: nil, token_stream: nil, event_stream: nil)
|
|
15
|
+
new(input: input, context: context, models: models, memory: memory, stream: stream, token_stream: token_stream, event_stream: event_stream).call
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
# Each subclass gets its own isolated config hash.
|
|
@@ -28,7 +28,7 @@ module ActiveHarness
|
|
|
28
28
|
# -------------------------------------------------------------------------
|
|
29
29
|
# Instance API
|
|
30
30
|
# -------------------------------------------------------------------------
|
|
31
|
-
attr_accessor :input, :context
|
|
31
|
+
attr_accessor :input, :context, :stream, :token_stream, :event_stream
|
|
32
32
|
attr_reader :result
|
|
33
33
|
|
|
34
34
|
def models=(list)
|
|
@@ -36,12 +36,18 @@ module ActiveHarness
|
|
|
36
36
|
@model_list_proxy = nil
|
|
37
37
|
end
|
|
38
38
|
|
|
39
|
-
def
|
|
39
|
+
def memory=(obj)
|
|
40
|
+
@memory = obj
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def initialize(input: nil, context: {}, models: nil, memory: nil, stream: nil, token_stream: nil, event_stream: nil)
|
|
40
44
|
@input = input
|
|
41
45
|
@context = context
|
|
42
46
|
@config = self.class.agent_config
|
|
43
47
|
@models_override = Array(models) if models
|
|
44
48
|
@stream = stream
|
|
49
|
+
@token_stream = token_stream
|
|
50
|
+
@event_stream = event_stream
|
|
45
51
|
# memory: can be passed directly or via context[:memory]
|
|
46
52
|
@memory = memory || @context[:memory]
|
|
47
53
|
run_hook(:setup)
|
|
@@ -53,9 +59,9 @@ module ActiveHarness
|
|
|
53
59
|
# Optionally accepts input and stream callback inline:
|
|
54
60
|
# agent.call("What is the capital of Japan?")
|
|
55
61
|
# agent.call("...", stream: ->(token) { print token })
|
|
56
|
-
def call(input = nil,
|
|
57
|
-
@input
|
|
58
|
-
@
|
|
62
|
+
def call(input = nil, token_stream: nil)
|
|
63
|
+
@input = input if input
|
|
64
|
+
@token_stream = token_stream if token_stream
|
|
59
65
|
@memory&.load
|
|
60
66
|
@system_prompt = resolve_system_prompt
|
|
61
67
|
run_hook(:before_call)
|
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.9
|
|
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-24 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: concurrent-ruby
|