gproxy_protocol/aws/converse/
content.rs1use serde::{Deserialize, Serialize};
2use serde_json::Value;
3
4use crate::aws::{CachePointType, CacheTtl, ConversationRole, Rest};
5
6use super::{DocumentBlock, ImageBlock, ToolResultBlock, ToolUseBlock};
7
8#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
9#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
10pub struct Message {
11 pub role: ConversationRole,
12 pub content: Vec<ContentBlock>,
13 #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
14 pub rest: Rest,
15}
16
17#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
18#[serde(untagged)]
19#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
20pub enum ContentBlock {
21 Text {
22 text: String,
23 #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
24 rest: Rest,
25 },
26 Image {
27 image: ImageBlock,
28 #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
29 rest: Rest,
30 },
31 Document {
32 document: DocumentBlock,
33 #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
34 rest: Rest,
35 },
36 ToolUse {
37 #[serde(rename = "toolUse")]
38 tool_use: ToolUseBlock,
39 #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
40 rest: Rest,
41 },
42 ToolResult {
43 #[serde(rename = "toolResult")]
44 tool_result: ToolResultBlock,
45 #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
46 rest: Rest,
47 },
48 ReasoningContent {
49 #[serde(rename = "reasoningContent")]
50 reasoning_content: ReasoningContentBlock,
51 #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
52 rest: Rest,
53 },
54 CachePoint {
55 #[serde(rename = "cachePoint")]
56 cache_point: CachePointBlock,
57 #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
58 rest: Rest,
59 },
60 Raw(Value),
61}
62
63#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
64#[serde(untagged)]
65#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
66pub enum SystemContentBlock {
67 Text {
68 text: String,
69 #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
70 rest: Rest,
71 },
72 CachePoint {
73 #[serde(rename = "cachePoint")]
74 cache_point: CachePointBlock,
75 #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
76 rest: Rest,
77 },
78 Raw(Value),
79}
80
81#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
82#[serde(untagged)]
83#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
84pub enum ReasoningContentBlock {
85 ReasoningText {
86 #[serde(rename = "reasoningText")]
87 reasoning_text: ReasoningTextBlock,
88 #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
89 rest: Rest,
90 },
91 RedactedContent {
92 #[serde(rename = "redactedContent")]
93 redacted_content: String,
94 #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
95 rest: Rest,
96 },
97 Raw(Value),
98}
99
100#[derive(
101 Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
102)]
103#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
104pub struct ReasoningTextBlock {
105 pub text: String,
106 #[serde(skip_serializing_if = "Option::is_none")]
107 pub signature: Option<String>,
108 #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
109 pub rest: Rest,
110}
111
112#[derive(
113 Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
114)]
115#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
116pub struct CachePointBlock {
117 #[serde(rename = "type")]
118 pub type_: CachePointType,
119 #[serde(skip_serializing_if = "Option::is_none")]
120 pub ttl: Option<CacheTtl>,
121 #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
122 pub rest: Rest,
123}