active_genie 0.0.12 → 0.0.18
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/README.md +65 -22
- data/VERSION +1 -1
- data/lib/active_genie/battle/README.md +7 -7
- data/lib/active_genie/battle/basic.rb +47 -31
- data/lib/active_genie/battle.rb +4 -0
- data/lib/active_genie/clients/anthropic_client.rb +110 -0
- data/lib/active_genie/clients/google_client.rb +158 -0
- data/lib/active_genie/clients/helpers/retry.rb +29 -0
- data/lib/active_genie/clients/openai_client.rb +61 -83
- data/lib/active_genie/clients/unified_client.rb +4 -4
- data/lib/active_genie/concerns/loggable.rb +44 -0
- data/lib/active_genie/configuration/log_config.rb +1 -1
- data/lib/active_genie/configuration/providers/anthropic_config.rb +54 -0
- data/lib/active_genie/configuration/providers/base_config.rb +85 -0
- data/lib/active_genie/configuration/providers/deepseek_config.rb +54 -0
- data/lib/active_genie/configuration/providers/google_config.rb +56 -0
- data/lib/active_genie/configuration/providers/openai_config.rb +54 -0
- data/lib/active_genie/configuration/providers_config.rb +7 -4
- data/lib/active_genie/configuration/runtime_config.rb +35 -0
- data/lib/active_genie/configuration.rb +18 -4
- data/lib/active_genie/data_extractor/basic.rb +15 -2
- data/lib/active_genie/data_extractor.rb +4 -0
- data/lib/active_genie/logger.rb +40 -21
- data/lib/active_genie/ranking/elo_round.rb +71 -50
- data/lib/active_genie/ranking/free_for_all.rb +31 -14
- data/lib/active_genie/ranking/player.rb +11 -16
- data/lib/active_genie/ranking/players_collection.rb +4 -4
- data/lib/active_genie/ranking/ranking.rb +74 -19
- data/lib/active_genie/ranking/ranking_scoring.rb +3 -3
- data/lib/active_genie/scoring/basic.rb +44 -25
- data/lib/active_genie/scoring.rb +3 -0
- data/lib/tasks/benchmark.rake +27 -0
- metadata +91 -70
- data/lib/active_genie/configuration/openai_config.rb +0 -56
@@ -31,14 +31,14 @@ module ActiveGenie::Ranking
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def generate_score(player)
|
34
|
-
score, reasoning = ActiveGenie::Scoring
|
34
|
+
score, reasoning = ActiveGenie::Scoring.call(
|
35
35
|
player.content,
|
36
36
|
@criteria,
|
37
37
|
@reviewers,
|
38
38
|
config: @config
|
39
39
|
).values_at('final_score', 'final_reasoning')
|
40
40
|
|
41
|
-
ActiveGenie::Logger.debug({
|
41
|
+
ActiveGenie::Logger.debug({ code: :new_score, player_id: player.id, score:, reasoning: })
|
42
42
|
|
43
43
|
score
|
44
44
|
end
|
@@ -52,7 +52,7 @@ module ActiveGenie::Ranking
|
|
52
52
|
config: @config
|
53
53
|
).values_at('reviewer1', 'reviewer2', 'reviewer3')
|
54
54
|
|
55
|
-
ActiveGenie::Logger.debug({
|
55
|
+
ActiveGenie::Logger.debug({ code: :new_reviewers, reviewers: [reviewer1, reviewer2, reviewer3] })
|
56
56
|
|
57
57
|
[reviewer1, reviewer2, reviewer3]
|
58
58
|
end
|
@@ -43,48 +43,67 @@ module ActiveGenie::Scoring
|
|
43
43
|
{ role: 'user', content: "Text to score: #{@text}" },
|
44
44
|
]
|
45
45
|
|
46
|
-
properties =
|
47
|
-
get_or_recommend_reviewers.each do |reviewer|
|
48
|
-
properties["#{reviewer}_reasoning"] = {
|
49
|
-
type: 'string',
|
50
|
-
description: "The reasoning of the scoring process by #{reviewer}.",
|
51
|
-
}
|
52
|
-
properties["#{reviewer}_score"] = {
|
53
|
-
type: 'number',
|
54
|
-
description: "The score given by #{reviewer}.",
|
55
|
-
min: 0,
|
56
|
-
max: 100
|
57
|
-
}
|
58
|
-
end
|
46
|
+
properties = build_properties
|
59
47
|
|
60
48
|
function = {
|
61
49
|
name: 'scoring',
|
62
50
|
description: 'Score the text based on the given criteria.',
|
63
51
|
schema: {
|
64
52
|
type: "object",
|
65
|
-
properties
|
66
|
-
|
67
|
-
final_score: {
|
68
|
-
type: 'number',
|
69
|
-
description: 'The final score based on the previous reviewers',
|
70
|
-
},
|
71
|
-
final_reasoning: {
|
72
|
-
type: 'string',
|
73
|
-
description: 'The final reasoning based on the previous reviewers',
|
74
|
-
}
|
75
|
-
}
|
53
|
+
properties:,
|
54
|
+
required: properties.keys
|
76
55
|
}
|
77
56
|
}
|
78
57
|
|
79
|
-
::ActiveGenie::Clients::UnifiedClient.function_calling(
|
58
|
+
result = ::ActiveGenie::Clients::UnifiedClient.function_calling(
|
80
59
|
messages,
|
81
60
|
function,
|
82
61
|
model_tier: 'lower_tier',
|
83
62
|
config: @config
|
84
63
|
)
|
64
|
+
|
65
|
+
result['final_score'] = 0 if result['final_score'].nil?
|
66
|
+
|
67
|
+
ActiveGenie::Logger.debug({
|
68
|
+
code: :scoring,
|
69
|
+
text: @text[0..30],
|
70
|
+
criteria: @criteria[0..30],
|
71
|
+
reviewers: get_or_recommend_reviewers,
|
72
|
+
score: result['final_score'],
|
73
|
+
reasoning: result['final_reasoning']
|
74
|
+
})
|
75
|
+
|
76
|
+
result
|
85
77
|
end
|
86
78
|
|
87
79
|
private
|
80
|
+
|
81
|
+
def build_properties
|
82
|
+
properties = {}
|
83
|
+
get_or_recommend_reviewers.each do |reviewer|
|
84
|
+
properties["#{reviewer}_reasoning"] = {
|
85
|
+
type: 'string',
|
86
|
+
description: "The reasoning of the scoring process by #{reviewer}.",
|
87
|
+
}
|
88
|
+
properties["#{reviewer}_score"] = {
|
89
|
+
type: 'number',
|
90
|
+
description: "The score given by #{reviewer}.",
|
91
|
+
min: 0,
|
92
|
+
max: 100
|
93
|
+
}
|
94
|
+
end
|
95
|
+
|
96
|
+
properties[:final_score] = {
|
97
|
+
type: 'number',
|
98
|
+
description: 'The final score based on the previous reviewers',
|
99
|
+
}
|
100
|
+
properties[:final_reasoning] = {
|
101
|
+
type: 'string',
|
102
|
+
description: 'The final reasoning based on the previous reviewers',
|
103
|
+
}
|
104
|
+
|
105
|
+
properties
|
106
|
+
end
|
88
107
|
|
89
108
|
def get_or_recommend_reviewers
|
90
109
|
@get_or_recommend_reviewers ||= if @reviewers.count > 0
|
data/lib/active_genie/scoring.rb
CHANGED
@@ -0,0 +1,27 @@
|
|
1
|
+
|
2
|
+
namespace :active_genie do
|
3
|
+
desc "Run benchmarks, optionally for a specific module (e.g., rake active_genie:benchmark[data_extractor])"
|
4
|
+
task :benchmark, [:module_name] do |_, args|
|
5
|
+
Rake::TestTask.new(:run_benchmarks) do |t|
|
6
|
+
t.libs << "benchmark"
|
7
|
+
|
8
|
+
if args[:module_name]
|
9
|
+
module_name = args[:module_name]
|
10
|
+
module_path = "benchmark/test_cases/#{module_name}/"
|
11
|
+
t.test_files = FileList["#{module_path}**/*_test.rb"]
|
12
|
+
puts "Running benchmarks for module: #{module_name}"
|
13
|
+
else
|
14
|
+
t.test_files = FileList["benchmark/test_cases/**/*_test.rb"]
|
15
|
+
puts "Running all benchmarks"
|
16
|
+
end
|
17
|
+
|
18
|
+
t.warning = false
|
19
|
+
end
|
20
|
+
|
21
|
+
begin
|
22
|
+
Rake::Task[:run_benchmarks].invoke
|
23
|
+
rescue => e
|
24
|
+
puts e
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
metadata
CHANGED
@@ -1,92 +1,103 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_genie
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.18
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Radamés Roriz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-04-02 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: "# ActiveGenie \U0001F9DE♂️\n> The lodash for GenAI, stop reinventing
|
14
|
-
the wheel\n\n[](https://badge.fury.io/rb/active_genie)\n[
|
14
|
+
the wheel\n\n[](https://badge.fury.io/rb/active_genie)\n[](https://github.com/roriz/active_genie/actions/workflows/benchmark.yml)\n\nActiveGenie
|
15
|
+
is a Ruby gem that provides valuable solutions powered by Generative AI (GenAI)
|
16
|
+
models. Just like Lodash or ActiveStorage, ActiveGenie brings a set of Modules reach
|
17
|
+
real value fast and reliable.\nActiveGenie is backed by a custom benchmarking system
|
18
|
+
that ensures consistent quality and performance across different models and providers
|
19
|
+
in every release.\n\n## Installation\n\n1. Add to your Gemfile:\n```ruby\ngem 'active_genie'\n```\n\n2.
|
20
|
+
Install the gem:\n```shell\nbundle install\n```\n\n3. Generate the configuration:\n```shell\necho
|
21
|
+
\"ActiveGenie.load_tasks\" >> Rakefile\nrails g active_genie:install\n```\n\n4.
|
22
|
+
Configure your credentials in `config/initializers/active_genie.rb`:\n```ruby\nActiveGenie.configure
|
23
|
+
do |config|\n config.openai.api_key = ENV['OPENAI_API_KEY']\nend\n```\n\n## Quick
|
24
|
+
Start\n\n### Data Extractor\n\nExtract structured data from text using AI-powered
|
25
|
+
analysis, handling informal language and complex expressions.\n\n```ruby\ntext =
|
26
|
+
\"Nike Air Max 90 - Size 42 - $199.99\"\nschema = {\n brand: { \n type: 'string',\n
|
27
|
+
\ enum: [\"Nike\", \"Adidas\", \"Puma\"]\n },\n price: { \n type: 'number',\n
|
28
|
+
\ minimum: 0\n },\n size: {\n type: 'number',\n minimum: 35,\n maximum:
|
29
|
+
46\n }\n}\n\nresult = ActiveGenie::DataExtractor.call(\n text,\n schema,\n config:
|
30
|
+
{ provider: :openai, model: 'gpt-4o-mini' } # optional\n)\n# => { \n# brand:
|
31
|
+
\"Nike\", \n# brand_explanation: \"Brand name found at start of text\",\n#
|
32
|
+
\ price: 199.99,\n# price_explanation: \"Price found in USD format at end\",\n#
|
33
|
+
\ size: 42,\n# size_explanation: \"Size explicitly stated in the middle\"\n#
|
34
|
+
\ }\n```\n\n*Recommended model*: `gpt-4o-mini`\n\nFeatures:\n- Structured data
|
35
|
+
extraction with type validation\n- Schema-based extraction with custom constraints\n-
|
36
|
+
Informal text analysis (litotes, hedging)\n- Detailed explanations for extracted
|
37
|
+
values\n\nSee the [Data Extractor README](lib/active_genie/data_extractor/README.md)
|
39
38
|
for informal text processing, advanced schemas, and detailed interface documentation.\n\n###
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
39
|
+
Scoring\nText evaluation system that provides detailed scoring and feedback using
|
40
|
+
multiple expert reviewers. Get balanced scoring through AI-powered expert reviewers
|
41
|
+
that automatically adapt to your content.\n\n```ruby\ntext = \"The code implements
|
42
|
+
a binary search algorithm with O(log n) complexity\"\ncriteria = \"Evaluate technical
|
43
|
+
accuracy and clarity\"\n\nresult = ActiveGenie::Scoring.basic(\n text,\n criteria,\n
|
44
|
+
\ config: { provider: :anthropic, model: 'claude-3-5-haiku-20241022' } # optional\n)\n#
|
45
45
|
=> {\n# algorithm_expert_score: 95,\n# algorithm_expert_reasoning: \"Accurately
|
46
46
|
describes binary search and its complexity\",\n# technical_writer_score: 90,\n#
|
47
47
|
\ technical_writer_reasoning: \"Clear and concise explanation of the algorithm\",\n#
|
48
|
-
\ final_score: 92.5\n# }\n```\n\nFeatures:\n-
|
49
|
-
automatic expert selection\n- Detailed feedback with
|
50
|
-
reviewer weights\n- Flexible evaluation criteria\n\nSee
|
48
|
+
\ final_score: 92.5\n# }\n```\n\n*Recommended model*: `claude-3-5-haiku-20241022`\n\nFeatures:\n-
|
49
|
+
Multi-reviewer evaluation with automatic expert selection\n- Detailed feedback with
|
50
|
+
scoring reasoning\n- Customizable reviewer weights\n- Flexible evaluation criteria\n\nSee
|
51
|
+
the [Scoring README](lib/active_genie/scoring/README.md) for advanced usage, custom
|
52
|
+
reviewers, and detailed interface documentation.\n\n### Battle\nAI-powered battle
|
53
|
+
evaluation system that determines winners between two players based on specified
|
54
|
+
criteria.\n\n```ruby\nrequire 'active_genie'\n\nplayer_1 = \"Implementation uses
|
55
|
+
dependency injection for better testability\"\nplayer_2 = \"Code has high test coverage
|
56
|
+
but tightly coupled components\"\ncriteria = \"Evaluate code quality and maintainability\"\n\nresult
|
57
|
+
= ActiveGenie::Battle.call(\n player_1,\n player_2,\n criteria,\n config: {
|
58
|
+
provider: :google, model: 'gemini-2.0-flash-lite' } # optional\n)\n# => {\n# winner_player:
|
59
|
+
\"Implementation uses dependency injection for better testability\",\n# reasoning:
|
60
|
+
\"Player 1 implementation demonstrates better maintainability through dependency
|
61
|
+
injection, \n# which allows for easier testing and component replacement.
|
62
|
+
While Player 2 has good test coverage, \n# the tight coupling makes
|
63
|
+
the code harder to maintain and modify.\",\n# what_could_be_changed_to_avoid_draw:
|
64
|
+
\"Focus on specific architectural patterns and design principles\"\n# }\n```\n\n*Recommended
|
65
|
+
model*: `gemini-2.0-flash-lite`\n\nFeatures:\n- Multi-reviewer evaluation with automatic
|
66
|
+
expert selection\n- Detailed feedback with scoring reasoning\n- Customizable reviewer
|
67
|
+
weights\n- Flexible evaluation criteria\n\nSee the [Battle README](lib/active_genie/battle/README.md)
|
51
68
|
for advanced usage, custom reviewers, and detailed interface documentation.\n\n###
|
52
|
-
|
53
|
-
|
54
|
-
= \"
|
55
|
-
= \
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
demonstrates better maintainability through dependency injection, \n# which
|
60
|
-
allows for easier testing and component replacement. While Player B has good test
|
61
|
-
coverage, \n# the tight coupling makes the code harder to maintain
|
62
|
-
and modify.\",\n# what_could_be_changed_to_avoid_draw: \"Focus on specific
|
63
|
-
architectural patterns and design principles\"\n# }\n```\n\nFeatures:\n- Multi-reviewer
|
64
|
-
evaluation with automatic expert selection\n- Detailed feedback with scoring reasoning\n-
|
65
|
-
Customizable reviewer weights\n- Flexible evaluation criteria\n\nSee the [Battle
|
66
|
-
README](lib/active_genie/battle/README.md) for advanced usage, custom reviewers,
|
67
|
-
and detailed interface documentation.\n\n### Data Ranking\nThe Ranking module provides
|
68
|
-
competitive ranking through multi-stage evaluation:\n\n\n```ruby\nrequire 'active_genie'\n\nplayers
|
69
|
-
= ['REST API', 'GraphQL API', 'SOAP API', 'gRPC API', 'Websocket API']\ncriteria
|
70
|
-
= \"Best one to be used into a high changing environment\"\n\nresult = ActiveGenie::Ranking.call(players,
|
71
|
-
criteria)\n# => {\n# winner_player: \"gRPC API\",\n# reasoning: \"gRPC
|
72
|
-
API is the best one to be used into a high changing environment\",\n# }\n```\n\n-
|
69
|
+
Ranking\nThe Ranking module provides competitive ranking through multi-stage evaluation:\n\n```ruby\nrequire
|
70
|
+
'active_genie'\n\nplayers = ['REST API', 'GraphQL API', 'SOAP API', 'gRPC API',
|
71
|
+
'Websocket API']\ncriteria = \"Best one to be used into a high changing environment\"\n\nresult
|
72
|
+
= ActiveGenie::Ranking.call(\n players,\n criteria,\n config: { provider: :google,
|
73
|
+
model: 'gemini-2.0-flash-lite' } # optional\n)\n# => {\n# winner_player: \"gRPC
|
74
|
+
API\",\n# reasoning: \"gRPC API is the best one to be used into a high changing
|
75
|
+
environment\",\n# }\n```\n\n*Recommended model*: `gemini-2.0-flash-lite`\n\n-
|
73
76
|
**Multi-phase ranking system** combining expert scoring and ELO algorithms\n- **Automatic
|
74
77
|
elimination** of inconsistent performers using statistical analysis\n- **Dynamic
|
75
78
|
ranking adjustments** based on simulated pairwise battles, from bottom to top\n\nSee
|
76
79
|
the [Ranking README](lib/active_genie/ranking/README.md) for implementation details,
|
77
80
|
configuration, and advanced ranking strategies.\n\n### Text Summarizer (Future)\n###
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
81
|
+
Categorizer (Future)\n### Language detector (Future)\n### Translator (Future)\n###
|
82
|
+
Sentiment analyzer (Future)\n\n## Benchmarking \U0001F9EA\n\nActiveGenie includes
|
83
|
+
a comprehensive benchmarking system to ensure consistent, high-quality outputs across
|
84
|
+
different LLM models and providers.\n\n```ruby\n# Run all benchmarks\nbundle exec
|
85
|
+
rake active_genie:benchmark\n\n# Run benchmarks for a specific module\nbundle exec
|
86
|
+
rake active_genie:benchmark[data_extractor]\n```\n\n### Latest Results\n\n| Model
|
87
|
+
| Overall Precision |\n|-------|-------------------|\n| claude-3-5-haiku-20241022
|
88
|
+
| 92.25% |\n| gemini-2.0-flash-lite | 84.25% |\n| gpt-4o-mini | 62.75% |\n| deepseek-chat
|
89
|
+
| 57.25% |\n\nSee the [Benchmark README](benchmark/README.md) for detailed results,
|
90
|
+
methodology, and how to contribute to our test suite.\n\n## Configuration\n\n| Config
|
91
|
+
| Description | Default |\n|--------|-------------|---------|\n| `provider` | LLM
|
92
|
+
provider (openai, anthropic, etc) | `nil` |\n| `model` | Model to use | `nil` |\n|
|
93
|
+
`api_key` | Provider API key | `nil` |\n| `timeout` | Request timeout in seconds
|
94
|
+
| `5` |\n| `max_retries` | Maximum retry attempts | `3` |\n\n> **Note:** Each module
|
95
|
+
can append its own set of configuration, see the individual module documentation
|
96
|
+
for details.\n\n## Contributing\n\n1. Fork the repository\n2. Create your feature
|
97
|
+
branch (`git checkout -b feature/amazing-feature`)\n3. Commit your changes (`git
|
98
|
+
commit -m 'Add amazing feature'`)\n4. Push to the branch (`git push origin feature/amazing-feature`)\n5.
|
99
|
+
Open a Pull Request\n\n## License\n\nThis project is licensed under the Apache License
|
100
|
+
2.0 License - see the [LICENSE](LICENSE) file for details.\n"
|
90
101
|
email:
|
91
102
|
- radames@roriz.dev
|
92
103
|
executables: []
|
@@ -100,12 +111,21 @@ files:
|
|
100
111
|
- lib/active_genie/battle.rb
|
101
112
|
- lib/active_genie/battle/README.md
|
102
113
|
- lib/active_genie/battle/basic.rb
|
114
|
+
- lib/active_genie/clients/anthropic_client.rb
|
115
|
+
- lib/active_genie/clients/google_client.rb
|
116
|
+
- lib/active_genie/clients/helpers/retry.rb
|
103
117
|
- lib/active_genie/clients/openai_client.rb
|
104
118
|
- lib/active_genie/clients/unified_client.rb
|
119
|
+
- lib/active_genie/concerns/loggable.rb
|
105
120
|
- lib/active_genie/configuration.rb
|
106
121
|
- lib/active_genie/configuration/log_config.rb
|
107
|
-
- lib/active_genie/configuration/
|
122
|
+
- lib/active_genie/configuration/providers/anthropic_config.rb
|
123
|
+
- lib/active_genie/configuration/providers/base_config.rb
|
124
|
+
- lib/active_genie/configuration/providers/deepseek_config.rb
|
125
|
+
- lib/active_genie/configuration/providers/google_config.rb
|
126
|
+
- lib/active_genie/configuration/providers/openai_config.rb
|
108
127
|
- lib/active_genie/configuration/providers_config.rb
|
128
|
+
- lib/active_genie/configuration/runtime_config.rb
|
109
129
|
- lib/active_genie/data_extractor.rb
|
110
130
|
- lib/active_genie/data_extractor/README.md
|
111
131
|
- lib/active_genie/data_extractor/basic.rb
|
@@ -123,6 +143,7 @@ files:
|
|
123
143
|
- lib/active_genie/scoring/README.md
|
124
144
|
- lib/active_genie/scoring/basic.rb
|
125
145
|
- lib/active_genie/scoring/recommended_reviewers.rb
|
146
|
+
- lib/tasks/benchmark.rake
|
126
147
|
- lib/tasks/install.rake
|
127
148
|
- lib/tasks/templates/active_genie.rb
|
128
149
|
homepage: https://github.com/Roriz/active_genie
|
@@ -142,7 +163,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
142
163
|
requirements:
|
143
164
|
- - ">="
|
144
165
|
- !ruby/object:Gem::Version
|
145
|
-
version:
|
166
|
+
version: 3.0.0
|
146
167
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
147
168
|
requirements:
|
148
169
|
- - ">="
|
@@ -1,56 +0,0 @@
|
|
1
|
-
require_relative '../clients/openai_client'
|
2
|
-
|
3
|
-
module ActiveGenie::Configuration
|
4
|
-
class OpenaiConfig
|
5
|
-
attr_writer :api_key, :organization, :api_url, :client,
|
6
|
-
:lower_tier_model, :middle_tier_model, :upper_tier_model
|
7
|
-
|
8
|
-
def api_key
|
9
|
-
@api_key || ENV['OPENAI_API_KEY']
|
10
|
-
end
|
11
|
-
|
12
|
-
def organization
|
13
|
-
@organization || ENV['OPENAI_ORGANIZATION']
|
14
|
-
end
|
15
|
-
|
16
|
-
def api_url
|
17
|
-
@api_url || 'https://api.openai.com/v1'
|
18
|
-
end
|
19
|
-
|
20
|
-
def client
|
21
|
-
@client ||= ::ActiveGenie::Clients::OpenaiClient.new(self)
|
22
|
-
end
|
23
|
-
|
24
|
-
def lower_tier_model
|
25
|
-
@lower_tier_model || 'gpt-4o-mini'
|
26
|
-
end
|
27
|
-
|
28
|
-
def middle_tier_model
|
29
|
-
@middle_tier_model || 'gpt-4o'
|
30
|
-
end
|
31
|
-
|
32
|
-
def upper_tier_model
|
33
|
-
@upper_tier_model || 'o1-preview'
|
34
|
-
end
|
35
|
-
|
36
|
-
def tier_to_model(tier)
|
37
|
-
{
|
38
|
-
lower_tier: lower_tier_model,
|
39
|
-
middle_tier: middle_tier_model,
|
40
|
-
upper_tier: upper_tier_model
|
41
|
-
}[tier&.to_sym] || lower_tier_model
|
42
|
-
end
|
43
|
-
|
44
|
-
def to_h(config = {})
|
45
|
-
{
|
46
|
-
api_key:,
|
47
|
-
organization:,
|
48
|
-
api_url:,
|
49
|
-
lower_tier_model:,
|
50
|
-
middle_tier_model:,
|
51
|
-
upper_tier_model:,
|
52
|
-
**config
|
53
|
-
}
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|