ruby/resources/evals/methods/retrieve/index.md +0 −414 deleted
File Deleted View Diff
1## Get an eval
2
3`evals.retrieve(eval_id) -> EvalRetrieveResponse`
4
5**get** `/evals/{eval_id}`
6
7Get an evaluation by ID.
8
9### Parameters
10
11- `eval_id: String`
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: String`
26
27 Unique identifier for the evaluation.
28
29 - `created_at: Integer`
30
31 The Unix timestamp (in seconds) for when the eval was created.
32
33 - `data_source_config: EvalCustomDataSourceConfig | Logs{ schema, type, metadata} | EvalStoredCompletionsDataSourceConfig`
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: Hash[Symbol, untyped]`
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: :custom`
51
52 The type of data source. Always `custom`.
53
54 - `:custom`
55
56 - `class Logs`
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: Hash[Symbol, untyped]`
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: :logs`
69
70 The type of data source. Always `logs`.
71
72 - `:logs`
73
74 - `metadata: 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: Hash[Symbol, untyped]`
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: :stored_completions`
93
94 The type of data source. Always `stored_completions`.
95
96 - `:stored_completions`
97
98 - `metadata: 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: 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: String`
117
118 The name of the evaluation.
119
120 - `object: :eval`
121
122 The object type.
123
124 - `:eval`
125
126 - `testing_criteria: Array[LabelModelGrader | StringCheckGrader | TextSimilarityGrader & { pass_threshold} | 2 more]`
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: Array[Input{ content, role, type}]`
136
137 - `content: String | ResponseInputText | OutputText{ text, type} | 3 more`
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 - `String = String`
142
143 A text input to the model.
144
145 - `class ResponseInputText`
146
147 A text input to the model.
148
149 - `text: String`
150
151 The text input to the model.
152
153 - `type: :input_text`
154
155 The type of the input item. Always `input_text`.
156
157 - `:input_text`
158
159 - `class OutputText`
160
161 A text output from the model.
162
163 - `text: String`
164
165 The text output from the model.
166
167 - `type: :output_text`
168
169 The type of the output text. Always `output_text`.
170
171 - `:output_text`
172
173 - `class InputImage`
174
175 An image input block used within EvalItem content arrays.
176
177 - `image_url: String`
178
179 The URL of the image input.
180
181 - `type: :input_image`
182
183 The type of the image input. Always `input_image`.
184
185 - `:input_image`
186
187 - `detail: String`
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{ data, format_}`
196
197 - `data: String`
198
199 Base64-encoded audio data.
200
201 - `format_: :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: :input_audio`
211
212 The type of the input item. Always `input_audio`.
213
214 - `:input_audio`
215
216 - `GraderInputs = Array[GraderInputItem]`
217
218 A list of inputs, each of which may be either an input text, output text, input
219 image, or input audio object.
220
221 - `String = String`
222
223 A text input to the model.
224
225 - `class ResponseInputText`
226
227 A text input to the model.
228
229 - `class OutputText`
230
231 A text output from the model.
232
233 - `text: String`
234
235 The text output from the model.
236
237 - `type: :output_text`
238
239 The type of the output text. Always `output_text`.
240
241 - `:output_text`
242
243 - `class InputImage`
244
245 An image input block used within EvalItem content arrays.
246
247 - `image_url: String`
248
249 The URL of the image input.
250
251 - `type: :input_image`
252
253 The type of the image input. Always `input_image`.
254
255 - `:input_image`
256
257 - `detail: String`
258
259 The detail level of the image to be sent to the model. One of `high`, `low`, or `auto`. Defaults to `auto`.
260
261 - `class ResponseInputAudio`
262
263 An audio input to the model.
264
265 - `role: :user | :assistant | :system | :developer`
266
267 The role of the message input. One of `user`, `assistant`, `system`, or
268 `developer`.
269
270 - `:user`
271
272 - `:assistant`
273
274 - `:system`
275
276 - `:developer`
277
278 - `type: :message`
279
280 The type of the message input. Always `message`.
281
282 - `:message`
283
284 - `labels: Array[String]`
285
286 The labels to assign to each item in the evaluation.
287
288 - `model: String`
289
290 The model to use for the evaluation. Must support structured outputs.
291
292 - `name: String`
293
294 The name of the grader.
295
296 - `passing_labels: Array[String]`
297
298 The labels that indicate a passing result. Must be a subset of labels.
299
300 - `type: :label_model`
301
302 The object type, which is always `label_model`.
303
304 - `:label_model`
305
306 - `class StringCheckGrader`
307
308 A StringCheckGrader object that performs a string comparison between input and reference using a specified operation.
309
310 - `input: String`
311
312 The input text. This may include template strings.
313
314 - `name: String`
315
316 The name of the grader.
317
318 - `operation: :eq | :ne | :like | :ilike`
319
320 The string check operation to perform. One of `eq`, `ne`, `like`, or `ilike`.
321
322 - `:eq`
323
324 - `:ne`
325
326 - `:like`
327
328 - `:ilike`
329
330 - `reference: String`
331
332 The reference text. This may include template strings.
333
334 - `type: :string_check`
335
336 The object type, which is always `string_check`.
337
338 - `:string_check`
339
340 - `class EvalGraderTextSimilarity`
341
342 A TextSimilarityGrader object which grades text based on similarity metrics.
343
344 - `pass_threshold: Float`
345
346 The threshold for the score.
347
348 - `class EvalGraderPython`
349
350 A PythonGrader object that runs a python script on the input.
351
352 - `pass_threshold: Float`
353
354 The threshold for the score.
355
356 - `class EvalGraderScoreModel`
357
358 A ScoreModelGrader object that uses a model to assign a score to the input.
359
360 - `pass_threshold: Float`
361
362 The threshold for the score.
363
364### Example
365
366```ruby
367require "openai"
368
369openai = OpenAI::Client.new(api_key: "My API Key")
370
371eval_ = openai.evals.retrieve("eval_id")
372
373puts(eval_)
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```