brute 2.0.0 → 2.0.1
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/brute/agent.rb +6 -4
- data/lib/brute/middleware/005_tracing.rb +8 -0
- data/lib/brute/version.rb +1 -1
- 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: 88f91b95b420900fabdfb38701a146b0599b93da03f682f595fe3ef0c56ef73d
|
|
4
|
+
data.tar.gz: 39211325840bbe237d5bbc58c626c5c0bcc916a3ebb4a02bfdd9313c277f0cc6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fa8266cb20ac5a6c6bca2e062d696a98d6bae16d1a1dc5af71d4ed19dc7ad7c6253f639f75787beace5fc8e1182dc398d06ab06a267b200811766e658bce63de
|
|
7
|
+
data.tar.gz: f57d43d509cd79006cc3678e742409a0dfee0d5037d8de419fce75532d06480e5c4684f8314292ab8d46bc966a25f34b15d0130d486c0f9de09f68c9b48d8e6d
|
data/lib/brute/agent.rb
CHANGED
|
@@ -41,7 +41,8 @@ module Brute
|
|
|
41
41
|
end
|
|
42
42
|
|
|
43
43
|
# Run one turn against the given session. The session is mutated
|
|
44
|
-
# in place (assistant + tool messages appended)
|
|
44
|
+
# in place (assistant + tool messages appended). Returns the env
|
|
45
|
+
# hash so callers can access metadata (timing, tokens, etc.).
|
|
45
46
|
def call(session, events: NullSink.new)
|
|
46
47
|
env = {
|
|
47
48
|
messages: session,
|
|
@@ -54,19 +55,20 @@ module Brute
|
|
|
54
55
|
current_iteration: 1,
|
|
55
56
|
}
|
|
56
57
|
super(env)
|
|
57
|
-
|
|
58
|
+
env
|
|
58
59
|
end
|
|
59
60
|
end
|
|
60
61
|
end
|
|
61
62
|
|
|
62
63
|
test do
|
|
63
|
-
it "runs a turn and returns the session" do
|
|
64
|
+
it "runs a turn and returns the env with session in :messages" do
|
|
64
65
|
agent = Brute::Agent.new(provider: :stub) do
|
|
65
66
|
run ->(env) { env[:messages].assistant("hello") }
|
|
66
67
|
end
|
|
67
68
|
session = Brute::Session.new
|
|
68
69
|
session.user("hi")
|
|
69
|
-
agent.call(session)
|
|
70
|
+
env = agent.call(session)
|
|
71
|
+
env[:messages].should == session
|
|
70
72
|
end
|
|
71
73
|
|
|
72
74
|
it "passes provider/model/tools through env" do
|
|
@@ -67,6 +67,14 @@ module Brute
|
|
|
67
67
|
last_call_elapsed: elapsed
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
+
if response.respond_to?(:usage) && (u = response.usage)
|
|
71
|
+
env[:metadata][:tokens] = {
|
|
72
|
+
total: read_token(u, :total_tokens),
|
|
73
|
+
total_input: read_token(u, :input_tokens),
|
|
74
|
+
total_output: read_token(u, :output_tokens),
|
|
75
|
+
}
|
|
76
|
+
end
|
|
77
|
+
|
|
70
78
|
response
|
|
71
79
|
end
|
|
72
80
|
|
data/lib/brute/version.rb
CHANGED