ai_chain_glm/chatgpt/
model.rs1use ai_chain::options::{ModelRef, Opt};
2use serde::{Deserialize, Serialize};
3use strum_macros::{EnumIter,EnumString};
4
5#[derive(EnumIter,Debug,Default, Clone, Serialize, Deserialize, EnumString, PartialEq, Eq)]
22#[non_exhaustive]
23pub enum Model {
24 #[strum(serialize = "glm-4")]
26 #[default]
27 GLM4,
28 #[strum(serialize = "glm-4v")]
29 GLM4V,
30 #[strum(serialize = "glm-3-turbo")]
31 GLM3Turbo,
32
33
34 #[strum(default)]
39 Other(String),
40}
41impl Model {
42
43}
44
45impl ToString for Model {
46 fn to_string(&self) -> String {
47 match &self {
48 Model::GLM4 => "glm-4".to_string(),
49 Model::GLM4V => "glm-4v".to_string(),
50 Model::GLM3Turbo => "glm-3-turbo".to_string(),
51
52 Model::Other(model) => model.to_string(),
53 }
54 }
55}
56
57
58
59impl From<Model> for ModelRef {
61 fn from(value: Model) -> Self {
62 ModelRef::from_model_name(value.to_string())
63 }
64}
65
66impl From<Model> for Opt {
68 fn from(value: Model) -> Self {
69 Opt::Model(value.into())
70 }
71}
72
73#[cfg(test)]
74mod tests {
75 use std::str::FromStr;
76 use strum::IntoEnumIterator;
77
78 use super::*;
79
80 #[test]
82 fn test_from_str() -> Result<(), Box<dyn std::error::Error>> {
83 let model_names = Model::iter().map(|model| model.to_string()).collect::<Vec<String>>();
85 println!("{:?}", model_names);
86 Ok(())
87 }
88
89 #[test]
91 fn test_to_string() {
92
93 }
94
95 #[test]
96 #[allow(deprecated)]
97 fn test_to_string_deprecated() {
98
99 }
100}