Skip to content

Commit e1a4171

Browse files
committed
chore: added documentation to the readme
1 parent 2d5dd69 commit e1a4171

File tree

1 file changed

+42
-3
lines changed

1 file changed

+42
-3
lines changed

README.md

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Ruby OpenAI
2+
23
[![Gem Version](https://img.shields.io/gem/v/ruby-openai.svg)](https://rubygems.org/gems/ruby-openai)
34
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/alexrudall/ruby-openai/blob/main/LICENSE.txt)
45
[![CircleCI Build Status](https://circleci.com/gh/alexrudall/ruby-openai.svg?style=shield)](https://circleci.com/gh/alexrudall/ruby-openai)
@@ -16,7 +17,7 @@ Stream chats with the Responses API, transcribe and translate audio with Whisper
1617
## Contents
1718

1819
- [Ruby OpenAI](#ruby-openai)
19-
- [Table of Contents](#table-of-contents)
20+
- [Contents](#contents)
2021
- [Installation](#installation)
2122
- [Bundler](#bundler)
2223
- [Gem install](#gem-install)
@@ -39,6 +40,13 @@ Stream chats with the Responses API, transcribe and translate audio with Whisper
3940
- [Vision](#vision)
4041
- [JSON Mode](#json-mode)
4142
- [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)
4250
- [Functions](#functions)
4351
- [Completions](#completions)
4452
- [Embeddings](#embeddings)
@@ -70,6 +78,7 @@ Stream chats with the Responses API, transcribe and translate audio with Whisper
7078
- [Usage](#usage)
7179
- [Errors](#errors-1)
7280
- [Development](#development)
81+
- [To check for deprecations](#to-check-for-deprecations)
7382
- [Release](#release)
7483
- [Contributing](#contributing)
7584
- [License](#license)
@@ -88,15 +97,15 @@ gem "ruby-openai"
8897
And then execute:
8998

9099
```bash
91-
$ bundle install
100+
bundle install
92101
```
93102

94103
### Gem install
95104

96105
Or install with:
97106

98107
```bash
99-
$ gem install ruby-openai
108+
gem install ruby-openai
100109
```
101110

102111
and require with:
@@ -472,9 +481,11 @@ You can stream it as well!
472481
```
473482

474483
### Responses API
484+
475485
[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.
476486

477487
#### Create a Response
488+
478489
```ruby
479490
response = client.responses.create(parameters: {
480491
model: "gpt-4o",
@@ -485,6 +496,7 @@ puts response.dig("output", 0, "content", 0, "text")
485496
```
486497

487498
#### Follow-up Messages
499+
488500
```ruby
489501
followup = client.responses.create(parameters: {
490502
model: "gpt-4o",
@@ -496,6 +508,7 @@ puts followup.dig("output", 0, "content", 0, "text")
496508
```
497509

498510
#### Tool Calls
511+
499512
```ruby
500513
response = client.responses.create(parameters: {
501514
model: "gpt-4o",
@@ -523,6 +536,7 @@ puts response.dig("output", 0, "name")
523536
```
524537

525538
#### Streaming
539+
526540
```ruby
527541
client.responses.create(
528542
parameters: {
@@ -540,20 +554,23 @@ client.responses.create(
540554
```
541555

542556
#### Retrieve a Response
557+
543558
```ruby
544559
retrieved_response = client.responses.retrieve(response_id: response["id"])
545560
puts retrieved_response["object"]
546561
# => "response"
547562
```
548563

549564
#### Delete a Response
565+
550566
```ruby
551567
deletion = client.responses.delete(response_id: response["id"])
552568
puts deletion["deleted"]
553569
# => true
554570
```
555571

556572
#### List Input Items
573+
557574
```ruby
558575
input_items = client.responses.input_items(response_id: response["id"])
559576
puts input_items["object"] # => "list"
@@ -948,6 +965,27 @@ You can get a `list` of all vector store files currently available under the vec
948965
client.vector_store_files.list(vector_store_id: "vector-store-abc123")
949966
```
950967

968+
You can search a vector store for relevant chunks based on a query:
969+
970+
```ruby
971+
response = client.vector_stores.search(
972+
id: vector_store_id,
973+
parameters: {
974+
query: "What is the return policy?",
975+
max_num_results: 20,
976+
ranking_options: {
977+
# Add any ranking options here in line with the API documentation
978+
},
979+
rewrite_query: true,
980+
filters: {
981+
type: "eq",
982+
property: "region",
983+
value: "us"
984+
}
985+
}
986+
)
987+
```
988+
951989
You can delete a vector store file:
952990

953991
```ruby
@@ -1588,6 +1626,7 @@ File.binwrite('demo.mp3', response)
15881626
```
15891627

15901628
### Usage
1629+
15911630
The Usage API provides information about the cost of various OpenAI services within your organization.
15921631
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).
15931632

0 commit comments

Comments
 (0)