langfuse_client_base/apis/
unstable_evaluators_api.rs1use super::{configuration, ContentType, Error};
12use crate::{apis::ResponseContent, models};
13use reqwest;
14use serde::{de::Error as _, Deserialize, Serialize};
15
16#[derive(Debug, Clone, Serialize, Deserialize)]
18#[serde(untagged)]
19pub enum UnstableEvaluatorsCreateError {
20 Status400(serde_json::Value),
21 Status401(serde_json::Value),
22 Status403(serde_json::Value),
23 Status404(serde_json::Value),
24 Status405(serde_json::Value),
25 Status409(models::UnstablePublicApiError),
26 Status422(models::UnstablePublicApiError),
27 Status429(models::UnstablePublicApiError),
28 Status500(models::UnstablePublicApiError),
29 UnknownValue(serde_json::Value),
30}
31
32#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum UnstableEvaluatorsGetError {
36 Status400(serde_json::Value),
37 Status401(serde_json::Value),
38 Status403(serde_json::Value),
39 Status404(serde_json::Value),
40 Status405(serde_json::Value),
41 Status429(models::UnstablePublicApiError),
42 Status500(models::UnstablePublicApiError),
43 UnknownValue(serde_json::Value),
44}
45
46#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum UnstableEvaluatorsListError {
50 Status400(serde_json::Value),
51 Status401(serde_json::Value),
52 Status403(serde_json::Value),
53 Status404(serde_json::Value),
54 Status405(serde_json::Value),
55 Status429(models::UnstablePublicApiError),
56 Status500(models::UnstablePublicApiError),
57 UnknownValue(serde_json::Value),
58}
59
60#[bon::builder]
62pub async fn unstable_evaluators_create(
63 configuration: &configuration::Configuration,
64 unstable_create_evaluator_request: models::UnstableCreateEvaluatorRequest,
65) -> Result<models::UnstableEvaluator, Error<UnstableEvaluatorsCreateError>> {
66 let p_body_unstable_create_evaluator_request = unstable_create_evaluator_request;
68
69 let uri_str = format!("{}/api/public/unstable/evaluators", configuration.base_path);
70 let mut req_builder = configuration
71 .client
72 .request(reqwest::Method::POST, &uri_str);
73
74 if let Some(ref user_agent) = configuration.user_agent {
75 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
76 }
77 if let Some(ref auth_conf) = configuration.basic_auth {
78 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
79 };
80 req_builder = req_builder.json(&p_body_unstable_create_evaluator_request);
81
82 let req = req_builder.build()?;
83 let resp = configuration.client.execute(req).await?;
84
85 let status = resp.status();
86 let content_type = resp
87 .headers()
88 .get("content-type")
89 .and_then(|v| v.to_str().ok())
90 .unwrap_or("application/octet-stream");
91 let content_type = super::ContentType::from(content_type);
92
93 if !status.is_client_error() && !status.is_server_error() {
94 let content = resp.text().await?;
95 match content_type {
96 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
97 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::UnstableEvaluator`"))),
98 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::UnstableEvaluator`")))),
99 }
100 } else {
101 let content = resp.text().await?;
102 let entity: Option<UnstableEvaluatorsCreateError> = serde_json::from_str(&content).ok();
103 Err(Error::ResponseError(ResponseContent {
104 status,
105 content,
106 entity,
107 }))
108 }
109}
110
111#[bon::builder]
113pub async fn unstable_evaluators_get(
114 configuration: &configuration::Configuration,
115 evaluator_id: &str,
116) -> Result<models::UnstableEvaluator, Error<UnstableEvaluatorsGetError>> {
117 let p_path_evaluator_id = evaluator_id;
119
120 let uri_str = format!(
121 "{}/api/public/unstable/evaluators/{evaluatorId}",
122 configuration.base_path,
123 evaluatorId = crate::apis::urlencode(p_path_evaluator_id)
124 );
125 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
126
127 if let Some(ref user_agent) = configuration.user_agent {
128 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
129 }
130 if let Some(ref auth_conf) = configuration.basic_auth {
131 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
132 };
133
134 let req = req_builder.build()?;
135 let resp = configuration.client.execute(req).await?;
136
137 let status = resp.status();
138 let content_type = resp
139 .headers()
140 .get("content-type")
141 .and_then(|v| v.to_str().ok())
142 .unwrap_or("application/octet-stream");
143 let content_type = super::ContentType::from(content_type);
144
145 if !status.is_client_error() && !status.is_server_error() {
146 let content = resp.text().await?;
147 match content_type {
148 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
149 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::UnstableEvaluator`"))),
150 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::UnstableEvaluator`")))),
151 }
152 } else {
153 let content = resp.text().await?;
154 let entity: Option<UnstableEvaluatorsGetError> = serde_json::from_str(&content).ok();
155 Err(Error::ResponseError(ResponseContent {
156 status,
157 content,
158 entity,
159 }))
160 }
161}
162
163#[bon::builder]
165pub async fn unstable_evaluators_list(
166 configuration: &configuration::Configuration,
167 page: Option<i32>,
168 limit: Option<i32>,
169) -> Result<models::UnstableEvaluators, Error<UnstableEvaluatorsListError>> {
170 let p_query_page = page;
172 let p_query_limit = limit;
173
174 let uri_str = format!("{}/api/public/unstable/evaluators", configuration.base_path);
175 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
176
177 if let Some(ref param_value) = p_query_page {
178 req_builder = req_builder.query(&[("page", ¶m_value.to_string())]);
179 }
180 if let Some(ref param_value) = p_query_limit {
181 req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
182 }
183 if let Some(ref user_agent) = configuration.user_agent {
184 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
185 }
186 if let Some(ref auth_conf) = configuration.basic_auth {
187 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
188 };
189
190 let req = req_builder.build()?;
191 let resp = configuration.client.execute(req).await?;
192
193 let status = resp.status();
194 let content_type = resp
195 .headers()
196 .get("content-type")
197 .and_then(|v| v.to_str().ok())
198 .unwrap_or("application/octet-stream");
199 let content_type = super::ContentType::from(content_type);
200
201 if !status.is_client_error() && !status.is_server_error() {
202 let content = resp.text().await?;
203 match content_type {
204 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
205 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::UnstableEvaluators`"))),
206 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::UnstableEvaluators`")))),
207 }
208 } else {
209 let content = resp.text().await?;
210 let entity: Option<UnstableEvaluatorsListError> = serde_json::from_str(&content).ok();
211 Err(Error::ResponseError(ResponseContent {
212 status,
213 content,
214 entity,
215 }))
216 }
217}