-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopenai-responses.wit
More file actions
452 lines (386 loc) · 10.4 KB
/
Copy pathopenai-responses.wit
File metadata and controls
452 lines (386 loc) · 10.4 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
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
package obelisk-components:openai-responses@0.1.0;
/// OpenAI Responses API types and interface
interface types {
/// Role of a message participant
enum role {
user,
assistant,
system,
developer,
}
/// Content types for input
variant input-content {
text(string),
image-url(image-url-content),
image-file(image-file-content),
}
record image-url-content {
url: string,
detail: option<image-detail>,
}
record image-file-content {
file-id: string,
detail: option<image-detail>,
}
enum image-detail {
low,
high,
auto,
}
/// Input message for the conversation
record input-message {
role: role,
content: list<input-content>,
}
/// Simple text-only input message
record simple-message {
role: role,
content: string,
}
/// Tool types
variant tool {
function(function-tool),
web-search(web-search-tool),
file-search(file-search-tool),
code-interpreter(code-interpreter-tool),
computer-use(computer-use-tool),
}
record function-tool {
name: string,
description: option<string>,
parameters: option<string>, // JSON Schema as string
strict: option<bool>,
}
record web-search-tool {
search-context-size: option<search-context-size>,
user-location: option<user-location>,
}
enum search-context-size {
low,
medium,
high,
}
record user-location {
%type: string,
city: option<string>,
country: option<string>,
region: option<string>,
timezone: option<string>,
}
record file-search-tool {
vector-store-ids: list<string>,
max-num-results: option<u32>,
ranking-options: option<ranking-options>,
}
record ranking-options {
ranker: option<string>,
score-threshold: option<f32>,
}
record code-interpreter-tool {
container: option<string>,
}
record computer-use-tool {
environment: string,
display-width: u32,
display-height: u32,
}
/// Response format options
variant response-format {
text,
json-object,
json-schema(json-schema-format),
}
record json-schema-format {
name: string,
schema: string, // JSON Schema as string
description: option<string>,
strict: option<bool>,
}
/// Tool choice options
variant tool-choice {
auto,
none,
required,
specific(specific-tool-choice),
}
record specific-tool-choice {
%type: string,
name: option<string>,
}
/// Truncation strategy
enum truncation {
auto,
disabled,
}
/// Reasoning effort level
enum reasoning-effort {
low,
medium,
high,
}
/// Reasoning configuration
record reasoning {
effort: reasoning-effort,
summary: option<reasoning-summary>,
}
enum reasoning-summary {
auto,
concise,
detailed,
}
/// Request to create a response
record create-response-request {
model: string,
input: list<input-message>,
instructions: option<string>,
max-output-tokens: option<u32>,
metadata: option<list<tuple<string, string>>>,
parallel-tool-calls: option<bool>,
previous-response-id: option<string>,
reasoning: option<reasoning>,
store: option<bool>,
temperature: option<f32>,
text: option<response-format>,
tool-choice: option<tool-choice>,
tools: option<list<tool>>,
top-p: option<f32>,
truncation: option<truncation>,
user: option<string>,
}
/// Simplified request with just text input
record simple-request {
model: string,
input: string,
instructions: option<string>,
max-output-tokens: option<u32>,
temperature: option<f32>,
tools: option<list<tool>>,
}
/// Output content item
variant output-content {
text(output-text),
refusal(string),
}
record output-text {
text: string,
annotations: list<annotation>,
}
variant annotation {
file-citation(file-citation),
url-citation(url-citation),
file-path(file-path),
}
record file-citation {
file-id: string,
index: u32,
}
record url-citation {
url: string,
title: string,
start-index: u32,
end-index: u32,
}
record file-path {
file-id: string,
index: u32,
}
/// Output item in a response
variant output-item {
message(output-message),
function-call(function-call-output),
function-call-output(function-call-result),
web-search-call(web-search-output),
file-search-call(file-search-output),
computer-call(computer-call-output),
reasoning(reasoning-output),
}
record output-message {
id: string,
role: role,
content: list<output-content>,
status: item-status,
}
enum item-status {
in-progress,
completed,
incomplete,
}
record function-call-output {
id: string,
call-id: string,
name: string,
arguments: string,
status: item-status,
}
record function-call-result {
id: string,
call-id: string,
output: string,
}
record web-search-output {
id: string,
status: item-status,
}
record file-search-output {
id: string,
queries: list<string>,
status: item-status,
results: option<list<file-search-result>>,
}
record file-search-result {
file-id: string,
filename: string,
score: f32,
text: string,
}
record computer-call-output {
id: string,
call-id: string,
action: string, // JSON encoded action
status: item-status,
pending-safety-checks: list<safety-check>,
}
record safety-check {
id: string,
code: string,
message: string,
}
record reasoning-output {
id: string,
summary: list<reasoning-summary-item>,
status: item-status,
}
record reasoning-summary-item {
%type: string,
text: string,
}
/// Token usage information
record usage {
input-tokens: u32,
output-tokens: u32,
total-tokens: u32,
input-tokens-details: option<input-tokens-details>,
output-tokens-details: option<output-tokens-details>,
}
record input-tokens-details {
cached-tokens: u32,
}
record output-tokens-details {
reasoning-tokens: u32,
}
/// Response status
enum response-status {
in-progress,
completed,
incomplete,
failed,
cancelled,
}
/// Incomplete details
record incomplete-details {
reason: string,
}
/// Error information
record response-error {
code: string,
message: string,
}
/// The main response object
record response {
id: string,
object: string,
created-at: u64,
model: string,
output: list<output-item>,
status: response-status,
usage: option<usage>,
error: option<response-error>,
incomplete-details: option<incomplete-details>,
instructions: option<string>,
metadata: option<list<tuple<string, string>>>,
parallel-tool-calls: bool,
previous-response-id: option<string>,
temperature: option<f32>,
top-p: option<f32>,
truncation: option<truncation>,
user: option<string>,
}
/// API Error - includes execution-failed for Obelisk compatibility
variant api-error {
/// Must be included for Obelisk compatibility, indicates timeout or trap in last retry.
execution-failed,
/// Missing or invalid API key
configuration-error(string),
/// HTTP request failed (network, timeout, etc.)
request-failed(string),
/// OpenAI API returned an error
api-error(api-error-details),
/// Failed to parse response
parse-error(string),
}
/// Details of an OpenAI API error response
record api-error-details {
code: string,
message: string,
param: option<string>,
%type: string,
}
/// List responses result
record list-responses-result {
object: string,
data: list<response>,
has-more: bool,
first-id: option<string>,
last-id: option<string>,
}
/// List input items result
record list-input-items-result {
object: string,
data: list<input-item>,
has-more: bool,
first-id: option<string>,
last-id: option<string>,
}
/// Input item (stored)
record input-item {
id: string,
%type: string,
content: option<string>, // JSON encoded for flexibility
}
}
/// The Responses API interface
interface api {
use types.{
create-response-request,
simple-request,
response,
api-error,
list-responses-result,
list-input-items-result,
};
/// Create a new response
create: func(request: create-response-request) -> result<response, api-error>;
/// Create a response with simple text input
create-simple: func(request: simple-request) -> result<response, api-error>;
/// Retrieve a response by ID
get: func(response-id: string) -> result<response, api-error>;
/// Delete a response by ID
delete: func(response-id: string) -> result<bool, api-error>;
/// List stored responses
list-responses: func(
limit: option<u32>,
order: option<string>,
after: option<string>,
before: option<string>,
) -> result<list-responses-result, api-error>;
/// List input items for a response
list-input-items: func(
response-id: string,
limit: option<u32>,
order: option<string>,
after: option<string>,
before: option<string>,
) -> result<list-input-items-result, api-error>;
/// Cancel an in-progress response
cancel: func(response-id: string) -> result<response, api-error>;
}