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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/active_harness/agent.rb +19 -2
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cc551806a5848e9157c21ee668ee38c139a55c46fb7e8c2a6a2e8022200c90cb
4
- data.tar.gz: f6110846af88ce73b7fe7a30221d18960a58e80adeaf01e2b19b5e14fac0640d
3
+ metadata.gz: 26824b777c1b0a68676671e07725a4ec171bb1491cf306b098aa97c6d4cf5510
4
+ data.tar.gz: bd0ca2f2fb3fa813eeea21bd48e49435babd989b761e5ea4a6dda194218a27ae
5
5
  SHA512:
6
- metadata.gz: d8884d36a5da2581707584068acc7315a00d417bd88a7776d1702c375e05470257c21cedb6c323fec5aa75562e6f118d635ae1b1a2053d3e7d60b48b0aca8d3f
7
- data.tar.gz: 02fa25dca8678816e76b2c2b2fad6131e26a7aa8b5a97cb78a5bcee84d7a9923507eb5981d0508663ecced5a6eb85c5f92799a00d80b59098252dc08438ff22f
6
+ metadata.gz: b51494c59af3664360e3a0cdaa650a309499bada4df3a10f46bb1c4f547e577276f27bcdfa2c5ebbe2e88a220245feca1c51aba018ecee495cb15d72c5a076bb
7
+ data.tar.gz: e770331ab6e5621fc5f55257bd736d24eb972dbcd800075113971665c652e3d553505488ae8dec58d184c1f8cc5fc971146861d7e264cd4e291c4d18ccd694ae
@@ -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
- @input = input if input
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
 
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.15
4
+ version: 0.2.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - the-teacher