Skip to main content

openai_interface/evals/runs/
retrieve.rs

1//! Retrieve an eval run via `GET /evals/{eval_id}/runs/{run_id}`.
2//!
3//! > ![warn] This module is untested!
4//! > If you encounter any issues, please report them on the repository.
5
6use url::Url;
7
8use crate::{
9    errors::OapiError,
10    evals::runs::EvalRun,
11    rest::get::{Get, GetNoStream},
12};
13
14/// Retrieves an eval run by its ID.
15#[derive(Debug, Clone)]
16pub struct RetrieveEvalRunRequest<'a> {
17    /// The ID of the eval, e.g. `eval_...`.
18    pub eval_id: &'a str,
19    /// The ID of the run to retrieve, e.g. `evalrun_...`.
20    pub run_id: &'a str,
21}
22
23impl Get for RetrieveEvalRunRequest<'_> {
24    /// Builds the URL for the request.
25    ///
26    /// `base_url` should be like <https://api.openai.com/v1>
27    fn build_url(&self, base_url: &str) -> Result<String, OapiError> {
28        let mut url = Url::parse(base_url.trim_end_matches('/')).map_err(OapiError::UrlError)?;
29        url.path_segments_mut()
30            .map_err(|_| OapiError::UrlCannotBeBase(base_url.to_string()))?
31            .push("evals")
32            .push(self.eval_id)
33            .push("runs")
34            .push(self.run_id);
35        Ok(url.to_string())
36    }
37}
38
39impl GetNoStream for RetrieveEvalRunRequest<'_> {
40    type Response = EvalRun;
41}