ruby-openai 8.2.0 → 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 +4 -4
- data/CHANGELOG.md +12 -0
- data/Gemfile.lock +1 -1
- data/README.md +125 -0
- data/lib/openai/client.rb +4 -0
- data/lib/openai/conversations.rb +40 -0
- data/lib/openai/stream.rb +1 -1
- data/lib/openai/version.rb +1 -1
- data/lib/openai.rb +1 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f5bfc460a4cb2984e54d01cf39ebd6bd20a73fb0ddb6ffd271d14e6100fe568
|
4
|
+
data.tar.gz: 7a01a225d40f4265762a1e14a31dae19dff5535f8626336cfba0b5780a96cc57
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 108a88a9ae16ed2aed8fee72dac815f4e045dbdca622437281c9f085b17b2f5bebc5ed85ced951a794993a8629dff5e55c15061fe13882c35fdbf0fde233b2ac
|
7
|
+
data.tar.gz: d5a189f8b196c691dce838a225dbfa6ba5e00e306c8b9bd29740f62ab3c281973509b5caab521c84262326f09f1f55932dd017df94cfd6b8f1741a69984cbba7
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,18 @@ 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
|
+
|
14
|
+
## [8.2.1] - 2025-08-29
|
15
|
+
|
16
|
+
### Fixed
|
17
|
+
|
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!
|
19
|
+
|
8
20
|
## [8.2.0] - 2025-08-10
|
9
21
|
|
10
22
|
### Added
|
data/Gemfile.lock
CHANGED
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)
|
@@ -547,6 +548,8 @@ response = client.responses.create(parameters: {
|
|
547
548
|
}
|
548
549
|
})
|
549
550
|
puts response.dig("output", 0, "content", 0, "text")
|
551
|
+
# => Thinking about how to answer this...
|
552
|
+
puts response.dig("output", 1, "content", 0, "text")
|
550
553
|
# => Hi Szymon! Great to meet you. How can I help today?
|
551
554
|
```
|
552
555
|
|
@@ -1096,6 +1099,128 @@ client.vector_store_file_batches.cancel(
|
|
1096
1099
|
)
|
1097
1100
|
```
|
1098
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
|
+
|
1099
1224
|
### Assistants
|
1100
1225
|
|
1101
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
@@ -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
|
data/lib/openai/stream.rb
CHANGED
data/lib/openai/version.rb
CHANGED
data/lib/openai.rb
CHANGED
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.
|
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
|