ruby-openai 1.1.0 → 1.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: 9fb70b90b84ff4b23bf8e9ed757ae39b82adf291e5bdcb07b8f0ef5ccbe12394
4
- data.tar.gz: 5391b9437fd05d7da1783e5ac960b216a7ad326f22a509ad28a21eb879bdf4a8
3
+ metadata.gz: a958db13dbbf94dbbeeadb2dba89e9c00eb17c40def662e85074410becbca3c5
4
+ data.tar.gz: 2ec73b390ef82c2e8f5498d6abf195cf49c40a03e6b446e42f7715df0bfc27fd
5
5
  SHA512:
6
- metadata.gz: 5cbf287bf8bfc9e1b949bc050ea456d62c5259a5316710db7a617126a7a3b018707c78c03d508a5619ac024a5767865f7e98925e5c6e867dc8cb1f3687e3b9c6
7
- data.tar.gz: a45ed235da6d261371ae6f1b26ae45ea2f28dd9ca3f9b362b66045d851666ea1b72e89c0253d64830183c6bae6c3c8093f7c586c65aed940b5b3003d9b652399
6
+ metadata.gz: ed8d2bcedcc30defd2acb28d29be00c2c07bf80b38dd7748323c0661b90f1b09da5c21c7dd7b6014161d7fd966e9da6854d996236c032744d4f0fe70f0a4abb2
7
+ data.tar.gz: a846cf9bb2888dd30a89b5796ead927615ccb46647ef803a88cfc281c08e7064857a6ee025f4611d9b7db4b0760198c7504b65257ec1584b88196ca4d27a8423
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
+ ## [1.2.0] - 2021-04-08
9
+
10
+ ### Added
11
+
12
+ - Add Client#answers endpoint for question/answer response on documents or a file.
13
+
8
14
  ## [1.1.0] - 2021-04-07
9
15
 
10
16
  ### Added
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ruby-openai (1.1.0)
4
+ ruby-openai (1.2.0)
5
5
  dotenv (~> 2.7.6)
6
6
  httparty (~> 0.18.1)
7
7
 
data/README.md CHANGED
@@ -92,6 +92,32 @@ You can alternatively search using the ID of a file you've uploaded:
92
92
  client.search(engine: "ada", file: "abc123", query: "happy")
93
93
  ```
94
94
 
95
+ ### Answers
96
+
97
+ Pass documents, a question string, and an example question/response to get an answer to a question:
98
+
99
+ ```
100
+ response = client.answers(parameters: {
101
+ documents: ["Puppy A is happy.", "Puppy B is sad."],
102
+ question: "which puppy is happy?",
103
+ model: "curie",
104
+ examples_context: "In 2017, U.S. life expectancy was 78.6 years.",
105
+ examples: [["What is human life expectancy in the United States?","78 years."]],
106
+ })
107
+ ```
108
+
109
+ You can alternatively search using the ID of a file you've uploaded:
110
+
111
+ ```
112
+ response = client.answers(parameters: {
113
+ file: "123abc",
114
+ question: "which puppy is happy?",
115
+ model: "curie",
116
+ examples_context: "In 2017, U.S. life expectancy was 78.6 years.",
117
+ examples: [["What is human life expectancy in the United States?","78 years."]],
118
+ })
119
+ ```
120
+
95
121
  ## Development
96
122
 
97
123
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -7,6 +7,17 @@ module OpenAI
7
7
  @access_token = access_token || ENV["OPENAI_ACCESS_TOKEN"]
8
8
  end
9
9
 
10
+ def answers(version: default_version, parameters: {})
11
+ self.class.post(
12
+ "/#{version}/answers",
13
+ headers: {
14
+ "Content-Type" => "application/json",
15
+ "Authorization" => "Bearer #{@access_token}"
16
+ },
17
+ body: parameters.to_json
18
+ )
19
+ end
20
+
10
21
  def completions(engine:, version: default_version, parameters: {})
11
22
  self.class.post(
12
23
  "/#{version}/engines/#{engine}/completions",
@@ -1,5 +1,5 @@
1
1
  module Ruby
2
2
  module OpenAI
3
- VERSION = "1.1.0".freeze
3
+ VERSION = "1.2.0".freeze
4
4
  end
5
5
  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: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-04-07 00:00:00.000000000 Z
11
+ date: 2021-04-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dotenv