Skip to content

Commit b5d76ac

Browse files
chore(api): specification cleanup
1 parent 413fd63 commit b5d76ac

File tree

4 files changed

+104
-3
lines changed

4 files changed

+104
-3
lines changed

.stats.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 88
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-2d116cda53321baa3479e628512def723207a81eb1cdaebb542bd0555e563bda.yml
3-
openapi_spec_hash: 809d958fec261a32004a4b026b718793
4-
config_hash: 5ef02e55671aae1ba9bd62fe4eb0f50f
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-de3e91790d0b9f3ce26d679ac07079880ccc695bd8c878f961c4d577a5025a2e.yml
3+
openapi_spec_hash: 4b44e3f287583d01fbe7b10cd943254a
4+
config_hash: 06b9a88561844d60d8efa4eaabf5fa3c

openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionCreateParams.kt

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -813,6 +813,39 @@ private constructor(
813813
/** Alias for calling [addMessage] with `assistant.toParam()`. */
814814
fun addMessage(assistant: ChatCompletionMessage) = apply { body.addMessage(assistant) }
815815

816+
/**
817+
* Alias for calling [addMessage] with the following:
818+
* ```java
819+
* ChatCompletionAssistantMessageParam.builder()
820+
* .content(content)
821+
* .build()
822+
* ```
823+
*/
824+
fun addAssistantMessage(content: ChatCompletionAssistantMessageParam.Content?) = apply {
825+
body.addAssistantMessage(content)
826+
}
827+
828+
/** Alias for calling [addAssistantMessage] with `content.orElse(null)`. */
829+
fun addAssistantMessage(content: Optional<ChatCompletionAssistantMessageParam.Content>) =
830+
addAssistantMessage(content.getOrNull())
831+
832+
/**
833+
* Alias for calling [addAssistantMessage] with
834+
* `ChatCompletionAssistantMessageParam.Content.ofText(text)`.
835+
*/
836+
fun addAssistantMessage(text: String) = apply { body.addAssistantMessage(text) }
837+
838+
/**
839+
* Alias for calling [addAssistantMessage] with
840+
* `ChatCompletionAssistantMessageParam.Content.ofArrayOfContentParts(arrayOfContentParts)`.
841+
*/
842+
fun addAssistantMessageOfArrayOfContentParts(
843+
arrayOfContentParts:
844+
List<
845+
ChatCompletionAssistantMessageParam.Content.ChatCompletionRequestAssistantMessageContentPart
846+
>
847+
) = apply { body.addAssistantMessageOfArrayOfContentParts(arrayOfContentParts) }
848+
816849
/** Alias for calling [addMessage] with `ChatCompletionMessageParam.ofTool(tool)`. */
817850
fun addMessage(tool: ChatCompletionToolMessageParam) = apply { body.addMessage(tool) }
818851

@@ -2816,6 +2849,45 @@ private constructor(
28162849
/** Alias for calling [addMessage] with `assistant.toParam()`. */
28172850
fun addMessage(assistant: ChatCompletionMessage) = addMessage(assistant.toParam())
28182851

2852+
/**
2853+
* Alias for calling [addMessage] with the following:
2854+
* ```java
2855+
* ChatCompletionAssistantMessageParam.builder()
2856+
* .content(content)
2857+
* .build()
2858+
* ```
2859+
*/
2860+
fun addAssistantMessage(content: ChatCompletionAssistantMessageParam.Content?) =
2861+
addMessage(ChatCompletionAssistantMessageParam.builder().content(content).build())
2862+
2863+
/** Alias for calling [addAssistantMessage] with `content.orElse(null)`. */
2864+
fun addAssistantMessage(
2865+
content: Optional<ChatCompletionAssistantMessageParam.Content>
2866+
) = addAssistantMessage(content.getOrNull())
2867+
2868+
/**
2869+
* Alias for calling [addAssistantMessage] with
2870+
* `ChatCompletionAssistantMessageParam.Content.ofText(text)`.
2871+
*/
2872+
fun addAssistantMessage(text: String) =
2873+
addAssistantMessage(ChatCompletionAssistantMessageParam.Content.ofText(text))
2874+
2875+
/**
2876+
* Alias for calling [addAssistantMessage] with
2877+
* `ChatCompletionAssistantMessageParam.Content.ofArrayOfContentParts(arrayOfContentParts)`.
2878+
*/
2879+
fun addAssistantMessageOfArrayOfContentParts(
2880+
arrayOfContentParts:
2881+
List<
2882+
ChatCompletionAssistantMessageParam.Content.ChatCompletionRequestAssistantMessageContentPart
2883+
>
2884+
) =
2885+
addAssistantMessage(
2886+
ChatCompletionAssistantMessageParam.Content.ofArrayOfContentParts(
2887+
arrayOfContentParts
2888+
)
2889+
)
2890+
28192891
/** Alias for calling [addMessage] with `ChatCompletionMessageParam.ofTool(tool)`. */
28202892
fun addMessage(tool: ChatCompletionToolMessageParam) =
28212893
addMessage(ChatCompletionMessageParam.ofTool(tool))

openai-java-core/src/main/kotlin/com/openai/models/chat/completions/StructuredChatCompletionCreateParams.kt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,28 @@ internal constructor(
139139
paramsBuilder.addMessage(assistant)
140140
}
141141

142+
/** @see ChatCompletionCreateParams.Builder.addAssistantMessage */
143+
fun addAssistantMessage(content: ChatCompletionAssistantMessageParam.Content?) = apply {
144+
paramsBuilder.addAssistantMessage(content)
145+
}
146+
147+
/** @see ChatCompletionCreateParams.Builder.addAssistantMessage */
148+
fun addAssistantMessage(content: Optional<ChatCompletionAssistantMessageParam.Content>) =
149+
apply {
150+
paramsBuilder.addAssistantMessage(content)
151+
}
152+
153+
/** @see ChatCompletionCreateParams.Builder.addAssistantMessage */
154+
fun addAssistantMessage(text: String) = apply { paramsBuilder.addAssistantMessage(text) }
155+
156+
/** @see ChatCompletionCreateParams.Builder.addAssistantMessageOfArrayOfContentParts */
157+
fun addAssistantMessageOfArrayOfContentParts(
158+
arrayOfContentParts:
159+
List<
160+
ChatCompletionAssistantMessageParam.Content.ChatCompletionRequestAssistantMessageContentPart
161+
>
162+
) = apply { paramsBuilder.addAssistantMessageOfArrayOfContentParts(arrayOfContentParts) }
163+
142164
/** @see ChatCompletionCreateParams.Builder.addMessage */
143165
fun addMessage(tool: ChatCompletionToolMessageParam) = apply {
144166
paramsBuilder.addMessage(tool)

openai-java-core/src/test/kotlin/com/openai/models/chat/completions/StructuredChatCompletionCreateParamsTest.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ internal class StructuredChatCompletionCreateParamsTest {
6868
ChatCompletionFunctionMessageParam.builder().content(STRING).name(STRING).build()
6969
private val MESSAGE_PARAM = ChatCompletionMessageParam.ofUser(USER_MESSAGE_PARAM)
7070

71+
private val ASSISTANT_MESSAGE_PARAM_CONTENT =
72+
ChatCompletionAssistantMessageParam.Content.ofText(STRING)
73+
7174
private val DEV_MESSAGE_PARAM_CONTENT =
7275
ChatCompletionDeveloperMessageParam.Content.ofText(STRING)
7376
private val SYS_MESSAGE_PARAM_CONTENT =
@@ -119,6 +122,10 @@ internal class StructuredChatCompletionCreateParamsTest {
119122
DelegationWriteTestCase("messages", JSON_FIELD),
120123
DelegationWriteTestCase("addMessage", MESSAGE_PARAM),
121124
DelegationWriteTestCase("addMessage", DEV_MESSAGE_PARAM),
125+
DelegationWriteTestCase("addAssistantMessage", ASSISTANT_MESSAGE_PARAM_CONTENT),
126+
DelegationWriteTestCase("addAssistantMessage", OPTIONAL),
127+
DelegationWriteTestCase("addAssistantMessage", STRING),
128+
DelegationWriteTestCase("addAssistantMessageOfArrayOfContentParts", LIST),
122129
DelegationWriteTestCase("addDeveloperMessage", DEV_MESSAGE_PARAM_CONTENT),
123130
DelegationWriteTestCase("addDeveloperMessage", STRING),
124131
DelegationWriteTestCase("addDeveloperMessageOfArrayOfContentParts", LIST),

0 commit comments

Comments
 (0)