Skip to content

Commit c9d757f

Browse files
committed
Fix: correct instructions typing in Responses
1 parent 61ab980 commit c9d757f

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

async-openai/src/types/responses.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1364,9 +1364,9 @@ pub struct Response {
13641364
#[serde(skip_serializing_if = "Option::is_none")]
13651365
pub incomplete_details: Option<IncompleteDetails>,
13661366

1367-
/// Instructions that were inserted as the first item in context.
1367+
/// Instructions that were inserted as the first item(s) in context.
13681368
#[serde(skip_serializing_if = "Option::is_none")]
1369-
pub instructions: Option<String>,
1369+
pub instructions: Option<Instructions>,
13701370

13711371
/// The value of `max_output_tokens` that was honored.
13721372
#[serde(skip_serializing_if = "Option::is_none")]
@@ -1447,13 +1447,27 @@ pub struct Response {
14471447
pub user: Option<String>,
14481448
}
14491449

1450+
/// Represents instructions inserted as the first item(s) in the model's context.
1451+
///
1452+
/// NOTE: When creating a response directly via the OpenAI API, only a string instruction can be specified.
1453+
/// However, when using prompts created through the OpenAI dashboard, both "developer" and "prompt" messages can be included.
1454+
/// "Prompt" messages may consist of both "user" and "assistant" message types.
1455+
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1456+
#[serde(untagged, rename_all = "snake_case")]
1457+
pub enum Instructions {
1458+
String(String),
1459+
Array(Vec<InputItem>),
1460+
}
1461+
14501462
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
14511463
#[serde(rename_all = "snake_case")]
14521464
pub enum Status {
14531465
Completed,
14541466
Failed,
14551467
InProgress,
14561468
Incomplete,
1469+
Queued,
1470+
Cancelled,
14571471
}
14581472

14591473
/// Event types for streaming responses from the Responses API

0 commit comments

Comments
 (0)