openai_interface/evals/
create.rs1use serde::{Deserialize, Serialize};
7use url::Url;
8
9use crate::{
10 errors::OapiError,
11 evals::Eval,
12 rest::post::{Post, PostNoStream},
13};
14
15crate::request_body! {
16 #[derive(Debug, Clone, Serialize, Deserialize)]
18 pub struct CreateEvalRequest {
19 #[serde(skip_serializing_if = "Option::is_none")]
21 pub name: Option<String>,
22 pub data_source_config: serde_json::Value,
25 pub testing_criteria: Vec<serde_json::Value>,
28 #[serde(skip_serializing_if = "Option::is_none")]
31 pub metadata: Option<std::collections::HashMap<String, String>>,
32 }
33}
34
35impl Post for CreateEvalRequest {
36 fn is_streaming(&self) -> bool {
37 false
38 }
39
40 fn build_url(&self, base_url: &str) -> Result<String, OapiError> {
44 let mut url = Url::parse(base_url.trim_end_matches('/')).map_err(OapiError::UrlError)?;
45 url.path_segments_mut()
46 .map_err(|_| OapiError::UrlCannotBeBase(base_url.to_string()))?
47 .push("evals");
48 Ok(url.to_string())
49 }
50}
51
52impl PostNoStream for CreateEvalRequest {
53 type Response = Eval;
54}