Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a spec to test the client with GPT-4 #252

Closed
wants to merge 11 commits into from
2 changes: 2 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ jobs:
- run:
name: Run tests
command: bundle exec rspec -fd
environment:
GPT4: true

workflows:
version: 2
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,10 @@ OPENAI_ACCESS_TOKEN=123abc bundle exec rspec

Then update the version number in `version.rb`, update `CHANGELOG.md`, run `bundle install` to update Gemfile.lock, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).

## Testing GPT-4

Since GPT-4 isn't widely available as of July 2023, and this project aims to be as inclusive as possible, specs that test GPT-4 models will not run unless an environment variable is set. To test GPT-4 models, set `GPT4=true` in your environment or on the command line like this: `GPT4=true bundle exec rspec`.

## Contributing

Bug reports and pull requests are welcome on GitHub at <https://github.com/alexrudall/ruby-openai>. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/alexrudall/ruby-openai/blob/main/CODE_OF_CONDUCT.md).
Expand Down
99 changes: 91 additions & 8 deletions spec/fixtures/cassettes/gpt-3_5-turbo-0301_chat.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

200 changes: 200 additions & 0 deletions spec/fixtures/cassettes/gpt-3_5-turbo-0301_streamed_chat.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
---
http_interactions:
- request:
method: post
uri: https://oai.hconeai.com/v1/chat/completions
body:
encoding: UTF-8
string: '{"model":"gpt-3.5-turbo-0301","messages":[{"role":"user","content":"Hello!"}],"stream":true}'
headers:
Content-Type:
- application/json
Authorization:
- Bearer <OPENAI_ACCESS_TOKEN>
Accept-Encoding:
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
Accept:
- "*/*"
User-Agent:
- Ruby
response:
status:
code: 200
message: OK
headers:
Date:
- Mon, 15 May 2023 13:19:16 GMT
Content-Type:
- text/event-stream
Transfer-Encoding:
- chunked
Connection:
- keep-alive
Cf-Ray:
- 7c7babe95d3be270-ORD
Access-Control-Allow-Origin:
- "*"
Cache-Control:
- no-cache, must-revalidate
Strict-Transport-Security:
- max-age=15724800; includeSubDomains
Cf-Cache-Status:
- DYNAMIC
Helicone-Id:
- 4ef4cb4e-66ca-4c22-8d09-8ec93b453b7e
Helicone-Status:
- success
Openai-Model:
- gpt-3.5-turbo-0301
Openai-Organization:
- union-media-llc
Openai-Processing-Ms:
- '738'
Openai-Version:
- '2020-10-01'
X-Ratelimit-Limit-Requests:
- '3500'
X-Ratelimit-Limit-Tokens:
- '90000'
X-Ratelimit-Remaining-Requests:
- '3499'
X-Ratelimit-Remaining-Tokens:
- '89980'
X-Ratelimit-Reset-Requests:
- 17ms
X-Ratelimit-Reset-Tokens:
- 12ms
X-Request-Id:
- d93830661ad8a249a470b4b39d729638
Vary:
- Accept-Encoding
Server:
- cloudflare
body:
encoding: UTF-8
string: |+
data: {"id":"chatcmpl-7GSOZsgnfHt2b9rw14r2bj3vawJkH","object":"chat.completion.chunk","created":1684156755,"model":"gpt-3.5-turbo-0301","choices":[{"delta":{"role":"assistant"},"index":0,"finish_reason":null}]}

data: {"id":"chatcmpl-7GSOZsgnfHt2b9rw14r2bj3vawJkH","object":"chat.completion.chunk","created":1684156755,"model":"gpt-3.5-turbo-0301","choices":[{"delta":{"content":"Hello"},"index":0,"finish_reason":null}]}

data: {"id":"chatcmpl-7GSOZsgnfHt2b9rw14r2bj3vawJkH","object":"chat.completion.chunk","created":1684156755,"model":"gpt-3.5-turbo-0301","choices":[{"delta":{"content":" there"},"index":0,"finish_reason":null}]}

