Skip to content

Commit 2b98ebb

Browse files
chore(api): openapi updates for conversations
1 parent 5f7e020 commit 2b98ebb

File tree

4 files changed

+26
-11
lines changed

4 files changed

+26
-11
lines changed

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 118
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-65d42621b731238ad4e59a35a705fc0608b17f53a14d047e66ce480c793da26b.yml
3-
openapi_spec_hash: d7ca86b2507600cbd5ed197cf31263c2
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-937fcfac8cbab692796cd9822b37e48a311e2220a8b103106ded0ee92a0b9484.yml
3+
openapi_spec_hash: 74a0c58b5b8c4e06792d79b685e02a01
44
config_hash: 666d6bb4b564f0d9d431124b5d1a0665

MIGRATION.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ client.example.list(undefined, { headers: { ... } });
133133
- `client.batches.list()`
134134
- `client.responses.retrieve()`
135135
- `client.responses.inputItems.list()`
136+
- `client.conversations.create()`
136137
- `client.conversations.items.list()`
137138
- `client.evals.list()`
138139
- `client.evals.runs.list()`

src/resources/conversations/conversations.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,22 @@ export class Conversations extends APIResource {
2424
/**
2525
* Create a conversation.
2626
*/
27-
create(body: ConversationCreateParams, options?: RequestOptions): APIPromise<Conversation> {
27+
create(
28+
body: ConversationCreateParams | null | undefined = {},
29+
options?: RequestOptions,
30+
): APIPromise<Conversation> {
2831
return this._client.post('/conversations', { body, ...options });
2932
}
3033

3134
/**
32-
* Get a conversation with the given ID.
35+
* Get a conversation
3336
*/
3437
retrieve(conversationID: string, options?: RequestOptions): APIPromise<Conversation> {
3538
return this._client.get(path`/conversations/${conversationID}`, options);
3639
}
3740

3841
/**
39-
* Update a conversation's metadata with the given ID.
42+
* Update a conversation
4043
*/
4144
update(
4245
conversationID: string,
@@ -47,7 +50,7 @@ export class Conversations extends APIResource {
4750
}
4851

4952
/**
50-
* Delete a conversation with the given ID.
53+
* Delete a conversation. Items in the conversation will not be deleted.
5154
*/
5255
delete(conversationID: string, options?: RequestOptions): APIPromise<ConversationDeletedResource> {
5356
return this._client.delete(path`/conversations/${conversationID}`, options);
@@ -233,11 +236,12 @@ export interface ConversationUpdateParams {
233236
/**
234237
* Set of 16 key-value pairs that can be attached to an object. This can be useful
235238
* for storing additional information about the object in a structured format, and
236-
* querying for objects via API or the dashboard. Keys are strings with a maximum
237-
* length of 64 characters. Values are strings with a maximum length of 512
238-
* characters.
239+
* querying for objects via API or the dashboard.
240+
*
241+
* Keys are strings with a maximum length of 64 characters. Values are strings with
242+
* a maximum length of 512 characters.
239243
*/
240-
metadata: { [key: string]: string };
244+
metadata: Shared.Metadata | null;
241245
}
242246

243247
Conversations.Items = Items;

tests/api-resources/conversations/conversations.test.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const client = new OpenAI({
99

1010
describe('resource conversations', () => {
1111
test('create', async () => {
12-
const responsePromise = client.conversations.create({});
12+
const responsePromise = client.conversations.create();
1313
const rawResponse = await responsePromise.asResponse();
1414
expect(rawResponse).toBeInstanceOf(Response);
1515
const response = await responsePromise;
@@ -19,6 +19,16 @@ describe('resource conversations', () => {
1919
expect(dataAndResponse.response).toBe(rawResponse);
2020
});
2121

22+
test('create: request options and params are passed correctly', async () => {
23+
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
24+
await expect(
25+
client.conversations.create(
26+
{ items: [{ content: 'string', role: 'user', type: 'message' }], metadata: { foo: 'string' } },
27+
{ path: '/_stainless_unknown_path' },
28+
),
29+
).rejects.toThrow(OpenAI.NotFoundError);
30+
});
31+
2232
test('retrieve', async () => {
2333
const responsePromise = client.conversations.retrieve('conv_123');
2434
const rawResponse = await responsePromise.asResponse();

0 commit comments

Comments
 (0)