#![allow(clippy::needless_return, clippy::into_iter_on_ref)]
use super::{configuration, ContentType, Error};
use crate::{apis::ResponseContent, models};
use reqwest;
use serde::{de::Error as _, Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CancelFineTuningJobError {
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateFineTuningCheckpointPermissionError {
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateFineTuningJobError {
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteFineTuningCheckpointPermissionError {
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListFineTuningCheckpointPermissionsError {
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListFineTuningEventsError {
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListFineTuningJobCheckpointsError {
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListPaginatedFineTuningJobsError {
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PauseFineTuningJobError {
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ResumeFineTuningJobError {
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum RetrieveFineTuningJobError {
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum RunGraderError {
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ValidateGraderError {
UnknownValue(serde_json::Value),
}
#[bon::builder]
pub async fn cancel_fine_tuning_job(
configuration: &configuration::Configuration,
fine_tuning_job_id: &str,
) -> Result<models::FineTuningJob, Error<CancelFineTuningJobError>> {
let p_path_fine_tuning_job_id = fine_tuning_job_id;
let uri_str = format!(
"{}/fine_tuning/jobs/{fine_tuning_job_id}/cancel",
configuration.base_path,
fine_tuning_job_id = crate::apis::urlencode(p_path_fine_tuning_job_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::FineTuningJob`"))),
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::FineTuningJob`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CancelFineTuningJobError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
#[bon::builder]
pub async fn create_fine_tuning_checkpoint_permission(
configuration: &configuration::Configuration,
fine_tuned_model_checkpoint: &str,
create_fine_tuning_checkpoint_permission_request: models::CreateFineTuningCheckpointPermissionRequest,
) -> Result<
models::ListFineTuningCheckpointPermissionResponse,
Error<CreateFineTuningCheckpointPermissionError>,
> {
let p_path_fine_tuned_model_checkpoint = fine_tuned_model_checkpoint;
let p_body_create_fine_tuning_checkpoint_permission_request =
create_fine_tuning_checkpoint_permission_request;
let uri_str = format!(
"{}/fine_tuning/checkpoints/{fine_tuned_model_checkpoint}/permissions",
configuration.base_path,
fine_tuned_model_checkpoint = crate::apis::urlencode(p_path_fine_tuned_model_checkpoint)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_create_fine_tuning_checkpoint_permission_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ListFineTuningCheckpointPermissionResponse`"))),
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::ListFineTuningCheckpointPermissionResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateFineTuningCheckpointPermissionError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
#[bon::builder]
pub async fn create_fine_tuning_job(
configuration: &configuration::Configuration,
create_fine_tuning_job_request: models::CreateFineTuningJobRequest,
) -> Result<models::FineTuningJob, Error<CreateFineTuningJobError>> {
let p_body_create_fine_tuning_job_request = create_fine_tuning_job_request;
let uri_str = format!("{}/fine_tuning/jobs", configuration.base_path);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_create_fine_tuning_job_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::FineTuningJob`"))),
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::FineTuningJob`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateFineTuningJobError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
#[bon::builder]
pub async fn delete_fine_tuning_checkpoint_permission(
configuration: &configuration::Configuration,
fine_tuned_model_checkpoint: &str,
permission_id: &str,
) -> Result<
models::DeleteFineTuningCheckpointPermissionResponse,
Error<DeleteFineTuningCheckpointPermissionError>,
> {
let p_path_fine_tuned_model_checkpoint = fine_tuned_model_checkpoint;
let p_path_permission_id = permission_id;
let uri_str = format!(
"{}/fine_tuning/checkpoints/{fine_tuned_model_checkpoint}/permissions/{permission_id}",
configuration.base_path,
fine_tuned_model_checkpoint = crate::apis::urlencode(p_path_fine_tuned_model_checkpoint),
permission_id = crate::apis::urlencode(p_path_permission_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::DELETE, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeleteFineTuningCheckpointPermissionResponse`"))),
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::DeleteFineTuningCheckpointPermissionResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<DeleteFineTuningCheckpointPermissionError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
#[bon::builder]
pub async fn list_fine_tuning_checkpoint_permissions(
configuration: &configuration::Configuration,
fine_tuned_model_checkpoint: &str,
project_id: Option<&str>,
after: Option<&str>,
limit: Option<i32>,
order: Option<&str>,
) -> Result<
models::ListFineTuningCheckpointPermissionResponse,
Error<ListFineTuningCheckpointPermissionsError>,
> {
let p_path_fine_tuned_model_checkpoint = fine_tuned_model_checkpoint;
let p_query_project_id = project_id;
let p_query_after = after;
let p_query_limit = limit;
let p_query_order = order;
let uri_str = format!(
"{}/fine_tuning/checkpoints/{fine_tuned_model_checkpoint}/permissions",
configuration.base_path,
fine_tuned_model_checkpoint = crate::apis::urlencode(p_path_fine_tuned_model_checkpoint)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_project_id {
req_builder = req_builder.query(&[("project_id", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_after {
req_builder = req_builder.query(&[("after", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_limit {
req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_order {
req_builder = req_builder.query(&[("order", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ListFineTuningCheckpointPermissionResponse`"))),
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::ListFineTuningCheckpointPermissionResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListFineTuningCheckpointPermissionsError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
#[bon::builder]
pub async fn list_fine_tuning_events(
configuration: &configuration::Configuration,
fine_tuning_job_id: &str,
after: Option<&str>,
limit: Option<i32>,
) -> Result<models::ListFineTuningJobEventsResponse, Error<ListFineTuningEventsError>> {
let p_path_fine_tuning_job_id = fine_tuning_job_id;
let p_query_after = after;
let p_query_limit = limit;
let uri_str = format!(
"{}/fine_tuning/jobs/{fine_tuning_job_id}/events",
configuration.base_path,
fine_tuning_job_id = crate::apis::urlencode(p_path_fine_tuning_job_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_after {
req_builder = req_builder.query(&[("after", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_limit {
req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ListFineTuningJobEventsResponse`"))),
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::ListFineTuningJobEventsResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListFineTuningEventsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
#[bon::builder]
pub async fn list_fine_tuning_job_checkpoints(
configuration: &configuration::Configuration,
fine_tuning_job_id: &str,
after: Option<&str>,
limit: Option<i32>,
) -> Result<models::ListFineTuningJobCheckpointsResponse, Error<ListFineTuningJobCheckpointsError>>
{
let p_path_fine_tuning_job_id = fine_tuning_job_id;
let p_query_after = after;
let p_query_limit = limit;
let uri_str = format!(
"{}/fine_tuning/jobs/{fine_tuning_job_id}/checkpoints",
configuration.base_path,
fine_tuning_job_id = crate::apis::urlencode(p_path_fine_tuning_job_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_after {
req_builder = req_builder.query(&[("after", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_limit {
req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ListFineTuningJobCheckpointsResponse`"))),
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::ListFineTuningJobCheckpointsResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListFineTuningJobCheckpointsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
#[bon::builder]
pub async fn list_paginated_fine_tuning_jobs(
configuration: &configuration::Configuration,
after: Option<&str>,
limit: Option<i32>,
metadata: Option<std::collections::HashMap<String, String>>,
) -> Result<models::ListPaginatedFineTuningJobsResponse, Error<ListPaginatedFineTuningJobsError>> {
let p_query_after = after;
let p_query_limit = limit;
let p_query_metadata = metadata;
let uri_str = format!("{}/fine_tuning/jobs", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_after {
req_builder = req_builder.query(&[("after", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_limit {
req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_metadata {
let mut query_params = Vec::with_capacity(param_value.len());
for (key, value) in param_value.iter() {
query_params.push((key.to_string(), serde_json::to_string(value)?));
}
req_builder = req_builder.query(&query_params);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ListPaginatedFineTuningJobsResponse`"))),
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::ListPaginatedFineTuningJobsResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListPaginatedFineTuningJobsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
#[bon::builder]
pub async fn pause_fine_tuning_job(
configuration: &configuration::Configuration,
fine_tuning_job_id: &str,
) -> Result<models::FineTuningJob, Error<PauseFineTuningJobError>> {
let p_path_fine_tuning_job_id = fine_tuning_job_id;
let uri_str = format!(
"{}/fine_tuning/jobs/{fine_tuning_job_id}/pause",
configuration.base_path,
fine_tuning_job_id = crate::apis::urlencode(p_path_fine_tuning_job_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::FineTuningJob`"))),
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::FineTuningJob`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<PauseFineTuningJobError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
#[bon::builder]
pub async fn resume_fine_tuning_job(
configuration: &configuration::Configuration,
fine_tuning_job_id: &str,
) -> Result<models::FineTuningJob, Error<ResumeFineTuningJobError>> {
let p_path_fine_tuning_job_id = fine_tuning_job_id;
let uri_str = format!(
"{}/fine_tuning/jobs/{fine_tuning_job_id}/resume",
configuration.base_path,
fine_tuning_job_id = crate::apis::urlencode(p_path_fine_tuning_job_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::FineTuningJob`"))),
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::FineTuningJob`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ResumeFineTuningJobError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
#[bon::builder]
pub async fn retrieve_fine_tuning_job(
configuration: &configuration::Configuration,
fine_tuning_job_id: &str,
) -> Result<models::FineTuningJob, Error<RetrieveFineTuningJobError>> {
let p_path_fine_tuning_job_id = fine_tuning_job_id;
let uri_str = format!(
"{}/fine_tuning/jobs/{fine_tuning_job_id}",
configuration.base_path,
fine_tuning_job_id = crate::apis::urlencode(p_path_fine_tuning_job_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::FineTuningJob`"))),
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::FineTuningJob`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<RetrieveFineTuningJobError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
#[bon::builder]
pub async fn run_grader(
configuration: &configuration::Configuration,
run_grader_request: models::RunGraderRequest,
) -> Result<models::RunGraderResponse, Error<RunGraderError>> {
let p_body_run_grader_request = run_grader_request;
let uri_str = format!("{}/fine_tuning/alpha/graders/run", configuration.base_path);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_run_grader_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RunGraderResponse`"))),
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::RunGraderResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<RunGraderError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
#[bon::builder]
pub async fn validate_grader(
configuration: &configuration::Configuration,
validate_grader_request: models::ValidateGraderRequest,
) -> Result<models::ValidateGraderResponse, Error<ValidateGraderError>> {
let p_body_validate_grader_request = validate_grader_request;
let uri_str = format!(
"{}/fine_tuning/alpha/graders/validate",
configuration.base_path
);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_validate_grader_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ValidateGraderResponse`"))),
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::ValidateGraderResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ValidateGraderError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}