Skip to content

fix<(responses)>: parsing Error if multiple instructions are given #399

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
12 changes: 11 additions & 1 deletion async-openai/src/types/responses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1326,6 +1326,16 @@ pub struct Usage {
pub total_tokens: u32,
}

#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
#[serde(untagged)]
pub enum ResponseInstructions {
/// if string is provided
Single(String),

/// if multiple instructions are provided
Multiple(Vec<InputMessage>),
}

/// The complete response returned by the Responses API.
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
pub struct Response {
Expand All @@ -1345,7 +1355,7 @@ pub struct Response {

/// Instructions that were inserted as the first item in context.
#[serde(skip_serializing_if = "Option::is_none")]
pub instructions: Option<String>,
pub instructions: Option<ResponseInstructions>,

/// The value of `max_output_tokens` that was honored.
#[serde(skip_serializing_if = "Option::is_none")]
Expand Down