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