Skip to main content

gproxy_protocol/openai/generate_content/responses/items/actions/
annotations.rs

1use std::collections::BTreeMap;
2
3use serde::{Deserialize, Serialize};
4use serde_json::Value;
5
6use crate::openai::common::Rest;
7
8#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9#[serde(tag = "type")]
10#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
11pub enum ResponseAnnotation {
12    #[serde(rename = "file_citation")]
13    FileCitation {
14        file_id: String,
15        filename: String,
16        index: u32,
17        #[serde(default, flatten)]
18        rest: Rest,
19    },
20    #[serde(rename = "url_citation")]
21    UrlCitation {
22        end_index: u32,
23        start_index: u32,
24        title: String,
25        url: String,
26        #[serde(default, flatten)]
27        rest: Rest,
28    },
29    #[serde(rename = "container_file_citation")]
30    ContainerFileCitation {
31        container_id: String,
32        end_index: u32,
33        file_id: String,
34        filename: String,
35        start_index: u32,
36        #[serde(default, flatten)]
37        rest: Rest,
38    },
39    #[serde(rename = "file_path")]
40    FilePath {
41        file_id: String,
42        index: u32,
43        #[serde(default, flatten)]
44        rest: Rest,
45    },
46}
47
48#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
49#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
50pub struct FileSearchResult {
51    #[serde(skip_serializing_if = "Option::is_none")]
52    pub attributes: Option<FileSearchResultAttributes>,
53    #[serde(skip_serializing_if = "Option::is_none")]
54    pub file_id: Option<String>,
55    #[serde(skip_serializing_if = "Option::is_none")]
56    pub filename: Option<String>,
57    #[serde(skip_serializing_if = "Option::is_none")]
58    pub score: Option<f64>,
59    #[serde(skip_serializing_if = "Option::is_none")]
60    pub text: Option<String>,
61    #[serde(default, flatten)]
62    pub rest: Rest,
63}
64
65pub type FileSearchResultAttributes = BTreeMap<String, FileSearchResultAttributeValue>;
66
67#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
68#[serde(untagged)]
69#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
70pub enum FileSearchResultAttributeValue {
71    String(String),
72    Number(f64),
73    Boolean(bool),
74    Unknown(Value),
75}