smart_agent 0.1.3 → 0.1.5
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/smart_agent/agent.rb +19 -15
- data/lib/smart_agent/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9de1bc240f9f64173711fb21130d07df5600f6a881b00562c8279d675f71d0d5
|
4
|
+
data.tar.gz: 5c54c6c88302886d2fb073f5176859fcd0902de2f70a4eb1ae4786dd8d2e6f21
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1574d1cbcc20199213d6af6541569965352910338ca6c8bc65cc03baf917963fbd434bd5d0837d0789047022ae803251f8c0b8e33edabcba1a7484bf85bfd738
|
7
|
+
data.tar.gz: a26a0a6885b9332b258e95dbf57c50adb95fe6b384ebebb25673f2c7ec371b5c8a7083c2d57da1bd59e9dcc4838a97de25ac5e49c391418428eacafa86122947
|
data/lib/smart_agent/agent.rb
CHANGED
@@ -85,29 +85,32 @@ module SmartAgent
|
|
85
85
|
params[:with_history] = with_history
|
86
86
|
ret = nil
|
87
87
|
if @agent.on_event
|
88
|
-
|
88
|
+
full_result = {}
|
89
89
|
tool_calls = []
|
90
90
|
result = SmartAgent.prompt_engine.call_worker_by_stream(name, params) do |chunk, _bytesize|
|
91
|
-
if
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
91
|
+
if full_result.empty?
|
92
|
+
full_result["id"] = chunk["id"]
|
93
|
+
full_result["object"] = chunk["object"]
|
94
|
+
full_result["created"] = chunk["created"]
|
95
|
+
full_result["model"] = chunk["model"]
|
96
|
+
full_result["choices"] = [{
|
97
97
|
"index" => 0,
|
98
98
|
"message" => {
|
99
99
|
"role" => "assistant",
|
100
100
|
"content" => "",
|
101
|
+
"reasoning_content" => "",
|
101
102
|
"tool_calls" => [],
|
102
103
|
},
|
103
104
|
}]
|
104
|
-
|
105
|
-
|
105
|
+
full_result["usage"] = chunk["usage"]
|
106
|
+
full_result["system_fingerprint"] = chunk["system_fingerprint"]
|
106
107
|
end
|
107
108
|
if chunk.dig("choices", 0, "delta", "reasoning_content")
|
109
|
+
full_result["choices"][0]["message"]["reasoning_content"] += chunk.dig("choices", 0, "delta", "reasoning_content")
|
108
110
|
@agent.processor(:reasoning).call(chunk) if @agent.processor(:reasoning)
|
109
111
|
end
|
110
112
|
if chunk.dig("choices", 0, "delta", "content")
|
113
|
+
full_result["choices"][0]["message"]["content"] += chunk.dig("choices", 0, "delta", "content")
|
111
114
|
@agent.processor(:content).call(chunk) if @agent.processor(:content)
|
112
115
|
end
|
113
116
|
if chunk_tool_calls = chunk.dig("choices", 0, "delta", "tool_calls")
|
@@ -120,8 +123,8 @@ module SmartAgent
|
|
120
123
|
end
|
121
124
|
end
|
122
125
|
end
|
123
|
-
|
124
|
-
result =
|
126
|
+
full_result["choices"][0]["message"]["tool_calls"] = tool_calls
|
127
|
+
result = full_result
|
125
128
|
else
|
126
129
|
result = SmartAgent.prompt_engine.call_worker(name, params)
|
127
130
|
end
|
@@ -141,17 +144,18 @@ module SmartAgent
|
|
141
144
|
@agent.processor(:tool).call({ :content => "ToolName is `#{tool_name}`\n" }) if @agent.processor(:tool)
|
142
145
|
@agent.processor(:tool).call({ :content => "params is `#{params}`\n" }) if @agent.processor(:tool)
|
143
146
|
tool_result = Tool.find_tool(tool_name).call(params)
|
144
|
-
|
147
|
+
|
148
|
+
SmartAgent.prompt_engine.history_messages << { "role" => "assistant", "content" => "", "tool_calls" => [tool] } #result.response.dig("choices", 0, "message")
|
145
149
|
SmartAgent.prompt_engine.history_messages << { "role" => "tool", "tool_call_id" => tool_call_id, "content" => tool_result.to_s.force_encoding("UTF-8") }
|
146
|
-
results <<
|
150
|
+
results << tool_result
|
147
151
|
end
|
148
152
|
if server_name = MCPClient.find_server_by_tool_name(tool_name)
|
149
153
|
@agent.processor(:tool).call({ :content => "MCP Server is `#{server_name}`, ToolName is `#{tool_name}`\n" }) if @agent.processor(:tool)
|
150
154
|
@agent.processor(:tool).call({ :content => "params is `#{params}`\n" }) if @agent.processor(:tool)
|
151
155
|
tool_result = MCPClient.new(server_name).call(tool_name, params)
|
152
|
-
SmartAgent.prompt_engine.history_messages << result.response.dig("choices", 0, "message")
|
156
|
+
SmartAgent.prompt_engine.history_messages << { "role" => "assistant", "content" => "", "tool_calls" => [tool] } # result.response.dig("choices", 0, "message")
|
153
157
|
SmartAgent.prompt_engine.history_messages << { "role" => "tool", "tool_call_id" => tool_call_id, "content" => tool_result.to_s }
|
154
|
-
results <<
|
158
|
+
results << tool_result
|
155
159
|
end
|
156
160
|
@agent.processor(:tool).call({ :content => " ... done\n" }) if @agent.processor(:tool)
|
157
161
|
end
|
data/lib/smart_agent/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smart_agent
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Your Name
|
@@ -15,14 +15,14 @@ dependencies:
|
|
15
15
|
requirements:
|
16
16
|
- - "~>"
|
17
17
|
- !ruby/object:Gem::Version
|
18
|
-
version:
|
18
|
+
version: 0.2.7
|
19
19
|
type: :runtime
|
20
20
|
prerelease: false
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
22
22
|
requirements:
|
23
23
|
- - "~>"
|
24
24
|
- !ruby/object:Gem::Version
|
25
|
-
version:
|
25
|
+
version: 0.2.7
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: rspec
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|