python/resources/evals/methods/retrieve/index.md +0 −472 deleted
File Deleted View Diff
1## Get an eval
2
3`evals.retrieve(streval_id) -> EvalRetrieveResponse`
4
5**get** `/evals/{eval_id}`
6
7Get an evaluation by ID.
8
9### Parameters
10
11- `eval_id: str`
12
13### Returns
14
15- `class EvalRetrieveResponse: …`
16
17 An Eval object with a data source config and testing criteria.
18 An Eval represents a task to be done for your LLM integration.
19 Like:
20
21 - Improve the quality of my chatbot
22 - See how well my chatbot handles customer support
23 - Check if o4-mini is better at my usecase than gpt-4o
24
25 - `id: str`
26
27 Unique identifier for the evaluation.
28
29 - `created_at: int`
30
31 The Unix timestamp (in seconds) for when the eval was created.
32
33 - `data_source_config: DataSourceConfig`
34
35 Configuration of data sources used in runs of the evaluation.
36
37 - `class EvalCustomDataSourceConfig: …`
38
39 A CustomDataSourceConfig which specifies the schema of your `item` and optionally `sample` namespaces.
40 The response schema defines the shape of the data that will be:
41
42 - Used to define your testing criteria and
43 - What data is required when creating a run
44
45 - `schema: Dict[str, object]`
46
47 The json schema for the run data source items.
48 Learn how to build JSON schemas [here](https://json-schema.org/).
49
50 - `type: Literal["custom"]`
51
52 The type of data source. Always `custom`.
53
54 - `"custom"`
55
56 - `class DataSourceConfigLogs: …`
57
58 A LogsDataSourceConfig which specifies the metadata property of your logs query.
59 This is usually metadata like `usecase=chatbot` or `prompt-version=v2`, etc.
60 The schema returned by this data source config is used to defined what variables are available in your evals.
61 `item` and `sample` are both defined when using this data source config.
62
63 - `schema: Dict[str, object]`
64
65 The json schema for the run data source items.
66 Learn how to build JSON schemas [here](https://json-schema.org/).
67
68 - `type: Literal["logs"]`
69
70 The type of data source. Always `logs`.
71
72 - `"logs"`
73
74 - `metadata: Optional[Metadata]`
75
76 Set of 16 key-value pairs that can be attached to an object. This can be
77 useful for storing additional information about the object in a structured
78 format, and querying for objects via API or the dashboard.
79
80 Keys are strings with a maximum length of 64 characters. Values are strings
81 with a maximum length of 512 characters.
82
83 - `class EvalStoredCompletionsDataSourceConfig: …`
84
85 Deprecated in favor of LogsDataSourceConfig.
86
87 - `schema: Dict[str, object]`
88
89 The json schema for the run data source items.
90 Learn how to build JSON schemas [here](https://json-schema.org/).
91
92 - `type: Literal["stored_completions"]`
93
94 The type of data source. Always `stored_completions`.
95
96 - `"stored_completions"`
97
98 - `metadata: Optional[Metadata]`
99
100 Set of 16 key-value pairs that can be attached to an object. This can be
101 useful for storing additional information about the object in a structured
102 format, and querying for objects via API or the dashboard.
103
104 Keys are strings with a maximum length of 64 characters. Values are strings
105 with a maximum length of 512 characters.
106
107 - `metadata: Optional[Metadata]`
108
109 Set of 16 key-value pairs that can be attached to an object. This can be
110 useful for storing additional information about the object in a structured
111 format, and querying for objects via API or the dashboard.
112
113 Keys are strings with a maximum length of 64 characters. Values are strings
114 with a maximum length of 512 characters.
115
116 - `name: str`
117
118 The name of the evaluation.
119
120 - `object: Literal["eval"]`
121
122 The object type.
123
124 - `"eval"`
125
126 - `testing_criteria: List[TestingCriterion]`
127
128 A list of testing criteria.
129
130 - `class LabelModelGrader: …`
131
132 A LabelModelGrader object which uses a model to assign labels to each item
133 in the evaluation.
134
135 - `input: List[Input]`
136
137 - `content: InputContent`
138
139 Inputs to the model - can contain template strings. Supports text, output text, input images, and input audio, either as a single item or an array of items.
140
141 - `str`
142
143 A text input to the model.
144
145 - `class ResponseInputText: …`
146
147 A text input to the model.
148
149 - `text: str`
150
151 The text input to the model.
152
153 - `type: Literal["input_text"]`
154
155 The type of the input item. Always `input_text`.
156
157 - `"input_text"`
158
159 - `class InputContentOutputText: …`
160
161 A text output from the model.
162
163 - `text: str`
164
165 The text output from the model.
166
167 - `type: Literal["output_text"]`
168
169 The type of the output text. Always `output_text`.
170
171 - `"output_text"`
172
173 - `class InputContentInputImage: …`
174
175 An image input block used within EvalItem content arrays.
176
177 - `image_url: str`
178
179 The URL of the image input.
180
181 - `type: Literal["input_image"]`
182
183 The type of the image input. Always `input_image`.
184
185 - `"input_image"`
186
187 - `detail: Optional[str]`
188
189 The detail level of the image to be sent to the model. One of `high`, `low`, or `auto`. Defaults to `auto`.
190
191 - `class ResponseInputAudio: …`
192
193 An audio input to the model.
194
195 - `input_audio: InputAudio`
196
197 - `data: str`
198
199 Base64-encoded audio data.
200
201 - `format: Literal["mp3", "wav"]`
202
203 The format of the audio data. Currently supported formats are `mp3` and
204 `wav`.
205
206 - `"mp3"`
207
208 - `"wav"`
209
210 - `type: Literal["input_audio"]`
211
212 The type of the input item. Always `input_audio`.
213
214 - `"input_audio"`
215
216 - `List[GraderInputItem]`
217
218 - `str`
219
220 A text input to the model.
221
222 - `class ResponseInputText: …`
223
224 A text input to the model.
225
226 - `class GraderInputItemOutputText: …`
227
228 A text output from the model.
229
230 - `text: str`
231
232 The text output from the model.
233
234 - `type: Literal["output_text"]`
235
236 The type of the output text. Always `output_text`.
237
238 - `"output_text"`
239
240 - `class GraderInputItemInputImage: …`
241
242 An image input block used within EvalItem content arrays.
243
244 - `image_url: str`
245
246 The URL of the image input.
247
248 - `type: Literal["input_image"]`
249
250 The type of the image input. Always `input_image`.
251
252 - `"input_image"`
253
254 - `detail: Optional[str]`
255
256 The detail level of the image to be sent to the model. One of `high`, `low`, or `auto`. Defaults to `auto`.
257
258 - `class ResponseInputAudio: …`
259
260 An audio input to the model.
261
262 - `role: Literal["user", "assistant", "system", "developer"]`
263
264 The role of the message input. One of `user`, `assistant`, `system`, or
265 `developer`.
266
267 - `"user"`
268
269 - `"assistant"`
270
271 - `"system"`
272
273 - `"developer"`
274
275 - `type: Optional[Literal["message"]]`
276
277 The type of the message input. Always `message`.
278
279 - `"message"`
280
281 - `labels: List[str]`
282
283 The labels to assign to each item in the evaluation.
284
285 - `model: str`
286
287 The model to use for the evaluation. Must support structured outputs.
288
289 - `name: str`
290
291 The name of the grader.
292
293 - `passing_labels: List[str]`
294
295 The labels that indicate a passing result. Must be a subset of labels.
296
297 - `type: Literal["label_model"]`
298
299 The object type, which is always `label_model`.
300
301 - `"label_model"`
302
303 - `class StringCheckGrader: …`
304
305 A StringCheckGrader object that performs a string comparison between input and reference using a specified operation.
306
307 - `input: str`
308
309 The input text. This may include template strings.
310
311 - `name: str`
312
313 The name of the grader.
314
315 - `operation: Literal["eq", "ne", "like", "ilike"]`
316
317 The string check operation to perform. One of `eq`, `ne`, `like`, or `ilike`.
318
319 - `"eq"`
320
321 - `"ne"`
322
323 - `"like"`
324
325 - `"ilike"`
326
327 - `reference: str`
328
329 The reference text. This may include template strings.
330
331 - `type: Literal["string_check"]`
332
333 The object type, which is always `string_check`.
334
335 - `"string_check"`
336
337 - `class TestingCriterionEvalGraderTextSimilarity: …`
338
339 A TextSimilarityGrader object which grades text based on similarity metrics.
340
341 - `pass_threshold: float`
342
343 The threshold for the score.
344
345 - `class TestingCriterionEvalGraderPython: …`
346
347 A PythonGrader object that runs a python script on the input.
348
349 - `pass_threshold: Optional[float]`
350
351 The threshold for the score.
352
353 - `class TestingCriterionEvalGraderScoreModel: …`
354
355 A ScoreModelGrader object that uses a model to assign a score to the input.
356
357 - `pass_threshold: Optional[float]`
358
359 The threshold for the score.
360
361### Example
362
363```python
364import os
365from openai import OpenAI
366
367client = OpenAI(
368 api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted
369)
370eval = client.evals.retrieve(
371 "eval_id",
372)
373print(eval.id)
374```
375
376#### Response
377
378```json
379{
380 "id": "id",
381 "created_at": 0,
382 "data_source_config": {
383 "schema": {
384 "foo": "bar"
385 },
386 "type": "custom"
387 },
388 "metadata": {
389 "foo": "string"
390 },
391 "name": "Chatbot effectiveness Evaluation",
392 "object": "eval",
393 "testing_criteria": [
394 {
395 "input": [
396 {
397 "content": "string",
398 "role": "user",
399 "type": "message"
400 }
401 ],
402 "labels": [
403 "string"
404 ],
405 "model": "model",
406 "name": "name",
407 "passing_labels": [
408 "string"
409 ],
410 "type": "label_model"
411 }
412 ]
413}
414```
415
416### Example
417
418```python
419from openai import OpenAI
420client = OpenAI()
421
422eval_obj = client.evals.retrieve("eval_67abd54d9b0081909a86353f6fb9317a")
423print(eval_obj)
424```
425
426#### Response
427
428```json
429{
430 "object": "eval",
431 "id": "eval_67abd54d9b0081909a86353f6fb9317a",
432 "data_source_config": {
433 "type": "custom",
434 "schema": {
435 "type": "object",
436 "properties": {
437 "item": {
438 "type": "object",
439 "properties": {
440 "input": {
441 "type": "string"
442 },
443 "ground_truth": {
444 "type": "string"
445 }
446 },
447 "required": [
448 "input",
449 "ground_truth"
450 ]
451 }
452 },
453 "required": [
454 "item"
455 ]
456 }
457 },
458 "testing_criteria": [
459 {
460 "name": "String check",
461 "id": "String check-2eaf2d8d-d649-4335-8148-9535a7ca73c2",
462 "type": "string_check",
463 "input": "{{item.input}}",
464 "reference": "{{item.ground_truth}}",
465 "operation": "eq"
466 }
467 ],
468 "name": "External Data Eval",
469 "created_at": 1739314509,
470 "metadata": {},
471}
472```