ruby-openai 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/Gemfile.lock +1 -1
- data/README.md +26 -0
- data/lib/ruby/openai/client.rb +11 -0
- data/lib/ruby/openai/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a958db13dbbf94dbbeeadb2dba89e9c00eb17c40def662e85074410becbca3c5
|
4
|
+
data.tar.gz: 2ec73b390ef82c2e8f5498d6abf195cf49c40a03e6b446e42f7715df0bfc27fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
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.
|
data/lib/ruby/openai/client.rb
CHANGED
@@ -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",
|
data/lib/ruby/openai/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2021-04-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dotenv
|