openai_chatgpt 0.1.2 → 0.2.0

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: 9b4916d348b6d695867cafa91caaa4d44d062a717d0bd3c39ca0e1682c5a9d01
4
- data.tar.gz: 187b7cd0b6c0efa240d61a15ae2513468664bbe424e1056b0f5faddeac728fd9
3
+ metadata.gz: b7ce4354bd99b71abfc50f90540d510f6abc76f7f96718a4a8bd8296dc4a2a85
4
+ data.tar.gz: 78b4850e744e9dbb5d040dfab71478eb6b6a85d3a3042dc1104499bedfac4ee0
5
5
  SHA512:
6
- metadata.gz: c5f52ca4c10ac0c671cd171f718e9510fd21a90964fdb646b72e52aec38c956bd5db2c7916afc0351e725200c007965b54cb4795746f38773d709aca91146618
7
- data.tar.gz: 27fe48ed304358e2bcd1dd220df1c64390c0d97d199fcbb481bdffc1a26dedc114c08ab8a87955335836a8cd6f3995c39b61aafc3e7595dabf4ac1abbfaa57b0
6
+ metadata.gz: 26b81265222e757ee2f519f88b34273bff642c0f6d3d6e71102d3d5f7b277f6c28b3ee2fe14951802b745e7d665fcf1ac3b043c1ca9da83c23418b633b40155a
7
+ data.tar.gz: 6ad3270dc2556fcaf8964c92be0cce8bc3a46fc122689c0d0c856baab55ab5b9ac1e490e3e4403652484d681dafe1ca5fd1b7f25f7581cfa3e496ac7eb49efe6
data/CHANGELOG.md CHANGED
@@ -1,4 +1,10 @@
1
- ## [0.1.2] - 2022=04-07
1
+ ## [0.2.0] - 2022-04-07
2
+
3
+ - added chatgpt 4 models "gpt-4", "gpt-4-0314", "gpt-4-32k", "gpt-4-32k-0314" by [@sulmanweb](https://github.com/sulmanweb)
4
+ - added `gpt-4` as default model by [@sulmanweb](https://github.com/sulmanweb)
5
+ - added `timeout_request` option in initializer by [@mennovergeer](https://github.com/mennovergeer)
6
+
7
+ ## [0.1.2] - 2022-04-07
2
8
 
3
9
  - increased `timeout` option to faraday connection by [@mennovergeer](https://github.com/mennovergeer)
4
10
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- openai_chatgpt (0.1.2)
4
+ openai_chatgpt (0.2.0)
5
5
  faraday (~> 2.5)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  OpenAI ChatGPT API is a light-weight Ruby wrapper for the Rubyists. It gives nice struct objects for completions of the chatgpt, even the raw responses are returned in nice open struct objects. It uses Faraday for HTTP requests.
4
4
 
5
+ > It supports all models of gpt-4 and gpt-3.5
6
+
5
7
  ## Installation
6
8
 
7
9
  Install the gem and add to the application's Gemfile by executing:
@@ -51,8 +53,8 @@ resp = OpenaiChatgpt::Client.new(api_key: "fake").completions(
51
53
  Params:
52
54
  - messages: Array[String] - Required - Messages to generate response for
53
55
  `[{role: "user", text: "Hello"}, {role: "bot", text: "Hi"}]`
54
- - model: String - Optional - Default: "gpt-3.5-turbo" - Model to use for generating response
55
- ["gpt-3.5-turbo", "gpt-3.5-turbo-0301"]
56
+ - model: String - Optional - Default: "gpt-4" - Model to use for generating response
57
+ ["gpt-4", "gpt-4-0314", "gpt-4-32k", "gpt-4-32k-0314", "gpt-3.5-turbo", "gpt-3.5-turbo-0301"]
56
58
  - temperature: Float - Optional - Default: 1.0 - Temperature for response generation between 0.0 and 2.0
57
59
  - top_p: Float - Optional - Default: 1.0 - Top p for response generation between 0.0 and 1.0
58
60
  - n: Integer - Optional - Default: 1 - Number of responses to generate
@@ -11,13 +11,15 @@ module OpenaiChatgpt
11
11
  # api_key: String - Required - API key for OpenAI ChatGPT API (https://platform.openai.com/account/api-keys)
12
12
  # adapter: Symbol - Optional - Default: :net_http - Adapter for Faraday connection
13
13
  # stubs: Faraday::Adapter::Test::Stubs - Optional - Default: nil - Stubs for Faraday connection
14
+ # request_timeout: Integer - Optional - Default: 1200 - Timeout for Faraday connection
14
15
  # #### Example:
15
16
  # client = OpenaiChatgpt::Client.new api_key: "test"
16
17
  # #### Description:
17
18
  # Client for OpenAI ChatGPT API
18
- def initialize(api_key:, adapter: Faraday.default_adapter, stubs: nil)
19
+ def initialize(api_key:, adapter: Faraday.default_adapter, stubs: nil, request_timeout: 1200)
19
20
  @api_key = api_key
20
21
  @adapter = adapter
22
+ @request_timeout = request_timeout
21
23
 
22
24
  # Test stubs for requests
23
25
  @stubs = stubs
@@ -26,8 +28,8 @@ module OpenaiChatgpt
26
28
  # #### Params:
27
29
  # messages: Array[String] - Required - Messages to generate response for
28
30
  # [{role: "user", text: "Hello"}, {role: "bot", text: "Hi"}]
29
- # model: String - Optional - Default: "gpt-3.5-turbo" - Model to use for generating response
30
- # ["gpt-3.5-turbo", "gpt-3.5-turbo-0301"]
31
+ # model: String - Optional - Default: "gpt-4" - Model to use for generating response
32
+ # ["gpt-4", "gpt-4-0314", "gpt-4-32k", "gpt-4-32k-0314", "gpt-3.5-turbo", "gpt-3.5-turbo-0301"]
31
33
  # temperature: Float - Optional - Default: 1.0 - Temperature for response generation between 0.0 and 2.0
32
34
  # top_p: Float - Optional - Default: 1.0 - Top p for response generation between 0.0 and 1.0
33
35
  # n: Integer - Optional - Default: 1 - Number of responses to generate
@@ -51,7 +53,7 @@ module OpenaiChatgpt
51
53
  # OpenaiChatgpt::Error
52
54
  def completions( # rubocop:disable Metrics/MethodLength, Metrics/ParameterLists
53
55
  messages:,
54
- model: "gpt-3.5-turbo",
56
+ model: "gpt-4",
55
57
  temperature: 1.0,
56
58
  top_p: 1.0,
57
59
  n: 1, # rubocop:disable Naming/MethodParameterName
@@ -100,7 +102,7 @@ module OpenaiChatgpt
100
102
  @connection ||= Faraday.new(BASE_URL) do |conn|
101
103
  conn.headers["Authorization"] = "Bearer #{@api_key}"
102
104
  conn.headers["Content-Type"] = "application/json"
103
- conn.options.timeout = 1200 # Increase the timeout limit to 1200 seconds
105
+ conn.options.timeout = @request_timeout
104
106
  conn.response :json, content_type: "application/json"
105
107
  conn.adapter adapter, @stubs
106
108
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OpenaiChatgpt
4
- VERSION = "0.1.2"
4
+ VERSION = "0.2.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openai_chatgpt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sulman Baig
@@ -38,8 +38,9 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.35'
41
- description: OpenAI ChatGPT API is a light-weight Ruby wrapper for the Rubyists. gpt-3.5-turbo, gpt-3.5-turbo-0301.
42
- You can use this gem to generate text using OpenAI's ChatGPT chat responses API.
41
+ description: OpenAI ChatGPT API is a light-weight Ruby wrapper for the Rubyists. [`gpt-4`,
42
+ `gpt-4-0314`, `gpt-4-32k`, `gpt-4-32k-0314`, `gpt-3.5-turbo`, `gpt-3.5-turbo-0301`].
43
+ You can use this gem to generate text using OpenAI's ChatGPT chat responses API.
43
44
  email:
44
45
  - sulman@hey.com
45
46
  executables: []
@@ -89,6 +90,6 @@ requirements: []
89
90
  rubygems_version: 3.4.8
90
91
  signing_key:
91
92
  specification_version: 4
92
- summary: OpenAI ChatGPT API is a light-weight Ruby wrapper for the Rubyists. gpt-3.5-turbo,
93
- gpt-3.5-turbo-0301
93
+ summary: OpenAI ChatGPT API is a light-weight Ruby wrapper for the Rubyists. All
94
+ models of gpt-4 and gpt-3.5 supported.
94
95
  test_files: []