test_openai 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.env.sample +2 -0
- data/.rspec +1 -0
- data/.rubocop-https---raw-githubusercontent-com-Thinkei-Thinkei-master--rubocop-default-v1-yml +299 -0
- data/.rubocop.yml +2 -0
- data/.ruby-version +1 -0
- data/.yardopts +1 -0
- data/CHANGELOG.md +23 -0
- data/README.md +31 -0
- data/Rakefile +16 -0
- data/lib/client.rb +102 -0
- data/lib/models.rb +63 -0
- data/lib/test_openai/version.rb +5 -0
- data/sig/test_openai.rbs +4 -0
- data/test_openai.gemspec +39 -0
- metadata +61 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 9c763fe9842a24a0bcede6e6ee36c0f0bff8549dd167fbaa11b30e693e6c5fc9
|
4
|
+
data.tar.gz: 534bcc0f10976d5781f02f25e887c3f30c7c884f02b92dcb491aaa49ef09f764
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 38d267fef20413d1617afcfb8cb3c92e09f091d39f8286a020d377921e09317c503ba7610dec039c772579c0d21e8197a5de56c55bdee3f8876237ecaa377920
|
7
|
+
data.tar.gz: 24bdef5502603dc7393c3620e8ab0ec773ddd171c1243d4e211200481f36340d5e983130d8fa921de11188944709de72837f1d3d33265cee0713d413a020a143
|
data/.env.sample
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--require spec_helper
|
data/.rubocop-https---raw-githubusercontent-com-Thinkei-Thinkei-master--rubocop-default-v1-yml
ADDED
@@ -0,0 +1,299 @@
|
|
1
|
+
########################################
|
2
|
+
# EmploymentHero Shared Rubocop Config #
|
3
|
+
########################################
|
4
|
+
# rubocop ~> 1.15.0
|
5
|
+
|
6
|
+
AllCops:
|
7
|
+
Exclude:
|
8
|
+
- 'db/schema.rb'
|
9
|
+
- 'node_modules/**/*'
|
10
|
+
- 'vendor/**/*'
|
11
|
+
- '.git/**/*'
|
12
|
+
EnabledByDefault: false
|
13
|
+
DisabledByDefault: false
|
14
|
+
NewCops: disable
|
15
|
+
|
16
|
+
Bundler:
|
17
|
+
Severity: warning
|
18
|
+
|
19
|
+
Bundler/OrderedGems:
|
20
|
+
Description: >-
|
21
|
+
Gems within groups in the Gemfile should be alphabetically sorted.
|
22
|
+
Enabled: false
|
23
|
+
VersionAdded: '0.46'
|
24
|
+
VersionChanged: '0.47'
|
25
|
+
TreatCommentsAsGroupSeparators: true
|
26
|
+
Include:
|
27
|
+
- '**/*.gemfile'
|
28
|
+
- '**/Gemfile'
|
29
|
+
- '**/gems.rb'
|
30
|
+
|
31
|
+
Gemspec:
|
32
|
+
Severity: warning
|
33
|
+
|
34
|
+
Layout/ClassStructure:
|
35
|
+
Severity: warning
|
36
|
+
Description: 'Enforces a configured order of definitions within a class body.'
|
37
|
+
StyleGuide: 'https://github.com/rubocop-hq/ruby-style-guide#consistent-classes'
|
38
|
+
Enabled: true
|
39
|
+
VersionAdded: '0.52'
|
40
|
+
Categories:
|
41
|
+
module_inclusion:
|
42
|
+
- include
|
43
|
+
- prepend
|
44
|
+
- extend
|
45
|
+
ExpectedOrder:
|
46
|
+
- module_inclusion
|
47
|
+
- constants
|
48
|
+
- public_class_methods
|
49
|
+
- initializer
|
50
|
+
- public_methods
|
51
|
+
- protected_methods
|
52
|
+
- private_methods
|
53
|
+
|
54
|
+
Metrics:
|
55
|
+
Severity: warning
|
56
|
+
|
57
|
+
Metrics/BlockLength:
|
58
|
+
Description: 'Avoid long blocks with many lines.'
|
59
|
+
Enabled: true
|
60
|
+
VersionAdded: '0.44'
|
61
|
+
VersionChanged: '0.58'
|
62
|
+
CountComments: false # count full line comments?
|
63
|
+
Max: 25
|
64
|
+
IgnoredMethods:
|
65
|
+
# By default, exclude the `#refine` method, as it tends to have larger
|
66
|
+
# associated blocks.
|
67
|
+
- configure
|
68
|
+
- included
|
69
|
+
- refine
|
70
|
+
- transaction
|
71
|
+
# rake methods
|
72
|
+
- namespace
|
73
|
+
- task
|
74
|
+
# rails methods
|
75
|
+
- create_table
|
76
|
+
- update_table
|
77
|
+
- setup
|
78
|
+
# grape api methods
|
79
|
+
- helpers
|
80
|
+
- group
|
81
|
+
- resource
|
82
|
+
- resources
|
83
|
+
- segment
|
84
|
+
- get
|
85
|
+
- post
|
86
|
+
- put
|
87
|
+
- patch
|
88
|
+
- delete
|
89
|
+
- route_param
|
90
|
+
# rspec methods
|
91
|
+
- after
|
92
|
+
- let
|
93
|
+
- let!
|
94
|
+
- before
|
95
|
+
- context
|
96
|
+
- describe
|
97
|
+
- describe_api
|
98
|
+
- feature
|
99
|
+
- shared_context
|
100
|
+
- shared_examples
|
101
|
+
- shared_examples_for
|
102
|
+
# factory_bot methods
|
103
|
+
- define
|
104
|
+
- factory
|
105
|
+
# cucumber methods
|
106
|
+
- scenario
|
107
|
+
- then
|
108
|
+
- when
|
109
|
+
- within
|
110
|
+
# pundit spec methods
|
111
|
+
- permissions
|
112
|
+
# Benchmark methods
|
113
|
+
- measure
|
114
|
+
|
115
|
+
Metrics/ClassLength:
|
116
|
+
Description: 'Avoid classes longer than 200 lines of code.'
|
117
|
+
Enabled: true
|
118
|
+
VersionAdded: '0.25'
|
119
|
+
CountComments: false # count full line comments?
|
120
|
+
Max: 200
|
121
|
+
|
122
|
+
# Avoid complex methods.
|
123
|
+
Metrics/CyclomaticComplexity:
|
124
|
+
Description: >-
|
125
|
+
A complexity metric that is strongly correlated to the number
|
126
|
+
of test cases needed to validate a method.
|
127
|
+
Enabled: true
|
128
|
+
VersionAdded: '0.25'
|
129
|
+
Max: 10
|
130
|
+
|
131
|
+
Layout/LineLength:
|
132
|
+
Description: 'Limit lines to 120 characters.'
|
133
|
+
StyleGuide: '#80-character-limits'
|
134
|
+
Enabled: true
|
135
|
+
VersionAdded: '0.25'
|
136
|
+
VersionChanged: '0.46'
|
137
|
+
Max: 120
|
138
|
+
# To make it possible to copy or click on URIs in the code, we allow lines
|
139
|
+
# containing a URI to be longer than Max.
|
140
|
+
AllowHeredoc: true
|
141
|
+
AllowURI: true
|
142
|
+
URISchemes:
|
143
|
+
- http
|
144
|
+
- https
|
145
|
+
# The IgnoreCopDirectives option causes the LineLength rule to ignore cop
|
146
|
+
# directives like '# rubocop: enable ...' when calculating a line's length.
|
147
|
+
IgnoreCopDirectives: true
|
148
|
+
# The IgnoredPatterns option is a list of !ruby/regexp and/or string
|
149
|
+
# elements. Strings will be converted to Regexp objects. A line that matches
|
150
|
+
# any regular expression listed in this option will be ignored by LineLength.
|
151
|
+
IgnoredPatterns: []
|
152
|
+
|
153
|
+
Metrics/MethodLength:
|
154
|
+
Description: 'Avoid methods longer than 15 lines of code.'
|
155
|
+
StyleGuide: '#short-methods'
|
156
|
+
Enabled: true
|
157
|
+
VersionAdded: '0.25'
|
158
|
+
VersionChanged: '0.59.2'
|
159
|
+
CountComments: false # count full line comments?
|
160
|
+
Max: 15
|
161
|
+
IgnoredMethods: []
|
162
|
+
|
163
|
+
Metrics/ModuleLength:
|
164
|
+
Description: 'Avoid modules longer than 200 lines of code.'
|
165
|
+
Enabled: true
|
166
|
+
VersionAdded: '0.31'
|
167
|
+
CountComments: false # count full line comments?
|
168
|
+
Max: 200
|
169
|
+
|
170
|
+
Metrics/PerceivedComplexity:
|
171
|
+
Description: >-
|
172
|
+
A complexity metric geared towards measuring complexity for a
|
173
|
+
human reader.
|
174
|
+
Enabled: true
|
175
|
+
VersionAdded: '0.25'
|
176
|
+
Max: 10
|
177
|
+
|
178
|
+
Security:
|
179
|
+
Severity: warning
|
180
|
+
|
181
|
+
Style/Alias:
|
182
|
+
Description: 'Use alias instead of alias_method.'
|
183
|
+
StyleGuide: '#alias-method'
|
184
|
+
Enabled: false
|
185
|
+
VersionAdded: '0.9'
|
186
|
+
VersionChanged: '0.36'
|
187
|
+
EnforcedStyle: prefer_alias
|
188
|
+
SupportedStyles:
|
189
|
+
- prefer_alias
|
190
|
+
- prefer_alias_method
|
191
|
+
|
192
|
+
Style/AndOr:
|
193
|
+
Severity: true
|
194
|
+
Description: 'Use &&/|| instead of and/or.'
|
195
|
+
StyleGuide: '#no-and-or-or'
|
196
|
+
Enabled: true
|
197
|
+
VersionAdded: '0.9'
|
198
|
+
VersionChanged: '0.25'
|
199
|
+
# Whether `and` and `or` are banned only in conditionals (conditionals)
|
200
|
+
# or completely (always).
|
201
|
+
EnforcedStyle: conditionals
|
202
|
+
SupportedStyles:
|
203
|
+
- always
|
204
|
+
- conditionals
|
205
|
+
|
206
|
+
Style/BlockDelimiters:
|
207
|
+
Severity: warning
|
208
|
+
Description: >-
|
209
|
+
Avoid using {...} for multi-line blocks (multiline chaining is
|
210
|
+
always ugly).
|
211
|
+
Prefer {...} over do...end for single-line blocks.
|
212
|
+
StyleGuide: '#single-line-blocks'
|
213
|
+
Enabled: true
|
214
|
+
VersionAdded: '0.30'
|
215
|
+
VersionChanged: '0.35'
|
216
|
+
EnforcedStyle: braces_for_chaining
|
217
|
+
SupportedStyles:
|
218
|
+
# The `line_count_based` style enforces braces around single line blocks and
|
219
|
+
# do..end around multi-line blocks.
|
220
|
+
- line_count_based
|
221
|
+
# The `semantic` style enforces braces around functional blocks, where the
|
222
|
+
# primary purpose of the block is to return a value and do..end for
|
223
|
+
# procedural blocks, where the primary purpose of the block is its
|
224
|
+
# side-effects.
|
225
|
+
#
|
226
|
+
# This looks at the usage of a block's method to determine its type (e.g. is
|
227
|
+
# the result of a `map` assigned to a variable or passed to another
|
228
|
+
# method) but exceptions are permitted in the `ProceduralMethods`,
|
229
|
+
# `FunctionalMethods` and `IgnoredMethods` sections below.
|
230
|
+
- semantic
|
231
|
+
# The `braces_for_chaining` style enforces braces around single line blocks
|
232
|
+
# and do..end around multi-line blocks, except for multi-line blocks whose
|
233
|
+
# return value is being chained with another method (in which case braces
|
234
|
+
# are enforced).
|
235
|
+
- braces_for_chaining
|
236
|
+
ProceduralMethods:
|
237
|
+
# Methods that are known to be procedural in nature but look functional from
|
238
|
+
# their usage, e.g.
|
239
|
+
#
|
240
|
+
# time = Benchmark.realtime do
|
241
|
+
# foo.bar
|
242
|
+
# end
|
243
|
+
#
|
244
|
+
# Here, the return value of the block is discarded but the return value of
|
245
|
+
# `Benchmark.realtime` is used.
|
246
|
+
- benchmark
|
247
|
+
- bm
|
248
|
+
- bmbm
|
249
|
+
- create
|
250
|
+
- each_with_object
|
251
|
+
- measure
|
252
|
+
- new
|
253
|
+
- realtime
|
254
|
+
- tap
|
255
|
+
- with_object
|
256
|
+
FunctionalMethods:
|
257
|
+
# Methods that are known to be functional in nature but look procedural from
|
258
|
+
# their usage, e.g.
|
259
|
+
#
|
260
|
+
# let(:foo) { Foo.new }
|
261
|
+
#
|
262
|
+
# Here, the return value of `Foo.new` is used to define a `foo` helper but
|
263
|
+
# doesn't appear to be used from the return value of `let`.
|
264
|
+
- let
|
265
|
+
- let!
|
266
|
+
- subject
|
267
|
+
- watch
|
268
|
+
IgnoredMethods:
|
269
|
+
# Methods that can be either procedural or functional and cannot be
|
270
|
+
# categorised from their usage alone, e.g.
|
271
|
+
#
|
272
|
+
# foo = lambda do |x|
|
273
|
+
# puts "Hello, #{x}"
|
274
|
+
# end
|
275
|
+
#
|
276
|
+
# foo = lambda do |x|
|
277
|
+
# x * 100
|
278
|
+
# end
|
279
|
+
#
|
280
|
+
# Here, it is impossible to tell from the return value of `lambda` whether
|
281
|
+
# the inner block's return value is significant.
|
282
|
+
- lambda
|
283
|
+
- proc
|
284
|
+
- it
|
285
|
+
|
286
|
+
Style/Documentation:
|
287
|
+
Description: 'Document classes and non-namespace modules.'
|
288
|
+
Enabled: false
|
289
|
+
VersionAdded: '0.9'
|
290
|
+
Exclude:
|
291
|
+
- 'spec/**/*'
|
292
|
+
- 'test/**/*'
|
293
|
+
|
294
|
+
Style/MultipleComparison:
|
295
|
+
Description: >-
|
296
|
+
Avoid comparing a variable with multiple items in a conditional,
|
297
|
+
use Array#include? instead.
|
298
|
+
Enabled: false
|
299
|
+
VersionAdded: '0.49'
|
data/.rubocop.yml
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.7.8
|
data/.yardopts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
lib/**/*.rb
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# Change Log
|
2
|
+
|
3
|
+
All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
4
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
5
|
+
|
6
|
+
## [Unreleased]
|
7
|
+
|
8
|
+
### Added
|
9
|
+
- New feature or enhancement X.
|
10
|
+
- Another feature Y.
|
11
|
+
|
12
|
+
### Changed
|
13
|
+
- Improvements to existing functionality.
|
14
|
+
- Modifications to behavior.
|
15
|
+
|
16
|
+
### Fixed
|
17
|
+
- Bug fixes.
|
18
|
+
- Addressed issues ABC and XYZ.
|
19
|
+
|
20
|
+
## [1.0.0] - 2023-11-01
|
21
|
+
|
22
|
+
### Added
|
23
|
+
- Initial release.
|
data/README.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# TestOpenai
|
2
|
+
|
3
|
+
TODO: Delete this and the text below, and describe your gem
|
4
|
+
|
5
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/test_openai`. To experiment with that code, run `bin/console` for an interactive prompt.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
|
10
|
+
|
11
|
+
Install the gem and add to the application's Gemfile by executing:
|
12
|
+
|
13
|
+
$ bundle add UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
|
14
|
+
|
15
|
+
If bundler is not being used to manage dependencies, install the gem by executing:
|
16
|
+
|
17
|
+
$ gem install UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Development
|
24
|
+
|
25
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
26
|
+
|
27
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
28
|
+
|
29
|
+
## Contributing
|
30
|
+
|
31
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/test_openai.
|
data/Rakefile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bundler/gem_tasks'
|
4
|
+
require 'rake/testtask'
|
5
|
+
|
6
|
+
Rake::TestTask.new(:test) do |t|
|
7
|
+
t.libs << 'test'
|
8
|
+
t.libs << 'lib'
|
9
|
+
t.test_files = FileList['test/**/test_*.rb']
|
10
|
+
end
|
11
|
+
|
12
|
+
require 'rubocop/rake_task'
|
13
|
+
|
14
|
+
RuboCop::RakeTask.new
|
15
|
+
|
16
|
+
task default: %i[test rubocop]
|
data/lib/client.rb
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'uri'
|
4
|
+
require 'json'
|
5
|
+
require 'net/http'
|
6
|
+
require 'rest-client'
|
7
|
+
|
8
|
+
module TestOpenai
|
9
|
+
class Client
|
10
|
+
attr_accessor :openai_host, :openai_key
|
11
|
+
|
12
|
+
# @param openai_host [String] The host of the OpenAI API
|
13
|
+
# @param openai_key [String] The key of the OpenAI API
|
14
|
+
# @return [TestOpenai::Client] A new instance of TestOpenai::OpenAIClient
|
15
|
+
def initialize(openai_host = 'https://api.openai.com', openai_key = '')
|
16
|
+
@openai_host = openai_host
|
17
|
+
@openai_key = openai_key
|
18
|
+
end
|
19
|
+
|
20
|
+
# @return [TestOpenai::ListFilesResp] The list of files
|
21
|
+
def list_files
|
22
|
+
url = "#{openai_host}/files"
|
23
|
+
headers = {
|
24
|
+
Authorization: "Bearer #{openai_key}"
|
25
|
+
}
|
26
|
+
res = RestClient.get(url, headers)
|
27
|
+
|
28
|
+
response_data = JSON.parse(res.body)
|
29
|
+
file_data = response_data['data']
|
30
|
+
TestOpenai::ListFilesResp.new(
|
31
|
+
object: response_data['object'],
|
32
|
+
has_more: response_data['has_more'],
|
33
|
+
data: file_data.map do |file|
|
34
|
+
parse_as_file(file)
|
35
|
+
end
|
36
|
+
)
|
37
|
+
end
|
38
|
+
|
39
|
+
# @param file_path [String] The path of the file to upload
|
40
|
+
# @return [TestOpenai::File] The file uploaded
|
41
|
+
def upload_file(file_path)
|
42
|
+
url = "#{openai_host}/files"
|
43
|
+
headers = {
|
44
|
+
Authorization: "Bearer #{openai_key}"
|
45
|
+
}
|
46
|
+
params = {
|
47
|
+
purpose: 'assistants',
|
48
|
+
file: ::File.new(file_path)
|
49
|
+
}
|
50
|
+
res = RestClient.post(url, params, headers)
|
51
|
+
parse_as_file(JSON.parse(res.body))
|
52
|
+
end
|
53
|
+
|
54
|
+
# @param file_id [String] The id of the file to delete
|
55
|
+
# @return [TestOpenai::DeleteFileResp] The response of the deletion
|
56
|
+
def delete_file(file_id)
|
57
|
+
url = "#{openai_host}/files/#{file_id}"
|
58
|
+
headers = {
|
59
|
+
Authorization: "Bearer #{openai_key}"
|
60
|
+
}
|
61
|
+
res = RestClient.delete(url, headers)
|
62
|
+
response_data = JSON.parse(res.body)
|
63
|
+
TestOpenai::DeleteFileResp.new(
|
64
|
+
object: response_data['object'],
|
65
|
+
id: response_data['id'],
|
66
|
+
deleted: response_data['deleted']
|
67
|
+
)
|
68
|
+
end
|
69
|
+
|
70
|
+
# @param file_id [String] The id of the file to get
|
71
|
+
# @return [TestOpenai::File] The file gotten
|
72
|
+
def get_file(file_id)
|
73
|
+
url = "#{openai_host}/files/#{file_id}"
|
74
|
+
headers = {
|
75
|
+
Authorization: "Bearer #{openai_key}"
|
76
|
+
}
|
77
|
+
res = RestClient.get(url, headers)
|
78
|
+
parse_as_file(JSON.parse(res.body))
|
79
|
+
end
|
80
|
+
|
81
|
+
def get_file_content(file_id)
|
82
|
+
url = "#{openai_host}/files/#{file_id}/content"
|
83
|
+
headers = {
|
84
|
+
Authorization: "Bearer #{openai_key}"
|
85
|
+
}
|
86
|
+
res = RestClient.get(url, headers)
|
87
|
+
res.body
|
88
|
+
end
|
89
|
+
|
90
|
+
# @private
|
91
|
+
def parse_as_file(data)
|
92
|
+
TestOpenai::File.new(
|
93
|
+
object: data['object'],
|
94
|
+
id: data['id'],
|
95
|
+
purpose: data['purpose'],
|
96
|
+
filename: data['filename'],
|
97
|
+
bytes: data['bytes'],
|
98
|
+
created_at: data['created_at']
|
99
|
+
)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
data/lib/models.rb
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'uri'
|
4
|
+
require 'json'
|
5
|
+
require 'net/http'
|
6
|
+
require 'rest-client'
|
7
|
+
|
8
|
+
module TestOpenai
|
9
|
+
# The file object used by OpenAI API
|
10
|
+
class File
|
11
|
+
# @return [String] Type of the data. Always: 'file'.
|
12
|
+
attr_accessor :object
|
13
|
+
# @return [String] The id of the data.
|
14
|
+
attr_accessor :id
|
15
|
+
# @return [String] The purpose of the data.
|
16
|
+
attr_accessor :purpose
|
17
|
+
# @return [String] Original filename.
|
18
|
+
attr_accessor :filename
|
19
|
+
# @return [Integer] Size of the file in bytes.
|
20
|
+
attr_accessor :bytes
|
21
|
+
# @return [Integer] Timestamp in seconds of creation time of the file.
|
22
|
+
attr_accessor :created_at
|
23
|
+
|
24
|
+
def initialize(**args)
|
25
|
+
@object = args[:object]
|
26
|
+
@id = args[:id]
|
27
|
+
@purpose = args[:purpose]
|
28
|
+
@filename = args[:filename]
|
29
|
+
@bytes = args[:bytes]
|
30
|
+
@created_at = args[:created_at]
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
class ListFilesResp
|
35
|
+
# @return [String] Type of the data. Ex: 'list'.
|
36
|
+
attr_accessor :object
|
37
|
+
# @return [Boolean] Whether there are more data to load.
|
38
|
+
attr_accessor :has_more
|
39
|
+
# @return [Array<TestOpenai::File>] The list of files.
|
40
|
+
attr_accessor :data
|
41
|
+
|
42
|
+
def initialize(**args)
|
43
|
+
@object = args.fetch(:object, 'list')
|
44
|
+
@has_more = args.fetch(:has_more, false)
|
45
|
+
@data = args.fetch(:data, [])
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
class DeleteFileResp
|
50
|
+
# @return [String] Type of the data. Ex: 'file'.
|
51
|
+
attr_accessor :object
|
52
|
+
# @return [String] The id of the data.
|
53
|
+
attr_accessor :id
|
54
|
+
# @return [true, false] Whether the data was deleted.
|
55
|
+
attr_accessor :deleted
|
56
|
+
|
57
|
+
def initialize(**args)
|
58
|
+
@object = args.fetch(:object, 'file')
|
59
|
+
@id = args.fetch(:id, '')
|
60
|
+
@deleted = args.fetch(:deleted, false)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
data/sig/test_openai.rbs
ADDED
data/test_openai.gemspec
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'lib/test_openai/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'test_openai'
|
7
|
+
spec.version = TestOpenai::VERSION
|
8
|
+
spec.authors = ['Brendon Dao']
|
9
|
+
spec.email = ['brendon.dao@employmenthero.com']
|
10
|
+
spec.metadata['source_code_uri'] = 'https://github.com/brendondaoateh/test_openai'
|
11
|
+
|
12
|
+
spec.summary = 'A sample gem to call OpenAI API'
|
13
|
+
spec.description = 'A sample gem to call OpenAI API'
|
14
|
+
spec.homepage = spec.metadata['source_code_uri']
|
15
|
+
spec.required_ruby_version = '>= 2.7.0'
|
16
|
+
spec.license = 'MIT'
|
17
|
+
|
18
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
19
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
20
|
+
spec.metadata['changelog_uri'] = 'https://github.com/brendondaoateh/test_openai/blob/main/CHANGELOG.md'
|
21
|
+
|
22
|
+
# Specify which files should be added to the gem when it is released.
|
23
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
24
|
+
spec.files = Dir.chdir(__dir__ || '') do
|
25
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
26
|
+
(File.expand_path(f) == __FILE__) ||
|
27
|
+
f.start_with?(*%w[bin/ test/ spec/ features/ .git .circleci appveyor Gemfile])
|
28
|
+
end
|
29
|
+
end
|
30
|
+
spec.bindir = 'exe'
|
31
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
32
|
+
spec.require_paths = ['lib']
|
33
|
+
|
34
|
+
# Uncomment to register a new dependency of your gem
|
35
|
+
# spec.add_dependency "example-gem", "~> 1.0"
|
36
|
+
|
37
|
+
# For more information and examples about making a new gem, check out our
|
38
|
+
# guide at: https://bundler.io/guides/creating_gem.html
|
39
|
+
end
|
metadata
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: test_openai
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Brendon Dao
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2023-11-27 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: A sample gem to call OpenAI API
|
14
|
+
email:
|
15
|
+
- brendon.dao@employmenthero.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- ".env.sample"
|
21
|
+
- ".rspec"
|
22
|
+
- ".rubocop-https---raw-githubusercontent-com-Thinkei-Thinkei-master--rubocop-default-v1-yml"
|
23
|
+
- ".rubocop.yml"
|
24
|
+
- ".ruby-version"
|
25
|
+
- ".yardopts"
|
26
|
+
- CHANGELOG.md
|
27
|
+
- README.md
|
28
|
+
- Rakefile
|
29
|
+
- lib/client.rb
|
30
|
+
- lib/models.rb
|
31
|
+
- lib/test_openai/version.rb
|
32
|
+
- sig/test_openai.rbs
|
33
|
+
- test_openai.gemspec
|
34
|
+
homepage: https://github.com/brendondaoateh/test_openai
|
35
|
+
licenses:
|
36
|
+
- MIT
|
37
|
+
metadata:
|
38
|
+
source_code_uri: https://github.com/brendondaoateh/test_openai
|
39
|
+
allowed_push_host: https://rubygems.org
|
40
|
+
homepage_uri: https://github.com/brendondaoateh/test_openai
|
41
|
+
changelog_uri: https://github.com/brendondaoateh/test_openai/blob/main/CHANGELOG.md
|
42
|
+
post_install_message:
|
43
|
+
rdoc_options: []
|
44
|
+
require_paths:
|
45
|
+
- lib
|
46
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
47
|
+
requirements:
|
48
|
+
- - ">="
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: 2.7.0
|
51
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
requirements: []
|
57
|
+
rubygems_version: 3.1.6
|
58
|
+
signing_key:
|
59
|
+
specification_version: 4
|
60
|
+
summary: A sample gem to call OpenAI API
|
61
|
+
test_files: []
|