ruby-openai 3.6.0 → 6.5.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: 0cee1b8ea9256b9e74487bd152c640acf176ee65f7860521b3ee9f0901dddb5f
4
- data.tar.gz: 12bb3313fbcfd6d9098a13975b2ea9784126e603a321a63e4540891efbf720ab
3
+ metadata.gz: f3db6f0c15b1015a875950a23ad157cb9f6f4eaed2005c35f75fd97197ee3dd6
4
+ data.tar.gz: e11f7020b2db2d627646c584feb7dfb2163f3bd8233860e5115ffe0f8d65c681
5
5
  SHA512:
6
- metadata.gz: c684505ae1469c9066c2b6731dc6e9ee32b4efed151a005bf83f6c070991d60d714122bb10dc7a6239dcbf99fbee9486397d22de0df74287754ac5088460732c
7
- data.tar.gz: 70381208b506f04536ced0db66b1519e34d3dfc368796c9f17e7994fa8f95d46f902746f4513ae570a7e41d36d788a88c6ca69f6b999b88ad6be247f6547b913
6
+ metadata.gz: 76100b527ed276b83190df15c1241be39d58288285e93caaeb20ca94c937082e1d19dd99b9ea69e1758352105e749e38940f1f0192b97c50fb18a8e81d321911
7
+ data.tar.gz: 425db82e5ae928dba3136351b697ac53335ffbce5afb81c98920efda2a0b4c600cf83a8273c8c627ad4b25a352ba76d2e77d88f00a48d4993dcbbc318077be53
@@ -0,0 +1,16 @@
1
+ FROM ruby:3.2.2-slim-bullseye
2
+
3
+ ENV TZ="Europe/London"
4
+
5
+ RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
6
+ && apt-get -y install --no-install-recommends \
7
+ apt-utils \
8
+ build-essential \
9
+ curl \
10
+ git \
11
+ vim \
12
+ zsh
13
+
14
+ RUN gem install bundler
15
+
16
+ WORKDIR /workspace
@@ -0,0 +1,36 @@
1
+ // For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
2
+ // https://github.com/microsoft/vscode-dev-containers/tree/v0.245.2/containers/ruby-rails-postgres
3
+ // Update the VARIANT arg in docker-compose.yml to pick a Ruby version
4
+ {
5
+ "name": "ruby-openai",
6
+ "dockerComposeFile": "docker-compose.yml",
7
+ "service": "app",
8
+ "workspaceFolder": "/workspace",
9
+ "containerEnv": {
10
+ "GITHUB_TOKEN": "${localEnv:GITHUB_TOKEN}",
11
+ "GITHUB_USER": "${localEnv:GITHUB_USER}"
12
+ },
13
+ // Configure tool-specific properties.
14
+ "customizations": {
15
+ // Configure properties specific to VS Code.
16
+ "vscode": {
17
+ // Add the IDs of extensions you want installed when the container is created.
18
+ "extensions": [
19
+ "rebornix.Ruby",
20
+ "sleistner.vscode-fileutils",
21
+ "ms-azuretools.vscode-docker",
22
+ "samverschueren.final-newline",
23
+ "GitHub.copilot",
24
+ "usernamehw.remove-empty-lines",
25
+ "wingrunr21.vscode-ruby",
26
+ ]
27
+ }
28
+ },
29
+ // Use 'postCreateCommand' to run commands after the container is created.
30
+ "postCreateCommand": "bundle install",
31
+ // Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
32
+ "features": {
33
+ "git": "os-provided",
34
+ "github-cli": "latest"
35
+ }
36
+ }
@@ -0,0 +1,19 @@
1
+ version: "3"
2
+
3
+ services:
4
+ app:
5
+ build:
6
+ context: ..
7
+ dockerfile: .devcontainer/Dockerfile
8
+
9
+ volumes:
10
+ - ..:/workspace:cached
11
+ - bundle_cache:/bundle
12
+
13
+ command: sleep infinity
14
+
15
+ environment:
16
+ TZ: Europe/London
17
+
18
+ volumes:
19
+ bundle_cache:
@@ -0,0 +1,13 @@
1
+ # These are supported funding model platforms
2
+
3
+ github: alexrudall
4
+ patreon: # Replace with a single Patreon username
5
+ open_collective: # Replace with a single Open Collective username
6
+ ko_fi: # Replace with a single Ko-fi username
7
+ tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8
+ community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9
+ liberapay: # Replace with a single Liberapay username
10
+ issuehunt: # Replace with a single IssueHunt username
11
+ otechie: # Replace with a single Otechie username
12
+ lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
13
+ custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
data/.gitignore CHANGED
@@ -1,16 +1,74 @@
1
- /.bundle/
2
- /.yardoc
3
- /_yardoc/
1
+ ### Ruby ###
2
+ *.gem
3
+ *.rbc
4
+ /.config
4
5
  /coverage/
