ruby-openai 4.0.0 → 6.3.1

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: ed826c08b658bc553da53acfc53a57c5a2f09320787dbe00fa6c901f1941e7a8
4
- data.tar.gz: 0b1cb51e0cd24f1e50877045881485cdb1c0ecf772c98464ff159b1001abd81d
3
+ metadata.gz: 958a72f1590182a35f447bb66e286adde77217e58b5d81e9621cd00e7f62cf58
4
+ data.tar.gz: 46729b5fc28187ba376af8c24d02e6b96f8dd4a18dca5cd19ad6fcea09e9d6a1
5
5
  SHA512:
6
- metadata.gz: d8575821c9b6921840c3e8b34916992ef0d947f1cce1308e19b2e82d0d3f968870649eb9e456d9c38cfb95ae667576330176bae45cb173dab116735450cfc0b2
7
- data.tar.gz: 8846dceef8669867c09168b19e0aedcb77cd76cd403a8ddf8a16e259132a17116c6c318adcbd4b04d0316c123166ef5e7da7e02cbbbe30e4e2ad3b13983fd67b
6
+ metadata.gz: f50b6b5044c70a5e549600c5563ec57daf1aefd4301cf04ca5bb992942d5ff3a361ad26e1defefa9cdc490b4eeae7ced18c4b304a6b44245516501286005c159
7
+ data.tar.gz: 26ce015243210f29239e4f993baabdee6e5a0265708ee407d5f7d3bef17db50b398e35c7ab225724aaec8519abc35f80e2d928d44e821bdfe27f6ff9db2bcc79
@@ -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,11 @@ 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
+
15
20
  Metrics/AbcSize:
16
21
  Max: 20
17
22
 
