active_harness 0.2.15 → 0.2.16
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 +4 -4
- data/lib/active_harness/agent.rb +19 -2
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 26824b777c1b0a68676671e07725a4ec171bb1491cf306b098aa97c6d4cf5510
|
|
4
|
+
data.tar.gz: bd0ca2f2fb3fa813eeea21bd48e49435babd989b761e5ea4a6dda194218a27ae
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b51494c59af3664360e3a0cdaa650a309499bada4df3a10f46bb1c4f547e577276f27bcdfa2c5ebbe2e88a220245feca1c51aba018ecee495cb15d72c5a076bb
|
|
7
|
+
data.tar.gz: e770331ab6e5621fc5f55257bd736d24eb972dbcd800075113971665c652e3d553505488ae8dec58d184c1f8cc5fc971146861d7e264cd4e291c4d18ccd694ae
|
data/lib/active_harness/agent.rb
CHANGED
|
@@ -23,6 +23,14 @@ module ActiveHarness
|
|
|
23
23
|
def inherited(subclass)
|
|
24
24
|
subclass.instance_variable_set(:@agent_config, {})
|
|
25
25
|
end
|
|
26
|
+
|
|
27
|
+
# Automatically strip and collapse whitespace in @input before each call.
|
|
28
|
+
# Enabled by default. Disable with:
|
|
29
|
+
#
|
|
30
|
+
# normalize_input false
|
|
31
|
+
def normalize_input(value = true)
|
|
32
|
+
agent_config[:normalize_input] = value
|
|
33
|
+
end
|
|
26
34
|
end
|
|
27
35
|
|
|
28
36
|
# -------------------------------------------------------------------------
|
|
@@ -42,8 +50,9 @@ module ActiveHarness
|
|
|
42
50
|
|
|
43
51
|
def initialize(input: nil, context: {}, models: nil, memory: nil, stream: nil, token_stream: nil, event_stream: nil)
|
|
44
52
|
@input = input
|
|
45
|
-
@context = context
|
|
46
53
|
@config = self.class.agent_config
|
|
54
|
+
normalize_input!
|
|
55
|
+
@context = context
|
|
47
56
|
@models_override = Array(models) if models
|
|
48
57
|
@stream = stream
|
|
49
58
|
@token_stream = token_stream
|
|
@@ -60,7 +69,10 @@ module ActiveHarness
|
|
|
60
69
|
# agent.call("What is the capital of Japan?")
|
|
61
70
|
# agent.call("...", stream: ->(token) { print token })
|
|
62
71
|
def call(input = nil, token_stream: nil)
|
|
63
|
-
|
|
72
|
+
if input
|
|
73
|
+
@input = input
|
|
74
|
+
normalize_input!
|
|
75
|
+
end
|
|
64
76
|
@token_stream = token_stream if token_stream
|
|
65
77
|
@memory&.load
|
|
66
78
|
@system_prompt = resolve_system_prompt
|
|
@@ -145,6 +157,11 @@ module ActiveHarness
|
|
|
145
157
|
model: result.model
|
|
146
158
|
)
|
|
147
159
|
end
|
|
160
|
+
|
|
161
|
+
def normalize_input!
|
|
162
|
+
return if @config.fetch(:normalize_input, true) == false
|
|
163
|
+
@input = @input&.strip&.gsub(/\s+/, " ")
|
|
164
|
+
end
|
|
148
165
|
end
|
|
149
166
|
end
|
|
150
167
|
|