1use serde::{Deserialize, Serialize};
2
3pub const DEFAULT_MODEL: &str = "gpt-4o-mini";
4pub const DEFAULT_PATH: &str = ".";
5pub const DEFAULT_API_BASE: &str = "https://api.openai.com/v1";
6
7#[derive(Debug, Deserialize, Serialize, Clone, Default)]
8pub struct Config {
9 #[serde(default)]
10 pub llm: LLMConfig,
11 #[serde(default)]
12 pub parse: ParseConfig,
13 #[serde(default)]
14 pub commit: CommitConfig,
15}
16
17#[derive(Debug, Deserialize, Serialize, Clone)]
18pub struct LLMConfig {
19 pub api_base: Option<String>,
20 pub api_key: Option<String>,
21 #[serde(default = "default_model")]
22 pub model: String,
23}
24
25#[derive(Debug, Deserialize, Serialize, Clone)]
26pub struct ParseConfig {
27 #[serde(default = "default_path")]
28 pub path: String,
29 pub include: Option<String>,
30 pub exclude: Option<String>,
31}
32
33#[derive(Debug, Serialize, Deserialize, Clone, Default)]
34pub struct CommitConfig {
35 #[serde(default)]
36 pub exclude: Option<String>,
37}
38
39impl Default for LLMConfig {
40 fn default() -> Self {
41 Self {
42 api_base: None,
43 api_key: None,
44 model: DEFAULT_MODEL.to_string(),
45 }
46 }
47}
48
49impl Default for ParseConfig {
50 fn default() -> Self {
51 Self {
52 path: DEFAULT_PATH.to_string(),
53 include: None,
54 exclude: None,
55 }
56 }
57}
58
59fn default_model() -> String {
60 DEFAULT_MODEL.to_string()
61}
62
63fn default_path() -> String {
64 DEFAULT_PATH.to_string()
65}