data: {"id":"chatcmpl-7GSOZsgnfHt2b9rw14r2bj3vawJkH","object":"chat.completion.chunk","created":1684156755,"model":"gpt-3.5-turbo-0301","choices":[{"delta":{"content":"!"},"index":0,"finish_reason":null}]}

data: {"id":"chatcmpl-7GSOZsgnfHt2b9rw14r2bj3vawJkH","object":"chat.completion.chunk","created":1684156755,"model":"gpt-3.5-turbo-0301","choices":[{"delta":{"content":" How"},"index":0,"finish_reason":null}]}

data: {"id":"chatcmpl-7GSOZsgnfHt2b9rw14r2bj3vawJkH","object":"chat.completion.chunk","created":1684156755,"model":"gpt-3.5-turbo-0301","choices":[{"delta":{"content":" can"},"index":0,"finish_reason":null}]}

data: {"id":"chatcmpl-7GSOZsgnfHt2b9rw14r2bj3vawJkH","object":"chat.completion.chunk","created":1684156755,"model":"gpt-3.5-turbo-0301","choices":[{"delta":{"content":" I"},"index":0,"finish_reason":null}]}

data: {"id":"chatcmpl-7GSOZsgnfHt2b9rw14r2bj3vawJkH","object":"chat.completion.chunk","created":1684156755,"model":"gpt-3.5-turbo-0301","choices":[{"delta":{"content":" assist"},"index":0,"finish_reason":null}]}

data: {"id":"chatcmpl-7GSOZsgnfHt2b9rw14r2bj3vawJkH","object":"chat.completion.chunk","created":1684156755,"model":"gpt-3.5-turbo-0301","choices":[{"delta":{"content":" you"},"index":0,"finish_reason":null}]}

data: {"id":"chatcmpl-7GSOZsgnfHt2b9rw14r2bj3vawJkH","object":"chat.completion.chunk","created":1684156755,"model":"gpt-3.5-turbo-0301","choices":[{"delta":{"content":" today"},"index":0,"finish_reason":null}]}

data: {"id":"chatcmpl-7GSOZsgnfHt2b9rw14r2bj3vawJkH","object":"chat.completion.chunk","created":1684156755,"model":"gpt-3.5-turbo-0301","choices":[{"delta":{"content":"?"},"index":0,"finish_reason":null}]}

data: {"id":"chatcmpl-7GSOZsgnfHt2b9rw14r2bj3vawJkH","object":"chat.completion.chunk","created":1684156755,"model":"gpt-3.5-turbo-0301","choices":[{"delta":{},"index":0,"finish_reason":"stop"}]}

data: [DONE]

recorded_at: Mon, 15 May 2023 13:19:16 GMT
- request:
method: post
uri: https://api.openai.com/v1/chat/completions
body:
encoding: UTF-8
string: '{"model":"gpt-3.5-turbo-0301","messages":[{"role":"user","content":"Hello!"}],"stream":true}'
headers:
Content-Type:
- application/json
Authorization:
- Bearer <OPENAI_ACCESS_TOKEN>
Accept-Encoding:
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
Accept:
- "*/*"
User-Agent:
- Ruby
response:
status:
code: 200
message: OK
headers:
Date:
- Mon, 15 May 2023 13:21:38 GMT
Content-Type:
- text/event-stream
Transfer-Encoding:
- chunked
Connection:
- keep-alive
Access-Control-Allow-Origin:
- "*"
Cache-Control:
- no-cache, must-revalidate
Openai-Model:
- gpt-3.5-turbo-0301
Openai-Organization:
- union-media-llc
Openai-Processing-Ms:
- '542'
Openai-Version:
- '2020-10-01'
Strict-Transport-Security:
- max-age=15724800; includeSubDomains
X-Ratelimit-Limit-Requests:
- '3500'
X-Ratelimit-Limit-Tokens:
- '90000'
X-Ratelimit-Remaining-Requests:
- '3499'
X-Ratelimit-Remaining-Tokens:
- '89980'
X-Ratelimit-Reset-Requests:
- 17ms
X-Ratelimit-Reset-Tokens:
- 12ms
X-Request-Id:
- 6104f033690f5e0eccda8054ddc9a3af
Cf-Cache-Status:
- DYNAMIC
Server:
- cloudflare
Cf-Ray:
- 7c7baf658abe2305-ORD
Alt-Svc:
- h3=":443"; ma=86400, h3-29=":443"; ma=86400
body:
encoding: UTF-8
string: |+
data: {"id":"chatcmpl-7GSQsdGVbiSDCP5XEGAhnWJREOB9y","object":"chat.completion.chunk","created":1684156898,"model":"gpt-3.5-turbo-0301","choices":[{"delta":{"role":"assistant"},"index":0,"finish_reason":null}]}

