luogu 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/luogu/agent_runner.rb +7 -1
- data/lib/luogu/openai.rb +8 -2
- data/lib/luogu/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: b43c4e8273fcaae684832481f227a4dc1ad3e453b3a7f97681a5c5251b4a0349
|
4
|
+
data.tar.gz: 4283068e62756e7f0c0c1bc3d2e8f08681e6dcfa4cdeec10c99aef32019b3e0f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 99c634daff06d449330d33fe506e0a8afdbd7b1d24cf8cb57d889835e19cd083ecdf25eb3faaea35da234fa4890e5a415bf5e19cdeff6f8248ee0741de6d29eb
|
7
|
+
data.tar.gz: 1dcb79abfdccec8b0dff6e5af95fec56e23a7b52302c267c04330173fe53d69d16fe0866948217a2c2cb5d82e1fadce21b8cffdb00acd8d54d18821d6dbd19bb
|
data/lib/luogu/agent_runner.rb
CHANGED
@@ -9,6 +9,8 @@ module Luogu
|
|
9
9
|
end
|
10
10
|
|
11
11
|
setting :run_agent_retries, default: Application.config.run_agent_retries
|
12
|
+
setting :mode, default: :agent # route 路由模式 agent 代理模式
|
13
|
+
setting :route_mode_response_handle, default: ->(tool_responses) { tool_responses&.first.fetch(:response, nil) }
|
12
14
|
|
13
15
|
setting :provider do
|
14
16
|
setting :parameter_model, default: ->() {
|
@@ -117,7 +119,11 @@ module Luogu
|
|
117
119
|
{ role: "assistant", content: agents.to_json },
|
118
120
|
{ role: "user", content: templates.tool.result(binding) }
|
119
121
|
]
|
120
|
-
|
122
|
+
if config.mode == :agent
|
123
|
+
request messages, run_agent_retries: run_agent_retries
|
124
|
+
else
|
125
|
+
config.route_mode_response_handle.call @tools_response
|
126
|
+
end
|
121
127
|
end
|
122
128
|
|
123
129
|
end
|
data/lib/luogu/openai.rb
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Luogu::OpenAI
|
4
|
+
extend Dry::Configurable
|
5
|
+
|
6
|
+
setting :after_parse_json, default: ->(data) { data }
|
7
|
+
|
4
8
|
class ChatRequestParams < Struct.new(:model, :messages, :temperature,
|
5
9
|
:top_p, :n, :stream, :stop,
|
6
10
|
:max_tokens, :presence_penalty,
|
@@ -45,12 +49,14 @@ module Luogu::OpenAI
|
|
45
49
|
end
|
46
50
|
|
47
51
|
if result_json.nil?
|
48
|
-
JSON.parse markdown
|
52
|
+
result_json = JSON.parse markdown
|
49
53
|
else
|
50
54
|
result_json
|
51
55
|
end
|
56
|
+
Luogu::OpenAI.config.after_parse_json.call(result_json)
|
52
57
|
rescue => e
|
53
|
-
|
58
|
+
Luogu::Application.logger.error "parse json error: #{markdown}"
|
59
|
+
Luogu::OpenAI.config.after_parse_json.call(markdown)
|
54
60
|
end
|
55
61
|
|
56
62
|
def chat_response_handle(response)
|
data/lib/luogu/version.rb
CHANGED