openaiext 0.0.2 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/openaiext/model.rb +3 -0
- data/lib/openaiext.rb +10 -5
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 13d53c7281c93ddb63f58c2caabe451add4d8bd1d1fe2a313ef986faac067763
|
4
|
+
data.tar.gz: a15831f5ad9fb9ca77c9567ea99aef2e23981d93b3c36883ed760d4107e44769
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 24ad02f85f085563c7ae41b4b673b728040791bb0e75567ba5d2a3d81a2d8e3a0c7a3a920a09bf8a017c499a4b7e4eab3161e17a64395814222868eae0a8cfc9
|
7
|
+
data.tar.gz: 2eadd29bd5314c6829eea303e0de76a955fd783de4edb0c61bd9e527c84648fd083d235e033481e419c2e9516f1d6caad8dfd5f5b0ad2204e80bf3ac5735ee6c
|
data/lib/openaiext/model.rb
CHANGED
@@ -2,6 +2,7 @@ module OpenAIExt
|
|
2
2
|
module Model
|
3
3
|
GPT_BASIC_MODEL = ENV.fetch('OPENAI_GPT_BASIC_MODEL', 'gpt-4o-mini')
|
4
4
|
GPT_ADVANCED_MODEL = ENV.fetch('OPENAI_GPT_ADVANCED_MODEL', 'gpt-4o-2024-08-06')
|
5
|
+
GPT_ADVANCED_MODEL_LATEST = ENV.fetch('OPENAI_GPT_ADVANCED_MODEL_LATEST', 'chatgpt-4o-latest')
|
5
6
|
|
6
7
|
O1_BASIC_MODEL = ENV.fetch('OPENAI_O1_BASIC_MODEL', 'o1-mini')
|
7
8
|
O1_ADVANCED_MODEL = ENV.fetch('OPENAI_O1_ADVANCED_MODEL', 'o1-preview')
|
@@ -12,6 +13,8 @@ module OpenAIExt
|
|
12
13
|
GPT_BASIC_MODEL
|
13
14
|
when :gpt_advanced
|
14
15
|
GPT_ADVANCED_MODEL
|
16
|
+
when :gpt_advanced_latest
|
17
|
+
GPT_ADVANCED_MODEL_LATEST
|
15
18
|
when :o1_basic
|
16
19
|
O1_BASIC_MODEL
|
17
20
|
when :o1_advanced
|
data/lib/openaiext.rb
CHANGED
@@ -19,15 +19,15 @@ module OpenAIExt
|
|
19
19
|
chat(messages: [{ role: :user, content: message_content }], model:, response_format:, max_tokens:, store:, tools:, auto_run_functions:, function_context:)
|
20
20
|
end
|
21
21
|
|
22
|
-
def self.single_prompt(prompt:, model: :gpt_basic, response_format: nil, max_tokens: MAX_TOKENS, store: true, metadata: nil, tools: nil, auto_run_functions: false, function_context: nil)
|
23
|
-
chat(messages: [{ user: prompt }], model:, response_format:, max_tokens:, store:, tools:, auto_run_functions:, function_context:)
|
22
|
+
def self.single_prompt(prompt:, model: :gpt_basic, response_format: nil, max_tokens: MAX_TOKENS, store: true, metadata: nil, tools: nil, auto_run_functions: false, function_context: nil, temperature: nil, top_p: nil, frequency_penalty: nil, presence_penalty: nil)
|
23
|
+
chat(messages: [{ user: prompt }], model:, response_format:, max_tokens:, store:, tools:, auto_run_functions:, function_context:, temperature:, top_p:, frequency_penalty:, presence_penalty:)
|
24
24
|
end
|
25
25
|
|
26
|
-
def self.single_chat(system:, user:, model: :gpt_basic, response_format: nil, max_tokens: MAX_TOKENS, store: true, metadata: nil, tools: nil, auto_run_functions: false, function_context: nil)
|
27
|
-
chat(messages: [{ system: }, { user: }], model:, response_format:, max_tokens:, store:, tools:, auto_run_functions:, function_context:)
|
26
|
+
def self.single_chat(system:, user:, model: :gpt_basic, response_format: nil, max_tokens: MAX_TOKENS, store: true, metadata: nil, tools: nil, auto_run_functions: false, function_context: nil, temperature: nil, top_p: nil, frequency_penalty: nil, presence_penalty: nil)
|
27
|
+
chat(messages: [{ system: }, { user: }], model:, response_format:, max_tokens:, store:, tools:, auto_run_functions:, function_context:, temperature:, top_p:, frequency_penalty:, presence_penalty:)
|
28
28
|
end
|
29
29
|
|
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)
|
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, temperature: nil, top_p: nil, frequency_penalty: nil, presence_penalty: nil)
|
31
31
|
model = OpenAIExt::Model.select(model)
|
32
32
|
is_o1_model = model.start_with?('o1')
|
33
33
|
|
@@ -43,6 +43,11 @@ module OpenAIExt
|
|
43
43
|
parameters[:response_format] = { type: 'json_object' } if response_format.eql?(:json)
|
44
44
|
parameters[:tools] = tools if tools
|
45
45
|
|
46
|
+
parameters[:temperature] = temperature if temperature
|
47
|
+
parameters[:top_p] = top_p if top_p
|
48
|
+
parameters[:frequency_penalty] = frequency_penalty if frequency_penalty
|
49
|
+
parameters[:presence_penalty] = presence_penalty if presence_penalty
|
50
|
+
|
46
51
|
begin
|
47
52
|
response = OpenAI::Client.new.chat(parameters:)
|
48
53
|
rescue => e
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gedean Dias
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-10-
|
11
|
+
date: 2024-10-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby-openai
|
@@ -83,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
83
83
|
- !ruby/object:Gem::Version
|
84
84
|
version: '0'
|
85
85
|
requirements: []
|
86
|
-
rubygems_version: 3.5.
|
86
|
+
rubygems_version: 3.5.22
|
87
87
|
signing_key:
|
88
88
|
specification_version: 4
|
89
89
|
summary: Ruby OpenAI Extended
|