ruby-openai 3.3.0 → 3.4.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: f31dd3158125262e5c187ee9503b21a9e9c0f423440c8da7a54e6abfaa932da3
4
- data.tar.gz: 1c80b95c3d6587c3ddf95145f970690bf83572ef24902b455d126e2205f42c0d
3
+ metadata.gz: f3d2b8f98be44b7f33fce40f271bccc3dc1c72237df7ad64baed43f4ea79fb51
4
+ data.tar.gz: f19cc5e7155b47e6f7ccb7c5642679e5d8f7a6600e6d4f9e592ebc16313b74f0
5
5
  SHA512:
6
- metadata.gz: 9c8e2185a4c2822a54aaeaaa6eca5034e01c2796010df65d4ac7688e70e19da7546e120a64eed8bd3bb30417be54492570a5713d2ba3b684778e508b053cc0d3
7
- data.tar.gz: d0d9a8aade92949b509882fe699809b659bc82ddf79ba54485f7d6e304abcfecf50e20dae18fa3df4bda5b41d364a6519f24d27e7177a64d773f7e408b644d23
6
+ metadata.gz: 8f2c05fae48718593ea7990c480f6108844a698a943c8db2e3e01f3e31e95ede1ca2a5bd0dec5364a9b1730698c3802e24eecec585d20e59b03e1a421c8a3c4e
7
+ data.tar.gz: 303d6df6cea50a4f9ac50f8cab7329e585e201aeb2532709b161b830896cc1e733e0c48dfa6ebff22d13d930c3a0ff76425b8e0294c7e175a1bc4e07b84710a2
data/CHANGELOG.md CHANGED
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [3.4.0] - 2023-03-01
9
+
10
+ ### Added
11
+
12
+ - Add Client#chat endpoint - ChatGPT over the wire!
13
+
8
14
  ## [3.3.0] - 2023-02-15
9
15
 
10
16
  ### Changed
data/Gemfile CHANGED
@@ -7,6 +7,6 @@ gem "byebug", "~> 11.1.3"
7
7
  gem "dotenv", "~> 2.8.1"
8
8
  gem "rake", "~> 13.0"
9
9
  gem "rspec", "~> 3.12"
10
- gem "rubocop", "~> 1.45.1"
10
+ gem "rubocop", "~> 1.46.0"
11
11
  gem "vcr", "~> 6.1.0"
12
12
  gem "webmock", "~> 3.18.1"
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ruby-openai (3.3.0)
4
+ ruby-openai (3.4.0)
5
5
  httparty (>= 0.18.1)
6
6
 
7
7
  GEM
@@ -23,7 +23,7 @@ GEM
23
23
  mini_mime (1.1.2)
24
24
  multi_xml (0.6.0)
25
25
  parallel (1.22.1)
26
- parser (3.2.0.0)
26
+ parser (3.2.1.0)
27
27
  ast (~> 2.4.1)
28
28
  public_suffix (5.0.1)
29
29
  rainbow (3.1.1)
@@ -43,18 +43,18 @@ GEM
43
43
  diff-lcs (>= 1.2.0, < 2.0)
44
44
  rspec-support (~> 3.12.0)
45
45
  rspec-support (3.12.0)
46
- rubocop (1.45.1)
46
+ rubocop (1.46.0)
47
47
  json (~> 2.3)
48
48
  parallel (~> 1.10)
49
49
  parser (>= 3.2.0.0)
50
50
  rainbow (>= 2.2.2, < 4.0)
51
51
  regexp_parser (>= 1.8, < 3.0)
52
52
  rexml (>= 3.2.5, < 4.0)
53
- rubocop-ast (>= 1.24.1, < 2.0)
53
+ rubocop-ast (>= 1.26.0, < 2.0)
54
54
  ruby-progressbar (~> 1.7)
55
55
  unicode-display_width (>= 2.4.0, < 3.0)
56
- rubocop-ast (1.24.1)
57
- parser (>= 3.1.1.0)
56
+ rubocop-ast (1.26.0)
57
+ parser (>= 3.2.1.0)
58
58
  ruby-progressbar (1.11.0)
59
59
  unicode-display_width (2.4.2)
60
60
  vcr (6.1.0)
@@ -71,7 +71,7 @@ DEPENDENCIES
71
71
  dotenv (~> 2.8.1)
72
72
  rake (~> 13.0)
73
73
  rspec (~> 3.12)
74
- rubocop (~> 1.45.1)
74
+ rubocop (~> 1.46.0)
75
75
  ruby-openai!
76
76
  vcr (~> 6.1.0)
77
77
  webmock (~> 3.18.1)
data/README.md CHANGED
@@ -7,7 +7,7 @@
7
7
 
8
8
  Use the [OpenAI API](https://openai.com/blog/openai-api/) with Ruby! 🤖❤️
9
9
 
10
- Generate text with GPT-3, create images with DALL·E, or write code with Codex...
10
+ Generate text with ChatGPT, create images with DALL·E, or write code with Codex...
11
11
 
12
12
  ## Installation
13
13
 
@@ -89,9 +89,24 @@ There are different models that can be used to generate text. For a full list an
89
89
  - code-davinci-002
90
90
  - code-cushman-001
91
91
 
92
+ ### ChatGPT
93
+
94
+ ChatGPT is a model that can be used to generate text in a conversational style. You can use it to generate a response to a sequence of [messages](https://platform.openai.com/docs/guides/chat/introduction):
95
+
96
+ ```ruby
97
+ response = client.chat(
98
+ parameters: {
99
+ model: "gpt-3.5-turbo",
100
+ messages: [{ role: "user", content: "Hello!"}],
101
+ })
102
+ puts response.dig("choices", 0, "message", "content")
103
+ => "Hello! How may I assist you today?"
104
+
105
+ ```
106
+
92
107
  ### Completions
93
108
 
94
- Hit the OpenAI API for a completion:
109
+ Hit the OpenAI API for a completion using other GPT-3 models:
95
110
 
96
111
  ```ruby
97
112
  response = client.completions(
data/lib/openai/client.rb CHANGED
@@ -7,6 +7,10 @@ module OpenAI
7
7
  OpenAI.configuration.organization_id = organization_id if organization_id
8
8
  end
9
9
 
10
+ def chat(parameters: {})
11
+ OpenAI::Client.json_post(path: "/chat/completions", parameters: parameters)
12
+ end
13
+
10
14
  def completions(parameters: {})
11
15
  OpenAI::Client.json_post(path: "/completions", parameters: parameters)
12
16
  end
@@ -1,3 +1,3 @@
1
1
  module OpenAI
2
- VERSION = "3.3.0".freeze
2
+ VERSION = "3.4.0".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-openai
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.0
4
+ version: 3.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-02-15 00:00:00.000000000 Z
11
+ date: 2023-03-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -24,7 +24,7 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.18.1
27
- description:
27
+ description:
28
28
  email:
29
29
  - alexrudall@users.noreply.github.com
30
30
  executables: []
@@ -85,8 +85,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
85
85
  - !ruby/object:Gem::Version
86
86
  version: '0'
87
87
  requirements: []
88
- rubygems_version: 3.4.5
89
- signing_key:
88
+ rubygems_version: 3.4.6
89
+ signing_key:
90
90
  specification_version: 4
91
91
  summary: A Ruby gem for the OpenAI GPT-3 API
92
92
  test_files: []