Skip to main content

gproxy_protocol/gemini/batch/
embedding.rs

1use serde::{Deserialize, Serialize};
2
3use super::super::{EmbedContentRequest, EmbedContentResponse, JsonMap, Status};
4use super::{BatchOperation, BatchResourceFields};
5
6#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
7#[serde(rename_all = "camelCase")]
8#[derive(gproxy_protocol_macros::WireBuilder)]
9#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
10pub struct AsyncBatchEmbedContentRequest {
11    #[serde(skip_serializing_if = "Option::is_none")]
12    pub batch: Option<EmbedContentBatch>,
13    #[serde(default, flatten, skip_serializing_if = "JsonMap::is_empty")]
14    pub rest: JsonMap,
15}
16
17pub type AsyncBatchEmbedContentResponse = BatchOperation;
18
19#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
20#[serde(rename_all = "camelCase")]
21#[derive(gproxy_protocol_macros::WireBuilder)]
22#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
23pub struct UpdateEmbedContentBatchQuery {
24    #[serde(skip_serializing_if = "Option::is_none")]
25    pub update_mask: Option<String>,
26    #[serde(default, flatten, skip_serializing_if = "JsonMap::is_empty")]
27    pub rest: JsonMap,
28}
29
30#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
31#[serde(rename_all = "camelCase")]
32#[derive(gproxy_protocol_macros::WireBuilder)]
33#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
34pub struct EmbedContentBatch {
35    #[serde(flatten)]
36    pub resource: BatchResourceFields,
37    #[serde(skip_serializing_if = "Option::is_none")]
38    pub input_config: Option<EmbedContentInputConfig>,
39    #[serde(skip_serializing_if = "Option::is_none")]
40    pub output: Option<EmbedContentBatchOutput>,
41    #[serde(default, flatten, skip_serializing_if = "JsonMap::is_empty")]
42    pub rest: JsonMap,
43}
44
45#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
46#[serde(rename_all = "camelCase")]
47#[derive(gproxy_protocol_macros::WireBuilder)]
48#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
49pub struct EmbedContentInputConfig {
50    #[serde(flatten, skip_serializing_if = "Option::is_none")]
51    pub source: Option<EmbedContentInputSource>,
52    #[serde(default, flatten, skip_serializing_if = "JsonMap::is_empty")]
53    pub rest: JsonMap,
54}
55
56#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
57#[serde(untagged)]
58#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
59pub enum EmbedContentInputSource {
60    File {
61        #[serde(rename = "fileName")]
62        file_name: String,
63    },
64    Requests {
65        requests: InlinedEmbedRequests,
66    },
67}
68
69#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
70#[serde(rename_all = "camelCase")]
71#[derive(gproxy_protocol_macros::WireBuilder)]
72#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
73pub struct InlinedEmbedRequests {
74    #[serde(default, skip_serializing_if = "Vec::is_empty")]
75    pub requests: Vec<InlinedEmbedRequest>,
76    #[serde(default, flatten, skip_serializing_if = "JsonMap::is_empty")]
77    pub rest: JsonMap,
78}
79
80#[derive(
81    Debug, Clone, PartialEq, Serialize, Deserialize, Default, gproxy_protocol_macros::WireBuilder,
82)]
83#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
84pub struct InlinedEmbedRequest {
85    #[serde(skip_serializing_if = "Option::is_none")]
86    pub request: Option<EmbedContentRequest>,
87    #[serde(skip_serializing_if = "Option::is_none")]
88    pub metadata: Option<JsonMap>,
89    #[serde(default, flatten, skip_serializing_if = "JsonMap::is_empty")]
90    pub rest: JsonMap,
91}
92
93#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
94#[serde(rename_all = "camelCase")]
95#[derive(gproxy_protocol_macros::WireBuilder)]
96#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
97pub struct EmbedContentBatchOutput {
98    #[serde(flatten, skip_serializing_if = "Option::is_none")]
99    pub output: Option<EmbedContentBatchOutputData>,
100    #[serde(default, flatten, skip_serializing_if = "JsonMap::is_empty")]
101    pub rest: JsonMap,
102}
103
104#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
105#[serde(untagged)]
106#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
107pub enum EmbedContentBatchOutputData {
108    ResponsesFile {
109        #[serde(rename = "responsesFile")]
110        responses_file: String,
111    },
112    InlinedResponses {
113        #[serde(rename = "inlinedResponses")]
114        inlined_responses: InlinedEmbedResponses,
115    },
116}
117
118#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
119#[serde(rename_all = "camelCase")]
120#[derive(gproxy_protocol_macros::WireBuilder)]
121#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
122pub struct InlinedEmbedResponses {
123    #[serde(default, skip_serializing_if = "Vec::is_empty")]
124    pub inlined_responses: Vec<InlinedEmbedResponse>,
125    #[serde(default, flatten, skip_serializing_if = "JsonMap::is_empty")]
126    pub rest: JsonMap,
127}
128
129#[derive(
130    Debug, Clone, PartialEq, Serialize, Deserialize, Default, gproxy_protocol_macros::WireBuilder,
131)]
132#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
133pub struct InlinedEmbedResponse {
134    #[serde(skip_serializing_if = "Option::is_none")]
135    pub metadata: Option<JsonMap>,
136    #[serde(flatten, skip_serializing_if = "Option::is_none")]
137    pub output: Option<InlinedEmbedResponseOutput>,
138    #[serde(default, flatten, skip_serializing_if = "JsonMap::is_empty")]
139    pub rest: JsonMap,
140}
141
142#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
143#[serde(untagged)]
144#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
145pub enum InlinedEmbedResponseOutput {
146    Error { error: Status },
147    Response { response: EmbedContentResponse },
148}
149
150pub type AsyncBatchEmbedContentRequestBody = AsyncBatchEmbedContentRequest;
151pub type AsyncBatchEmbedContentResponseBody = AsyncBatchEmbedContentResponse;
152pub type UpdateEmbedContentBatchRequestBody = EmbedContentBatch;
153pub type UpdateEmbedContentBatchResponseBody = EmbedContentBatch;
154pub type InputEmbedContentConfig = EmbedContentInputConfig;
155pub type InputEmbedContentConfigSource = EmbedContentInputSource;
156pub type InlinedEmbedContentRequests = InlinedEmbedRequests;
157pub type InlinedEmbedContentRequest = InlinedEmbedRequest;
158pub type InlinedEmbedContentResponses = InlinedEmbedResponses;
159pub type InlinedEmbedContentResponse = InlinedEmbedResponse;
160pub type InlinedEmbedContentResponseOutput = InlinedEmbedResponseOutput;