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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0e121e0329cf0f92c56754426facf7c5142941bdb859a19b3125cc9a53e30221
4
- data.tar.gz: 0a8d2f4ae3b4599bbe60960dfaf6d5cfc8c6d21c5e9e69bd7e7432d30ec9c36f
3
+ metadata.gz: b43c4e8273fcaae684832481f227a4dc1ad3e453b3a7f97681a5c5251b4a0349
4
+ data.tar.gz: 4283068e62756e7f0c0c1bc3d2e8f08681e6dcfa4cdeec10c99aef32019b3e0f
5
5
  SHA512:
6
- metadata.gz: 22d8dd554b0620536b9ac858ad6e5009da3bf5eb3bba502b10710f4f783ca0b8f392895805cb9ad6db3c2f567d7c95891dc2c26149e1be76f9493622427bf74e
7
- data.tar.gz: 89be4a1d4d4525885fcdb77889c07365b1dd22f223f2de225c79ebb99b80126bd110cec51721c03110321ce239a0bbef4e262011f9b8822c0135383c27256a81
6
+ metadata.gz: 99c634daff06d449330d33fe506e0a8afdbd7b1d24cf8cb57d889835e19cd083ecdf25eb3faaea35da234fa4890e5a415bf5e19cdeff6f8248ee0741de6d29eb
7
+ data.tar.gz: 1dcb79abfdccec8b0dff6e5af95fec56e23a7b52302c267c04330173fe53d69d16fe0866948217a2c2cb5d82e1fadce21b8cffdb00acd8d54d18821d6dbd19bb
@@ -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
- request messages, run_agent_retries: run_agent_retries
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
- raise e, "Input must be JSON and contain action and action_input."
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Luogu
4
- VERSION = "0.2.5"
4
+ VERSION = "0.2.6"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: luogu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - MJ