ruby-openai 8.2.1 → 8.3.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: edad531342b6296e28117d60bd553335744abf4aec719af050fbc08894afbe29
4
- data.tar.gz: 9118084194b776895d59495ee1b4040e06ba6922414d7231df7b0d3b7ecbcee1
3
+ metadata.gz: 8f5bfc460a4cb2984e54d01cf39ebd6bd20a73fb0ddb6ffd271d14e6100fe568
4
+ data.tar.gz: 7a01a225d40f4265762a1e14a31dae19dff5535f8626336cfba0b5780a96cc57
5
5
  SHA512:
6
- metadata.gz: 782e4a2dfdcfcdea758114fadae57d38a3cb452b9e14a42af35e62cb4cef88793f9d4ec3d676706c700ea0533dc621a79c928a884b998e18ed09f68ba954c676
7
- data.tar.gz: b51f699d07b20dcd665cc9ac42d02fe296844f929a75dd89f9b324c8ce1532e559dd6975593a9aabb8410fc0229b276ee60abfd5a8bd14e050785c6dbb02261c
6
+ metadata.gz: 108a88a9ae16ed2aed8fee72dac815f4e045dbdca622437281c9f085b17b2f5bebc5ed85ced951a794993a8629dff5e55c15061fe13882c35fdbf0fde233b2ac
7
+ data.tar.gz: d5a189f8b196c691dce838a225dbfa6ba5e00e306c8b9bd29740f62ab3c281973509b5caab521c84262326f09f1f55932dd017df94cfd6b8f1741a69984cbba7
data/CHANGELOG.md CHANGED
@@ -5,11 +5,17 @@ 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.3.0] - 2025-08-29
9
+
10
+ ### Added
11
+
12
+ - Add Conversations API - thanks to [@parterburn](https://github.com/parterburn) for the great PR!
13
+
8
14
  ## [8.2.1] - 2025-08-29
9
15
 
10
16
  ### Fixed
11
17
 
12
- - Fix bug introduce in v8.2 which broke streaming with Faraday 2.1.0 - thanks to [@fabioxgn](https://github.com/fabioxgn) for the excellent PR!
18
+ - Fix bug introduce in v8.2 which broke streaming with Faraday 2.1.0 - thanks to [@daikimiura](https://github.com/daikimiura) for the excellent PR!
13
19
 
14
20
  ## [8.2.0] - 2025-08-10
15
21
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ruby-openai (8.2.1)
4
+ ruby-openai (8.3.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
@@ -77,6 +77,7 @@ Stream GPT-5 chats with the Responses API, initiate Realtime WebRTC conversation
77
77
  - [Vector Store Files](#vector-store-files)
78
78
  - [Vector Store File Batches](#vector-store-file-batches)
79
79
  - [Assistants](#assistants)
80
+ - [Conversations](#conversations)
80
81
  - [Threads and Messages](#threads-and-messages)
81
82
  - [Runs](#runs)
82
83
  - [Create and Run](#create-and-run)
@@ -1098,6 +1099,128 @@ client.vector_store_file_batches.cancel(
1098
1099
  )
1099
1100
  ```
1100
1101
 
1102
+ ### Conversations
1103
+
1104
+ The Conversations API enables you to create and manage persistent conversations with your models. This is useful for maintaining conversation state across multiple interactions.
1105
+
1106
+ **Supported Endpoints:**
1107
+ - `POST /v1/conversations` - Create a conversation
1108
+ - `GET /v1/conversations/{id}` - Retrieve a conversation
1109
+ - `PATCH /v1/conversations/{id}` - Modify a conversation
1110
+ - `DELETE /v1/conversations/{id}` - Delete a conversation
1111
+ - `POST /v1/conversations/{id}/items` - Create items in a conversation
1112
+ - `GET /v1/conversations/{id}/items` - List items in a conversation
1113
+ - `GET /v1/conversations/{id}/items/{item_id}` - Get a specific item
1114
+ - `DELETE /v1/conversations/{id}/items/{item_id}` - Delete an item
1115
+
1116
+ #### Creating a Conversation
1117
+
1118
+ To create a new conversation:
1119
+
1120
+ ```ruby
1121
+ response = client.conversations.create(
1122
+ parameters: {
1123
+ metadata: { purpose: "customer_support" }
1124
+ }
1125
+ )
1126
+ conversation_id = response["id"]
1127
+ ```
1128
+
1129
+ #### Retrieving a Conversation
1130
+
1131
+ To retrieve a specific conversation:
1132
+
1133
+ ```ruby
1134
+ conversation = client.conversations.retrieve(id: conversation_id)
1135
+ ```
1136
+
1137
+ #### Modifying a Conversation
1138
+
1139
+ To update a conversation's metadata:
1140
+
1141
+ ```ruby
1142
+ response = client.conversations.modify(
1143
+ id: conversation_id,
1144
+ parameters: {
1145
+ metadata: { status: "resolved" }
1146
+ }
1147
+ )
1148
+ ```
1149
+
1150
+ #### Deleting a Conversation
1151
+
1152
+ To delete a conversation:
1153
+
1154
+ ```ruby
1155
+ response = client.conversations.delete(id: conversation_id)
1156
+ ```
1157
+
1158
+ #### Managing Items in Conversations
1159
+
1160
+ You can add, retrieve, and manage items within a conversation.
1161
+
1162
+ ##### Creating Items
1163
+
1164
+ ```ruby
1165
+ # Create multiple items at once
1166
+ response = client.conversations.create_items(
1167
+ conversation_id: conversation_id,
1168
+ parameters: {
1169
+ items: [
1170
+ {
1171
+ type: "message",
1172
+ role: "user",
1173
+ content: [
1174
+ { type: "input_text", text: "Hello!" }
1175
+ ]
1176
+ },
1177
+ {
1178
+ type: "message",
1179
+ role: "assistant",
1180
+ content: [
1181
+ { type: "input_text", text: "How are you?" }
1182
+ ]
1183
+ }
1184
+ ]
1185
+ }
1186
+ )
1187
+ ```
1188
+
1189
+ ##### Listing Items
1190
+
1191
+ ```ruby
1192
+ # List all items in a conversation
1193
+ response = client.conversations.list_items(conversation_id: conversation_id)
1194
+ items = response["data"]
1195
+
1196
+ # With parameters
1197
+ response = client.conversations.list_items(
1198
+ conversation_id: conversation_id,
1199
+ parameters: {
1200
+ limit: 10,
1201
+ order: "asc"
1202
+ }
1203
+ )
1204
+ ```
1205
+
1206
+ ##### Retrieving a Specific Item
1207
+
1208
+ ```ruby
1209
+ item = client.conversations.get_item(
1210
+ conversation_id: conversation_id,
1211
+ item_id: item_id
1212
+ )
1213
+ ```
1214
+
1215
+ ##### Deleting an Item
1216
+
1217
+ ```ruby
1218
+ response = client.conversations.delete_item(
1219
+ conversation_id: conversation_id,
1220
+ item_id: item_id
1221
+ )
1222
+ ```
1223
+
1101
1224
  ### Assistants
1102
1225
 
1103
1226
  Assistants are stateful actors that can have many conversations and use tools to perform tasks (see [Assistant Overview](https://platform.openai.com/docs/assistants/overview)).
data/lib/openai/client.rb CHANGED
@@ -105,6 +105,10 @@ module OpenAI
105
105
  @usage ||= OpenAI::Usage.new(client: self)
106
106
  end
107
107
 
108
+ def conversations
109
+ @conversations ||= OpenAI::Conversations.new(client: self)
110
+ end
111
+
108
112
  def azure?
109
113
  @api_type&.to_sym == :azure
110
114
  end
@@ -0,0 +1,40 @@
1
+ module OpenAI
2
+ class Conversations
3
+ def initialize(client:)
4
+ @client = client
5
+ end
6
+
7
+ def retrieve(id:)
8
+ @client.get(path: "/conversations/#{id}")
9
+ end
10
+
11
+ def create(parameters: {})
12
+ @client.json_post(path: "/conversations", parameters: parameters)
13
+ end
14
+
15
+ def modify(id:, parameters: {})
16
+ @client.json_post(path: "/conversations/#{id}", parameters: parameters)
17
+ end
18
+
19
+ def delete(id:)
20
+ @client.delete(path: "/conversations/#{id}")
21
+ end
22
+
23
+ # Item operations within a conversation
24
+ def create_items(conversation_id:, parameters: {})
25
+ @client.json_post(path: "/conversations/#{conversation_id}/items", parameters: parameters)
26
+ end
27
+
28
+ def list_items(conversation_id:, parameters: {})
29
+ @client.get(path: "/conversations/#{conversation_id}/items", parameters: parameters)
30
+ end
31
+
32
+ def get_item(conversation_id:, item_id:)
33
+ @client.get(path: "/conversations/#{conversation_id}/items/#{item_id}")
34
+ end
35
+
36
+ def delete_item(conversation_id:, item_id:)
37
+ @client.delete(path: "/conversations/#{conversation_id}/items/#{item_id}")
38
+ end
39
+ end
40
+ end
@@ -1,3 +1,3 @@
1
1
  module OpenAI
2
- VERSION = "8.2.1".freeze
2
+ VERSION = "8.3.0".freeze
3
3
  end
data/lib/openai.rb CHANGED
@@ -21,6 +21,7 @@ require_relative "openai/audio"
21
21
  require_relative "openai/version"
22
22
  require_relative "openai/batches"
23
23
  require_relative "openai/usage"
24
+ require_relative "openai/conversations"
24
25
 
25
26
  module OpenAI
26
27
  class Error < StandardError; end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-openai
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.2.1
4
+ version: 8.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex
@@ -90,6 +90,7 @@ files:
90
90
  - lib/openai/audio.rb
91
91
  - lib/openai/batches.rb
92
92
  - lib/openai/client.rb
93
+ - lib/openai/conversations.rb
93
94
  - lib/openai/files.rb
94
95
  - lib/openai/finetunes.rb
95
96
  - lib/openai/http.rb