gproxy_protocol/claude/common/blocks/
base.rs1use serde::{Deserialize, Serialize};
2
3use super::super::{CacheControl, Citation, CitationConfig};
4use super::{DocumentSource, ImageSource};
5
6#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
7#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
8pub struct TextBlock {
9 pub text: String,
10 #[serde(rename = "type")]
11 pub type_: TextBlockType,
12 #[serde(skip_serializing_if = "Option::is_none")]
13 pub cache_control: Option<CacheControl>,
14 #[serde(skip_serializing_if = "Option::is_none")]
15 pub citations: Option<Vec<Citation>>,
16 #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
17 pub rest: serde_json::Map<String, serde_json::Value>,
18}
19
20#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
21#[non_exhaustive]
22pub enum TextBlockType {
23 #[serde(rename = "text")]
24 Text,
25}
26
27#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
28#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
29pub struct ImageBlock {
30 pub source: ImageSource,
31 #[serde(rename = "type")]
32 pub type_: ImageBlockType,
33 #[serde(skip_serializing_if = "Option::is_none")]
34 pub cache_control: Option<CacheControl>,
35 #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
36 pub rest: serde_json::Map<String, serde_json::Value>,
37}
38
39#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
40#[non_exhaustive]
41pub enum ImageBlockType {
42 #[serde(rename = "image")]
43 Image,
44}
45
46#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
47#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
48pub struct DocumentBlock {
49 pub source: DocumentSource,
50 #[serde(rename = "type")]
51 pub type_: DocumentBlockType,
52 #[serde(skip_serializing_if = "Option::is_none")]
53 pub cache_control: Option<CacheControl>,
54 #[serde(skip_serializing_if = "Option::is_none")]
55 pub citations: Option<CitationConfig>,
56 #[serde(skip_serializing_if = "Option::is_none")]
57 pub context: Option<String>,
58 #[serde(skip_serializing_if = "Option::is_none")]
59 pub title: Option<String>,
60 #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
61 pub rest: serde_json::Map<String, serde_json::Value>,
62}
63
64#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
65#[non_exhaustive]
66pub enum DocumentBlockType {
67 #[serde(rename = "document")]
68 Document,
69}
70
71#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
72#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
73pub struct SearchResultBlock {
74 pub content: Vec<TextBlock>,
75 pub source: String,
76 pub title: String,
77 #[serde(rename = "type")]
78 pub type_: SearchResultBlockType,
79 #[serde(skip_serializing_if = "Option::is_none")]
80 pub cache_control: Option<CacheControl>,
81 #[serde(skip_serializing_if = "Option::is_none")]
82 pub citations: Option<CitationConfig>,
83 #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
84 pub rest: serde_json::Map<String, serde_json::Value>,
85}
86
87#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
88#[non_exhaustive]
89pub enum SearchResultBlockType {
90 #[serde(rename = "search_result")]
91 SearchResult,
92}
93
94#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
95#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
96pub struct ThinkingBlock {
97 #[serde(skip_serializing_if = "Option::is_none")]
98 pub signature: Option<String>,
99 pub thinking: String,
100 #[serde(rename = "type")]
101 pub type_: ThinkingBlockType,
102 #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
103 pub rest: serde_json::Map<String, serde_json::Value>,
104}
105
106#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
107#[non_exhaustive]
108pub enum ThinkingBlockType {
109 #[serde(rename = "thinking")]
110 Thinking,
111}
112
113#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
114#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
115pub struct RedactedThinkingBlock {
116 pub data: String,
117 #[serde(rename = "type")]
118 pub type_: RedactedThinkingBlockType,
119 #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
120 pub rest: serde_json::Map<String, serde_json::Value>,
121}
122
123#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
124#[non_exhaustive]
125pub enum RedactedThinkingBlockType {
126 #[serde(rename = "redacted_thinking")]
127 RedactedThinking,
128}