ruby-openai 8.0.0 → 8.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: db56b0b2e16d752cb827fcc80f47d6880187d4f3140c29d3519f9527539dcc29
4
- data.tar.gz: dff6c57719e2cf0ae912b9815d58c9cb08c46ff3b1e7e71bf1c4952de605bbad
3
+ metadata.gz: 25124958f17722e0cc4168772bf02daf283b0d43dd2a2c143575ad23fc5539ac
4
+ data.tar.gz: cfaa4cb81ee668a4296774d7bce0591a2c23a3f0944794acde1db3e89586d199
5
5
  SHA512:
6
- metadata.gz: 6a2035500d97c58f4637ccfdc40cd09edb9545a77242ee4b02a6f53fb83b4c2dd616e2e8069265439067ab8f52d54c5316e42cf067b9096820ff67672914ce17
7
- data.tar.gz: 1ba769f55b5ca75b48aadf906e4b75618e090681d4410f0e60da6d470d432901197106538912e17b24762587f956c8b5770c7e338083878d672596736bc5b891
6
+ metadata.gz: d2ded6da66a157a190c24b0f7748a833d13ae9a4da67b52879eae8510e74cd90d80ffa6faaf573375c3a26d74b091165af6b30ca51c4cf860b1ba6f5c633cbdf
7
+ data.tar.gz: d31a28fafe6cac7caa99537f97a0fa1b0b918ebea09371d730e6d425b9bf228c726d9207c7a2bd08070103d49c9aa71e34ecf4f7ea888c2321f5fa128abf4fdc
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
+ ## [8.1.0] - 2025-03-30
9
+
10
+ ### Added
11
+
12
+ - Add Vector#search endpoint - thank you [@jaebrownn](https://github.com/jaebrownn) for this PR!
13
+
8
14
  ## [8.0.0] - 2025-03-14
9
15
 
10
16
  ### Added
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ruby-openai (8.0.0)
4
+ ruby-openai (8.1.0)
5
5
  event_stream_parser (>= 0.3.0, < 2.0.0)
6
6
  faraday (>= 1)
7
7
  faraday-multipart (>= 1)
data/README.md CHANGED
@@ -1,11 +1,12 @@
1
1
  # Ruby OpenAI