5
- /doc/
6
+ /InstalledFiles
6
7
  /pkg/
7
8
  /spec/reports/
9
+ /spec/examples.txt
10
+ /test/tmp/
11
+ /test/version_tmp/
8
12
  /tmp/
13
+ /.bundle/
14
+ /.yardoc
15
+ /_yardoc/
16
+ /doc/
17
+
18
+
19
+ # Used by dotenv library to load environment variables.
20
+ .env
21
+
22
+ # Ignore Byebug command history file.
23
+ .byebug_history
24
+
25
+ ## Specific to RubyMotion:
26
+ .dat*
27
+ .repl_history
28
+ build/
29
+ *.bridgesupport
30
+ build-iPhoneOS/
31
+ build-iPhoneSimulator/
32
+
33
+ ## Specific to RubyMotion (use of CocoaPods):
34
+ #
35
+ # We recommend against adding the Pods directory to your .gitignore. However
36
+ # you should judge for yourself, the pros and cons are mentioned at:
37
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
38
+ # vendor/Pods/
39
+
40
+ ## Documentation cache and generated files:
41
+ /.yardoc/
42
+ /_yardoc/
43
+ /doc/
44
+ /rdoc/
45
+
46
+ ## Environment normalization:
47
+ /.bundle/
48
+ /vendor/bundle
49
+ /lib/bundler/man/
50
+
51
+ # for a library or gem, you might want to ignore these files since the code is
52
+ # intended to run in multiple environments; otherwise, check them in:
53
+ # Gemfile.lock
54
+ # .ruby-version
55
+ # .ruby-gemset
56
+
57
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
58
+ .rvmrc
59
+
60
+ # Used by RuboCop. Remote config files pulled in from inherit_from directive.
61
+ # .rubocop-https?--*
9
62
 
10
63
  # rspec failure tracking
11
64
  .rspec_status
12
65
 
13
- .byebug_history
14
- .env
66
+ # IDE
67
+ .idea
68
+ .idea/
69
+ .idea/*
70
+ .vscode
71
+ .vs/
15
72
 
16
- *.gem
73
+ # Mac
74
+ .DS_Store
data/.rubocop.yml CHANGED
@@ -12,6 +12,14 @@ Layout/LineLength:
12
12
  Exclude:
13
13
  - "**/*.gemspec"
14
14
 
15
+ Lint/AmbiguousOperator:
16
+ # https://github.com/rubocop/rubocop/issues/4294
17
+ Exclude:
18
+ - "lib/openai/client.rb"
19
+
20
+ Metrics/AbcSize:
21
+ Max: 20
22
+
15
23
  Metrics/BlockLength:
16
24
  Exclude:
17
25
  - "spec/**/*"