data/CHANGELOG.md CHANGED
@@ -5,6 +5,107 @@ 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.3.1] - 2023-12-04
9
+
10
+ ### Fixed
11
+
12
+ - 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!
13
+
14
+ ## [6.3.0] - 2023-11-26
15
+
16
+ ### Added
17
+
18
+ - 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.
19
+ - Add better error logging to the client by default.
20
+ - Bump Event Source to v1, thank you [@atesgoral](https://github.com/atesgoral) @ Shopify!
21
+
22
+ ## [6.2.0] - 2023-11-15
23
+
24
+ ### Added
25
+
26
+ - Add text-to-speech! Thank you [@codergeek121](https://github.com/codergeek121)
27
+
28
+ ## [6.1.0] - 2023-11-14
29
+
30
+ ### Added
31
+
32
+ - 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!
33
+
34
+ ## [6.0.1] - 2023-11-07
35
+
36
+ ### Fix
37
+
38
+ - Gracefully handle the case where an HTTP error response may not have valid JSON in its body. Thank you [@atesgoral](https://github.com/atesgoral)!
39
+
40
+ ## [6.0.0] - 2023-11-06
41
+
42
+ ### Added
43
+
44
+ - [BREAKING] HTTP errors will now be raised by ruby-openai as Faraday:Errors, including when streaming! Implemented by [@atesgoral](https://github.com/atesgoral)
45
+ - [BREAKING] Switch from legacy Finetunes to the new Fine-tune-jobs endpoints. Implemented by [@lancecarlson](https://github.com/lancecarlson)
46
+ - [BREAKING] Remove deprecated Completions endpoints - use Chat instead.
47
+
48
+ ### Fix
49
+
50
+ - [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.
51
+
52
+ ## [5.2.0] - 2023-10-30
53
+
54
+ ### Fix
55
+
56
+ - Added more spec-compliant SSE parsing: see here https://html.spec.whatwg.org/multipage/server-sent-events.html#event-stream-interpretation
57
+ - Fixes issue where OpenAI or an intermediary returns only partial JSON per chunk of streamed data
58
+ - Huge thanks to [@atesgoral](https://github.com/atesgoral) for this important fix!
59
+
60
+ ## [5.1.0] - 2023-08-20
61
+
62
+ ### Added
63
+
64
+ - 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!
65
+
66
+ ## [5.0.0] - 2023-08-14
67
+
68
+ ### Added
69
+
70
+ - 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.
71
+ - [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.
72
+ - 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.
73
+
74
+ ### Changed
75
+
76
+ - [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`.
77
+
78
+ ## [4.3.2] - 2023-08-14
79
+
80
+ ### Fixed
81
+
82
+ - Don't overwrite config extra-headers when making a client without different ones. Thanks to [@swistaczek](https://github.com/swistaczek) for raising this!
83
+ - Include extra-headers for Azure requests.
84
+
85
+ ## [4.3.1] - 2023-08-13
86
+
87
+ ### Fixed
88
+
89
+ - 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!
90
+
91
+ ## [4.3.0] - 2023-08-12
92
+
93
+ ### Added
94
+
95
+ - 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!
96
+
97
+ ## [4.2.0] - 2023-06-20
98
+
99
+ ### Added
100
+
101
+ - 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!
102
+
103
+ ## [4.1.0] - 2023-05-15
104
+
105
+ ### Added
106
+
107
+ - 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.
108
+
8
109
  ## [4.0.0] - 2023-04-25
9
110
 
10
111
  ### 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
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,22 +1,26 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ruby-openai (4.0.0)
4
+ ruby-openai (6.3.1)
5
+ event_stream_parser (>= 0.3.0, < 2.0.0)
5
6
  faraday (>= 1)
6
7
  faraday-multipart (>= 1)
7
8
 
8
9
  GEM
9
10
  remote: https://rubygems.org/
10
11
  specs:
11
- addressable (2.8.1)
12
+ addressable (2.8.5)
12
13
  public_suffix (>= 2.0.2, < 6.0)
13
14
  ast (2.4.2)
15
+ base64 (0.1.1)
14
16
  byebug (11.1.3)
15
17
  crack (0.4.5)
16
18
  rexml
17
19
  diff-lcs (1.5.0)
18
20
  dotenv (2.8.1)
19
- faraday (2.7.4)
21
+ event_stream_parser (1.0.0)
22
+ faraday (2.7.11)
23
+ base64
20
24
  faraday-net_http (>= 2.0, < 3.1)
21
25
  ruby2_keywords (>= 0.0.4)
22
26
  faraday-multipart (1.0.4)
@@ -28,11 +32,11 @@ GEM
28
32
  parallel (1.22.1)
29
33
  parser (3.2.2.0)
30
34
  ast (~> 2.4.1)
31
- public_suffix (5.0.1)
35
+ public_suffix (5.0.3)
32
36
  rainbow (3.1.1)
33
- rake (13.0.6)
37
+ rake (13.1.0)
34
38
  regexp_parser (2.8.0)
35
- rexml (3.2.5)
39
+ rexml (3.2.6)
36
40
  rspec (3.12.0)
37
41
  rspec-core (~> 3.12.0)
38
42
  rspec-expectations (~> 3.12.0)
@@ -62,7 +66,7 @@ GEM
62
66
  ruby2_keywords (0.0.5)
63
67
  unicode-display_width (2.4.2)
64
68
  vcr (6.1.0)
65
- webmock (3.18.1)
69
+ webmock (3.19.1)
66
70
  addressable (>= 2.8.0)
67
71
  crack (>= 0.3.2)
68
72
  hashdiff (>= 0.4.0, < 2.0.0)
@@ -73,12 +77,12 @@ PLATFORMS
73
77
  DEPENDENCIES
74
78
  byebug (~> 11.1.3)
75
79
  dotenv (~> 2.8.1)
76
- rake (~> 13.0)
80
+ rake (~> 13.1)
77
81
  rspec (~> 3.12)
78
82
  rubocop (~> 1.50.2)
79
83
  ruby-openai!
80
84
  vcr (~> 6.1.0)
81
- webmock (~> 3.18.1)
85
+ webmock (~> 3.19.1)
82
86
 
83
87
  BUNDLED WITH
84
88
  2.4.5