Repository navigation
Expand file tree
/
Copy pathdecisions.ts
More file actions
635 lines (505 loc) · 16.3 KB
/
Copy pathdecisions.ts
File metadata and controls
635 lines (505 loc) · 16.3 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
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
// File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details.
import { APIResource } from '../core/resource';
import * as DecisionsAPI from './decisions';
import * as Shared from './shared';
import { APIPromise } from '../core/api-promise';
import { RequestOptions } from '../internal/request-options';
function resolveResourceRequestOptions(
options: RequestOptions | undefined,
buildOptions: (options: RequestOptions | undefined) => RequestOptions | Promise<RequestOptions>,
): Promise<RequestOptions> {
return Promise.resolve(options).then(buildOptions);
}
export class Decisions extends APIResource {
/**
* Use this endpoint to quickly answer classification or scoring questions about
* some input. You can ask multiple questions in one request.
*/
create(body: DecisionCreateParams, options?: RequestOptions): APIPromise<Decision> {
return this._client.post(
'/decisions',
resolveResourceRequestOptions(options, (options) => ({
body,
...options,
__security: { bearerAuth: true },
})),
);
}
}
export interface Decision {
/**
* Answers in question order. Any question can return a refusal instead of an
* answer; other questions can still receive answers. A refusal has
* `type: "refusal"` and the question's `name`, or `null` if it was unnamed.
*/
answers: Array<
| Decision.AnswerResourcePredicate
| Decision.AnswerResourceChoice
| Decision.AnswerResourceScore
| Decision.AnswerResourceRefusal
>;
/**
* The model used.
*/
model: string;
/**
* Token usage for the request.
*/
usage: Decision.Usage;
}
export namespace Decision {
export interface AnswerResourcePredicate {
name: string | null;
probability: number;
/**
* The type of the object. Always `predicate`.
*/
type: 'predicate';
}
export interface AnswerResourceChoice {
/**
* Choice values are typed: a string and a boolean with the same text are distinct.
*/
choice: string | boolean;
confidence: number;
name: string | null;
probabilities: Array<AnswerResourceChoice.Probability>;
/**
* The type of the object. Always `choice`.
*/
type: 'choice';
}
export namespace AnswerResourceChoice {
export interface Probability {
probability: number;
/**
* Choice values are typed: a string and a boolean with the same text are distinct.
*/
value: string | boolean;
}
}
export interface AnswerResourceScore {
confidence: number;
name: string | null;
probabilities: Array<AnswerResourceScore.Probability>;
score: number;
/**
* The type of the object. Always `score`.
*/
type: 'score';
}
export namespace AnswerResourceScore {
export interface Probability {
label: string;
probability: number;
value: number;
}
}
/**
* The model declined to answer this question. Other questions in the same request
* can still receive answers.
*/
export interface AnswerResourceRefusal {
name: string | null;
/**
* The type of the object. Always `refusal`.
*/
type: 'refusal';
}
/**
* Token usage for the request.
*/
export interface Usage {
input_tokens: number;
input_tokens_details: Usage.InputTokensDetails;
output_tokens: number;
output_tokens_details: Usage.OutputTokensDetails;
total_tokens: number;
}
export namespace Usage {
export interface InputTokensDetails {
cache_write_tokens: number;
cached_tokens: number;
}
export interface OutputTokensDetails {
reasoning_tokens: number;
}
}
}
/**
* An image provided as a base64 data URL or a publicly accessible HTTP(S) URL.
* File IDs are not supported.
*/
export interface DecisionInputImage {
/**
* A base64-encoded image in a data URL or a publicly accessible HTTP(S) image URL.
*/
image_url: string;
type: 'input_image';
/**
* The image detail level, using the selected model's image profile. Defaults to
* auto.
*/
detail?: 'low' | 'high' | 'auto' | 'original' | null;
/**
* Marks the exact end of a reusable prompt prefix. The breakpoint inherits its TTL
* from the request's `prompt_cache_options.ttl`; the boundary is not rounded to a
* token block.
*/
prompt_cache_breakpoint?: DecisionPromptCacheBreakpoint | null;
}
/**
* A user message containing input text, images, or JSON.
*/
export type DecisionInputMessage =
| DecisionInputMessage.DecisionInputUserMessage
| DecisionInputMessage.DecisionInputDeveloperMessage
| DecisionInputMessage.DecisionInputSystemMessage
| DecisionInputMessage.DecisionInputAssistantMessage;
export namespace DecisionInputMessage {
/**
* A user message containing input text, images, or JSON.
*/
export interface DecisionInputUserMessage {
/**
* A text string or an ordered list of text, image, and JSON parts.
*/
content: string | Array<DecisionsAPI.DecisionInputPart>;
role: 'user';
type?: 'message';
}
/**
* A developer message containing input text.
*/
export interface DecisionInputDeveloperMessage {
/**
* A text string or an ordered list of input text parts.
*/
content: string | Array<DecisionsAPI.DecisionInputText>;
role: 'developer';
type?: 'message';
}
/**
* A system message containing input text.
*/
export interface DecisionInputSystemMessage {
/**
* A text string or an ordered list of input text parts.
*/
content: string | Array<DecisionsAPI.DecisionInputText>;
role: 'system';
type?: 'message';
}
/**
* An assistant message containing output text or refusals.
*/
export interface DecisionInputAssistantMessage {
/**
* A text string or an ordered list of output text and refusal parts.
*/
content:
| string
| Array<
| DecisionInputAssistantMessage.DecisionInputOutputText
| DecisionInputAssistantMessage.DecisionInputRefusal
>;
role: 'assistant';
/**
* The phase of an assistant message.
*/
phase?: 'commentary' | 'final_answer' | null;
type?: 'message';
}
export namespace DecisionInputAssistantMessage {
export interface DecisionInputOutputText {
text: string;
type: 'output_text';
}
export interface DecisionInputRefusal {
refusal: string;
type: 'refusal';
}
}
}
/**
* An image provided as a base64 data URL or a publicly accessible HTTP(S) URL.
* File IDs are not supported.
*/
export type DecisionInputPart = DecisionInputText | DecisionInputImage | Shared.DecisionInputJSON;
export interface DecisionInputText {
text: string;
type: 'input_text';
/**
* Marks the exact end of a reusable prompt prefix. The breakpoint inherits its TTL
* from the request's `prompt_cache_options.ttl`; the boundary is not rounded to a
* token block.
*/
prompt_cache_breakpoint?: DecisionPromptCacheBreakpoint | null;
}
/**
* Marks the exact end of a reusable prompt prefix. The breakpoint inherits its TTL
* from the request's `prompt_cache_options.ttl`; the boundary is not rounded to a
* token block.
*/
export interface DecisionPromptCacheBreakpoint {
/**
* The breakpoint mode. Always `explicit`.
*/
mode: 'explicit';
}
export type DecisionInputJson = Shared.DecisionInputJSON;
export type DecisionQuestionInputImage = Shared.DecisionQuestionInputImage;
export type DecisionQuestionInputPart = Shared.DecisionQuestionInputPart;
export type DecisionQuestionInputText = Shared.DecisionQuestionInputText;
export interface DecisionCreateParams {
/**
* The input to evaluate for every question. Provide a text string or an ordered
* array of messages, function calls and outputs, or custom tool calls and outputs.
* Each tool output must identify a matching call by call ID.
*/
input:
| string
| Array<
| DecisionCreateParams.DecisionInputUserMessage
| DecisionCreateParams.DecisionInputDeveloperMessage
| DecisionCreateParams.DecisionInputSystemMessage
| DecisionCreateParams.DecisionInputAssistantMessage
| DecisionCreateParams.DecisionInputFunctionCall
| DecisionCreateParams.DecisionInputFunctionCallOutput
| DecisionCreateParams.DecisionInputCustomToolCall
| DecisionCreateParams.DecisionInputCustomToolCallOutput
>;
/**
* The model to use. Only `gpt-6-luna` is supported.
*/
model: string;
/**
* Ask 1–400 questions about the input. Each question can be a predicate, choice,
* or score. Answers come back in the same order.
*/
questions: Array<
| DecisionCreateParams.QuestionParamPredicate
| DecisionCreateParams.QuestionParamChoice
| DecisionCreateParams.QuestionParamScore
>;
/**
* Partition prompt cache reuse by caller-provided key.
*/
prompt_cache_key?: string | null;
/**
* Options for prompt caching. Supported for `gpt-5.6` and later models. By
* default, OpenAI automatically chooses one implicit cache breakpoint. You can add
* explicit breakpoints to content blocks with `prompt_cache_breakpoint`. Each
* request can write up to four breakpoints. For cache matching, OpenAI considers
* up to the latest 80 breakpoints in the conversation, without a content-block
* lookback limit. Set `mode` to `explicit` to disable the implicit breakpoint. The
* `ttl` defaults to `30m`, which is currently the only supported value. See the
* [prompt caching guide](https://developers.openai.com/api/docs/guides/prompt-caching)
* for current details.
*/
prompt_cache_options?: DecisionCreateParams.PromptCacheOptions | null;
/**
* Opaque caller-provided end-user identifier, scoped by the verified org. Match
* Responses' limit; this is never the authenticated user identity.
*/
safety_identifier?: string | null;
}
export namespace DecisionCreateParams {
/**
* A user message containing input text, images, or JSON.
*/
export interface DecisionInputUserMessage {
/**
* A text string or an ordered list of text, image, and JSON parts.
*/
content: string | Array<DecisionsAPI.DecisionInputPart>;
role: 'user';
type?: 'message';
}
/**
* A developer message containing input text.
*/
export interface DecisionInputDeveloperMessage {
/**
* A text string or an ordered list of input text parts.
*/
content: string | Array<DecisionsAPI.DecisionInputText>;
role: 'developer';
type?: 'message';
}
/**
* A system message containing input text.
*/
export interface DecisionInputSystemMessage {
/**
* A text string or an ordered list of input text parts.
*/
content: string | Array<DecisionsAPI.DecisionInputText>;
role: 'system';
type?: 'message';
}
/**
* An assistant message containing output text or refusals.
*/
export interface DecisionInputAssistantMessage {
/**
* A text string or an ordered list of output text and refusal parts.
*/
content:
| string
| Array<
| DecisionInputAssistantMessage.DecisionInputOutputText
| DecisionInputAssistantMessage.DecisionInputRefusal
>;
role: 'assistant';
/**
* The phase of an assistant message.
*/
phase?: 'commentary' | 'final_answer' | null;
type?: 'message';
}
export namespace DecisionInputAssistantMessage {
export interface DecisionInputOutputText {
text: string;
type: 'output_text';
}
export interface DecisionInputRefusal {
refusal: string;
type: 'refusal';
}
}
export interface DecisionInputFunctionCall {
arguments: string;
call_id: string;
name: string;
type: 'function_call';
id?: string | null;
namespace?: string | null;
status?: 'in_progress' | 'completed' | 'incomplete' | null;
}
export interface DecisionInputFunctionCallOutput {
call_id: string;
/**
* Text evidence or an ordered list of text and image parts.
*/
output: string | Array<DecisionsAPI.DecisionInputText | DecisionsAPI.DecisionInputImage>;
type: 'function_call_output';
id?: string | null;
status?: 'in_progress' | 'completed' | 'incomplete' | null;
}
export interface DecisionInputCustomToolCall {
call_id: string;
input: string;
name: string;
type: 'custom_tool_call';
id?: string | null;
namespace?: string | null;
status?: 'in_progress' | 'completed' | 'incomplete' | null;
}
export interface DecisionInputCustomToolCallOutput {
call_id: string;
/**
* Text evidence or an ordered list of text and image parts.
*/
output: string | Array<DecisionsAPI.DecisionInputText | DecisionsAPI.DecisionInputImage>;
type: 'custom_tool_call_output';
id?: string | null;
status?: 'in_progress' | 'completed' | 'incomplete' | null;
}
/**
* Estimate how likely it is that a statement about the input is true.
*/
export interface QuestionParamPredicate {
instructions: string | Array<Shared.DecisionQuestionInputPart>;
/**
* The type of the object. Always `predicate`.
*/
type: 'predicate';
name?: string;
}
/**
* Choose from the supplied options based on the input.
*/
export interface QuestionParamChoice {
/**
* Provide between 2 and 255 choices. Each choice must be unique.
*/
choices: Array<QuestionParamChoice.Choice>;
instructions: string | Array<Shared.DecisionQuestionInputPart>;
/**
* The type of the object. Always `choice`.
*/
type: 'choice';
name?: string;
}
export namespace QuestionParamChoice {
export interface Choice {
/**
* Choice values are typed: a string and a boolean with the same text are distinct.
*/
value: string | boolean;
description?: string;
}
}
/**
* Rate the input against the supplied ordered levels.
*/
export interface QuestionParamScore {
instructions: string | Array<Shared.DecisionQuestionInputPart>;
levels: Array<QuestionParamScore.Level>;
/**
* The type of the object. Always `score`.
*/
type: 'score';
name?: string;
}
export namespace QuestionParamScore {
export interface Level {
label: string;
description?: string;
}
}
/**
* Options for prompt caching. Supported for `gpt-5.6` and later models. By
* default, OpenAI automatically chooses one implicit cache breakpoint. You can add
* explicit breakpoints to content blocks with `prompt_cache_breakpoint`. Each
* request can write up to four breakpoints. For cache matching, OpenAI considers
* up to the latest 80 breakpoints in the conversation, without a content-block
* lookback limit. Set `mode` to `explicit` to disable the implicit breakpoint. The
* `ttl` defaults to `30m`, which is currently the only supported value. See the
* [prompt caching guide](https://developers.openai.com/api/docs/guides/prompt-caching)
* for current details.
*/
export interface PromptCacheOptions {
/**
* Controls whether OpenAI automatically creates an implicit cache breakpoint.
* Defaults to `implicit`. With `implicit`, OpenAI creates one implicit breakpoint
* and writes up to the latest three explicit breakpoints in the request. With
* `explicit`, OpenAI does not create an implicit breakpoint and writes up to the
* latest four explicit breakpoints. If there are no explicit breakpoints, the
* request does not use prompt caching.
*/
mode?: 'implicit' | 'explicit' | null;
/**
* The minimum lifetime applied to every implicit and explicit cache breakpoint
* written by the request. Defaults to `30m`, which is currently the only supported
* value. The backend may retain cache entries for longer.
*/
ttl?: '30m';
}
}
export declare namespace Decisions {
export {
type Decision as Decision,
type DecisionInputImage as DecisionInputImage,
type DecisionInputMessage as DecisionInputMessage,
type DecisionInputPart as DecisionInputPart,
type DecisionInputText as DecisionInputText,
type DecisionPromptCacheBreakpoint as DecisionPromptCacheBreakpoint,
type DecisionInputJson as DecisionInputJson,
type DecisionQuestionInputImage as DecisionQuestionInputImage,
type DecisionQuestionInputPart as DecisionQuestionInputPart,
type DecisionQuestionInputText as DecisionQuestionInputText,
type DecisionCreateParams as DecisionCreateParams,
};
}