forked from openai/openai-node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgraders.ts
More file actions
171 lines (137 loc) · 4.23 KB
/
graders.ts
File metadata and controls
171 lines (137 loc) · 4.23 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
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from '../../../core/resource';
import * as GraderModelsAPI from '../../graders/grader-models';
import { APIPromise } from '../../../core/api-promise';
import { RequestOptions } from '../../../internal/request-options';
export class Graders extends APIResource {
/**
* Run a grader.
*
* @example
* ```ts
* const response = await client.fineTuning.alpha.graders.run({
* grader: {
* input: 'input',
* name: 'name',
* operation: 'eq',
* reference: 'reference',
* type: 'string_check',
* },
* model_sample: 'model_sample',
* });
* ```
*/
run(body: GraderRunParams, options?: RequestOptions): APIPromise<GraderRunResponse> {
return this._client.post('/fine_tuning/alpha/graders/run', { body, ...options });
}
/**
* Validate a grader.
*
* @example
* ```ts
* const response =
* await client.fineTuning.alpha.graders.validate({
* grader: {
* input: 'input',
* name: 'name',
* operation: 'eq',
* reference: 'reference',
* type: 'string_check',
* },
* });
* ```
*/
validate(body: GraderValidateParams, options?: RequestOptions): APIPromise<GraderValidateResponse> {
return this._client.post('/fine_tuning/alpha/graders/validate', { body, ...options });
}
}
export interface GraderRunResponse {
metadata: GraderRunResponse.Metadata;
model_grader_token_usage_per_model: Record<string, unknown>;
reward: number;
sub_rewards: Record<string, unknown>;
}
export namespace GraderRunResponse {
export interface Metadata {
errors: Metadata.Errors;
execution_time: number;
name: string;
sampled_model_name: string | null;
scores: Record<string, unknown>;
token_usage: number | null;
type: string;
}
export namespace Metadata {
export interface Errors {
formula_parse_error: boolean;
invalid_variable_error: boolean;
model_grader_parse_error: boolean;
model_grader_refusal_error: boolean;
model_grader_server_error: boolean;
model_grader_server_error_details: string | null;
other_error: boolean;
python_grader_runtime_error: boolean;
python_grader_runtime_error_details: string | null;
python_grader_server_error: boolean;
python_grader_server_error_type: string | null;
sample_parse_error: boolean;
truncated_observation_error: boolean;
unresponsive_reward_error: boolean;
}
}
}
export interface GraderValidateResponse {
/**
* The grader used for the fine-tuning job.
*/
grader?:
| GraderModelsAPI.StringCheckGrader
| GraderModelsAPI.TextSimilarityGrader
| GraderModelsAPI.PythonGrader
| GraderModelsAPI.ScoreModelGrader
| GraderModelsAPI.MultiGrader;
}
export interface GraderRunParams {
/**
* The grader used for the fine-tuning job.
*/
grader:
| GraderModelsAPI.StringCheckGrader
| GraderModelsAPI.TextSimilarityGrader
| GraderModelsAPI.PythonGrader
| GraderModelsAPI.ScoreModelGrader
| GraderModelsAPI.MultiGrader;
/**
* The model sample to be evaluated. This value will be used to populate the
* `sample` namespace. See
* [the guide](https://platform.openai.com/docs/guides/graders) for more details.
* The `output_json` variable will be populated if the model sample is a valid JSON
* string.
*/
model_sample: string;
/**
* The dataset item provided to the grader. This will be used to populate the
* `item` namespace. See
* [the guide](https://platform.openai.com/docs/guides/graders) for more details.
*/
item?: unknown;
}
export interface GraderValidateParams {
/**
* The grader used for the fine-tuning job.
*/
grader:
| GraderModelsAPI.StringCheckGrader
| GraderModelsAPI.TextSimilarityGrader
| GraderModelsAPI.PythonGrader
| GraderModelsAPI.ScoreModelGrader
| GraderModelsAPI.MultiGrader;
}
export declare namespace Graders {
export {
type GraderRunResponse as GraderRunResponse,
type GraderValidateResponse as GraderValidateResponse,
type GraderRunParams as GraderRunParams,
type GraderValidateParams as GraderValidateParams,
};
}