mirror of
https://github.com/mii443/openai-api-rs.git
synced 2025-08-22 15:15:34 +00:00
Add headers to client
This commit is contained in:
@ -10,7 +10,7 @@ use std::env;
|
|||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let api_key = env::var("OPENAI_API_KEY").unwrap().to_string();
|
let api_key = env::var("OPENAI_API_KEY").unwrap().to_string();
|
||||||
let client = OpenAIClient::builder().with_api_key(api_key).build()?;
|
let mut client = OpenAIClient::builder().with_api_key(api_key).build()?;
|
||||||
|
|
||||||
let mut tools = HashMap::new();
|
let mut tools = HashMap::new();
|
||||||
tools.insert("type".to_string(), "code_interpreter".to_string());
|
tools.insert("type".to_string(), "code_interpreter".to_string());
|
||||||
|
@ -5,7 +5,7 @@ use std::env;
|
|||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let api_key = env::var("OPENAI_API_KEY").unwrap().to_string();
|
let api_key = env::var("OPENAI_API_KEY").unwrap().to_string();
|
||||||
let client = OpenAIClient::builder().with_api_key(api_key).build()?;
|
let mut client = OpenAIClient::builder().with_api_key(api_key).build()?;
|
||||||
|
|
||||||
let req = AudioSpeechRequest::new(
|
let req = AudioSpeechRequest::new(
|
||||||
TTS_1.to_string(),
|
TTS_1.to_string(),
|
||||||
|
@ -7,7 +7,7 @@ use std::io::Read;
|
|||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let api_key = env::var("OPENAI_API_KEY").unwrap().to_string();
|
let api_key = env::var("OPENAI_API_KEY").unwrap().to_string();
|
||||||
let client = OpenAIClient::builder().with_api_key(api_key).build()?;
|
let mut client = OpenAIClient::builder().with_api_key(api_key).build()?;
|
||||||
|
|
||||||
let file_path = "examples/data/problem.mp3";
|
let file_path = "examples/data/problem.mp3";
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ use std::env;
|
|||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let api_key = env::var("OPENAI_API_KEY").unwrap().to_string();
|
let api_key = env::var("OPENAI_API_KEY").unwrap().to_string();
|
||||||
let client = OpenAIClient::builder().with_api_key(api_key).build()?;
|
let mut client = OpenAIClient::builder().with_api_key(api_key).build()?;
|
||||||
|
|
||||||
let req = AudioTranslationRequest::new(
|
let req = AudioTranslationRequest::new(
|
||||||
"examples/data/problem_cn.mp3".to_string(),
|
"examples/data/problem_cn.mp3".to_string(),
|
||||||
|
@ -10,7 +10,7 @@ use std::str;
|
|||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let api_key = env::var("OPENAI_API_KEY").unwrap().to_string();
|
let api_key = env::var("OPENAI_API_KEY").unwrap().to_string();
|
||||||
let client = OpenAIClient::builder().with_api_key(api_key).build()?;
|
let mut client = OpenAIClient::builder().with_api_key(api_key).build()?;
|
||||||
|
|
||||||
let req = FileUploadRequest::new(
|
let req = FileUploadRequest::new(
|
||||||
"examples/data/batch_request.json".to_string(),
|
"examples/data/batch_request.json".to_string(),
|
||||||
|
@ -6,7 +6,7 @@ use std::env;
|
|||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let api_key = env::var("OPENAI_API_KEY").unwrap().to_string();
|
let api_key = env::var("OPENAI_API_KEY").unwrap().to_string();
|
||||||
let client = OpenAIClient::builder().with_api_key(api_key).build()?;
|
let mut client = OpenAIClient::builder().with_api_key(api_key).build()?;
|
||||||
|
|
||||||
let req = ChatCompletionRequest::new(
|
let req = ChatCompletionRequest::new(
|
||||||
GPT4_O_MINI.to_string(),
|
GPT4_O_MINI.to_string(),
|
||||||
@ -21,7 +21,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
|
|
||||||
let result = client.chat_completion(req).await?;
|
let result = client.chat_completion(req).await?;
|
||||||
println!("Content: {:?}", result.choices[0].message.content);
|
println!("Content: {:?}", result.choices[0].message.content);
|
||||||
println!("Response Headers: {:?}", result.headers);
|
println!("Response Headers: {:?}", client.headers);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ use std::env;
|
|||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let api_key = env::var("OPENAI_API_KEY").unwrap().to_string();
|
let api_key = env::var("OPENAI_API_KEY").unwrap().to_string();
|
||||||
let client = OpenAIClient::builder().with_api_key(api_key).build()?;
|
let mut client = OpenAIClient::builder().with_api_key(api_key).build()?;
|
||||||
|
|
||||||
let req = CompletionRequest::new(
|
let req = CompletionRequest::new(
|
||||||
completion::GPT3_TEXT_DAVINCI_003.to_string(),
|
completion::GPT3_TEXT_DAVINCI_003.to_string(),
|
||||||
|
@ -6,7 +6,7 @@ use std::env;
|
|||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let api_key = env::var("OPENAI_API_KEY").unwrap().to_string();
|
let api_key = env::var("OPENAI_API_KEY").unwrap().to_string();
|
||||||
let client = OpenAIClient::builder().with_api_key(api_key).build()?;
|
let mut client = OpenAIClient::builder().with_api_key(api_key).build()?;
|
||||||
|
|
||||||
let mut req = EmbeddingRequest::new(
|
let mut req = EmbeddingRequest::new(
|
||||||
TEXT_EMBEDDING_3_SMALL.to_string(),
|
TEXT_EMBEDDING_3_SMALL.to_string(),
|
||||||
|
@ -18,7 +18,7 @@ fn get_coin_price(coin: &str) -> f64 {
|
|||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let api_key = env::var("OPENAI_API_KEY").unwrap().to_string();
|
let api_key = env::var("OPENAI_API_KEY").unwrap().to_string();
|
||||||
let client = OpenAIClient::builder().with_api_key(api_key).build()?;
|
let mut client = OpenAIClient::builder().with_api_key(api_key).build()?;
|
||||||
|
|
||||||
let mut properties = HashMap::new();
|
let mut properties = HashMap::new();
|
||||||
properties.insert(
|
properties.insert(
|
||||||
|
@ -18,7 +18,7 @@ fn get_coin_price(coin: &str) -> f64 {
|
|||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let api_key = env::var("OPENAI_API_KEY").unwrap().to_string();
|
let api_key = env::var("OPENAI_API_KEY").unwrap().to_string();
|
||||||
let client = OpenAIClient::builder().with_api_key(api_key).build()?;
|
let mut client = OpenAIClient::builder().with_api_key(api_key).build()?;
|
||||||
|
|
||||||
let mut properties = HashMap::new();
|
let mut properties = HashMap::new();
|
||||||
properties.insert(
|
properties.insert(
|
||||||
|
@ -6,7 +6,7 @@ use std::env;
|
|||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let api_key = env::var("OPENROUTER_API_KEY").unwrap().to_string();
|
let api_key = env::var("OPENROUTER_API_KEY").unwrap().to_string();
|
||||||
let client = OpenAIClient::builder()
|
let mut client = OpenAIClient::builder()
|
||||||
.with_endpoint("https://openrouter.ai/api/v1")
|
.with_endpoint("https://openrouter.ai/api/v1")
|
||||||
.with_api_key(api_key)
|
.with_api_key(api_key)
|
||||||
.build()?;
|
.build()?;
|
||||||
@ -24,7 +24,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
|
|
||||||
let result = client.chat_completion(req).await?;
|
let result = client.chat_completion(req).await?;
|
||||||
println!("Content: {:?}", result.choices[0].message.content);
|
println!("Content: {:?}", result.choices[0].message.content);
|
||||||
println!("Response Headers: {:?}", result.headers);
|
println!("Response Headers: {:?}", client.headers);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ use std::env;
|
|||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let api_key = env::var("OPENAI_API_KEY").unwrap().to_string();
|
let api_key = env::var("OPENAI_API_KEY").unwrap().to_string();
|
||||||
let client = OpenAIClient::builder().with_api_key(api_key).build()?;
|
let mut client = OpenAIClient::builder().with_api_key(api_key).build()?;
|
||||||
|
|
||||||
let req = ChatCompletionRequest::new(
|
let req = ChatCompletionRequest::new(
|
||||||
GPT4_O.to_string(),
|
GPT4_O.to_string(),
|
||||||
|
122
src/v1/api.rs
122
src/v1/api.rs
@ -68,7 +68,7 @@ pub struct OpenAIClient {
|
|||||||
organization: Option<String>,
|
organization: Option<String>,
|
||||||
proxy: Option<String>,
|
proxy: Option<String>,
|
||||||
timeout: Option<u64>,
|
timeout: Option<u64>,
|
||||||
headers: Option<HeaderMap>,
|
pub headers: Option<HeaderMap>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl OpenAIClientBuilder {
|
impl OpenAIClientBuilder {
|
||||||
@ -175,7 +175,7 @@ impl OpenAIClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fn post<T: serde::de::DeserializeOwned>(
|
async fn post<T: serde::de::DeserializeOwned>(
|
||||||
&self,
|
&mut self,
|
||||||
path: &str,
|
path: &str,
|
||||||
body: &impl serde::ser::Serialize,
|
body: &impl serde::ser::Serialize,
|
||||||
) -> Result<T, APIError> {
|
) -> Result<T, APIError> {
|
||||||
@ -185,7 +185,7 @@ impl OpenAIClient {
|
|||||||
self.handle_response(response).await
|
self.handle_response(response).await
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn get<T: serde::de::DeserializeOwned>(&self, path: &str) -> Result<T, APIError> {
|
async fn get<T: serde::de::DeserializeOwned>(&mut self, path: &str) -> Result<T, APIError> {
|
||||||
let request = self.build_request(Method::GET, path).await;
|
let request = self.build_request(Method::GET, path).await;
|
||||||
let response = request.send().await?;
|
let response = request.send().await?;
|
||||||
self.handle_response(response).await
|
self.handle_response(response).await
|
||||||
@ -197,14 +197,14 @@ impl OpenAIClient {
|
|||||||
Ok(response.bytes().await?)
|
Ok(response.bytes().await?)
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn delete<T: serde::de::DeserializeOwned>(&self, path: &str) -> Result<T, APIError> {
|
async fn delete<T: serde::de::DeserializeOwned>(&mut self, path: &str) -> Result<T, APIError> {
|
||||||
let request = self.build_request(Method::DELETE, path).await;
|
let request = self.build_request(Method::DELETE, path).await;
|
||||||
let response = request.send().await?;
|
let response = request.send().await?;
|
||||||
self.handle_response(response).await
|
self.handle_response(response).await
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn post_form<T: serde::de::DeserializeOwned>(
|
async fn post_form<T: serde::de::DeserializeOwned>(
|
||||||
&self,
|
&mut self,
|
||||||
path: &str,
|
path: &str,
|
||||||
form: Form,
|
form: Form,
|
||||||
) -> Result<T, APIError> {
|
) -> Result<T, APIError> {
|
||||||
@ -222,14 +222,18 @@ impl OpenAIClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fn handle_response<T: serde::de::DeserializeOwned>(
|
async fn handle_response<T: serde::de::DeserializeOwned>(
|
||||||
&self,
|
&mut self,
|
||||||
response: Response,
|
response: Response,
|
||||||
) -> Result<T, APIError> {
|
) -> Result<T, APIError> {
|
||||||
let status = response.status();
|
let status = response.status();
|
||||||
|
let headers = response.headers().clone();
|
||||||
if status.is_success() {
|
if status.is_success() {
|
||||||
let text = response.text().await.unwrap_or_else(|_| "".to_string());
|
let text = response.text().await.unwrap_or_else(|_| "".to_string());
|
||||||
match serde_json::from_str::<T>(&text) {
|
match serde_json::from_str::<T>(&text) {
|
||||||
Ok(parsed) => Ok(parsed),
|
Ok(parsed) => {
|
||||||
|
self.headers = Some(headers);
|
||||||
|
Ok(parsed)
|
||||||
|
},
|
||||||
Err(e) => Err(APIError::CustomError {
|
Err(e) => Err(APIError::CustomError {
|
||||||
message: format!("Failed to parse JSON: {} / response {}", e, text),
|
message: format!("Failed to parse JSON: {} / response {}", e, text),
|
||||||
}),
|
}),
|
||||||
@ -245,42 +249,42 @@ impl OpenAIClient {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn completion(&self, req: CompletionRequest) -> Result<CompletionResponse, APIError> {
|
pub async fn completion(&mut self, req: CompletionRequest) -> Result<CompletionResponse, APIError> {
|
||||||
self.post("completions", &req).await
|
self.post("completions", &req).await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn edit(&self, req: EditRequest) -> Result<EditResponse, APIError> {
|
pub async fn edit(&mut self, req: EditRequest) -> Result<EditResponse, APIError> {
|
||||||
self.post("edits", &req).await
|
self.post("edits", &req).await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn image_generation(
|
pub async fn image_generation(
|
||||||
&self,
|
&mut self,
|
||||||
req: ImageGenerationRequest,
|
req: ImageGenerationRequest,
|
||||||
) -> Result<ImageGenerationResponse, APIError> {
|
) -> Result<ImageGenerationResponse, APIError> {
|
||||||
self.post("images/generations", &req).await
|
self.post("images/generations", &req).await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn image_edit(&self, req: ImageEditRequest) -> Result<ImageEditResponse, APIError> {
|
pub async fn image_edit(&mut self, req: ImageEditRequest) -> Result<ImageEditResponse, APIError> {
|
||||||
self.post("images/edits", &req).await
|
self.post("images/edits", &req).await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn image_variation(
|
pub async fn image_variation(
|
||||||
&self,
|
&mut self,
|
||||||
req: ImageVariationRequest,
|
req: ImageVariationRequest,
|
||||||
) -> Result<ImageVariationResponse, APIError> {
|
) -> Result<ImageVariationResponse, APIError> {
|
||||||
self.post("images/variations", &req).await
|
self.post("images/variations", &req).await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn embedding(&self, req: EmbeddingRequest) -> Result<EmbeddingResponse, APIError> {
|
pub async fn embedding(&mut self, req: EmbeddingRequest) -> Result<EmbeddingResponse, APIError> {
|
||||||
self.post("embeddings", &req).await
|
self.post("embeddings", &req).await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn file_list(&self) -> Result<FileListResponse, APIError> {
|
pub async fn file_list(&mut self) -> Result<FileListResponse, APIError> {
|
||||||
self.get("files").await
|
self.get("files").await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn upload_file(
|
pub async fn upload_file(
|
||||||
&self,
|
&mut self,
|
||||||
req: FileUploadRequest,
|
req: FileUploadRequest,
|
||||||
) -> Result<FileUploadResponse, APIError> {
|
) -> Result<FileUploadResponse, APIError> {
|
||||||
let form = Self::create_form(&req, "file")?;
|
let form = Self::create_form(&req, "file")?;
|
||||||
@ -288,13 +292,13 @@ impl OpenAIClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn delete_file(
|
pub async fn delete_file(
|
||||||
&self,
|
&mut self,
|
||||||
req: FileDeleteRequest,
|
req: FileDeleteRequest,
|
||||||
) -> Result<FileDeleteResponse, APIError> {
|
) -> Result<FileDeleteResponse, APIError> {
|
||||||
self.delete(&format!("files/{}", req.file_id)).await
|
self.delete(&format!("files/{}", req.file_id)).await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn retrieve_file(&self, file_id: String) -> Result<FileRetrieveResponse, APIError> {
|
pub async fn retrieve_file(&mut self, file_id: String) -> Result<FileRetrieveResponse, APIError> {
|
||||||
self.get(&format!("files/{}", file_id)).await
|
self.get(&format!("files/{}", file_id)).await
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -303,14 +307,14 @@ impl OpenAIClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn chat_completion(
|
pub async fn chat_completion(
|
||||||
&self,
|
&mut self,
|
||||||
req: ChatCompletionRequest,
|
req: ChatCompletionRequest,
|
||||||
) -> Result<ChatCompletionResponse, APIError> {
|
) -> Result<ChatCompletionResponse, APIError> {
|
||||||
self.post("chat/completions", &req).await
|
self.post("chat/completions", &req).await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn audio_transcription(
|
pub async fn audio_transcription(
|
||||||
&self,
|
&mut self,
|
||||||
req: AudioTranscriptionRequest,
|
req: AudioTranscriptionRequest,
|
||||||
) -> Result<AudioTranscriptionResponse, APIError> {
|
) -> Result<AudioTranscriptionResponse, APIError> {
|
||||||
// https://platform.openai.com/docs/api-reference/audio/createTranscription#audio-createtranscription-response_format
|
// https://platform.openai.com/docs/api-reference/audio/createTranscription#audio-createtranscription-response_format
|
||||||
@ -335,7 +339,7 @@ impl OpenAIClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn audio_transcription_raw(
|
pub async fn audio_transcription_raw(
|
||||||
&self,
|
&mut self,
|
||||||
req: AudioTranscriptionRequest,
|
req: AudioTranscriptionRequest,
|
||||||
) -> Result<Bytes, APIError> {
|
) -> Result<Bytes, APIError> {
|
||||||
// https://platform.openai.com/docs/api-reference/audio/createTranscription#audio-createtranscription-response_format
|
// https://platform.openai.com/docs/api-reference/audio/createTranscription#audio-createtranscription-response_format
|
||||||
@ -360,7 +364,7 @@ impl OpenAIClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn audio_translation(
|
pub async fn audio_translation(
|
||||||
&self,
|
&mut self,
|
||||||
req: AudioTranslationRequest,
|
req: AudioTranslationRequest,
|
||||||
) -> Result<AudioTranslationResponse, APIError> {
|
) -> Result<AudioTranslationResponse, APIError> {
|
||||||
let form = Self::create_form(&req, "file")?;
|
let form = Self::create_form(&req, "file")?;
|
||||||
@ -368,7 +372,7 @@ impl OpenAIClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn audio_speech(
|
pub async fn audio_speech(
|
||||||
&self,
|
&mut self,
|
||||||
req: AudioSpeechRequest,
|
req: AudioSpeechRequest,
|
||||||
) -> Result<AudioSpeechResponse, APIError> {
|
) -> Result<AudioSpeechResponse, APIError> {
|
||||||
let request = self.build_request(Method::POST, "audio/speech").await;
|
let request = self.build_request(Method::POST, "audio/speech").await;
|
||||||
@ -410,20 +414,20 @@ impl OpenAIClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn create_fine_tuning_job(
|
pub async fn create_fine_tuning_job(
|
||||||
&self,
|
&mut self,
|
||||||
req: CreateFineTuningJobRequest,
|
req: CreateFineTuningJobRequest,
|
||||||
) -> Result<FineTuningJobObject, APIError> {
|
) -> Result<FineTuningJobObject, APIError> {
|
||||||
self.post("fine_tuning/jobs", &req).await
|
self.post("fine_tuning/jobs", &req).await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn list_fine_tuning_jobs(
|
pub async fn list_fine_tuning_jobs(
|
||||||
&self,
|
&mut self,
|
||||||
) -> Result<FineTuningPagination<FineTuningJobObject>, APIError> {
|
) -> Result<FineTuningPagination<FineTuningJobObject>, APIError> {
|
||||||
self.get("fine_tuning/jobs").await
|
self.get("fine_tuning/jobs").await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn list_fine_tuning_job_events(
|
pub async fn list_fine_tuning_job_events(
|
||||||
&self,
|
&mut self,
|
||||||
req: ListFineTuningJobEventsRequest,
|
req: ListFineTuningJobEventsRequest,
|
||||||
) -> Result<FineTuningPagination<FineTuningJobEvent>, APIError> {
|
) -> Result<FineTuningPagination<FineTuningJobEvent>, APIError> {
|
||||||
self.get(&format!(
|
self.get(&format!(
|
||||||
@ -434,7 +438,7 @@ impl OpenAIClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn retrieve_fine_tuning_job(
|
pub async fn retrieve_fine_tuning_job(
|
||||||
&self,
|
&mut self,
|
||||||
req: RetrieveFineTuningJobRequest,
|
req: RetrieveFineTuningJobRequest,
|
||||||
) -> Result<FineTuningJobObject, APIError> {
|
) -> Result<FineTuningJobObject, APIError> {
|
||||||
self.get(&format!("fine_tuning/jobs/{}", req.fine_tuning_job_id))
|
self.get(&format!("fine_tuning/jobs/{}", req.fine_tuning_job_id))
|
||||||
@ -442,7 +446,7 @@ impl OpenAIClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn cancel_fine_tuning_job(
|
pub async fn cancel_fine_tuning_job(
|
||||||
&self,
|
&mut self,
|
||||||
req: CancelFineTuningJobRequest,
|
req: CancelFineTuningJobRequest,
|
||||||
) -> Result<FineTuningJobObject, APIError> {
|
) -> Result<FineTuningJobObject, APIError> {
|
||||||
self.post(
|
self.post(
|
||||||
@ -453,28 +457,28 @@ impl OpenAIClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn create_moderation(
|
pub async fn create_moderation(
|
||||||
&self,
|
&mut self,
|
||||||
req: CreateModerationRequest,
|
req: CreateModerationRequest,
|
||||||
) -> Result<CreateModerationResponse, APIError> {
|
) -> Result<CreateModerationResponse, APIError> {
|
||||||
self.post("moderations", &req).await
|
self.post("moderations", &req).await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn create_assistant(
|
pub async fn create_assistant(
|
||||||
&self,
|
&mut self,
|
||||||
req: AssistantRequest,
|
req: AssistantRequest,
|
||||||
) -> Result<AssistantObject, APIError> {
|
) -> Result<AssistantObject, APIError> {
|
||||||
self.post("assistants", &req).await
|
self.post("assistants", &req).await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn retrieve_assistant(
|
pub async fn retrieve_assistant(
|
||||||
&self,
|
&mut self,
|
||||||
assistant_id: String,
|
assistant_id: String,
|
||||||
) -> Result<AssistantObject, APIError> {
|
) -> Result<AssistantObject, APIError> {
|
||||||
self.get(&format!("assistants/{}", assistant_id)).await
|
self.get(&format!("assistants/{}", assistant_id)).await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn modify_assistant(
|
pub async fn modify_assistant(
|
||||||
&self,
|
&mut self,
|
||||||
assistant_id: String,
|
assistant_id: String,
|
||||||
req: AssistantRequest,
|
req: AssistantRequest,
|
||||||
) -> Result<AssistantObject, APIError> {
|
) -> Result<AssistantObject, APIError> {
|
||||||
@ -482,12 +486,12 @@ impl OpenAIClient {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn delete_assistant(&self, assistant_id: String) -> Result<DeletionStatus, APIError> {
|
pub async fn delete_assistant(&mut self, assistant_id: String) -> Result<DeletionStatus, APIError> {
|
||||||
self.delete(&format!("assistants/{}", assistant_id)).await
|
self.delete(&format!("assistants/{}", assistant_id)).await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn list_assistant(
|
pub async fn list_assistant(
|
||||||
&self,
|
&mut self,
|
||||||
limit: Option<i64>,
|
limit: Option<i64>,
|
||||||
order: Option<String>,
|
order: Option<String>,
|
||||||
after: Option<String>,
|
after: Option<String>,
|
||||||
@ -498,7 +502,7 @@ impl OpenAIClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn create_assistant_file(
|
pub async fn create_assistant_file(
|
||||||
&self,
|
&mut self,
|
||||||
assistant_id: String,
|
assistant_id: String,
|
||||||
req: AssistantFileRequest,
|
req: AssistantFileRequest,
|
||||||
) -> Result<AssistantFileObject, APIError> {
|
) -> Result<AssistantFileObject, APIError> {
|
||||||
@ -507,7 +511,7 @@ impl OpenAIClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn retrieve_assistant_file(
|
pub async fn retrieve_assistant_file(
|
||||||
&self,
|
&mut self,
|
||||||
assistant_id: String,
|
assistant_id: String,
|
||||||
file_id: String,
|
file_id: String,
|
||||||
) -> Result<AssistantFileObject, APIError> {
|
) -> Result<AssistantFileObject, APIError> {
|
||||||
@ -516,7 +520,7 @@ impl OpenAIClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn delete_assistant_file(
|
pub async fn delete_assistant_file(
|
||||||
&self,
|
&mut self,
|
||||||
assistant_id: String,
|
assistant_id: String,
|
||||||
file_id: String,
|
file_id: String,
|
||||||
) -> Result<DeletionStatus, APIError> {
|
) -> Result<DeletionStatus, APIError> {
|
||||||
@ -525,7 +529,7 @@ impl OpenAIClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn list_assistant_file(
|
pub async fn list_assistant_file(
|
||||||
&self,
|
&mut self,
|
||||||
assistant_id: String,
|
assistant_id: String,
|
||||||
limit: Option<i64>,
|
limit: Option<i64>,
|
||||||
order: Option<String>,
|
order: Option<String>,
|
||||||
@ -542,28 +546,28 @@ impl OpenAIClient {
|
|||||||
self.get(&url).await
|
self.get(&url).await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn create_thread(&self, req: CreateThreadRequest) -> Result<ThreadObject, APIError> {
|
pub async fn create_thread(&mut self, req: CreateThreadRequest) -> Result<ThreadObject, APIError> {
|
||||||
self.post("threads", &req).await
|
self.post("threads", &req).await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn retrieve_thread(&self, thread_id: String) -> Result<ThreadObject, APIError> {
|
pub async fn retrieve_thread(&mut self, thread_id: String) -> Result<ThreadObject, APIError> {
|
||||||
self.get(&format!("threads/{}", thread_id)).await
|
self.get(&format!("threads/{}", thread_id)).await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn modify_thread(
|
pub async fn modify_thread(
|
||||||
&self,
|
&mut self,
|
||||||
thread_id: String,
|
thread_id: String,
|
||||||
req: ModifyThreadRequest,
|
req: ModifyThreadRequest,
|
||||||
) -> Result<ThreadObject, APIError> {
|
) -> Result<ThreadObject, APIError> {
|
||||||
self.post(&format!("threads/{}", thread_id), &req).await
|
self.post(&format!("threads/{}", thread_id), &req).await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn delete_thread(&self, thread_id: String) -> Result<DeletionStatus, APIError> {
|
pub async fn delete_thread(&mut self, thread_id: String) -> Result<DeletionStatus, APIError> {
|
||||||
self.delete(&format!("threads/{}", thread_id)).await
|
self.delete(&format!("threads/{}", thread_id)).await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn create_message(
|
pub async fn create_message(
|
||||||
&self,
|
&mut self,
|
||||||
thread_id: String,
|
thread_id: String,
|
||||||
req: CreateMessageRequest,
|
req: CreateMessageRequest,
|
||||||
) -> Result<MessageObject, APIError> {
|
) -> Result<MessageObject, APIError> {
|
||||||
@ -572,7 +576,7 @@ impl OpenAIClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn retrieve_message(
|
pub async fn retrieve_message(
|
||||||
&self,
|
&mut self,
|
||||||
thread_id: String,
|
thread_id: String,
|
||||||
message_id: String,
|
message_id: String,
|
||||||
) -> Result<MessageObject, APIError> {
|
) -> Result<MessageObject, APIError> {
|
||||||
@ -581,7 +585,7 @@ impl OpenAIClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn modify_message(
|
pub async fn modify_message(
|
||||||
&self,
|
&mut self,
|
||||||
thread_id: String,
|
thread_id: String,
|
||||||
message_id: String,
|
message_id: String,
|
||||||
req: ModifyMessageRequest,
|
req: ModifyMessageRequest,
|
||||||
@ -593,12 +597,12 @@ impl OpenAIClient {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn list_messages(&self, thread_id: String) -> Result<ListMessage, APIError> {
|
pub async fn list_messages(&mut self, thread_id: String) -> Result<ListMessage, APIError> {
|
||||||
self.get(&format!("threads/{}/messages", thread_id)).await
|
self.get(&format!("threads/{}/messages", thread_id)).await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn retrieve_message_file(
|
pub async fn retrieve_message_file(
|
||||||
&self,
|
&mut self,
|
||||||
thread_id: String,
|
thread_id: String,
|
||||||
message_id: String,
|
message_id: String,
|
||||||
file_id: String,
|
file_id: String,
|
||||||
@ -611,7 +615,7 @@ impl OpenAIClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn list_message_file(
|
pub async fn list_message_file(
|
||||||
&self,
|
&mut self,
|
||||||
thread_id: String,
|
thread_id: String,
|
||||||
message_id: String,
|
message_id: String,
|
||||||
limit: Option<i64>,
|
limit: Option<i64>,
|
||||||
@ -630,7 +634,7 @@ impl OpenAIClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn create_run(
|
pub async fn create_run(
|
||||||
&self,
|
&mut self,
|
||||||
thread_id: String,
|
thread_id: String,
|
||||||
req: CreateRunRequest,
|
req: CreateRunRequest,
|
||||||
) -> Result<RunObject, APIError> {
|
) -> Result<RunObject, APIError> {
|
||||||
@ -639,7 +643,7 @@ impl OpenAIClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn retrieve_run(
|
pub async fn retrieve_run(
|
||||||
&self,
|
&mut self,
|
||||||
thread_id: String,
|
thread_id: String,
|
||||||
run_id: String,
|
run_id: String,
|
||||||
) -> Result<RunObject, APIError> {
|
) -> Result<RunObject, APIError> {
|
||||||
@ -648,7 +652,7 @@ impl OpenAIClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn modify_run(
|
pub async fn modify_run(
|
||||||
&self,
|
&mut self,
|
||||||
thread_id: String,
|
thread_id: String,
|
||||||
run_id: String,
|
run_id: String,
|
||||||
req: ModifyRunRequest,
|
req: ModifyRunRequest,
|
||||||
@ -658,7 +662,7 @@ impl OpenAIClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn list_run(
|
pub async fn list_run(
|
||||||
&self,
|
&mut self,
|
||||||
thread_id: String,
|
thread_id: String,
|
||||||
limit: Option<i64>,
|
limit: Option<i64>,
|
||||||
order: Option<String>,
|
order: Option<String>,
|
||||||
@ -676,7 +680,7 @@ impl OpenAIClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn cancel_run(
|
pub async fn cancel_run(
|
||||||
&self,
|
&mut self,
|
||||||
thread_id: String,
|
thread_id: String,
|
||||||
run_id: String,
|
run_id: String,
|
||||||
) -> Result<RunObject, APIError> {
|
) -> Result<RunObject, APIError> {
|
||||||
@ -688,14 +692,14 @@ impl OpenAIClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn create_thread_and_run(
|
pub async fn create_thread_and_run(
|
||||||
&self,
|
&mut self,
|
||||||
req: CreateThreadAndRunRequest,
|
req: CreateThreadAndRunRequest,
|
||||||
) -> Result<RunObject, APIError> {
|
) -> Result<RunObject, APIError> {
|
||||||
self.post("threads/runs", &req).await
|
self.post("threads/runs", &req).await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn retrieve_run_step(
|
pub async fn retrieve_run_step(
|
||||||
&self,
|
&mut self,
|
||||||
thread_id: String,
|
thread_id: String,
|
||||||
run_id: String,
|
run_id: String,
|
||||||
step_id: String,
|
step_id: String,
|
||||||
@ -708,7 +712,7 @@ impl OpenAIClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn list_run_step(
|
pub async fn list_run_step(
|
||||||
&self,
|
&mut self,
|
||||||
thread_id: String,
|
thread_id: String,
|
||||||
run_id: String,
|
run_id: String,
|
||||||
limit: Option<i64>,
|
limit: Option<i64>,
|
||||||
@ -726,15 +730,15 @@ impl OpenAIClient {
|
|||||||
self.get(&url).await
|
self.get(&url).await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn create_batch(&self, req: CreateBatchRequest) -> Result<BatchResponse, APIError> {
|
pub async fn create_batch(&mut self, req: CreateBatchRequest) -> Result<BatchResponse, APIError> {
|
||||||
self.post("batches", &req).await
|
self.post("batches", &req).await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn retrieve_batch(&self, batch_id: String) -> Result<BatchResponse, APIError> {
|
pub async fn retrieve_batch(&mut self, batch_id: String) -> Result<BatchResponse, APIError> {
|
||||||
self.get(&format!("batches/{}", batch_id)).await
|
self.get(&format!("batches/{}", batch_id)).await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn cancel_batch(&self, batch_id: String) -> Result<BatchResponse, APIError> {
|
pub async fn cancel_batch(&mut self, batch_id: String) -> Result<BatchResponse, APIError> {
|
||||||
self.post(
|
self.post(
|
||||||
&format!("batches/{}/cancel", batch_id),
|
&format!("batches/{}/cancel", batch_id),
|
||||||
&common::EmptyRequestBody {},
|
&common::EmptyRequestBody {},
|
||||||
@ -743,7 +747,7 @@ impl OpenAIClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn list_batch(
|
pub async fn list_batch(
|
||||||
&self,
|
&mut self,
|
||||||
after: Option<String>,
|
after: Option<String>,
|
||||||
limit: Option<i64>,
|
limit: Option<i64>,
|
||||||
) -> Result<ListBatchResponse, APIError> {
|
) -> Result<ListBatchResponse, APIError> {
|
||||||
|
@ -61,7 +61,6 @@ pub struct AssistantObject {
|
|||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub tool_resources: Option<ToolResource>,
|
pub tool_resources: Option<ToolResource>,
|
||||||
pub metadata: Option<HashMap<String, String>>,
|
pub metadata: Option<HashMap<String, String>>,
|
||||||
pub headers: Option<HashMap<String, String>>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Serialize, Clone)]
|
#[derive(Debug, Deserialize, Serialize, Clone)]
|
||||||
@ -101,14 +100,12 @@ pub struct DeletionStatus {
|
|||||||
pub id: String,
|
pub id: String,
|
||||||
pub object: String,
|
pub object: String,
|
||||||
pub deleted: bool,
|
pub deleted: bool,
|
||||||
pub headers: Option<HashMap<String, String>>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
pub struct ListAssistant {
|
pub struct ListAssistant {
|
||||||
pub object: String,
|
pub object: String,
|
||||||
pub data: Vec<AssistantObject>,
|
pub data: Vec<AssistantObject>,
|
||||||
pub headers: Option<HashMap<String, String>>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Clone)]
|
#[derive(Debug, Serialize, Clone)]
|
||||||
@ -122,12 +119,10 @@ pub struct AssistantFileObject {
|
|||||||
pub object: String,
|
pub object: String,
|
||||||
pub created_at: i64,
|
pub created_at: i64,
|
||||||
pub assistant_id: String,
|
pub assistant_id: String,
|
||||||
pub headers: Option<HashMap<String, String>>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
pub struct ListAssistantFile {
|
pub struct ListAssistantFile {
|
||||||
pub object: String,
|
pub object: String,
|
||||||
pub data: Vec<AssistantFileObject>,
|
pub data: Vec<AssistantFileObject>,
|
||||||
pub headers: Option<HashMap<String, String>>,
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
use reqwest::header::HeaderMap;
|
use reqwest::header::HeaderMap;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::collections::HashMap;
|
|
||||||
|
|
||||||
use crate::impl_builder_methods;
|
use crate::impl_builder_methods;
|
||||||
|
|
||||||
@ -59,7 +58,6 @@ impl_builder_methods!(
|
|||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
pub struct AudioTranscriptionResponse {
|
pub struct AudioTranscriptionResponse {
|
||||||
pub text: String,
|
pub text: String,
|
||||||
pub headers: Option<HashMap<String, String>>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Clone)]
|
#[derive(Debug, Serialize, Clone)]
|
||||||
@ -96,7 +94,6 @@ impl_builder_methods!(
|
|||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
pub struct AudioTranslationResponse {
|
pub struct AudioTranslationResponse {
|
||||||
pub text: String,
|
pub text: String,
|
||||||
pub headers: Option<HashMap<String, String>>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const TTS_1: &str = "tts-1";
|
pub const TTS_1: &str = "tts-1";
|
||||||
|
@ -250,7 +250,6 @@ pub struct ChatCompletionResponse {
|
|||||||
pub choices: Vec<ChatCompletionChoice>,
|
pub choices: Vec<ChatCompletionChoice>,
|
||||||
pub usage: common::Usage,
|
pub usage: common::Usage,
|
||||||
pub system_fingerprint: Option<String>,
|
pub system_fingerprint: Option<String>,
|
||||||
pub headers: Option<HashMap<String, String>>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Serialize, PartialEq, Eq)]
|
#[derive(Debug, Deserialize, Serialize, PartialEq, Eq)]
|
||||||
|
@ -117,5 +117,4 @@ pub struct CompletionResponse {
|
|||||||
pub model: String,
|
pub model: String,
|
||||||
pub choices: Vec<CompletionChoice>,
|
pub choices: Vec<CompletionChoice>,
|
||||||
pub usage: common::Usage,
|
pub usage: common::Usage,
|
||||||
pub headers: Option<HashMap<String, String>>,
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::collections::HashMap;
|
|
||||||
use std::option::Option;
|
use std::option::Option;
|
||||||
|
|
||||||
use crate::impl_builder_methods;
|
use crate::impl_builder_methods;
|
||||||
@ -52,5 +51,4 @@ pub struct EditResponse {
|
|||||||
pub created: i64,
|
pub created: i64,
|
||||||
pub usage: common::Usage,
|
pub usage: common::Usage,
|
||||||
pub choices: Vec<EditChoice>,
|
pub choices: Vec<EditChoice>,
|
||||||
pub headers: Option<HashMap<String, String>>,
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::collections::HashMap;
|
|
||||||
use std::option::Option;
|
use std::option::Option;
|
||||||
|
|
||||||
use crate::impl_builder_methods;
|
use crate::impl_builder_methods;
|
||||||
@ -52,7 +51,6 @@ pub struct EmbeddingResponse {
|
|||||||
pub data: Vec<EmbeddingData>,
|
pub data: Vec<EmbeddingData>,
|
||||||
pub model: String,
|
pub model: String,
|
||||||
pub usage: Usage,
|
pub usage: Usage,
|
||||||
pub headers: Option<HashMap<String, String>>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
use std::collections::HashMap;
|
|
||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
@ -16,7 +14,6 @@ pub struct FileData {
|
|||||||
pub struct FileListResponse {
|
pub struct FileListResponse {
|
||||||
pub object: String,
|
pub object: String,
|
||||||
pub data: Vec<FileData>,
|
pub data: Vec<FileData>,
|
||||||
pub headers: Option<HashMap<String, String>>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize)]
|
||||||
@ -39,7 +36,6 @@ pub struct FileUploadResponse {
|
|||||||
pub created_at: i64,
|
pub created_at: i64,
|
||||||
pub filename: String,
|
pub filename: String,
|
||||||
pub purpose: String,
|
pub purpose: String,
|
||||||
pub headers: Option<HashMap<String, String>>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize)]
|
||||||
@ -58,7 +54,6 @@ pub struct FileDeleteResponse {
|
|||||||
pub id: String,
|
pub id: String,
|
||||||
pub object: String,
|
pub object: String,
|
||||||
pub delete: bool,
|
pub delete: bool,
|
||||||
pub headers: Option<HashMap<String, String>>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
@ -69,5 +64,4 @@ pub struct FileRetrieveResponse {
|
|||||||
pub created_at: i64,
|
pub created_at: i64,
|
||||||
pub filename: String,
|
pub filename: String,
|
||||||
pub purpose: String,
|
pub purpose: String,
|
||||||
pub headers: Option<HashMap<String, String>>,
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::collections::HashMap;
|
|
||||||
|
|
||||||
use crate::impl_builder_methods;
|
use crate::impl_builder_methods;
|
||||||
|
|
||||||
@ -99,7 +98,6 @@ pub struct FineTuningPagination<T> {
|
|||||||
pub object: String,
|
pub object: String,
|
||||||
pub data: Vec<T>,
|
pub data: Vec<T>,
|
||||||
pub has_more: bool,
|
pub has_more: bool,
|
||||||
pub headers: Option<HashMap<String, String>>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
@ -118,7 +116,6 @@ pub struct FineTuningJobObject {
|
|||||||
pub trained_tokens: Option<i64>,
|
pub trained_tokens: Option<i64>,
|
||||||
pub training_file: String,
|
pub training_file: String,
|
||||||
pub validation_file: Option<String>,
|
pub validation_file: Option<String>,
|
||||||
pub headers: Option<HashMap<String, String>>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::collections::HashMap;
|
|
||||||
use std::option::Option;
|
use std::option::Option;
|
||||||
|
|
||||||
use crate::impl_builder_methods;
|
use crate::impl_builder_methods;
|
||||||
@ -50,7 +49,6 @@ impl_builder_methods!(
|
|||||||
pub struct ImageGenerationResponse {
|
pub struct ImageGenerationResponse {
|
||||||
pub created: i64,
|
pub created: i64,
|
||||||
pub data: Vec<ImageData>,
|
pub data: Vec<ImageData>,
|
||||||
pub headers: Option<HashMap<String, String>>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Clone)]
|
#[derive(Debug, Serialize, Clone)]
|
||||||
@ -100,7 +98,6 @@ impl_builder_methods!(
|
|||||||
pub struct ImageEditResponse {
|
pub struct ImageEditResponse {
|
||||||
pub created: i64,
|
pub created: i64,
|
||||||
pub data: Vec<ImageData>,
|
pub data: Vec<ImageData>,
|
||||||
pub headers: Option<HashMap<String, String>>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Clone)]
|
#[derive(Debug, Serialize, Clone)]
|
||||||
@ -144,5 +141,4 @@ impl_builder_methods!(
|
|||||||
pub struct ImageVariationResponse {
|
pub struct ImageVariationResponse {
|
||||||
pub created: i64,
|
pub created: i64,
|
||||||
pub data: Vec<ImageData>,
|
pub data: Vec<ImageData>,
|
||||||
pub headers: Option<HashMap<String, String>>,
|
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,6 @@ pub struct MessageObject {
|
|||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub attachments: Option<Vec<Attachment>>,
|
pub attachments: Option<Vec<Attachment>>,
|
||||||
pub metadata: Option<HashMap<String, String>>,
|
pub metadata: Option<HashMap<String, String>>,
|
||||||
pub headers: Option<HashMap<String, String>>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||||
@ -111,7 +110,6 @@ pub struct ListMessage {
|
|||||||
pub first_id: String,
|
pub first_id: String,
|
||||||
pub last_id: String,
|
pub last_id: String,
|
||||||
pub has_more: bool,
|
pub has_more: bool,
|
||||||
pub headers: Option<HashMap<String, String>>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
@ -120,7 +118,6 @@ pub struct MessageFileObject {
|
|||||||
pub object: String,
|
pub object: String,
|
||||||
pub created_at: i64,
|
pub created_at: i64,
|
||||||
pub message_id: String,
|
pub message_id: String,
|
||||||
pub headers: Option<HashMap<String, String>>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
@ -130,7 +127,6 @@ pub struct ListMessageFile {
|
|||||||
pub first_id: String,
|
pub first_id: String,
|
||||||
pub last_id: String,
|
pub last_id: String,
|
||||||
pub has_more: bool,
|
pub has_more: bool,
|
||||||
pub headers: Option<HashMap<String, String>>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::collections::HashMap;
|
|
||||||
|
|
||||||
use crate::impl_builder_methods;
|
use crate::impl_builder_methods;
|
||||||
|
|
||||||
@ -26,7 +25,6 @@ pub struct CreateModerationResponse {
|
|||||||
pub id: String,
|
pub id: String,
|
||||||
pub model: String,
|
pub model: String,
|
||||||
pub results: Vec<ModerationResult>,
|
pub results: Vec<ModerationResult>,
|
||||||
pub headers: Option<HashMap<String, String>>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
|
@ -98,7 +98,6 @@ pub struct RunObject {
|
|||||||
pub instructions: Option<String>,
|
pub instructions: Option<String>,
|
||||||
pub tools: Vec<types::Tools>,
|
pub tools: Vec<types::Tools>,
|
||||||
pub metadata: HashMap<String, String>,
|
pub metadata: HashMap<String, String>,
|
||||||
pub headers: Option<HashMap<String, String>>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
@ -108,7 +107,6 @@ pub struct ListRun {
|
|||||||
pub first_id: String,
|
pub first_id: String,
|
||||||
pub last_id: String,
|
pub last_id: String,
|
||||||
pub has_more: bool,
|
pub has_more: bool,
|
||||||
pub headers: Option<HashMap<String, String>>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Clone)]
|
#[derive(Debug, Serialize, Clone)]
|
||||||
@ -151,7 +149,6 @@ pub struct RunStepObject {
|
|||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub completed_at: Option<i64>,
|
pub completed_at: Option<i64>,
|
||||||
pub metadata: HashMap<String, String>,
|
pub metadata: HashMap<String, String>,
|
||||||
pub headers: Option<HashMap<String, String>>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Serialize, Clone)]
|
#[derive(Debug, Deserialize, Serialize, Clone)]
|
||||||
@ -161,5 +158,4 @@ pub struct ListRunStep {
|
|||||||
pub first_id: String,
|
pub first_id: String,
|
||||||
pub last_id: String,
|
pub last_id: String,
|
||||||
pub has_more: bool,
|
pub has_more: bool,
|
||||||
pub headers: Option<HashMap<String, String>>,
|
|
||||||
}
|
}
|
||||||
|
@ -67,8 +67,6 @@ pub struct ThreadObject {
|
|||||||
pub metadata: HashMap<String, String>,
|
pub metadata: HashMap<String, String>,
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub tool_resources: Option<ToolResource>,
|
pub tool_resources: Option<ToolResource>,
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
|
||||||
pub headers: Option<HashMap<String, String>>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Serialize, Clone)]
|
#[derive(Debug, Deserialize, Serialize, Clone)]
|
||||||
@ -86,7 +84,6 @@ pub struct Message {
|
|||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub attachments: Option<Vec<Attachment>>,
|
pub attachments: Option<Vec<Attachment>>,
|
||||||
pub metadata: Option<HashMap<String, String>>,
|
pub metadata: Option<HashMap<String, String>>,
|
||||||
pub headers: Option<HashMap<String, String>>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Serialize, Clone)]
|
#[derive(Debug, Deserialize, Serialize, Clone)]
|
||||||
|
Reference in New Issue
Block a user