openaiext 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/openaiext/agent.rb +1 -1
- data/lib/openaiext/model.rb +24 -0
- data/lib/openaiext.rb +2 -22
- 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: 276d45b2a3e4b7e984a1fe2dbc7a05275500c8e15f0e331fe2a2f980db72dea0
|
4
|
+
data.tar.gz: 3366f551da7e14cfb6b0f273e352d79e9eb2c9eb159eb579b4e426f522d3e800
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 38cd47294905c538f82f2a594148e4e8e64fb63caf9858be1f3efdd44613890654f941baab616e4f524f47cacaa5266809c23df9a0a87c360e4ebe70b4783d20
|
7
|
+
data.tar.gz: 6705205f99790956d259acc4793444d3c5740e656cf0e05427aa9f01bd1df0b8941363850793c146cf8bfe898f1cd267d08e7e052bb8d82e7fef20f5b9da5749
|
data/lib/openaiext/agent.rb
CHANGED
@@ -36,7 +36,7 @@ module OpenAIExt
|
|
36
36
|
|
37
37
|
params[:additional_messages] = [{ role: :user, content: additional_message }] unless additional_message.nil?
|
38
38
|
|
39
|
-
params[:model] = model || @assistant['model']
|
39
|
+
params[:model] = OpenAIExt::Model.select(model) || @assistant['model']
|
40
40
|
|
41
41
|
run_id = @openai_client.runs.create(thread_id: @thread['id'], parameters: params)['id']
|
42
42
|
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module OpenAIExt
|
2
|
+
module Model
|
3
|
+
GPT_BASIC_MODEL = ENV.fetch('OPENAI_GPT_BASIC_MODEL', 'gpt-4o-mini')
|
4
|
+
GPT_ADVANCED_MODEL = ENV.fetch('OPENAI_GPT_ADVANCED_MODEL', 'gpt-4o-2024-08-06')
|
5
|
+
|
6
|
+
O1_BASIC_MODEL = ENV.fetch('OPENAI_O1_BASIC_MODEL', 'o1-mini')
|
7
|
+
O1_ADVANCED_MODEL = ENV.fetch('OPENAI_O1_ADVANCED_MODEL', 'o1-preview')
|
8
|
+
|
9
|
+
def self.select(model)
|
10
|
+
case model
|
11
|
+
when :gpt_basic
|
12
|
+
GPT_BASIC_MODEL
|
13
|
+
when :gpt_advanced
|
14
|
+
GPT_ADVANCED_MODEL
|
15
|
+
when :o1_basic
|
16
|
+
O1_BASIC_MODEL
|
17
|
+
when :o1_advanced
|
18
|
+
O1_ADVANCED_MODEL
|
19
|
+
else
|
20
|
+
model
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/openaiext.rb
CHANGED
@@ -1,16 +1,11 @@
|
|
1
1
|
require 'openai'
|
2
2
|
|
3
|
+
require 'openaiext/model'
|
3
4
|
require 'openaiext/messages'
|
4
5
|
require 'openaiext/response_extender'
|
5
6
|
require 'openaiext/agent'
|
6
7
|
|
7
8
|
module OpenAIExt
|
8
|
-
GPT_BASIC_MODEL = ENV.fetch('OPENAI_GPT_BASIC_MODEL', 'gpt-4o-mini')
|
9
|
-
GPT_ADVANCED_MODEL = ENV.fetch('OPENAI_GPT_ADVANCED_MODEL', 'gpt-4o-2024-08-06')
|
10
|
-
|
11
|
-
O1_BASIC_MODEL = ENV.fetch('OPENAI_O1_BASIC_MODEL', 'o1-mini')
|
12
|
-
O1_ADVANCED_MODEL = ENV.fetch('OPENAI_O1_ADVANCED_MODEL', 'o1-preview')
|
13
|
-
|
14
9
|
MAX_TOKENS = ENV.fetch('OPENAI_MAX_TOKENS', 16_383).to_i
|
15
10
|
|
16
11
|
def self.embeddings(input, model: 'text-embedding-3-large')
|
@@ -33,7 +28,7 @@ module OpenAIExt
|
|
33
28
|
end
|
34
29
|
|
35
30
|
def self.chat(messages:, model: :gpt_basic, response_format: nil, max_tokens: MAX_TOKENS, store: true, metadata: nil, tools: nil, auto_run_functions: false, function_context: nil)
|
36
|
-
model =
|
31
|
+
model = OpenAIExt::Model.select(model)
|
37
32
|
is_o1_model = model.start_with?('o1')
|
38
33
|
|
39
34
|
messages = OpenAIExt::Messages.new(messages) unless messages.is_a?(OpenAIExt::Messages)
|
@@ -69,19 +64,4 @@ module OpenAIExt
|
|
69
64
|
end
|
70
65
|
|
71
66
|
def self.models = OpenAI::Client.new.models.list
|
72
|
-
|
73
|
-
def self.select_model(model)
|
74
|
-
case model
|
75
|
-
when :gpt_basic
|
76
|
-
GPT_BASIC_MODEL
|
77
|
-
when :gpt_advanced
|
78
|
-
GPT_ADVANCED_MODEL
|
79
|
-
when :o1_basic
|
80
|
-
O1_BASIC_MODEL
|
81
|
-
when :o1_advanced
|
82
|
-
O1_ADVANCED_MODEL
|
83
|
-
else
|
84
|
-
model
|
85
|
-
end
|
86
|
-
end
|
87
67
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: openaiext
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gedean Dias
|
@@ -62,6 +62,7 @@ files:
|
|
62
62
|
- lib/openaiext.rb
|
63
63
|
- lib/openaiext/agent.rb
|
64
64
|
- lib/openaiext/messages.rb
|
65
|
+
- lib/openaiext/model.rb
|
65
66
|
- lib/openaiext/response_extender.rb
|
66
67
|
homepage: https://github.com/gedean/openaiext
|
67
68
|
licenses:
|