Skip to main content

outfox_openai/evals/
eval_run_output_items.rs

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