luo 0.1.7 → 0.1.9
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/luo/agent.rb +4 -2
- data/lib/luo/aiui.rb +1 -1
- data/lib/luo/init_project.rb +2 -2
- data/lib/luo/open_ai.rb +2 -2
- data/lib/luo/version.rb +1 -1
- data/lib/luo/xinghuo.rb +2 -2
- data/lib/luo.rb +1 -0
- data/luo.gemspec +0 -1
- data/sig/luo/agent.rbs +4 -1
- data/sig/luo/agent_runner_context.rbs +3 -0
- data/sig/luo/client.rbs +5 -0
- data/sig/luo/open_ai.rbs +2 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 102af9d7257f2583c64ff49ad555fd6bfe6127e2d5ef5db2817ef88c0deff2dd
|
4
|
+
data.tar.gz: f407808206d508f2741a165fe45534d5d951dd3f064481ed75e683cee577a6a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 732fd0060a870fa7439d7699fad27929f21873c1051e7ec79dc70478501d5d66a7eff359184530b214624e01c3446f5ee75ead7eee6227d24cebdd074ee100dc
|
7
|
+
data.tar.gz: 9327870633acba5bcbea062e3bbee7487d6d91cb9168d645b641422742d25c95fb2574f1d55bbc569bb36538a631795b25217b4449314132326836338d08b88a
|
data/Gemfile.lock
CHANGED
data/lib/luo/agent.rb
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
module Luo
|
4
4
|
class Agent
|
5
|
+
extend Dry::Initializer
|
6
|
+
|
5
7
|
attr_reader :context, :action_input, :client
|
6
8
|
def initialize(context: nil, action_input: nil, client: nil)
|
7
9
|
@context = context
|
@@ -27,7 +29,7 @@ module Luo
|
|
27
29
|
result = instance_eval(&block)
|
28
30
|
if result.nil?
|
29
31
|
messages = context.messages.to_a[0...-1] + [{role: :user, content: context.user_input}]
|
30
|
-
context.final_result = client
|
32
|
+
context.final_result = client&.chat(messages)
|
31
33
|
else
|
32
34
|
context.final_result = result
|
33
35
|
end
|
@@ -35,7 +37,7 @@ module Luo
|
|
35
37
|
end
|
36
38
|
|
37
39
|
alias_method :on_call_with_fallback, :on_call_with_final_result
|
38
|
-
|
40
|
+
|
39
41
|
def self.create_parameter_method(method_name, not_provided = Object.new, &block)
|
40
42
|
define_method(method_name.to_sym) do |content = not_provided|
|
41
43
|
if content === not_provided
|
data/lib/luo/aiui.rb
CHANGED
data/lib/luo/init_project.rb
CHANGED
@@ -11,12 +11,12 @@ module Luo
|
|
11
11
|
puts "create Gemfile"
|
12
12
|
version = Luo::VERSION
|
13
13
|
unless File.exist?('Gemfile')
|
14
|
-
gemfile = <<-GEMFILE
|
14
|
+
gemfile = <<-GEMFILE.gsub(/^ */, '')
|
15
15
|
source 'https://rubygems.org'
|
16
16
|
gem 'luo', '~> #{version}'
|
17
17
|
GEMFILE
|
18
18
|
File.open('Gemfile', 'w') do |file|
|
19
|
-
file.
|
19
|
+
file.puts(gemfile)
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
data/lib/luo/open_ai.rb
CHANGED
@@ -48,13 +48,13 @@ module Luo
|
|
48
48
|
embeddings(params).body.dig("data").map { |v| v["embedding"] }
|
49
49
|
end
|
50
50
|
|
51
|
-
def chat(messages)
|
51
|
+
def chat(messages, temperature: nil)
|
52
52
|
if messages.is_a?(Messages)
|
53
53
|
messages = messages.to_a
|
54
54
|
end
|
55
55
|
params = PARAMS.call(
|
56
56
|
model: 'gpt-3.5-turbo',
|
57
|
-
temperature: config.temperature,
|
57
|
+
temperature: temperature || config.temperature,
|
58
58
|
messages: messages
|
59
59
|
)
|
60
60
|
return params.errors unless params.success?
|
data/lib/luo/version.rb
CHANGED
data/lib/luo/xinghuo.rb
CHANGED
@@ -30,7 +30,7 @@ module Luo
|
|
30
30
|
client.post('/external/ls_log/xf_completions', params.to_h)
|
31
31
|
end
|
32
32
|
|
33
|
-
def chat(messages)
|
33
|
+
def chat(messages, temperature: nil)
|
34
34
|
if messages.is_a?(Messages)
|
35
35
|
messages = messages.to_a
|
36
36
|
end
|
@@ -39,7 +39,7 @@ module Luo
|
|
39
39
|
domain: config.domain,
|
40
40
|
messages: messages,
|
41
41
|
max_tokens: config.max_tokens,
|
42
|
-
random_threshold: config.temperature,
|
42
|
+
random_threshold: temperature || config.temperature,
|
43
43
|
uid: config.uid.call
|
44
44
|
)
|
45
45
|
return params.errors unless params.success?
|
data/lib/luo.rb
CHANGED
data/luo.gemspec
CHANGED
@@ -37,7 +37,6 @@ Gem::Specification.new do |spec|
|
|
37
37
|
spec.add_dependency 'dry-configurable', '~> 1.0', '>= 1.0.1'
|
38
38
|
spec.add_dependency 'dry-cli', '~> 1.0'
|
39
39
|
spec.add_dependency 'tty-markdown', '~> 0.7.2'
|
40
|
-
# spec.add_dependency "example-gem", "~> 1.0"
|
41
40
|
|
42
41
|
spec.add_development_dependency "rspec", '~> 3.12'
|
43
42
|
|
data/sig/luo/agent.rbs
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Luo
|
2
2
|
class Agent
|
3
3
|
@action_input: untyped
|
4
|
-
@context: AgentRunnerContext
|
4
|
+
@context: AgentRunnerContext?
|
5
5
|
|
6
6
|
attr_reader self.agent_desc: String
|
7
7
|
attr_reader self.agent_name: String
|
@@ -9,6 +9,7 @@ module Luo
|
|
9
9
|
def self.on_call_with_final_result: -> untyped
|
10
10
|
|
11
11
|
attr_reader action_input: untyped
|
12
|
+
attr_reader client: _Client?
|
12
13
|
attr_reader context: AgentRunnerContext
|
13
14
|
|
14
15
|
def initialize: (AgentRunnerContext) -> untyped
|
@@ -19,5 +20,7 @@ module Luo
|
|
19
20
|
|
20
21
|
attr_reader input: String
|
21
22
|
attr_reader row_input: String?
|
23
|
+
|
24
|
+
def call: -> untyped
|
22
25
|
end
|
23
26
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
module Luo
|
2
2
|
class AgentRunnerContext
|
3
|
+
@client: untyped
|
3
4
|
@histories: MemoryHistory
|
4
5
|
|
5
6
|
@running_agents: Array[Agent]
|
@@ -14,6 +15,8 @@ module Luo
|
|
14
15
|
|
15
16
|
def client: -> untyped
|
16
17
|
|
18
|
+
def client=: -> untyped
|
19
|
+
|
17
20
|
def have_running_agents: -> Set[Agent]
|
18
21
|
|
19
22
|
def histories: -> MemoryHistory
|
data/sig/luo/client.rbs
ADDED
data/sig/luo/open_ai.rbs
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: luo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- MJ
|
@@ -228,6 +228,7 @@ files:
|
|
228
228
|
- sig/luo/agent_runner_base.rbs
|
229
229
|
- sig/luo/agent_runner_context.rbs
|
230
230
|
- sig/luo/aiui.rbs
|
231
|
+
- sig/luo/client.rbs
|
231
232
|
- sig/luo/configurable.rbs
|
232
233
|
- sig/luo/env.rbs
|
233
234
|
- sig/luo/helpers.rbs
|