Skip to content

Commit a82279d

Browse files
feat(api): new streaming helpers for background responses
1 parent 6d93489 commit a82279d

File tree

200 files changed

+40035
-2472
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

200 files changed

+40035
-2472
lines changed

.stats.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 99
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-d51538ac955164de98b0c94a0a4718d96623fe39bf31a1d168be06c93c94e645.yml
3-
openapi_spec_hash: 33e00a48df8f94c94f46290c489f132b
4-
config_hash: c42d37618b8628ce7e1c76437db5dd8f
1+
configured_endpoints: 109
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-fc64d7c2c8f51f750813375356c3f3fdfc7fc1b1b34f19c20a5410279d445d37.yml
3+
openapi_spec_hash: 618285fc70199ee32b9ebe4bf72f7e4c
4+
config_hash: c497f6b750cc89c0bf2eefc0bc839c70

openai-java-core/src/main/kotlin/com/openai/client/OpenAIClient.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import com.openai.services.blocking.BatchService
77
import com.openai.services.blocking.BetaService
88
import com.openai.services.blocking.ChatService
99
import com.openai.services.blocking.CompletionService
10+
import com.openai.services.blocking.ContainerService
1011
import com.openai.services.blocking.EmbeddingService
1112
import com.openai.services.blocking.EvalService
1213
import com.openai.services.blocking.FileService
@@ -80,6 +81,8 @@ interface OpenAIClient {
8081

8182
fun evals(): EvalService
8283

84+
fun containers(): ContainerService
85+
8386
/**
8487
* Closes this client, relinquishing any underlying resources.
8588
*
@@ -127,5 +130,7 @@ interface OpenAIClient {
127130
fun responses(): ResponseService.WithRawResponse
128131

129132
fun evals(): EvalService.WithRawResponse
133+
134+
fun containers(): ContainerService.WithRawResponse
130135
}
131136
}

openai-java-core/src/main/kotlin/com/openai/client/OpenAIClientAsync.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import com.openai.services.async.BatchServiceAsync
77
import com.openai.services.async.BetaServiceAsync
88
import com.openai.services.async.ChatServiceAsync
99
import com.openai.services.async.CompletionServiceAsync
10+
import com.openai.services.async.ContainerServiceAsync
1011
import com.openai.services.async.EmbeddingServiceAsync
1112
import com.openai.services.async.EvalServiceAsync
1213
import com.openai.services.async.FileServiceAsync
@@ -80,6 +81,8 @@ interface OpenAIClientAsync {
8081

8182
fun evals(): EvalServiceAsync
8283

84+
fun containers(): ContainerServiceAsync
85+
8386
/**
8487
* Closes this client, relinquishing any underlying resources.
8588
*
@@ -127,5 +130,7 @@ interface OpenAIClientAsync {
127130
fun responses(): ResponseServiceAsync.WithRawResponse
128131

129132
fun evals(): EvalServiceAsync.WithRawResponse
133+
134+
fun containers(): ContainerServiceAsync.WithRawResponse
130135
}
131136
}

openai-java-core/src/main/kotlin/com/openai/client/OpenAIClientAsyncImpl.kt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import com.openai.services.async.ChatServiceAsync
1414
import com.openai.services.async.ChatServiceAsyncImpl
1515
import com.openai.services.async.CompletionServiceAsync
1616
import com.openai.services.async.CompletionServiceAsyncImpl
17+
import com.openai.services.async.ContainerServiceAsync
18+
import com.openai.services.async.ContainerServiceAsyncImpl
1719
import com.openai.services.async.EmbeddingServiceAsync
1820
import com.openai.services.async.EmbeddingServiceAsyncImpl
1921
import com.openai.services.async.EvalServiceAsync
@@ -110,6 +112,10 @@ class OpenAIClientAsyncImpl(private val clientOptions: ClientOptions) : OpenAICl
110112

111113
private val evals: EvalServiceAsync by lazy { EvalServiceAsyncImpl(clientOptionsWithUserAgent) }
112114

115+
private val containers: ContainerServiceAsync by lazy {
116+
ContainerServiceAsyncImpl(clientOptionsWithUserAgent)
117+
}
118+
113119
override fun sync(): OpenAIClient = sync
114120

115121
override fun withRawResponse(): OpenAIClientAsync.WithRawResponse = withRawResponse
@@ -146,6 +152,8 @@ class OpenAIClientAsyncImpl(private val clientOptions: ClientOptions) : OpenAICl
146152

147153
override fun evals(): EvalServiceAsync = evals
148154

155+
override fun containers(): ContainerServiceAsync = containers
156+
149157
override fun close() = clientOptions.httpClient.close()
150158

151159
class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) :
@@ -215,6 +223,10 @@ class OpenAIClientAsyncImpl(private val clientOptions: ClientOptions) : OpenAICl
215223
EvalServiceAsyncImpl.WithRawResponseImpl(clientOptions)
216224
}
217225

226+
private val containers: ContainerServiceAsync.WithRawResponse by lazy {
227+
ContainerServiceAsyncImpl.WithRawResponseImpl(clientOptions)
228+
}
229+
218230
override fun completions(): CompletionServiceAsync.WithRawResponse = completions
219231

220232
override fun chat(): ChatServiceAsync.WithRawResponse = chat
@@ -246,5 +258,7 @@ class OpenAIClientAsyncImpl(private val clientOptions: ClientOptions) : OpenAICl
246258
override fun responses(): ResponseServiceAsync.WithRawResponse = responses
247259

248260
override fun evals(): EvalServiceAsync.WithRawResponse = evals
261+
262+
override fun containers(): ContainerServiceAsync.WithRawResponse = containers
249263
}
250264
}

openai-java-core/src/main/kotlin/com/openai/client/OpenAIClientImpl.kt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import com.openai.services.blocking.ChatService
1414
import com.openai.services.blocking.ChatServiceImpl
1515
import com.openai.services.blocking.CompletionService
1616
import com.openai.services.blocking.CompletionServiceImpl
17+
import com.openai.services.blocking.ContainerService
18+
import com.openai.services.blocking.ContainerServiceImpl
1719
import com.openai.services.blocking.EmbeddingService
1820
import com.openai.services.blocking.EmbeddingServiceImpl
1921
import com.openai.services.blocking.EvalService
@@ -98,6 +100,10 @@ class OpenAIClientImpl(private val clientOptions: ClientOptions) : OpenAIClient
98100

99101
private val evals: EvalService by lazy { EvalServiceImpl(clientOptionsWithUserAgent) }
100102

103+
private val containers: ContainerService by lazy {
104+
ContainerServiceImpl(clientOptionsWithUserAgent)
105+
}
106+
101107
override fun async(): OpenAIClientAsync = async
102108

103109
override fun withRawResponse(): OpenAIClient.WithRawResponse = withRawResponse
@@ -134,6 +140,8 @@ class OpenAIClientImpl(private val clientOptions: ClientOptions) : OpenAIClient
134140

135141
override fun evals(): EvalService = evals
136142

143+
override fun containers(): ContainerService = containers
144+
137145
override fun close() = clientOptions.httpClient.close()
138146

139147
class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) :
@@ -203,6 +211,10 @@ class OpenAIClientImpl(private val clientOptions: ClientOptions) : OpenAIClient
203211
EvalServiceImpl.WithRawResponseImpl(clientOptions)
204212
}
205213

214+
private val containers: ContainerService.WithRawResponse by lazy {
215+
ContainerServiceImpl.WithRawResponseImpl(clientOptions)
216+
}
217+
206218
override fun completions(): CompletionService.WithRawResponse = completions
207219

208220
override fun chat(): ChatService.WithRawResponse = chat
@@ -234,5 +246,7 @@ class OpenAIClientImpl(private val clientOptions: ClientOptions) : OpenAIClient
234246
override fun responses(): ResponseService.WithRawResponse = responses
235247

236248
override fun evals(): EvalService.WithRawResponse = evals
249+
250+
override fun containers(): ContainerService.WithRawResponse = containers
237251
}
238252
}

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -399,8 +399,8 @@ private constructor(
399399
fun topP(): Optional<Double> = body.topP()
400400

401401
/**
402-
* A unique identifier representing your end-user, which can help OpenAI to monitor and detect
403-
* abuse.
402+
* A stable identifier for your end-users. Used to boost cache hit rates by better bucketing
403+
* similar requests and to help OpenAI detect and prevent abuse.
404404
* [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#end-user-ids).
405405
*
406406
* @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the
@@ -1590,8 +1590,8 @@ private constructor(
15901590
fun topP(topP: JsonField<Double>) = apply { body.topP(topP) }
15911591

15921592
/**
1593-
* A unique identifier representing your end-user, which can help OpenAI to monitor and
1594-
* detect abuse.
1593+
* A stable identifier for your end-users. Used to boost cache hit rates by better bucketing
1594+
* similar requests and to help OpenAI detect and prevent abuse.
15951595
* [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#end-user-ids).
15961596
*/
15971597
fun user(user: String) = apply { body.user(user) }
@@ -2260,8 +2260,8 @@ private constructor(
22602260
fun topP(): Optional<Double> = topP.getOptional("top_p")
22612261

22622262
/**
2263-
* A unique identifier representing your end-user, which can help OpenAI to monitor and
2264-
* detect abuse.
2263+
* A stable identifier for your end-users. Used to boost cache hit rates by better bucketing
2264+
* similar requests and to help OpenAI detect and prevent abuse.
22652265
* [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#end-user-ids).
22662266
*
22672267
* @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the
@@ -3587,8 +3587,8 @@ private constructor(
35873587
fun topP(topP: JsonField<Double>) = apply { this.topP = topP }
35883588

35893589
/**
3590-
* A unique identifier representing your end-user, which can help OpenAI to monitor and
3591-
* detect abuse.
3590+
* A stable identifier for your end-users. Used to boost cache hit rates by better
3591+
* bucketing similar requests and to help OpenAI detect and prevent abuse.
35923592
* [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#end-user-ids).
35933593
*/
35943594
fun user(user: String) = user(JsonField.of(user))

0 commit comments

Comments
 (0)