Skip to content

Commit da0fb59

Browse files
feat(api): add context_management to responses
1 parent 5c01787 commit da0fb59

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

openai-java-core/src/main/kotlin/com/openai/models/responses/StructuredResponseCreateParams.kt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,28 @@ class StructuredResponseCreateParams<T : Any>(
116116
paramsBuilder.background(background)
117117
}
118118

119+
/** @see ResponseCreateParams.Builder.contextManagement */
120+
fun contextManagement(contextManagement: List<ResponseCreateParams.ContextManagement>?) =
121+
apply {
122+
paramsBuilder.contextManagement(contextManagement)
123+
}
124+
125+
/** @see ResponseCreateParams.Builder.contextManagement */
126+
fun contextManagement(
127+
contextManagement: Optional<List<ResponseCreateParams.ContextManagement>>
128+
) = apply { paramsBuilder.contextManagement(contextManagement) }
129+
130+
/** @see ResponseCreateParams.Builder.contextManagement */
131+
fun contextManagement(
132+
contextManagement: JsonField<List<ResponseCreateParams.ContextManagement>>
133+
) = apply { paramsBuilder.contextManagement(contextManagement) }
134+
135+
/** @see ResponseCreateParams.Builder.addContextManagement */
136+
fun addContextManagement(contextManagement: ResponseCreateParams.ContextManagement) =
137+
apply {
138+
paramsBuilder.addContextManagement(contextManagement)
139+
}
140+
119141
/** @see ResponseCreateParams.Builder.conversation */
120142
fun conversation(conversation: ResponseCreateParams.Conversation?) = apply {
121143
paramsBuilder.conversation(conversation)

openai-java-core/src/test/kotlin/com/openai/models/responses/StructuredResponseCreateParamsTest.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ internal class StructuredResponseCreateParamsTest {
6565
private val RESPONSE_CONVERSATION_PARAM =
6666
ResponseConversationParam.builder().id(STRING).build()
6767
private val CONVERSATION = ResponseCreateParams.Conversation.ofId(STRING)
68+
private val CONTEXT_MANAGEMENT =
69+
ResponseCreateParams.ContextManagement.builder().type(STRING).build()
6870
private val PROMPT_CACHE_RETENTION = ResponseCreateParams.PromptCacheRetention.IN_MEMORY
6971
private val PROMPT_CACHE_RETENTION_OPTIONAL = Optional.of(PROMPT_CACHE_RETENTION)
7072
private val PROMPT_CACHE_RETENTION_JSON_FIELD = JsonField.of(PROMPT_CACHE_RETENTION)
@@ -136,6 +138,10 @@ internal class StructuredResponseCreateParamsTest {
136138
DelegationWriteTestCase("background", BOOLEAN),
137139
DelegationWriteTestCase("background", OPTIONAL),
138140
DelegationWriteTestCase("background", JSON_FIELD),
141+
DelegationWriteTestCase("contextManagement", LIST),
142+
DelegationWriteTestCase("contextManagement", OPTIONAL),
143+
DelegationWriteTestCase("contextManagement", JSON_FIELD),
144+
DelegationWriteTestCase("addContextManagement", CONTEXT_MANAGEMENT),
139145
DelegationWriteTestCase("conversation", CONVERSATION),
140146
DelegationWriteTestCase("conversation", OPTIONAL),
141147
DelegationWriteTestCase("conversation", JSON_FIELD),

0 commit comments

Comments
 (0)