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
96
97
98
99
100
101
102
103
104
105
106
107
/*
* OpenAI API
*
* The OpenAI REST API. Please see pub https:///platform.openai.com/docs/api-reference for more details.
*
* OpenAPI spec pub version: 2.3.0
*
* Generated pub by: https:///github.com/swagger-api/swagger-codegen.git
*/
#[allow(unused_imports)]
use serde_json::Value;
/// # on openapi.yaml
///
/// ```yaml
/// ChatCompletionRequestToolMessage:
/// type: object
/// title: Tool message
/// properties:
/// role:
/// type: string
/// enum:
/// - tool
/// description: The role of the messages author, in this case `tool`.
/// x-stainless-const: true
/// content:
/// oneOf:
/// - type: string
/// description: The contents of the tool message.
/// title: Text content
/// - type: array
/// description:
/// An array of content parts with a defined type. For tool messages,
/// only type `text` is supported.
/// title: Array of content parts
/// items:
/// $ref: "#/components/schemas/ChatCompletionRequestToolMessageContentPart"
/// minItems: 1
/// description: The contents of the tool message.
/// tool_call_id:
/// type: string
/// description: Tool call that this message is responding to.
/// required:
/// - role
/// - content
/// - tool_call_id
/// ```
#[derive(Debug, Serialize, Deserialize, PartialEq)]
pub struct ChatCompletionRequestToolMessage {
/// The contents of the tool message.
#[serde(rename = "content")]
pub content: ChatCompletionRequestToolMessageContent,
/// Tool call that this message is responding to.
#[serde(rename = "tool_call_id")]
pub tool_call_id: String,
}
/// # on openapi.yaml
///
/// ```yaml
/// content:
/// oneOf:
/// - type: string
/// description: The contents of the tool message.
/// title: Text content
/// - type: array
/// description:
/// An array of content parts with a defined type. For tool messages,
/// only type `text` is supported.
/// title: Array of content parts
/// items:
/// $ref: "#/components/schemas/ChatCompletionRequestToolMessageContentPart"
/// minItems: 1
/// description: The contents of the tool message.
/// ```
#[derive(Debug, Serialize, Deserialize, PartialEq)]
#[serde(untagged)]
pub enum ChatCompletionRequestToolMessageContent {
Text(String),
Array(Vec<crate::ChatCompletionRequestToolMessageContentPart>),
}
#[test]
fn chat_message_developer_message_content() {
assert_eq!(
serde_json::to_string(&ChatCompletionRequestToolMessage {
content: ChatCompletionRequestToolMessageContent::Array(vec![
crate::ChatCompletionRequestToolMessageContentPart::Text(
crate::ChatCompletionRequestMessageContentPartText {
text: "233".into(),
_type: "qw".into(),
}
),
crate::ChatCompletionRequestToolMessageContentPart::Text(
crate::ChatCompletionRequestMessageContentPartText {
text: "emm".into(),
_type: "hk".into(),
}
),
]),
tool_call_id: "1228".into(),
})
.unwrap(),
r#"{"content":[{"text":"233","type":"qw"},{"text":"emm","type":"hk"}],"tool_call_id":"1228"}"#
);
}