async_openai/evals/
eval_run_output_items.rs

1use crate::{
2    config::Config,
3    error::OpenAIError,
4    types::evals::{EvalRunOutputItem, EvalRunOutputItemList},
5    Client, RequestOptions,
6};
7
8pub struct EvalRunOutputItems<'c, C: Config> {
9    client: &'c Client<C>,
10    pub eval_id: String,
11    pub run_id: String,
12    pub(crate) request_options: RequestOptions,
13}
14
15impl<'c, C: Config> EvalRunOutputItems<'c, C> {
16    pub fn new(client: &'c Client<C>, eval_id: &str, run_id: &str) -> Self {
17        Self {
18            client,
19            eval_id: eval_id.into(),
20            run_id: run_id.into(),
21            request_options: RequestOptions::new(),
22        }
23    }
24
25    /// Get a list of output items for an evaluation run.
26    #[crate::byot(R = serde::de::DeserializeOwned)]
27    pub async fn list(&self) -> Result<EvalRunOutputItemList, OpenAIError> {
28        self.client
29            .get(
30                &format!("/evals/{}/runs/{}/output_items", self.eval_id, self.run_id),
31                &self.request_options,
32            )
33            .await
34    }
35
36    /// Get an evaluation run output item by ID.
37    #[crate::byot(T0 = std::fmt::Display, R = serde::de::DeserializeOwned)]
38    pub async fn retrieve(&self, output_item_id: &str) -> Result<EvalRunOutputItem, OpenAIError> {
39        self.client
40            .get(
41                &format!(
42                    "/evals/{}/runs/{}/output_items/{}",
43                    self.eval_id, self.run_id, output_item_id
44                ),
45                &self.request_options,
46            )
47            .await
48    }
49}