1#[derive(Debug, Clone, PartialEq)]
2pub struct ChatConfig {
3 pub model: Model,
4 pub temperature: f64,
5}
6
7impl Default for ChatConfig {
8 fn default() -> Self {
9 Self {
10 model: Default::default(),
11 temperature: 0.5,
12 }
13 }
14}
15
16impl ChatConfig {
17 pub fn set_model(mut self, model: Model) -> Self {
18 self.model = model;
19 self
20 }
21 pub fn set_temprature(mut self, temprature: f64) -> Self {
22 self.temperature = temprature;
23 self
24 }
25 pub fn build(self) -> Self {
26 self
27 }
28}
29
30#[derive(Debug, Default, Copy, Clone, PartialEq, PartialOrd)]
31#[allow(non_camel_case_types)]
32pub enum Model {
33 #[default]
34 Gpt35Turbo,
35 Gpt35Turbo_0301,
36 Gpt4,
37 Gpt4_32k,
38 Gpt4_0314,
39 Gpt4_32k_0314,
40 Custom(&'static str),
41}
42
43impl AsRef<str> for Model {
44 fn as_ref(&self) -> &'static str {
45 match self {
46 Model::Gpt35Turbo => "gpt-3.5-turbo",
47 Model::Gpt35Turbo_0301 => "gpt-3.5-turbo-0301",
48 Model::Gpt4 => "gpt-4",
49 Model::Gpt4_32k => "gpt-4-32k",
50 Model::Gpt4_0314 => "gpt-4-0314",
51 Model::Gpt4_32k_0314 => "gpt-4-32k-0314",
52 Model::Custom(custom) => custom,
53 }
54 }
55}