Repository navigation
Expand file tree
/
Copy pathOpenAIClientAsync.kt
More file actions
245 lines (182 loc) · 8.84 KB
/
Copy pathOpenAIClientAsync.kt
File metadata and controls
245 lines (182 loc) · 8.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
// File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details.
package com.openai.client
import com.openai.core.ClientOptions
import com.openai.services.async.AdminServiceAsync
import com.openai.services.async.AudioServiceAsync
import com.openai.services.async.BatchServiceAsync
import com.openai.services.async.BetaServiceAsync
import com.openai.services.async.ChatServiceAsync
import com.openai.services.async.CompletionServiceAsync
import com.openai.services.async.ContainerServiceAsync
import com.openai.services.async.ContentProvenanceCheckServiceAsync
import com.openai.services.async.ConversationServiceAsync
import com.openai.services.async.DecisionServiceAsync
import com.openai.services.async.EmbeddingServiceAsync
import com.openai.services.async.EvalServiceAsync
import com.openai.services.async.FileServiceAsync
import com.openai.services.async.FineTuningServiceAsync
import com.openai.services.async.GraderServiceAsync
import com.openai.services.async.ImageServiceAsync
import com.openai.services.async.LiveServiceAsync
import com.openai.services.async.ModelServiceAsync
import com.openai.services.async.ModerationServiceAsync
import com.openai.services.async.RealtimeServiceAsync
import com.openai.services.async.ResponseServiceAsync
import com.openai.services.async.SafetyServiceAsync
import com.openai.services.async.SkillServiceAsync
import com.openai.services.async.UploadServiceAsync
import com.openai.services.async.VectorStoreServiceAsync
import com.openai.services.async.VideoServiceAsync
import com.openai.services.async.WebhookServiceAsync
import java.util.function.Consumer
/**
* A client for interacting with the OpenAI REST API asynchronously. You can also switch to
* synchronous execution via the [sync] method.
*
* This client performs best when you create a single instance and reuse it for interactions with
* the REST API. Reusing the client allows requests to share underlying connections and threads,
* reducing latency and saving memory. The client automatically retries certain failed requests when
* retries are enabled, but it does not coordinate request rates across concurrent requests or
* client instances. Applications should manage their request rate as needed to stay within API rate
* limits.
*
* The threads and connections that are held will be released automatically if they remain idle. But
* if you are writing an application that needs to aggressively release unused resources, then you
* may call [close].
*/
interface OpenAIClientAsync {
/**
* Returns a version of this client that uses synchronous execution.
*
* The returned client shares its resources, like its connection pool and thread pools, with
* this client.
*/
fun sync(): OpenAIClient
/**
* Returns a view of this service that provides access to raw HTTP responses for each method.
*/
fun withRawResponse(): WithRawResponse
/**
* Returns a view of this service with the given option modifications applied.
*
* The original service is not modified.
*/
fun withOptions(modifier: Consumer<ClientOptions.Builder>): OpenAIClientAsync
fun decisions(): DecisionServiceAsync
/**
* Given a prompt, the model will return one or more predicted completions, and can also return
* the probabilities of alternative tokens at each position.
*/
fun completions(): CompletionServiceAsync
fun chat(): ChatServiceAsync
/**
* Get a vector representation of a given input that can be easily consumed by machine learning
* models and algorithms.
*/
fun embeddings(): EmbeddingServiceAsync
/**
* Files are used to upload documents that can be used with features like Assistants and
* Fine-tuning.
*/
fun files(): FileServiceAsync
/** Given a prompt and/or an input image, the model will generate a new image. */
fun images(): ImageServiceAsync
fun contentProvenanceChecks(): ContentProvenanceCheckServiceAsync
fun audio(): AudioServiceAsync
/** Given text and/or image inputs, classifies if those inputs are potentially harmful. */
fun moderations(): ModerationServiceAsync
/** List and describe the various models available in the API. */
fun models(): ModelServiceAsync
fun fineTuning(): FineTuningServiceAsync
fun graders(): GraderServiceAsync
fun vectorStores(): VectorStoreServiceAsync
fun safety(): SafetyServiceAsync
fun webhooks(): WebhookServiceAsync
fun beta(): BetaServiceAsync
/** Create large batches of API requests to run asynchronously. */
fun batches(): BatchServiceAsync
/** Use Uploads to upload large files in multiple parts. */
fun uploads(): UploadServiceAsync
fun admin(): AdminServiceAsync
/** Create and manage model responses. */
fun responses(): ResponseServiceAsync
fun live(): LiveServiceAsync
fun realtime(): RealtimeServiceAsync
/** Manage conversations and conversation items. */
fun conversations(): ConversationServiceAsync
/** Manage and run evals in the OpenAI platform. */
fun evals(): EvalServiceAsync
fun containers(): ContainerServiceAsync
fun skills(): SkillServiceAsync
fun videos(): VideoServiceAsync
/**
* Closes this client, relinquishing any underlying resources.
*
* This is purposefully not inherited from [AutoCloseable] because the client is long-lived and
* usually should not be synchronously closed via try-with-resources.
*
* It's also usually not necessary to call this method at all. the default HTTP client
* automatically releases threads and connections if they remain idle, but if you are writing an
* application that needs to aggressively release unused resources, then you may call this
* method.
*/
fun close()
/** A view of [OpenAIClientAsync] that provides access to raw HTTP responses for each method. */
interface WithRawResponse {
/**
* Returns a view of this service with the given option modifications applied.
*
* The original service is not modified.
*/
fun withOptions(
modifier: Consumer<ClientOptions.Builder>
): OpenAIClientAsync.WithRawResponse
fun decisions(): DecisionServiceAsync.WithRawResponse
/**
* Given a prompt, the model will return one or more predicted completions, and can also
* return the probabilities of alternative tokens at each position.
*/
fun completions(): CompletionServiceAsync.WithRawResponse
fun chat(): ChatServiceAsync.WithRawResponse
/**
* Get a vector representation of a given input that can be easily consumed by machine
* learning models and algorithms.
*/
fun embeddings(): EmbeddingServiceAsync.WithRawResponse
/**
* Files are used to upload documents that can be used with features like Assistants and
* Fine-tuning.
*/
fun files(): FileServiceAsync.WithRawResponse
/** Given a prompt and/or an input image, the model will generate a new image. */
fun images(): ImageServiceAsync.WithRawResponse
fun contentProvenanceChecks(): ContentProvenanceCheckServiceAsync.WithRawResponse
fun audio(): AudioServiceAsync.WithRawResponse
/** Given text and/or image inputs, classifies if those inputs are potentially harmful. */
fun moderations(): ModerationServiceAsync.WithRawResponse
/** List and describe the various models available in the API. */
fun models(): ModelServiceAsync.WithRawResponse
fun fineTuning(): FineTuningServiceAsync.WithRawResponse
fun graders(): GraderServiceAsync.WithRawResponse
fun vectorStores(): VectorStoreServiceAsync.WithRawResponse
fun safety(): SafetyServiceAsync.WithRawResponse
fun webhooks(): WebhookServiceAsync.WithRawResponse
fun beta(): BetaServiceAsync.WithRawResponse
/** Create large batches of API requests to run asynchronously. */
fun batches(): BatchServiceAsync.WithRawResponse
/** Use Uploads to upload large files in multiple parts. */
fun uploads(): UploadServiceAsync.WithRawResponse
fun admin(): AdminServiceAsync.WithRawResponse
/** Create and manage model responses. */
fun responses(): ResponseServiceAsync.WithRawResponse
fun live(): LiveServiceAsync.WithRawResponse
fun realtime(): RealtimeServiceAsync.WithRawResponse
/** Manage conversations and conversation items. */
fun conversations(): ConversationServiceAsync.WithRawResponse
/** Manage and run evals in the OpenAI platform. */
fun evals(): EvalServiceAsync.WithRawResponse
fun containers(): ContainerServiceAsync.WithRawResponse
fun skills(): SkillServiceAsync.WithRawResponse
fun videos(): VideoServiceAsync.WithRawResponse
}
}