Skip to content

Commit f9affae

Browse files
refactor: adding missing fields from Responses API (#394)
1 parent 4b52f20 commit f9affae

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

async-openai/src/types/responses.rs

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,11 @@ pub struct CreateResponse {
155155
/// performance characteristics, and price points.
156156
pub model: String,
157157

158+
/// Whether to run the model response in the background.
159+
/// boolean or null.
160+
#[serde(skip_serializing_if = "Option::is_none")]
161+
pub background: Option<bool>,
162+
158163
/// Specify additional output data to include in the model response.
159164
///
160165
/// Supported values:
@@ -188,6 +193,11 @@ pub struct CreateResponse {
188193
#[serde(skip_serializing_if = "Option::is_none")]
189194
pub max_output_tokens: Option<u32>,
190195

196+
/// The maximum number of total calls to built-in tools that can be processed in a response.
197+
/// This maximum number applies across all built-in tool calls, not per individual tool.
198+
/// Any further attempts to call a tool by the model will be ignored.
199+
pub max_tool_calls: Option<u32>,
200+
191201
/// Set of 16 key-value pairs that can be attached to an object. This can be
192202
/// useful for storing additional information about the object in a structured
193203
/// format, and querying for objects via API or the dashboard.
@@ -206,6 +216,10 @@ pub struct CreateResponse {
206216
#[serde(skip_serializing_if = "Option::is_none")]
207217
pub previous_response_id: Option<String>,
208218

219+
/// Reference to a prompt template and its variables.
220+
#[serde(skip_serializing_if = "Option::is_none")]
221+
pub prompt: Option<PromptConfig>,
222+
209223
/// **o-series models only**: Configuration options for reasoning models.
210224
#[serde(skip_serializing_if = "Option::is_none")]
211225
pub reasoning: Option<ReasoningConfig>,
@@ -236,6 +250,11 @@ pub struct CreateResponse {
236250
#[serde(skip_serializing_if = "Option::is_none")]
237251
pub store: Option<bool>,
238252

253+
/// If set to true, the model response data will be streamed to the client as it is
254+
/// generated using server-sent events.
255+
#[serde(skip_serializing_if = "Option::is_none")]
256+
pub stream: Option<bool>,
257+
239258
/// What sampling temperature to use, between 0 and 2. Higher values like 0.8
240259
/// will make the output more random, while lower values like 0.2 will make it
241260
/// more focused and deterministic. We generally recommend altering this or
@@ -259,6 +278,11 @@ pub struct CreateResponse {
259278
#[serde(skip_serializing_if = "Option::is_none")]
260279
pub tools: Option<Vec<ToolDefinition>>,
261280

281+
/// An integer between 0 and 20 specifying the number of most likely tokens to return
282+
/// at each token position, each with an associated log probability.
283+
#[serde(skip_serializing_if = "Option::is_none")]
284+
pub top_logprobs: Option<u32>, // TODO add validation of range
285+
262286
/// An alternative to sampling with temperature, called nucleus sampling,
263287
/// where the model considers the results of the tokens with top_p probability
264288
/// mass. So 0.1 means only the tokens comprising the top 10% probability mass
@@ -279,6 +303,23 @@ pub struct CreateResponse {
279303
pub user: Option<String>,
280304
}
281305

306+
/// Service tier request options.
307+
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
308+
pub struct PromptConfig {
309+
/// The unique identifier of the prompt template to use.
310+
pub id: String,
311+
312+
/// Optional version of the prompt template.
313+
#[serde(skip_serializing_if = "Option::is_none")]
314+
pub version: Option<String>,
315+
316+
/// Optional map of values to substitute in for variables in your prompt. The substitution
317+
/// values can either be strings, or other Response input types like images or files.
318+
/// For now only supporting Strings.
319+
#[serde(skip_serializing_if = "Option::is_none")]
320+
pub variables: Option<HashMap<String, String>>,
321+
}
322+
282323
/// Service tier request options.
283324
#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq)]
284325
#[serde(rename_all = "lowercase")]
@@ -1323,6 +1364,12 @@ pub struct Response {
13231364
/// The array of content items generated by the model.
13241365
pub output: Vec<OutputContent>,
13251366

1367+
/// SDK-only convenience property that contains the aggregated text output from all
1368+
/// `output_text` items in the `output` array, if any are present.
1369+
/// Supported in the Python and JavaScript SDKs.
1370+
#[serde(skip_serializing_if = "Option::is_none")]
1371+
pub output_text: Option<String>,
1372+
13261373
/// Whether parallel tool calls were enabled.
13271374
#[serde(skip_serializing_if = "Option::is_none")]
13281375
pub parallel_tool_calls: Option<bool>,
@@ -1335,6 +1382,10 @@ pub struct Response {
13351382
#[serde(skip_serializing_if = "Option::is_none")]
13361383
pub reasoning: Option<ReasoningConfig>,
13371384

1385+
/// Whether to store the generated model response for later retrieval via API.
1386+
#[serde(skip_serializing_if = "Option::is_none")]
1387+
pub store: Option<bool>,
1388+
13381389
/// The service tier that actually processed this response.
13391390
#[serde(skip_serializing_if = "Option::is_none")]
13401391
pub service_tier: Option<ServiceTier>,

0 commit comments

Comments
 (0)