|
1 | 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. |
2 | 2 |
|
3 | 3 | import { APIResource } from '../../core/resource'; |
4 | | -import { APIPromise } from '../../core/api-promise'; |
5 | | -import { RequestOptions } from '../../internal/request-options'; |
6 | | -import { path } from '../../internal/utils/path'; |
7 | 4 |
|
8 | | -export class Evaluations extends APIResource { |
9 | | - /** |
10 | | - * Create a new evaluation. |
11 | | - * |
12 | | - * Creates a new evaluation with the specified prompt, dataset, and objective |
13 | | - * configuration. The evaluation will be associated with the specified project and |
14 | | - * will automatically create an evaluation iteration that processes all dataset |
15 | | - * entries. |
16 | | - */ |
17 | | - create( |
18 | | - projectID: string, |
19 | | - body: EvaluationCreateParams, |
20 | | - options?: RequestOptions, |
21 | | - ): APIPromise<EvaluationEntry> { |
22 | | - return this._client.post(path`/project/${projectID}/evaluations`, { body, ...options }); |
23 | | - } |
24 | | - |
25 | | - /** |
26 | | - * Get an evaluation by ID. |
27 | | - * |
28 | | - * Retrieves a specific evaluation by its ID. The evaluation must belong to the |
29 | | - * specified project, which must belong to the current user's tenant. |
30 | | - */ |
31 | | - retrieve( |
32 | | - evaluationID: string, |
33 | | - params: EvaluationRetrieveParams, |
34 | | - options?: RequestOptions, |
35 | | - ): APIPromise<EvaluationEntry> { |
36 | | - const { project_id } = params; |
37 | | - return this._client.get(path`/project/${project_id}/evaluations/${evaluationID}`, options); |
38 | | - } |
39 | | - |
40 | | - /** |
41 | | - * List all evaluations for the specified project. |
42 | | - * |
43 | | - * Retrieves all evaluations that belong to the specified project. The project must |
44 | | - * belong to the current user's tenant. |
45 | | - */ |
46 | | - list(projectID: string, options?: RequestOptions): APIPromise<EvaluationListResponse> { |
47 | | - return this._client.get(path`/project/${projectID}/evaluations/`, options); |
48 | | - } |
49 | | - |
50 | | - /** |
51 | | - * Delete an evaluation by ID. |
52 | | - * |
53 | | - * Permanently deletes an evaluation and all its associated data. This action |
54 | | - * cannot be undone. The evaluation must belong to the specified project, which |
55 | | - * must belong to the current user's tenant. |
56 | | - */ |
57 | | - delete( |
58 | | - evaluationID: string, |
59 | | - params: EvaluationDeleteParams, |
60 | | - options?: RequestOptions, |
61 | | - ): APIPromise<EvaluationDeleteResponse> { |
62 | | - const { project_id } = params; |
63 | | - return this._client.delete(path`/project/${project_id}/evaluations/${evaluationID}`, options); |
64 | | - } |
65 | | - |
66 | | - /** |
67 | | - * Create a new evaluation iteration. |
68 | | - * |
69 | | - * Creates a new evaluation iteration that will process all entries in the |
70 | | - * evaluation's dataset. The method reads all files from the dataset's S3 folder |
71 | | - * and creates evaluation results for each dataset entry. |
72 | | - * |
73 | | - * Args: evaluation_id: The ID of the evaluation to create an iteration for |
74 | | - * request_data: Contains the prompt iteration ID to use project_id: The ID of the |
75 | | - * project the evaluation belongs to request: FastAPI request object for tenant |
76 | | - * information |
77 | | - * |
78 | | - * Returns: The created EvaluationIterationEntry with COMPLETED status |
79 | | - */ |
80 | | - createIteration( |
81 | | - evaluationID: string, |
82 | | - params: EvaluationCreateIterationParams, |
83 | | - options?: RequestOptions, |
84 | | - ): APIPromise<EvaluationCreateIterationResponse> { |
85 | | - const { project_id, ...body } = params; |
86 | | - return this._client.post(path`/project/${project_id}/evaluations/${evaluationID}/iterations`, { |
87 | | - body, |
88 | | - ...options, |
89 | | - }); |
90 | | - } |
91 | | -} |
92 | | - |
93 | | -/** |
94 | | - * Evaluation entry database model. |
95 | | - */ |
96 | | -export interface EvaluationEntry { |
97 | | - /** |
98 | | - * The ID of the dataset to evaluate against |
99 | | - */ |
100 | | - datasetId: string; |
101 | | - |
102 | | - /** |
103 | | - * Configuration for the evaluation objective |
104 | | - */ |
105 | | - objectiveConfig: { [key: string]: unknown }; |
106 | | - |
107 | | - /** |
108 | | - * The type of evaluation objective |
109 | | - */ |
110 | | - objectiveType: EvaluationObjectiveType; |
111 | | - |
112 | | - projectId: string; |
113 | | - |
114 | | - id?: string; |
115 | | - |
116 | | - /** |
117 | | - * The ID of the agent to evaluate (mutually exclusive with promptId) |
118 | | - */ |
119 | | - agentId?: string | null; |
120 | | - |
121 | | - /** |
122 | | - * Timestamp when the record was created |
123 | | - */ |
124 | | - createdAt?: string | null; |
125 | | - |
126 | | - /** |
127 | | - * The ID of the prompt to evaluate (mutually exclusive with agentId) |
128 | | - */ |
129 | | - promptId?: string | null; |
130 | | - |
131 | | - /** |
132 | | - * Timestamp when the record was last updated |
133 | | - */ |
134 | | - updatedAt?: string | null; |
135 | | -} |
136 | | - |
137 | | -/** |
138 | | - * Enum for evaluation objective types. |
139 | | - */ |
140 | | -export type EvaluationObjectiveType = 'RUBRIC' | 'ACCURACY' | 'REGRESSION'; |
141 | | - |
142 | | -export type EvaluationListResponse = Array<EvaluationEntry>; |
143 | | - |
144 | | -export type EvaluationDeleteResponse = boolean; |
145 | | - |
146 | | -/** |
147 | | - * Evaluation iteration entry database model. |
148 | | - */ |
149 | | -export interface EvaluationCreateIterationResponse { |
150 | | - /** |
151 | | - * The ID of the evaluation |
152 | | - */ |
153 | | - evaluationId: string; |
154 | | - |
155 | | - id?: string; |
156 | | - |
157 | | - /** |
158 | | - * Timestamp when the record was created |
159 | | - */ |
160 | | - createdAt?: string | null; |
161 | | - |
162 | | - /** |
163 | | - * The number of entries completed for this evaluation iteration |
164 | | - */ |
165 | | - entriesCompleted?: number; |
166 | | - |
167 | | - /** |
168 | | - * The number of entries required for this evaluation iteration |
169 | | - */ |
170 | | - entriesRequired?: number; |
171 | | - |
172 | | - /** |
173 | | - * The ID of the prompt iteration (optional for agent evaluations) |
174 | | - */ |
175 | | - promptIterationId?: string | null; |
176 | | - |
177 | | - /** |
178 | | - * The status of the evaluation iteration |
179 | | - */ |
180 | | - status?: 'PENDING' | 'COMPLETED'; |
181 | | - |
182 | | - /** |
183 | | - * Timestamp when the record was last updated |
184 | | - */ |
185 | | - updatedAt?: string | null; |
186 | | -} |
187 | | - |
188 | | -export interface EvaluationCreateParams { |
189 | | - /** |
190 | | - * The ID of the dataset to evaluate against |
191 | | - */ |
192 | | - datasetId: string; |
193 | | - |
194 | | - /** |
195 | | - * Configuration for the evaluation objective |
196 | | - */ |
197 | | - objectiveConfig: { [key: string]: unknown }; |
198 | | - |
199 | | - /** |
200 | | - * The type of evaluation objective |
201 | | - */ |
202 | | - objectiveType: EvaluationObjectiveType; |
203 | | - |
204 | | - /** |
205 | | - * The ID of the agent to evaluate (mutually exclusive with promptId) |
206 | | - */ |
207 | | - agentId?: string | null; |
208 | | - |
209 | | - /** |
210 | | - * The ID of the prompt to evaluate (mutually exclusive with agentId) |
211 | | - */ |
212 | | - promptId?: string | null; |
213 | | -} |
214 | | - |
215 | | -export interface EvaluationRetrieveParams { |
216 | | - project_id: string; |
217 | | -} |
218 | | - |
219 | | -export interface EvaluationDeleteParams { |
220 | | - project_id: string; |
221 | | -} |
222 | | - |
223 | | -export interface EvaluationCreateIterationParams { |
224 | | - /** |
225 | | - * Path param: |
226 | | - */ |
227 | | - project_id: string; |
228 | | - |
229 | | - /** |
230 | | - * Body param: The ID of the prompt iteration to use |
231 | | - */ |
232 | | - promptIterationId: string; |
233 | | -} |
234 | | - |
235 | | -export declare namespace Evaluations { |
236 | | - export { |
237 | | - type EvaluationEntry as EvaluationEntry, |
238 | | - type EvaluationObjectiveType as EvaluationObjectiveType, |
239 | | - type EvaluationListResponse as EvaluationListResponse, |
240 | | - type EvaluationDeleteResponse as EvaluationDeleteResponse, |
241 | | - type EvaluationCreateIterationResponse as EvaluationCreateIterationResponse, |
242 | | - type EvaluationCreateParams as EvaluationCreateParams, |
243 | | - type EvaluationRetrieveParams as EvaluationRetrieveParams, |
244 | | - type EvaluationDeleteParams as EvaluationDeleteParams, |
245 | | - type EvaluationCreateIterationParams as EvaluationCreateIterationParams, |
246 | | - }; |
247 | | -} |
| 5 | +export class Evaluations extends APIResource {} |
0 commit comments