active_genie 0.25.0 → 0.25.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 834f343cf29bd29843a2d5af3f0911148cd59ab493d4a4ec30f6fca89fc35e63
4
- data.tar.gz: 5c59a508a4a86bb421f6cfa8575d6f2b8dd925f1a831972605e02e211fda3ec7
3
+ metadata.gz: c91ce12dad609d42839c1d71d172ae5ed6922357374097ec29de8bcbb0c7a3fd
4
+ data.tar.gz: 4de847656eff030d4bdf93bf8f492584c5ace9458af7f13b962941eabbe1e308
5
5
  SHA512:
6
- metadata.gz: a2d315d013b92e7c5fbbd1bb3812269dd4a61259c5dd0d303d0ae4009e9dff2d346e280c750e76b889afc0f5cbe1fc68a243233402965eb667f1261b3dfc6dbf
7
- data.tar.gz: cc30b3ba4b240dbc65e734e5f19c2d7f4e30d655bcec3499f16d0b6039fa0c600e5389f198aa4f26ddb5a71b27256ac967329170b1eb71c2da85181dede7d15a
6
+ metadata.gz: 0c9c8fbf3f4e940408d3a1051f280aec1da7d196ac61ba1fa02812b68376411a74198a44fb888fbd0c3cf385d39330c7c2265a3a73448c6b2a9179a1c29bdd48
7
+ data.tar.gz: 2d7001c0bb3b2ce274ecef96eaf10a0228d949f447d5df7cccca4f686c6f2b14273c71d376f5f7b8e39d9448a3ee27bd2f1358f4a7a69cdad2ac4fd34dfac574
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.25.0
1
+ 0.25.1
@@ -38,7 +38,8 @@ module ActiveGenie
38
38
 
39
39
  def normalize_response(response)
40
40
  response.each do |key, value|
41
- response[key] = nil if ['null', 'none', 'undefined', '', 'unknown', '<unknown>'].include?(value.to_s.strip.downcase)
41
+ response[key] = nil if ['null', 'none', 'undefined', '', 'unknown',
42
+ '<unknown>'].include?(value.to_s.strip.downcase)
42
43
  end
43
44
 
44
45
  response
@@ -13,9 +13,9 @@ module ActiveGenie
13
13
 
14
14
  def merge(config_params = {})
15
15
  dup.tap do |config|
16
- config.with_explanation = config_params[:with_explanation] if config_params[:with_explanation]
17
- config.min_accuracy = config_params[:min_accuracy] if config_params[:min_accuracy]
18
- config.verbose = config_params[:verbose] if config_params[:verbose]
16
+ config.with_explanation = config_params[:with_explanation] if config_params.key?(:with_explanation)
17
+ config.min_accuracy = config_params[:min_accuracy] if config_params.key?(:min_accuracy)
18
+ config.verbose = config_params[:verbose] if config_params.key?(:verbose)
19
19
  end
20
20
  end
21
21
  end
@@ -16,7 +16,7 @@ module ActiveGenie
16
16
 
17
17
  def default=(provider)
18
18
  normalized_provider = provider.to_s.downcase.strip
19
- @default = normalized_provider.size > 0 ? normalized_provider : valid.keys.first
19
+ @default = normalized_provider.size.positive? ? normalized_provider : valid.keys.first
20
20
  end
21
21
 
22
22
  def valid
@@ -47,6 +47,7 @@ module ActiveGenie
47
47
  def merge(config_params = {})
48
48
  dup.tap do |config|
49
49
  config.add(config_params[:providers]) if config_params[:providers]
50
+ config.default = config_params[:default] if config_params[:default]
50
51
  end
51
52
  end
52
53
 
@@ -48,8 +48,10 @@ module ActiveGenie
48
48
 
49
49
  next unless config.respond_to?(:merge)
50
50
 
51
- new_config = if config_params.key?(key)
52
- config.merge(config_params[key])
51
+ new_config = if config_params.key?(key.to_s)
52
+ config.merge(config_params[key.to_s])
53
+ elsif config_params.key?(key.to_sym)
54
+ config.merge(config_params[key.to_sym])
53
55
  else
54
56
  config.merge(config_params)
55
57
  end
@@ -104,10 +104,10 @@ module ActiveGenie
104
104
  simplified_response = {}
105
105
 
106
106
  @data_to_extract.each_key do |key|
107
- next if !response.key?(key)
107
+ next unless response.key?(key.to_s)
108
108
  next if response.key?("#{key}_accuracy") && response["#{key}_accuracy"] < min_accuracy
109
109
 
110
- simplified_response[key] = response[key]
110
+ simplified_response[key] = response[key.to_s]
111
111
  end
112
112
 
113
113
  simplified_response
@@ -9,8 +9,8 @@ module ActiveGenie
9
9
  1. Set up global configuration:
10
10
  ```ruby
11
11
  ActiveGenie.configure do |config|
12
- config.provider = 'your_provider'
13
- config.api_key = 'your_api_key'
12
+ config.providers.default = 'openai'
13
+ config.providers.openai.api_key = 'your_api_key'
14
14
  # ... other configuration options
15
15
  end
16
16
  ```
@@ -21,8 +21,12 @@ module ActiveGenie
21
21
  arg1,
22
22
  arg2,
23
23
  config: {
24
- provider: 'your_provider',
25
- api_key: 'your_api_key'
24
+ providers: {
25
+ default: 'openai',
26
+ openai: {
27
+ api_key: 'your_api_key'
28
+ }
29
+ }
26
30
  }
27
31
  )
28
32
  ```
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_genie
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.25.0
4
+ version: 0.25.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Radamés Roriz