2
+
2
3
  [![Gem Version](https://img.shields.io/gem/v/ruby-openai.svg)](https://rubygems.org/gems/ruby-openai)
3
4
  [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/alexrudall/ruby-openai/blob/main/LICENSE.txt)
4
5
  [![CircleCI Build Status](https://circleci.com/gh/alexrudall/ruby-openai.svg?style=shield)](https://circleci.com/gh/alexrudall/ruby-openai)
5
6
 
6
7
  Use the [OpenAI API](https://openai.com/blog/openai-api/) with Ruby! 🤖❤️
7
8
 
8
- Stream text with GPT-4, transcribe and translate audio with Whisper, or create images with DALL·E...
9
+ Stream chats with the Responses API, transcribe and translate audio with Whisper, create images with DALL·E, and much more...
9
10
 
10
11
  💥 Click [subscribe now](https://mailchi.mp/8c7b574726a9/ruby-openai) to hear first about new releases in the Rails AI newsletter!
11
12
 
@@ -16,7 +17,7 @@ Stream text with GPT-4, transcribe and translate audio with Whisper, or create i
16
17
  ## Contents
17
18
 
18
19
  - [Ruby OpenAI](#ruby-openai)
19
- - [Table of Contents](#table-of-contents)
20
+ - [Contents](#contents)
20
21
  - [Installation](#installation)
21
22
  - [Bundler](#bundler)
22
23
  - [Gem install](#gem-install)
@@ -39,6 +40,13 @@ Stream text with GPT-4, transcribe and translate audio with Whisper, or create i
39
40
  - [Vision](#vision)
40
41
  - [JSON Mode](#json-mode)
41
42
  - [Responses API](#responses-api)
43
+ - [Create a Response](#create-a-response)
44
+ - [Follow-up Messages](#follow-up-messages)
45
+ - [Tool Calls](#tool-calls)
46
+ - [Streaming](#streaming)
47
+ - [Retrieve a Response](#retrieve-a-response)
48
+ - [Delete a Response](#delete-a-response)
49
+ - [List Input Items](#list-input-items)
42
50
  - [Functions](#functions)
43
51
  - [Completions](#completions)
44
52
  - [Embeddings](#embeddings)
@@ -70,6 +78,7 @@ Stream text with GPT-4, transcribe and translate audio with Whisper, or create i
70
78
  - [Usage](#usage)
71
79
  - [Errors](#errors-1)
72
80
  - [Development](#development)
81
+ - [To check for deprecations](#to-check-for-deprecations)
73
82
  - [Release](#release)
74
83
  - [Contributing](#contributing)
75
84
  - [License](#license)
@@ -88,7 +97,7 @@ gem "ruby-openai"
88
97
  And then execute:
89
98
 
90
99
  ```bash
91
- $ bundle install
100
+ bundle install
92
101
  ```
93
102
 
94
103
  ### Gem install
@@ -96,7 +105,7 @@ $ bundle install
96
105
  Or install with:
97
106
 
98
107
  ```bash
99
- $ gem install ruby-openai
108
+ gem install ruby-openai
100
109
  ```
101
110
 
102
111
  and require with:
@@ -472,9 +481,11 @@ You can stream it as well!
472
481
  ```
473
482
 
474
483
  ### Responses API
484
+
475
485
  [OpenAI's most advanced interface for generating model responses](https://platform.openai.com/docs/api-reference/responses). Supports text and image inputs, and text outputs. Create stateful interactions with the model, using the output of previous responses as input. Extend the model's capabilities with built-in tools for file search, web search, computer use, and more. Allow the model access to external systems and data using function calling.
476
486
 
477
487
  #### Create a Response
488
+
478
489
  ```ruby
479
490
  response = client.responses.create(parameters: {
480
491
  model: "gpt-4o",
@@ -485,6 +496,7 @@ puts response.dig("output", 0, "content", 0, "text")
485
496
  ```
486
497
 
487
498
  #### Follow-up Messages
499
+
488
500
  ```ruby
489
501
  followup = client.responses.create(parameters: {
490
502
  model: "gpt-4o",
@@ -496,6 +508,7 @@ puts followup.dig("output", 0, "content", 0, "text")
496
508
  ```
497
509
 
498
510
  #### Tool Calls
511
+
499
512
  ```ruby
500
513
  response = client.responses.create(parameters: {
501
514
  model: "gpt-4o",
@@ -523,6 +536,7 @@ puts response.dig("output", 0, "name")
523
536
  ```
524
537
 
525
538
  #### Streaming
539
+
526
540
  ```ruby
527
541
  client.responses.create(
528
542
  parameters: {
@@ -540,6 +554,7 @@ client.responses.create(
540
554
  ```
541
555
 
542
556
  #### Retrieve a Response
557
+
543
558
  ```ruby
544
559
  retrieved_response = client.responses.retrieve(response_id: response["id"])
545
560
  puts retrieved_response["object"]
@@ -547,6 +562,7 @@ puts retrieved_response["object"]
547
562
  ```
548
563
 
549
564
  #### Delete a Response
565
+
550
566
  ```ruby
551
567
  deletion = client.responses.delete(response_id: response["id"])
552
568
  puts deletion["deleted"]
@@ -554,6 +570,7 @@ puts deletion["deleted"]
554
570
  ```
555
571
 
556
572
  #### List Input Items
573
+
557
574
  ```ruby
558
575
  input_items = client.responses.input_items(response_id: response["id"])
559
576
  puts input_items["object"] # => "list"
@@ -910,6 +927,27 @@ response = client.vector_stores.modify(
910
927
  )
911
928
  ```
912
929
 
930
+ You can search a vector store for relevant chunks based on a query:
931
+
932
+ ```ruby
933
+ response = client.vector_stores.search(
934
+ id: vector_store_id,
935
+ parameters: {
936
+ query: "What is the return policy?",
937
+ max_num_results: 20,
938
+ ranking_options: {
939
+ # Add any ranking options here in line with the API documentation
940
+ },
941
+ rewrite_query: true,
942
+ filters: {
943
+ type: "eq",
944
+ property: "region",
945
+ value: "us"
946
+ }
947
+ }
948
+ )
949
+ ```
950
+
913
951
  You can delete vector stores:
914
952
 
915
953
  ```ruby
@@ -1588,6 +1626,7 @@ File.binwrite('demo.mp3', response)
1588
1626
  ```
1589
1627
 
1590
1628
  ### Usage
1629
+
1591
1630
  The Usage API provides information about the cost of various OpenAI services within your organization.
1592
1631
  To use Admin APIs like Usage, you need to set an OPENAI_ADMIN_TOKEN, which can be generated [here](https://platform.openai.com/settings/organization/admin-keys).
1593
1632
 
@@ -23,5 +23,9 @@ module OpenAI
23
23
  def delete(id:)
24
24
  @client.delete(path: "/vector_stores/#{id}")
25
25
  end
26
+
27
+ def search(id:, parameters: {})
28
+ @client.json_post(path: "/vector_stores/#{id}/search", parameters: parameters)
29
+ end
26
30
  end
27
31
  end
@@ -1,3 +1,3 @@
1
1
  module OpenAI
2
- VERSION = "8.0.0".freeze
2
+ VERSION = "8.1.0".freeze
3
3
  end
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: 8.0.0
4
+ version: 8.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-03-14 00:00:00.000000000 Z
11
+ date: 2025-03-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: event_stream_parser