Skip to content

Commit a47219b

Browse files
committed
fix(client): update StructuredResponse with Prompt details
1 parent ec235f7 commit a47219b

File tree

4 files changed

+24
-2
lines changed

4 files changed

+24
-2
lines changed

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class StructuredResponse<T : Any>(
3232
fun incompleteDetails(): Optional<Response.IncompleteDetails> = rawResponse.incompleteDetails()
3333

3434
/** @see Response.instructions */
35-
fun instructions(): Optional<String> = rawResponse.instructions()
35+
fun instructions(): Optional<Response.Instructions> = rawResponse.instructions()
3636

3737
/** @see Response.metadata */
3838
fun metadata(): Optional<Response.Metadata> = rawResponse.metadata()
@@ -73,6 +73,9 @@ class StructuredResponse<T : Any>(
7373
/** @see Response.previousResponseId */
7474
fun previousResponseId(): Optional<String> = rawResponse.previousResponseId()
7575

76+
/** @see Response.prompt */
77+
fun prompt(): Optional<ResponsePrompt> = rawResponse.prompt()
78+
7679
/** @see Response.reasoning */
7780
fun reasoning(): Optional<Reasoning> = rawResponse.reasoning()
7881

@@ -111,7 +114,7 @@ class StructuredResponse<T : Any>(
111114
rawResponse._incompleteDetails()
112115

113116
/** @see Response._instructions */
114-
fun _instructions(): JsonField<String> = rawResponse._instructions()
117+
fun _instructions(): JsonField<Response.Instructions> = rawResponse._instructions()
115118

116119
/** @see Response._metadata */
117120
fun _metadata(): JsonField<Response.Metadata> = rawResponse._metadata()
@@ -143,6 +146,9 @@ class StructuredResponse<T : Any>(
143146
/** @see Response._previousResponseId */
144147
fun _previousResponseId(): JsonField<String> = rawResponse._previousResponseId()
145148

149+
/** @see Response._prompt */
150+
fun _prompt(): JsonField<ResponsePrompt> = rawResponse._prompt()
151+
146152
/** @see Response._reasoning */
147153
fun _reasoning(): JsonField<Reasoning> = rawResponse._reasoning()
148154

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,15 @@ class StructuredResponseCreateParams<T : Any>(
205205
paramsBuilder.previousResponseId(previousResponseId)
206206
}
207207

208+
/** @see ResponseCreateParams.Builder.prompt */
209+
fun prompt(prompt: ResponsePrompt?) = apply { paramsBuilder.prompt(prompt) }
210+
211+
/** @see ResponseCreateParams.Builder.prompt */
212+
fun prompt(prompt: Optional<ResponsePrompt>) = apply { paramsBuilder.prompt(prompt) }
213+
214+
/** @see ResponseCreateParams.Builder.prompt */
215+
fun prompt(prompt: JsonField<ResponsePrompt>) = apply { paramsBuilder.prompt(prompt) }
216+
208217
/** @see ResponseCreateParams.Builder.reasoning */
209218
fun reasoning(reasoning: Reasoning?) = apply { paramsBuilder.reasoning(reasoning) }
210219

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import com.openai.core.textConfigFromClass
2929
import com.openai.models.ChatModel
3030
import com.openai.models.Reasoning
3131
import com.openai.models.ResponsesModel
32+
import com.openai.models.completions.CompletionCreateParams
3233
import org.junit.jupiter.api.Test
3334
import org.junit.jupiter.params.ParameterizedTest
3435
import org.junit.jupiter.params.provider.MethodSource
@@ -59,6 +60,7 @@ internal class StructuredResponseCreateParamsTest {
5960
private val METADATA = ResponseCreateParams.Metadata.builder().build()
6061
private val SERVICE_TIER = ResponseCreateParams.ServiceTier.AUTO
6162
private val REASONING = Reasoning.builder().build()
63+
private val PROMPT = ResponsePrompt.builder().build()
6264

6365
private val TOOL_CHOICE_TYPE = ToolChoiceTypes.Type.FILE_SEARCH
6466
private val TOOL_CHOICE_TYPES = ToolChoiceTypes.builder().type(TOOL_CHOICE_TYPE).build()
@@ -132,6 +134,9 @@ internal class StructuredResponseCreateParamsTest {
132134
DelegationWriteTestCase("previousResponseId", NULLABLE_STRING),
133135
DelegationWriteTestCase("previousResponseId", OPTIONAL),
134136
DelegationWriteTestCase("previousResponseId", JSON_FIELD),
137+
DelegationWriteTestCase("prompt", PROMPT),
138+
DelegationWriteTestCase("prompt", OPTIONAL),
139+
DelegationWriteTestCase("prompt", JSON_FIELD),
135140
DelegationWriteTestCase("reasoning", REASONING),
136141
DelegationWriteTestCase("reasoning", OPTIONAL),
137142
DelegationWriteTestCase("reasoning", JSON_FIELD),

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ internal class StructuredResponseTest {
7171
DelegationReadTestCase("topP", OPTIONAL),
7272
DelegationReadTestCase("maxOutputTokens", OPTIONAL),
7373
DelegationReadTestCase("previousResponseId", OPTIONAL),
74+
DelegationReadTestCase("prompt", OPTIONAL),
7475
DelegationReadTestCase("reasoning", OPTIONAL),
7576
DelegationReadTestCase("serviceTier", OPTIONAL),
7677
DelegationReadTestCase("status", OPTIONAL),
@@ -93,6 +94,7 @@ internal class StructuredResponseTest {
9394
DelegationReadTestCase("_topP", JSON_FIELD),
9495
DelegationReadTestCase("_maxOutputTokens", JSON_FIELD),
9596
DelegationReadTestCase("_previousResponseId", JSON_FIELD),
97+
DelegationReadTestCase("_prompt", JSON_FIELD),
9698
DelegationReadTestCase("_reasoning", JSON_FIELD),
9799
DelegationReadTestCase("_serviceTier", JSON_FIELD),
98100
DelegationReadTestCase("_status", JSON_FIELD),

0 commit comments

Comments
 (0)