data: {"id":"chatcmpl-7GSQsdGVbiSDCP5XEGAhnWJREOB9y","object":"chat.completion.chunk","created":1684156898,"model":"gpt-3.5-turbo-0301","choices":[{"delta":{"content":"Hello"},"index":0,"finish_reason":null}]}

data: {"id":"chatcmpl-7GSQsdGVbiSDCP5XEGAhnWJREOB9y","object":"chat.completion.chunk","created":1684156898,"model":"gpt-3.5-turbo-0301","choices":[{"delta":{"content":" there"},"index":0,"finish_reason":null}]}

data: {"id":"chatcmpl-7GSQsdGVbiSDCP5XEGAhnWJREOB9y","object":"chat.completion.chunk","created":1684156898,"model":"gpt-3.5-turbo-0301","choices":[{"delta":{"content":"!"},"index":0,"finish_reason":null}]}

data: {"id":"chatcmpl-7GSQsdGVbiSDCP5XEGAhnWJREOB9y","object":"chat.completion.chunk","created":1684156898,"model":"gpt-3.5-turbo-0301","choices":[{"delta":{"content":" How"},"index":0,"finish_reason":null}]}

data: {"id":"chatcmpl-7GSQsdGVbiSDCP5XEGAhnWJREOB9y","object":"chat.completion.chunk","created":1684156898,"model":"gpt-3.5-turbo-0301","choices":[{"delta":{"content":" can"},"index":0,"finish_reason":null}]}

data: {"id":"chatcmpl-7GSQsdGVbiSDCP5XEGAhnWJREOB9y","object":"chat.completion.chunk","created":1684156898,"model":"gpt-3.5-turbo-0301","choices":[{"delta":{"content":" I"},"index":0,"finish_reason":null}]}

data: {"id":"chatcmpl-7GSQsdGVbiSDCP5XEGAhnWJREOB9y","object":"chat.completion.chunk","created":1684156898,"model":"gpt-3.5-turbo-0301","choices":[{"delta":{"content":" assist"},"index":0,"finish_reason":null}]}

data: {"id":"chatcmpl-7GSQsdGVbiSDCP5XEGAhnWJREOB9y","object":"chat.completion.chunk","created":1684156898,"model":"gpt-3.5-turbo-0301","choices":[{"delta":{"content":" you"},"index":0,"finish_reason":null}]}

data: {"id":"chatcmpl-7GSQsdGVbiSDCP5XEGAhnWJREOB9y","object":"chat.completion.chunk","created":1684156898,"model":"gpt-3.5-turbo-0301","choices":[{"delta":{"content":" today"},"index":0,"finish_reason":null}]}

data: {"id":"chatcmpl-7GSQsdGVbiSDCP5XEGAhnWJREOB9y","object":"chat.completion.chunk","created":1684156898,"model":"gpt-3.5-turbo-0301","choices":[{"delta":{"content":"?"},"index":0,"finish_reason":null}]}

data: {"id":"chatcmpl-7GSQsdGVbiSDCP5XEGAhnWJREOB9y","object":"chat.completion.chunk","created":1684156898,"model":"gpt-3.5-turbo-0301","choices":[{"delta":{},"index":0,"finish_reason":"stop"}]}

data: [DONE]

recorded_at: Mon, 15 May 2023 13:21:39 GMT
recorded_with: VCR 6.1.0
...
Loading