Skip to content

Commit 024566f

Browse files
chore(api): openapi updates for conversations
1 parent da4dd05 commit 024566f

File tree

8 files changed

+47
-32
lines changed

8 files changed

+47
-32
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

openai-java-core/src/main/kotlin/com/openai/models/conversations/ConversationCreateParams.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,6 @@ private constructor(
438438

439439
override fun _queryParams(): QueryParams = additionalQueryParams
440440

441-
/** Create a conversation */
442441
class Body
443442
private constructor(
444443
private val items: JsonField<List<ResponseInputItem>>,

openai-java-core/src/main/kotlin/com/openai/models/conversations/ConversationDeleteParams.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import java.util.Objects
1111
import java.util.Optional
1212
import kotlin.jvm.optionals.getOrNull
1313

14-
/** Delete a conversation with the given ID. */
14+
/** Delete a conversation. Items in the conversation will not be deleted. */
1515
class ConversationDeleteParams
1616
private constructor(
1717
private val conversationId: String?,

openai-java-core/src/main/kotlin/com/openai/models/conversations/ConversationRetrieveParams.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import java.util.Objects
99
import java.util.Optional
1010
import kotlin.jvm.optionals.getOrNull
1111

12-
/** Get a conversation with the given ID. */
12+
/** Get a conversation */
1313
class ConversationRetrieveParams
1414
private constructor(
1515
private val conversationId: String?,

openai-java-core/src/main/kotlin/com/openai/models/conversations/ConversationUpdateParams.kt

Lines changed: 36 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import java.util.Objects
2121
import java.util.Optional
2222
import kotlin.jvm.optionals.getOrNull
2323

24-
/** Update a conversation's metadata with the given ID. */
24+
/** Update a conversation */
2525
class ConversationUpdateParams
2626
private constructor(
2727
private val conversationId: String?,
@@ -35,13 +35,15 @@ private constructor(
3535
/**
3636
* Set of 16 key-value pairs that can be attached to an object. This can be useful for storing
3737
* additional information about the object in a structured format, and querying for objects via
38-
* API or the dashboard. Keys are strings with a maximum length of 64 characters. Values are
39-
* strings with a maximum length of 512 characters.
38+
* API or the dashboard.
4039
*
41-
* @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is
42-
* unexpectedly missing or null (e.g. if the server responded with an unexpected value).
40+
* Keys are strings with a maximum length of 64 characters. Values are strings with a maximum
41+
* length of 512 characters.
42+
*
43+
* @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the
44+
* server responded with an unexpected value).
4345
*/
44-
fun metadata(): Metadata = body.metadata()
46+
fun metadata(): Optional<Metadata> = body.metadata()
4547

4648
/**
4749
* Returns the raw JSON value of [metadata].
@@ -107,10 +109,15 @@ private constructor(
107109
/**
108110
* Set of 16 key-value pairs that can be attached to an object. This can be useful for
109111
* storing additional information about the object in a structured format, and querying for
110-
* objects via API or the dashboard. Keys are strings with a maximum length of 64
111-
* characters. Values are strings with a maximum length of 512 characters.
112+
* objects via API or the dashboard.
113+
*
114+
* Keys are strings with a maximum length of 64 characters. Values are strings with a
115+
* maximum length of 512 characters.
112116
*/
113-
fun metadata(metadata: Metadata) = apply { body.metadata(metadata) }
117+
fun metadata(metadata: Metadata?) = apply { body.metadata(metadata) }
118+
119+
/** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */
120+
fun metadata(metadata: Optional<Metadata>) = metadata(metadata.getOrNull())
114121

115122
/**
116123
* Sets [Builder.metadata] to an arbitrary JSON value.
@@ -287,13 +294,15 @@ private constructor(
287294
/**
288295
* Set of 16 key-value pairs that can be attached to an object. This can be useful for
289296
* storing additional information about the object in a structured format, and querying for
290-
* objects via API or the dashboard. Keys are strings with a maximum length of 64
291-
* characters. Values are strings with a maximum length of 512 characters.
297+
* objects via API or the dashboard.
298+
*
299+
* Keys are strings with a maximum length of 64 characters. Values are strings with a
300+
* maximum length of 512 characters.
292301
*
293-
* @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is
294-
* unexpectedly missing or null (e.g. if the server responded with an unexpected value).
302+
* @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the
303+
* server responded with an unexpected value).
295304
*/
296-
fun metadata(): Metadata = metadata.getRequired("metadata")
305+
fun metadata(): Optional<Metadata> = metadata.getOptional("metadata")
297306

298307
/**
299308
* Returns the raw JSON value of [metadata].
@@ -342,10 +351,15 @@ private constructor(
342351
/**
343352
* Set of 16 key-value pairs that can be attached to an object. This can be useful for
344353
* storing additional information about the object in a structured format, and querying
345-
* for objects via API or the dashboard. Keys are strings with a maximum length of 64
346-
* characters. Values are strings with a maximum length of 512 characters.
354+
* for objects via API or the dashboard.
355+
*
356+
* Keys are strings with a maximum length of 64 characters. Values are strings with a
357+
* maximum length of 512 characters.
347358
*/
348-
fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata))
359+
fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata))
360+
361+
/** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */
362+
fun metadata(metadata: Optional<Metadata>) = metadata(metadata.getOrNull())
349363

350364
/**
351365
* Sets [Builder.metadata] to an arbitrary JSON value.
@@ -398,7 +412,7 @@ private constructor(
398412
return@apply
399413
}
400414

401-
metadata().validate()
415+
metadata().ifPresent { it.validate() }
402416
validated = true
403417
}
404418

@@ -440,8 +454,10 @@ private constructor(
440454
/**
441455
* Set of 16 key-value pairs that can be attached to an object. This can be useful for storing
442456
* additional information about the object in a structured format, and querying for objects via
443-
* API or the dashboard. Keys are strings with a maximum length of 64 characters. Values are
444-
* strings with a maximum length of 512 characters.
457+
* API or the dashboard.
458+
*
459+
* Keys are strings with a maximum length of 64 characters. Values are strings with a maximum
460+
* length of 512 characters.
445461
*/
446462
class Metadata
447463
@JsonCreator

openai-java-core/src/main/kotlin/com/openai/services/async/ConversationServiceAsync.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ interface ConversationServiceAsync {
4949
fun create(requestOptions: RequestOptions): CompletableFuture<Conversation> =
5050
create(ConversationCreateParams.none(), requestOptions)
5151

52-
/** Get a conversation with the given ID. */
52+
/** Get a conversation */
5353
fun retrieve(conversationId: String): CompletableFuture<Conversation> =
5454
retrieve(conversationId, ConversationRetrieveParams.none())
5555

@@ -84,7 +84,7 @@ interface ConversationServiceAsync {
8484
): CompletableFuture<Conversation> =
8585
retrieve(conversationId, ConversationRetrieveParams.none(), requestOptions)
8686

87-
/** Update a conversation's metadata with the given ID. */
87+
/** Update a conversation */
8888
fun update(
8989
conversationId: String,
9090
params: ConversationUpdateParams,
@@ -108,7 +108,7 @@ interface ConversationServiceAsync {
108108
requestOptions: RequestOptions = RequestOptions.none(),
109109
): CompletableFuture<Conversation>
110110

111-
/** Delete a conversation with the given ID. */
111+
/** Delete a conversation. Items in the conversation will not be deleted. */
112112
fun delete(conversationId: String): CompletableFuture<ConversationDeletedResource> =
113113
delete(conversationId, ConversationDeleteParams.none())
114114

openai-java-core/src/main/kotlin/com/openai/services/blocking/ConversationService.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ interface ConversationService {
4848
fun create(requestOptions: RequestOptions): Conversation =
4949
create(ConversationCreateParams.none(), requestOptions)
5050

51-
/** Get a conversation with the given ID. */
51+
/** Get a conversation */
5252
fun retrieve(conversationId: String): Conversation =
5353
retrieve(conversationId, ConversationRetrieveParams.none())
5454

@@ -80,7 +80,7 @@ interface ConversationService {
8080
fun retrieve(conversationId: String, requestOptions: RequestOptions): Conversation =
8181
retrieve(conversationId, ConversationRetrieveParams.none(), requestOptions)
8282

83-
/** Update a conversation's metadata with the given ID. */
83+
/** Update a conversation */
8484
fun update(conversationId: String, params: ConversationUpdateParams): Conversation =
8585
update(conversationId, params, RequestOptions.none())
8686

@@ -102,7 +102,7 @@ interface ConversationService {
102102
requestOptions: RequestOptions = RequestOptions.none(),
103103
): Conversation
104104

105-
/** Delete a conversation with the given ID. */
105+
/** Delete a conversation. Items in the conversation will not be deleted. */
106106
fun delete(conversationId: String): ConversationDeletedResource =
107107
delete(conversationId, ConversationDeleteParams.none())
108108

openai-java-core/src/test/kotlin/com/openai/models/conversations/ConversationUpdateParamsTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ internal class ConversationUpdateParamsTest {
5252
val body = params._body()
5353

5454
assertThat(body.metadata())
55-
.isEqualTo(
55+
.contains(
5656
ConversationUpdateParams.Metadata.builder()
5757
.putAdditionalProperty("foo", JsonValue.from("string"))
5858
.build()

0 commit comments

Comments
 (0)