data/CHANGELOG.md CHANGED
@@ -5,6 +5,147 @@ 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
+ ## [6.5.0] - 2024-03-31
9
+
10
+ ### Added
11
+
12
+ - Add back the deprecated Completions endpoint that I removed a bit prematurely. Thanks, [@mishranant](https://github.com/
13
+ mishranant) and everyone who requested this.
14
+
15
+ ## [6.4.0] - 2024-03-27
16
+
17
+ ### Added
18
+
19
+ - Add DALL·E 3 to specs and README - thanks to [@Gary-H9](https://github.com/Gary-H9)
20
+ - Add Whisper transcription language selection parameter to README - thanks to [@nfedyashev](https://github.com/nfedyashev)
21
+ - Add bundle exec rake lint and bundle exec rake test to make development easier - thanks to [@ignacio-chiazzo](https://github.com/ignacio-chiazzo)
22
+ - Add link to [https://github.com/sponsors/alexrudall](https://github.com/sponsors/alexrudall) when users run `bundle fund`
23
+
24
+ ### Fixed
25
+
26
+ - Update README and spec to use tool calls instead of functions - thanks to [@mpallenjr](https://github.com/mpallenjr)
27
+ - Remove nonexistent Thread#list method - thanks again! to [@ignacio-chiazzo](https://github.com/ignacio-chiazzo)
28
+ - Update finetunes docs in README to use chat instead of completions endpoint - thanks to [@blefev](https://github.com/blefev)
29
+
30
+ ## [6.3.1] - 2023-12-04
31
+
32
+ ### Fixed
33
+
34
+ - Allow any kind of file (eg. PDFs) to be uploaded to the API, not just JSONL files. Thank you [@stefan-kp](https://github.com/stefan-kp) for the PR!
35
+
36
+ ## [6.3.0] - 2023-11-26
37
+
38
+ ### Added
39
+
40
+ - Add ability to pass [Faraday middleware](https://lostisland.github.io/faraday/#/middleware/index) to the client in a block, eg. to enable verbose logging - shout out to [@obie](https://github.com/obie) for pushing for this.
41
+ - Add better error logging to the client by default.
42
+ - Bump Event Source to v1, thank you [@atesgoral](https://github.com/atesgoral) @ Shopify!
43
+
44
+ ## [6.2.0] - 2023-11-15
45
+
46
+ ### Added
47
+
48
+ - Add text-to-speech! Thank you [@codergeek121](https://github.com/codergeek121)
49
+
50
+ ## [6.1.0] - 2023-11-14
51
+
52
+ ### Added
53
+
54
+ - Add support for Assistants, Threads, Messages and Runs. Thank you [@Haegin](https://github.com/Haegin) for the excellent work on this PR, and many reviewers for their contributions!
55
+
56
+ ## [6.0.1] - 2023-11-07
57
+
58
+ ### Fix
59
+
60
+ - Gracefully handle the case where an HTTP error response may not have valid JSON in its body. Thank you [@atesgoral](https://github.com/atesgoral)!
61
+
62
+ ## [6.0.0] - 2023-11-06
63
+
64
+ ### Added
65
+
66
+ - [BREAKING] HTTP errors will now be raised by ruby-openai as Faraday:Errors, including when streaming! Implemented by [@atesgoral](https://github.com/atesgoral)
67
+ - [BREAKING] Switch from legacy Finetunes to the new Fine-tune-jobs endpoints. Implemented by [@lancecarlson](https://github.com/lancecarlson)
68
+ - [BREAKING] Remove deprecated Completions endpoints - use Chat instead.
69
+
70
+ ### Fix
71
+
72
+ - [BREAKING] Fix issue where :stream parameters were replaced by a boolean in the client application. Thanks to [@martinjaimem](https://github.com/martinjaimem), [@vickymadrid03](https://github.com/vickymadrid03) and [@nicastelo](https://github.com/nicastelo) for spotting and fixing this issue.
73
+
74
+ ## [5.2.0] - 2023-10-30
75
+
76
+ ### Fix
77
+
78
+ - Added more spec-compliant SSE parsing: see here https://html.spec.whatwg.org/multipage/server-sent-events.html#event-stream-interpretation
79
+ - Fixes issue where OpenAI or an intermediary returns only partial JSON per chunk of streamed data
80
+ - Huge thanks to [@atesgoral](https://github.com/atesgoral) for this important fix!
81
+
82
+ ## [5.1.0] - 2023-08-20
83
+
84
+ ### Added
85
+
86
+ - Added rough_token_count to estimate tokens in a string according to OpenAI's "rules of thumb". Thank you to [@jamiemccarthy](https://github.com/jamiemccarthy) for the idea and implementation!
87
+
88
+ ## [5.0.0] - 2023-08-14
89
+
90
+ ### Added
91
+
92
+ - Support multi-tenant use of the gem! Each client now holds its own config, so you can create unlimited clients in the same project, for example to Azure and OpenAI, or for different headers, access keys, etc.
93
+ - [BREAKING-ish] This change should only break your usage of ruby-openai if you are directly calling class methods like `OpenAI::Client.get` for some reason, as they are now instance methods. Normal usage of the gem should be unaffected, just you can make new clients and they'll keep their own config if you want, overriding the global config.
94
+ - Huge thanks to [@petergoldstein](https://github.com/petergoldstein) for his original work on this, [@cthulhu](https://github.com/cthulhu) for testing and many others for reviews and suggestions.
95
+
96
+ ### Changed
97
+
98
+ - [BREAKING] Move audio related method to Audio model from Client model. You will need to update your code to handle this change, changing `client.translate` to `client.audio.translate` and `client.transcribe` to `client.audio.transcribe`.
99
+
100
+ ## [4.3.2] - 2023-08-14
101
+
102
+ ### Fixed
103
+
104
+ - Don't overwrite config extra-headers when making a client without different ones. Thanks to [@swistaczek](https://github.com/swistaczek) for raising this!
105
+ - Include extra-headers for Azure requests.
106
+
107
+ ## [4.3.1] - 2023-08-13
108
+
109
+ ### Fixed
110
+
111
+ - Tempfiles can now be sent to the API as well as Files, eg for Whisper. Thanks to [@codergeek121](https://github.com/codergeek121) for the fix!
112
+
113
+ ## [4.3.0] - 2023-08-12
114
+
115
+ ### Added
116
+
117
+ - Add extra-headers to config to allow setting openai-caching-proxy-worker TTL, Helicone Auth and anything else ya need. Ty to [@deltaguita](https://github.com/deltaguita) and [@marckohlbrugge](https://github.com/marckohlbrugge) for the PR!
118
+
119
+ ## [4.2.0] - 2023-06-20
120
+
121
+ ### Added
122
+
123
+ - Add Azure OpenAI Service support. Thanks to [@rmachielse](https://github.com/rmachielse) and [@steffansluis](https://github.com/steffansluis) for the PR and to everyone who requested this feature!
124
+
125
+ ## [4.1.0] - 2023-05-15
126
+
127
+ ### Added
128
+
129
+ - Add the ability to trigger any callable object as stream chunks come through, not just Procs. Big thanks to [@obie](https://github.com/obie) for this change.
130
+
131
+ ## [4.0.0] - 2023-04-25
132
+
133
+ ### Added
134
+
135
+ - Add the ability to stream Chat responses from the API! Thanks to everyone who requested this and made suggestions.
136
+ - Added instructions for streaming to the README.
137
+
138
+ ### Changed
139
+
140
+ - Switch HTTP library from HTTParty to Faraday to allow streaming and future feature and performance improvements.
141
+ - [BREAKING] Endpoints now return JSON rather than HTTParty objects. You will need to update your code to handle this change, changing `JSON.parse(response.body)["key"]` and `response.parsed_response["key"]` to just `response["key"]`.
142
+
143
+ ## [3.7.0] - 2023-03-25
144
+
145
+ ### Added
146
+
147
+ - Allow the usage of proxy base URIs like https://www.helicone.ai/. Thanks to [@mmmaia](https://github.com/mmmaia) for the PR!
148
+
8
149
  ## [3.6.0] - 2023-03-22
9
150
 
10
151
  ### Added
data/Gemfile CHANGED
@@ -5,8 +5,8 @@ gemspec
5
5
 
6
6
  gem "byebug", "~> 11.1.3"
7
7
  gem "dotenv", "~> 2.8.1"
8
- gem "rake", "~> 13.0"
8
+ gem "rake", "~> 13.1"
9
9
  gem "rspec", "~> 3.12"
10
- gem "rubocop", "~> 1.48.1"
10
+ gem "rubocop", "~> 1.50.2"
11
11
  gem "vcr", "~> 6.1.0"
12
- gem "webmock", "~> 3.18.1"
12
+ gem "webmock", "~> 3.19.1"
data/Gemfile.lock CHANGED
@@ -1,35 +1,42 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ruby-openai (3.6.0)
5
- httparty (>= 0.18.1)
4
+ ruby-openai (6.5.0)
5
+ event_stream_parser (>= 0.3.0, < 2.0.0)
6
+ faraday (>= 1)
7
+ faraday-multipart (>= 1)
6
8
 
7
9
  GEM
8
10
  remote: https://rubygems.org/
9
11
  specs:
10
- addressable (2.8.1)
12
+ addressable (2.8.5)
11
13
  public_suffix (>= 2.0.2, < 6.0)
12
14
  ast (2.4.2)
15
+ base64 (0.2.0)
13
16
  byebug (11.1.3)
14
17
  crack (0.4.5)
15
18
  rexml
16
19
  diff-lcs (1.5.0)
17
20
  dotenv (2.8.1)
21
+ event_stream_parser (1.0.0)
22
+ faraday (2.7.12)
23
+ base64
24
+ faraday-net_http (>= 2.0, < 3.1)
25
+ ruby2_keywords (>= 0.0.4)
26
+ faraday-multipart (1.0.4)
27
+ multipart-post (~> 2)
28
+ faraday-net_http (3.0.2)
18
29
  hashdiff (1.0.1)
19
- httparty (0.21.0)
20
- mini_mime (>= 1.0.0)
21
- multi_xml (>= 0.5.2)
22
30
  json (2.6.3)
23
- mini_mime (1.1.2)
24
- multi_xml (0.6.0)
31
+ multipart-post (2.3.0)
25
32
  parallel (1.22.1)
26
- parser (3.2.1.1)
33
+ parser (3.2.2.0)
27
34
  ast (~> 2.4.1)
28
- public_suffix (5.0.1)
35
+ public_suffix (5.0.3)
29
36
  rainbow (3.1.1)
30
- rake (13.0.6)
31
- regexp_parser (2.7.0)
32
- rexml (3.2.5)
37
+ rake (13.1.0)
38
+ regexp_parser (2.8.0)
39
+ rexml (3.2.6)
33
40
  rspec (3.12.0)
34
41
  rspec-core (~> 3.12.0)
35
42
  rspec-expectations (~> 3.12.0)
@@ -43,22 +50,23 @@ GEM
43
50
  diff-lcs (>= 1.2.0, < 2.0)
44
51
  rspec-support (~> 3.12.0)
45
52
  rspec-support (3.12.0)
46
- rubocop (1.48.1)
53
+ rubocop (1.50.2)
47
54
  json (~> 2.3)
48
55
  parallel (~> 1.10)
49
56
  parser (>= 3.2.0.0)
50
57
  rainbow (>= 2.2.2, < 4.0)
51
58
  regexp_parser (>= 1.8, < 3.0)
52
59
  rexml (>= 3.2.5, < 4.0)
53
- rubocop-ast (>= 1.26.0, < 2.0)
60
+ rubocop-ast (>= 1.28.0, < 2.0)
54
61
  ruby-progressbar (~> 1.7)
55
62
  unicode-display_width (>= 2.4.0, < 3.0)
56
- rubocop-ast (1.27.0)
63
+ rubocop-ast (1.28.0)
57
64
  parser (>= 3.2.1.0)
58
65
  ruby-progressbar (1.13.0)
66
+ ruby2_keywords (0.0.5)
59
67
  unicode-display_width (2.4.2)
60
68
  vcr (6.1.0)
61
- webmock (3.18.1)
69
+ webmock (3.19.1)
62
70
  addressable (>= 2.8.0)
63
71
  crack (>= 0.3.2)
64
72
  hashdiff (>= 0.4.0, < 2.0.0)
@@ -69,12 +77,12 @@ PLATFORMS
69
77
  DEPENDENCIES
70
78
  byebug (~> 11.1.3)
71
79
  dotenv (~> 2.8.1)
72
- rake (~> 13.0)
80
+ rake (~> 13.1)
73
81
  rspec (~> 3.12)
74
- rubocop (~> 1.48.1)
82
+ rubocop (~> 1.50.2)
75
83
  ruby-openai!
76
84
  vcr (~> 6.1.0)
77
- webmock (~> 3.18.1)
85
+ webmock (~> 3.19.1)
78
86
 
79
87
  BUNDLED WITH
80
88
  2.4.5