1#[derive(Debug, Clone)]
2pub struct Config {
3 pub llm_api_base: String,
4 pub openai_api_key: Option<String>,
5 pub llm_ready_timeout_s: f64,
6 pub llm_ready_interval_s: f64,
7 pub skip_llm_ready_check: bool,
8 pub db_url: Option<String>,
11}
12
13#[must_use]
14pub fn normalize_base_url(url: &str) -> String {
15 let mut s = url.trim_end_matches('/').to_owned();
16 if s.ends_with("/v1") {
17 s.truncate(s.len() - 3);
18 s = s.trim_end_matches('/').to_owned();
19 }
20 s
21}
22
23#[cfg(test)]
24mod tests {
25 use super::*;
26
27 #[test]
28 fn strip_trailing_v1() {
29 assert_eq!(normalize_base_url("http://host:8000/v1"), "http://host:8000");
30 assert_eq!(normalize_base_url("http://host:8000/v1/"), "http://host:8000");
31 }
32
33 #[test]
34 fn no_v1_unchanged() {
35 assert_eq!(normalize_base_url("http://host:8000"), "http://host:8000");
36 assert_eq!(normalize_base_url("http://host:8000/"), "http://host:8000");
37 }
38}