1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/*
* OpenAI API
*
* The OpenAI REST API. Please see https://platform.openai.com/docs/api-reference for more details.
*
* The version of the OpenAPI document: 2.3.0
*
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
/// ComputerToolCall : A tool call to a computer use tool. See the [computer use guide](/docs/guides/tools-computer-use) for more information.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct ComputerToolCall {
/// The type of the computer call. Always `computer_call`.
#[serde(rename = "type")]
pub r#type: Type,
/// The unique ID of the computer call.
#[serde(rename = "id")]
pub id: String,
/// An identifier used when responding to the tool call with output.
#[serde(rename = "call_id")]
pub call_id: String,
#[serde(rename = "action", skip_serializing_if = "Option::is_none")]
pub action: Option<serde_json::Value>,
/// Flattened batched actions for `computer_use`. Each action includes an `type` discriminator and action-specific fields.
#[serde(rename = "actions", skip_serializing_if = "Option::is_none")]
pub actions: Option<Vec<serde_json::Value>>,
/// The pending safety checks for the computer call.
#[serde(rename = "pending_safety_checks")]
pub pending_safety_checks: Vec<models::ComputerCallSafetyCheckParam>,
/// The status of the item. One of `in_progress`, `completed`, or `incomplete`. Populated when items are returned via API.
#[serde(rename = "status")]
pub status: Status,
}
impl ComputerToolCall {
/// A tool call to a computer use tool. See the [computer use guide](/docs/guides/tools-computer-use) for more information.
pub fn new(
r#type: Type,
id: String,
call_id: String,
pending_safety_checks: Vec<models::ComputerCallSafetyCheckParam>,
status: Status,
) -> ComputerToolCall {
ComputerToolCall {
r#type,
id,
call_id,
action: None,
actions: None,
pending_safety_checks,
status,
}
}
}
/// The type of the computer call. Always `computer_call`.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Type {
#[serde(rename = "computer_call")]
ComputerCall,
}
impl Default for Type {
fn default() -> Type {
Self::ComputerCall
}
}
/// The status of the item. One of `in_progress`, `completed`, or `incomplete`. Populated when items are returned via API.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Status {
#[serde(rename = "in_progress")]
InProgress,
#[serde(rename = "completed")]
Completed,
#[serde(rename = "incomplete")]
Incomplete,
}
impl Default for Status {
fn default() -> Status {
Self::InProgress
}
}
impl std::fmt::Display for ComputerToolCall {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match serde_json::to_string(self) {
Ok(s) => write!(f, "{}", s),
Err(_) => Err(std::fmt::Error),
}
}
}