Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions async-openai/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! Errors originating from API calls, parsing responses, and reading-or-writing to the file system.
use serde::Deserialize;
use serde::{Deserialize, Serialize};

#[derive(Debug, thiserror::Error)]
pub enum OpenAIError {
Expand Down Expand Up @@ -28,7 +28,7 @@ pub enum OpenAIError {
}

/// OpenAI API returns error object on failure
#[derive(Debug, Deserialize, Clone)]
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct ApiError {
pub message: String,
pub r#type: Option<String>,
Expand Down Expand Up @@ -62,9 +62,9 @@ impl std::fmt::Display for ApiError {
}

/// Wrapper to deserialize the error object nested in "error" JSON key
#[derive(Debug, Deserialize)]
pub(crate) struct WrappedError {
pub(crate) error: ApiError,
#[derive(Debug, Deserialize, Serialize)]
pub struct WrappedError {
pub error: ApiError,
}

pub(crate) fn map_deserialization_error(e: serde_json::Error, bytes: &[u8]) -> OpenAIError {
Expand Down
2 changes: 1 addition & 1 deletion async-openai/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
//! ```
//! use async_openai::{Client, config::Config, config::OpenAIConfig};
//! unsafe { std::env::set_var("OPENAI_API_KEY", "only for doc test") }
//!
//!
//! let openai_config = OpenAIConfig::default();
//! // You can use `std::sync::Arc` to wrap the config as well
//! let config = Box::new(openai_config) as Box<dyn Config>;
Expand Down