act_as_agent 0.2.0 → 0.3.0
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/Gemfile.lock +1 -1
- data/lib/act_as_agent/providers/anthropic.rb +5 -7
- data/lib/act_as_agent/tools/list_files.rb +1 -1
- data/lib/act_as_agent/tools/read_file.rb +45 -0
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7f0a2fea9ab22df1f6420509ac58b4e666fe2b935fa4a452a651f366a50b9201
|
|
4
|
+
data.tar.gz: 1b1b554adc81bbfbcb325fa7abbaf2b7b06e06428e61123aabbb264fc718bc2f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: dc8afbb5eb5106ca85c1fe5f65199fd21f25e0450064b8fd519d545ac88d92120c07b18ba4cdfc87b5c28ee33c326233ca6442305b95e0cab1c939d470f5367a
|
|
7
|
+
data.tar.gz: a8311e8f892629d8d8b51e62c322e77e1ab989ae45bedc41286c9805327ed3f892e5f66d6be77c75e96a17329d4651ca021a2e89c1d4e7048fc4a1f1b477c671
|
data/Gemfile.lock
CHANGED
|
@@ -37,22 +37,22 @@ module ActAsAgent
|
|
|
37
37
|
end
|
|
38
38
|
end
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
return response if response["stop_reason"] == "end_turn"
|
|
41
41
|
|
|
42
|
-
response["content"].
|
|
43
|
-
next unless message["type"] == "tool_use"
|
|
42
|
+
tool_responses = response["content"].each_with_object([]) do |message, memo|
|
|
43
|
+
next memo unless message["type"] == "tool_use"
|
|
44
44
|
|
|
45
45
|
@tools.each do |tool|
|
|
46
46
|
next unless tool.name == message["name"]
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
memo << {
|
|
49
49
|
"role" => "assistant",
|
|
50
50
|
"content" => [
|
|
51
51
|
message
|
|
52
52
|
]
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
memo << {
|
|
56
56
|
role: "user",
|
|
57
57
|
content: [
|
|
58
58
|
{
|
|
@@ -66,8 +66,6 @@ module ActAsAgent
|
|
|
66
66
|
end
|
|
67
67
|
|
|
68
68
|
request(content: content + tool_responses) unless tool_responses.empty?
|
|
69
|
-
|
|
70
|
-
response["content"]
|
|
71
69
|
end
|
|
72
70
|
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
|
73
71
|
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "act_as_agent/errors/tool_incorrect_args_error"
|
|
4
|
+
|
|
5
|
+
module ActAsAgent
|
|
6
|
+
module Tools
|
|
7
|
+
class ReadFile
|
|
8
|
+
ERROR = ActAsAgent::Errors::ToolIncorrectArgsError
|
|
9
|
+
|
|
10
|
+
attr_reader :file_path
|
|
11
|
+
|
|
12
|
+
def initialize(file_path: nil)
|
|
13
|
+
@file_path = file_path
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def name
|
|
17
|
+
self.class.to_s.gsub("::", "__")
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def description
|
|
21
|
+
"Read file by the given path"
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def input_schema
|
|
25
|
+
{
|
|
26
|
+
type: "object",
|
|
27
|
+
properties: {
|
|
28
|
+
file_path: { type: "string",
|
|
29
|
+
description: "File path to read" }
|
|
30
|
+
},
|
|
31
|
+
required: []
|
|
32
|
+
}
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def call(args = {})
|
|
36
|
+
path = args.fetch("file_path", nil)
|
|
37
|
+
|
|
38
|
+
return File.read(path) unless path.nil? || path.chomp == ""
|
|
39
|
+
return File.read(file_path) unless file_path.nil?
|
|
40
|
+
|
|
41
|
+
ERROR.new("Incorrect params have been given to list files tool")
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: act_as_agent
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Max Rukomoynikov
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2025-11-
|
|
11
|
+
date: 2025-11-17 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: act_as_api_client
|
|
@@ -53,6 +53,7 @@ files:
|
|
|
53
53
|
- lib/act_as_agent/errors/tool_incorrect_args_error.rb
|
|
54
54
|
- lib/act_as_agent/providers/anthropic.rb
|
|
55
55
|
- lib/act_as_agent/tools/list_files.rb
|
|
56
|
+
- lib/act_as_agent/tools/read_file.rb
|
|
56
57
|
- sig/act_as_agent.rbs
|
|
57
58
|
homepage: https://github.com/Rukomoynikov/act_as_agent
|
|
58
59
|
licenses:
|