smg_mcp/transform/
types.rs1use serde::{Deserialize, Serialize};
4
5use crate::core::config::ResponseFormatConfig;
6
7#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Default)]
9#[serde(rename_all = "snake_case")]
10pub enum ResponseFormat {
11 #[default]
13 Passthrough,
14 WebSearchCall,
16 CodeInterpreterCall,
18 FileSearchCall,
20}
21
22impl From<ResponseFormatConfig> for ResponseFormat {
23 fn from(config: ResponseFormatConfig) -> Self {
24 match config {
25 ResponseFormatConfig::Passthrough => ResponseFormat::Passthrough,
26 ResponseFormatConfig::WebSearchCall => ResponseFormat::WebSearchCall,
27 ResponseFormatConfig::CodeInterpreterCall => ResponseFormat::CodeInterpreterCall,
28 ResponseFormatConfig::FileSearchCall => ResponseFormat::FileSearchCall,
29 }
30 }
31}
32
33#[cfg(test)]
34mod tests {
35 use super::*;
36
37 #[test]
38 fn test_response_format_serde() {
39 let formats = vec![
40 (ResponseFormat::Passthrough, "\"passthrough\""),
41 (ResponseFormat::WebSearchCall, "\"web_search_call\""),
42 (
43 ResponseFormat::CodeInterpreterCall,
44 "\"code_interpreter_call\"",
45 ),
46 (ResponseFormat::FileSearchCall, "\"file_search_call\""),
47 ];
48
49 for (format, expected) in formats {
50 let serialized = serde_json::to_string(&format).unwrap();
51 assert_eq!(serialized, expected);
52
53 let deserialized: ResponseFormat = serde_json::from_str(&serialized).unwrap();
54 assert_eq!(deserialized, format);
55 }
56 }
57
58 #[test]
59 fn test_response_format_default() {
60 assert_eq!(ResponseFormat::default(), ResponseFormat::Passthrough);
61 }
62}