Skip to content

Commit 56f22a1

Browse files
fix(responses): correct computer use enum value (#298)
1 parent d742459 commit 56f22a1

File tree

5 files changed

+24
-24
lines changed

5 files changed

+24
-24
lines changed

.stats.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
configured_endpoints: 78
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-3dcde80cac724357b8cdc20deff52a568447d6518ac1e7be98818d231660b9db.yml
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-9ce5257763fb30c6e0e1ee2bef7e13baf661511e09572207e528d643da8e16b3.yml

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ private constructor(
8181
displayWidth()
8282
environment()
8383
_type().let {
84-
if (it != JsonValue.from("computer-preview")) {
84+
if (it != JsonValue.from("computer_use_preview")) {
8585
throw OpenAIInvalidDataException("'type' is invalid, received $it")
8686
}
8787
}
@@ -111,7 +111,7 @@ private constructor(
111111
private var displayHeight: JsonField<Double>? = null
112112
private var displayWidth: JsonField<Double>? = null
113113
private var environment: JsonField<Environment>? = null
114-
private var type: JsonValue = JsonValue.from("computer-preview")
114+
private var type: JsonValue = JsonValue.from("computer_use_preview")
115115
private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf()
116116

117117
@JvmSynthetic

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -885,8 +885,8 @@ private constructor(
885885
* A tool that controls a virtual computer. Learn more about the
886886
* [computer tool](https://platform.openai.com/docs/guides/tools-computer-use).
887887
*/
888-
fun addTool(computerPreview: ComputerTool) =
889-
addTool(Tool.ofComputerPreview(computerPreview))
888+
fun addTool(computerUsePreview: ComputerTool) =
889+
addTool(Tool.ofComputerUsePreview(computerUsePreview))
890890

891891
/**
892892
* This tool searches the web for relevant results to use in a response. Learn more about

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -1239,8 +1239,8 @@ private constructor(
12391239
* A tool that controls a virtual computer. Learn more about the
12401240
* [computer tool](https://platform.openai.com/docs/guides/tools-computer-use).
12411241
*/
1242-
fun addTool(computerPreview: ComputerTool) =
1243-
addTool(Tool.ofComputerPreview(computerPreview))
1242+
fun addTool(computerUsePreview: ComputerTool) =
1243+
addTool(Tool.ofComputerUsePreview(computerUsePreview))
12441244

12451245
/**
12461246
* This tool searches the web for relevant results to use in a response. Learn more
@@ -1839,7 +1839,7 @@ private constructor(
18391839
* A tool that controls a virtual computer. Learn more about the
18401840
* [computer tool](https://platform.openai.com/docs/guides/tools-computer-use).
18411841
*/
1842-
fun addTool(computerPreview: ComputerTool) = apply { body.addTool(computerPreview) }
1842+
fun addTool(computerUsePreview: ComputerTool) = apply { body.addTool(computerUsePreview) }
18431843

18441844
/**
18451845
* This tool searches the web for relevant results to use in a response. Learn more about

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

+16-16
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class Tool
2828
private constructor(
2929
private val fileSearch: FileSearchTool? = null,
3030
private val function: FunctionTool? = null,
31-
private val computerPreview: ComputerTool? = null,
31+
private val computerUsePreview: ComputerTool? = null,
3232
private val webSearch: WebSearchTool? = null,
3333
private val _json: JsonValue? = null,
3434
) {
@@ -49,7 +49,7 @@ private constructor(
4949
* A tool that controls a virtual computer. Learn more about the
5050
* [computer tool](https://platform.openai.com/docs/guides/tools-computer-use).
5151
*/
52-
fun computerPreview(): Optional<ComputerTool> = Optional.ofNullable(computerPreview)
52+
fun computerUsePreview(): Optional<ComputerTool> = Optional.ofNullable(computerUsePreview)
5353

5454
/**
5555
* This tool searches the web for relevant results to use in a response. Learn more about the
@@ -61,7 +61,7 @@ private constructor(
6161

6262
fun isFunction(): Boolean = function != null
6363

64-
fun isComputerPreview(): Boolean = computerPreview != null
64+
fun isComputerUsePreview(): Boolean = computerUsePreview != null
6565

6666
fun isWebSearch(): Boolean = webSearch != null
6767

@@ -81,7 +81,7 @@ private constructor(
8181
* A tool that controls a virtual computer. Learn more about the
8282
* [computer tool](https://platform.openai.com/docs/guides/tools-computer-use).
8383
*/
84-
fun asComputerPreview(): ComputerTool = computerPreview.getOrThrow("computerPreview")
84+
fun asComputerUsePreview(): ComputerTool = computerUsePreview.getOrThrow("computerUsePreview")
8585

8686
/**
8787
* This tool searches the web for relevant results to use in a response. Learn more about the
@@ -95,7 +95,7 @@ private constructor(
9595
return when {
9696
fileSearch != null -> visitor.visitFileSearch(fileSearch)
9797
function != null -> visitor.visitFunction(function)
98-
computerPreview != null -> visitor.visitComputerPreview(computerPreview)
98+
computerUsePreview != null -> visitor.visitComputerUsePreview(computerUsePreview)
9999
webSearch != null -> visitor.visitWebSearch(webSearch)
100100
else -> visitor.unknown(_json)
101101
}
@@ -118,8 +118,8 @@ private constructor(
118118
function.validate()
119119
}
120120

121-
override fun visitComputerPreview(computerPreview: ComputerTool) {
122-
computerPreview.validate()
121+
override fun visitComputerUsePreview(computerUsePreview: ComputerTool) {
122+
computerUsePreview.validate()
123123
}
124124

125125
override fun visitWebSearch(webSearch: WebSearchTool) {
@@ -135,16 +135,16 @@ private constructor(
135135
return true
136136
}
137137

138-
return /* spotless:off */ other is Tool && fileSearch == other.fileSearch && function == other.function && computerPreview == other.computerPreview && webSearch == other.webSearch /* spotless:on */
138+
return /* spotless:off */ other is Tool && fileSearch == other.fileSearch && function == other.function && computerUsePreview == other.computerUsePreview && webSearch == other.webSearch /* spotless:on */
139139
}
140140

141-
override fun hashCode(): Int = /* spotless:off */ Objects.hash(fileSearch, function, computerPreview, webSearch) /* spotless:on */
141+
override fun hashCode(): Int = /* spotless:off */ Objects.hash(fileSearch, function, computerUsePreview, webSearch) /* spotless:on */
142142

143143
override fun toString(): String =
144144
when {
145145
fileSearch != null -> "Tool{fileSearch=$fileSearch}"
146146
function != null -> "Tool{function=$function}"
147-
computerPreview != null -> "Tool{computerPreview=$computerPreview}"
147+
computerUsePreview != null -> "Tool{computerUsePreview=$computerUsePreview}"
148148
webSearch != null -> "Tool{webSearch=$webSearch}"
149149
_json != null -> "Tool{_unknown=$_json}"
150150
else -> throw IllegalStateException("Invalid Tool")
@@ -169,8 +169,8 @@ private constructor(
169169
* [computer tool](https://platform.openai.com/docs/guides/tools-computer-use).
170170
*/
171171
@JvmStatic
172-
fun ofComputerPreview(computerPreview: ComputerTool) =
173-
Tool(computerPreview = computerPreview)
172+
fun ofComputerUsePreview(computerUsePreview: ComputerTool) =
173+
Tool(computerUsePreview = computerUsePreview)
174174

175175
/**
176176
* This tool searches the web for relevant results to use in a response. Learn more about
@@ -198,7 +198,7 @@ private constructor(
198198
* A tool that controls a virtual computer. Learn more about the
199199
* [computer tool](https://platform.openai.com/docs/guides/tools-computer-use).
200200
*/
201-
fun visitComputerPreview(computerPreview: ComputerTool): T
201+
fun visitComputerUsePreview(computerUsePreview: ComputerTool): T
202202

203203
/**
204204
* This tool searches the web for relevant results to use in a response. Learn more about
@@ -239,10 +239,10 @@ private constructor(
239239
return Tool(function = it, _json = json)
240240
}
241241
}
242-
"computer-preview" -> {
242+
"computer_use_preview" -> {
243243
tryDeserialize(node, jacksonTypeRef<ComputerTool>()) { it.validate() }
244244
?.let {
245-
return Tool(computerPreview = it, _json = json)
245+
return Tool(computerUsePreview = it, _json = json)
246246
}
247247
}
248248
}
@@ -266,7 +266,7 @@ private constructor(
266266
when {
267267
value.fileSearch != null -> generator.writeObject(value.fileSearch)
268268
value.function != null -> generator.writeObject(value.function)
269-
value.computerPreview != null -> generator.writeObject(value.computerPreview)
269+
value.computerUsePreview != null -> generator.writeObject(value.computerUsePreview)
270270
value.webSearch != null -> generator.writeObject(value.webSearch)
271271
value._json != null -> generator.writeObject(value._json)
272272
else -> throw IllegalStateException("Invalid Tool")

0 commit comments

Comments
 (0)