luo 0.1.8 → 0.1.9

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: e9c2a48667ea14c7c9d58e171baa44342929cb9ef585867543ba545559623cb8
4
- data.tar.gz: d586451833334193d7da2f08efc9b0ffa0a06e66dbf3e1de1d18c8c46cf53706
3
+ metadata.gz: 102af9d7257f2583c64ff49ad555fd6bfe6127e2d5ef5db2817ef88c0deff2dd
4
+ data.tar.gz: f407808206d508f2741a165fe45534d5d951dd3f064481ed75e683cee577a6a2
5
5
  SHA512:
6
- metadata.gz: f45e76d27242650bf196acec577d910b7134ccfe693742eb5c2e200c9e9b68a91b8113d8a3c198231ae6fc4cf96caffea918fb6f1c40ad0db0ad5742eaf2b03c
7
- data.tar.gz: ed3a621280d191459520076628630716b5e684a01623df426dd048d28df2eb55fbf2ff7dc3eaa5e235a6518a858bc8b0fd65e1bc7dec8acfc7f99e05d003c1d6
6
+ metadata.gz: 732fd0060a870fa7439d7699fad27929f21873c1051e7ec79dc70478501d5d66a7eff359184530b214624e01c3446f5ee75ead7eee6227d24cebdd074ee100dc
7
+ data.tar.gz: 9327870633acba5bcbea062e3bbee7487d6d91cb9168d645b641422742d25c95fb2574f1d55bbc569bb36538a631795b25217b4449314132326836338d08b88a
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- luo (0.1.7)
4
+ luo (0.1.8)
5
5
  dotenv (~> 2.8, >= 2.8.1)
6
6
  dry-cli (~> 1.0)
7
7
  dry-configurable (~> 1.0, >= 1.0.1)
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.chat(messages)
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
@@ -23,7 +23,7 @@ module Luo
23
23
  client.post('/external/ls_log/aiui_request', params.to_h)
24
24
  end
25
25
 
26
- def chat(messages)
26
+ def chat(messages, temperature: nil)
27
27
  if messages.is_a?(Messages)
28
28
  messages = messages.to_a
29
29
  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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Luo
4
- VERSION = "0.1.8"
4
+ VERSION = "0.1.9"
5
5
  end
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
@@ -13,6 +13,7 @@ require 'dry/cli'
13
13
  require 'yaml'
14
14
  require 'tty-markdown'
15
15
  require 'fileutils'
16
+ require 'dry-initializer'
16
17
 
17
18
  require "zeitwerk"
18
19
  loader = Zeitwerk::Loader.for_gem
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
@@ -0,0 +1,5 @@
1
+ module Luo
2
+ interface _Client
3
+ def chat: (untyped, temperature: Integer) -> String
4
+ end
5
+ end
data/sig/luo/open_ai.rbs CHANGED
@@ -11,6 +11,8 @@ module Luo
11
11
 
12
12
  def create_embedding: -> untyped
13
13
 
14
+ def create_embeddings: -> untyped
15
+
14
16
  def embeddings: -> untyped
15
17
  end
16
18
  end
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.8
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