@@ -4,8 +4,8 @@ use std::{borrow::Cow, collections::BTreeMap, fmt};
44
55use indexmap:: IndexMap ;
66
7- use crate :: headers:: HeaderRule ;
87use crate :: rate_limit:: TokenRateLimitsConfig ;
8+ use crate :: { headers:: HeaderRule , proxy:: ProxyConfig } ;
99use regex:: { Regex , RegexBuilder } ;
1010use secrecy:: SecretString ;
1111use serde:: { Deserialize , Deserializer } ;
@@ -195,7 +195,10 @@ pub struct LlmProtocolsConfig {
195195#[ serde( default , deny_unknown_fields) ]
196196pub struct LlmConfig {
197197 /// Whether the LLM functionality is enabled.
198- enabled : bool ,
198+ pub enabled : bool ,
199+
200+ /// Proxy configuration for LLM requests.
201+ pub proxy : ProxyConfig ,
199202
200203 /// Protocol-specific endpoint configurations.
201204 pub protocols : LlmProtocolsConfig ,
@@ -210,16 +213,12 @@ impl Default for LlmConfig {
210213 enabled : true ,
211214 protocols : LlmProtocolsConfig :: default ( ) ,
212215 providers : IndexMap :: new ( ) ,
216+ proxy : Default :: default ( ) ,
213217 }
214218 }
215219}
216220
217221impl LlmConfig {
218- /// Whether the LLM functionality is enabled.
219- pub fn enabled ( & self ) -> bool {
220- self . enabled
221- }
222-
223222 /// Whether there are any LLM providers configured.
224223 pub fn has_providers ( & self ) -> bool {
225224 !self . providers . is_empty ( )
@@ -494,6 +493,12 @@ mod tests {
494493 assert_debug_snapshot ! ( & config, @r#"
495494 LlmConfig {
496495 enabled: true,
496+ proxy: ProxyConfig {
497+ anthropic: AnthropicProxyConfig {
498+ enabled: false,
499+ path: "/proxy/anthropic",
500+ },
501+ },
497502 protocols: LlmProtocolsConfig {
498503 openai: OpenAIProtocolConfig {
499504 enabled: true,
@@ -532,6 +537,12 @@ mod tests {
532537 assert_debug_snapshot ! ( & config, @r#"
533538 LlmConfig {
534539 enabled: true,
540+ proxy: ProxyConfig {
541+ anthropic: AnthropicProxyConfig {
542+ enabled: false,
543+ path: "/proxy/anthropic",
544+ },
545+ },
535546 protocols: LlmProtocolsConfig {
536547 openai: OpenAIProtocolConfig {
537548 enabled: true,
@@ -595,6 +606,12 @@ mod tests {
595606 assert_debug_snapshot ! ( & config, @r#"
596607 LlmConfig {
597608 enabled: true,
609+ proxy: ProxyConfig {
610+ anthropic: AnthropicProxyConfig {
611+ enabled: false,
612+ path: "/proxy/anthropic",
613+ },
614+ },
598615 protocols: LlmProtocolsConfig {
599616 openai: OpenAIProtocolConfig {
600617 enabled: true,
@@ -656,6 +673,12 @@ mod tests {
656673 assert_debug_snapshot ! ( & config, @r#"
657674 LlmConfig {
658675 enabled: true,
676+ proxy: ProxyConfig {
677+ anthropic: AnthropicProxyConfig {
678+ enabled: false,
679+ path: "/proxy/anthropic",
680+ },
681+ },
659682 protocols: LlmProtocolsConfig {
660683 openai: OpenAIProtocolConfig {
661684 enabled: true,
@@ -728,6 +751,12 @@ path = "/ai"
728751 assert_debug_snapshot ! ( & config, @r#"
729752 LlmConfig {
730753 enabled: true,
754+ proxy: ProxyConfig {
755+ anthropic: AnthropicProxyConfig {
756+ enabled: false,
757+ path: "/proxy/anthropic",
758+ },
759+ },
731760 protocols: LlmProtocolsConfig {
732761 openai: OpenAIProtocolConfig {
733762 enabled: true,
@@ -926,6 +955,12 @@ path = "/ai"
926955 assert_debug_snapshot ! ( & config, @r#"
927956 LlmConfig {
928957 enabled: false,
958+ proxy: ProxyConfig {
959+ anthropic: AnthropicProxyConfig {
960+ enabled: false,
961+ path: "/proxy/anthropic",
962+ },
963+ },
929964 protocols: LlmProtocolsConfig {
930965 openai: OpenAIProtocolConfig {
931966 enabled: true,
@@ -954,6 +989,12 @@ path = "/models"
954989 assert_debug_snapshot ! ( & config, @r#"
955990 LlmConfig {
956991 enabled: true,
992+ proxy: ProxyConfig {
993+ anthropic: AnthropicProxyConfig {
994+ enabled: false,
995+ path: "/proxy/anthropic",
996+ },
997+ },
957998 protocols: LlmProtocolsConfig {
958999 openai: OpenAIProtocolConfig {
9591000 enabled: true,
@@ -1002,6 +1043,12 @@ path = "/llm"
10021043 assert_debug_snapshot ! ( & config, @r#"
10031044 LlmConfig {
10041045 enabled: true,
1046+ proxy: ProxyConfig {
1047+ anthropic: AnthropicProxyConfig {
1048+ enabled: false,
1049+ path: "/proxy/anthropic",
1050+ },
1051+ },
10051052 protocols: LlmProtocolsConfig {
10061053 openai: OpenAIProtocolConfig {
10071054 enabled: true,
@@ -1059,6 +1106,12 @@ path = "/llm"
10591106 assert_debug_snapshot ! ( & config, @r#"
10601107 LlmConfig {
10611108 enabled: true,
1109+ proxy: ProxyConfig {
1110+ anthropic: AnthropicProxyConfig {
1111+ enabled: false,
1112+ path: "/proxy/anthropic",
1113+ },
1114+ },
10621115 protocols: LlmProtocolsConfig {
10631116 openai: OpenAIProtocolConfig {
10641117 enabled: true,
@@ -1125,6 +1178,12 @@ path = "/llm"
11251178 assert_debug_snapshot ! ( & config, @r#"
11261179 LlmConfig {
11271180 enabled: true,
1181+ proxy: ProxyConfig {
1182+ anthropic: AnthropicProxyConfig {
1183+ enabled: false,
1184+ path: "/proxy/anthropic",
1185+ },
1186+ },
11281187 protocols: LlmProtocolsConfig {
11291188 openai: OpenAIProtocolConfig {
11301189 enabled: true,
@@ -1194,6 +1253,12 @@ path = "/llm"
11941253 assert_debug_snapshot ! ( & config, @r#"
11951254 LlmConfig {
11961255 enabled: true,
1256+ proxy: ProxyConfig {
1257+ anthropic: AnthropicProxyConfig {
1258+ enabled: false,
1259+ path: "/proxy/anthropic",
1260+ },
1261+ },
11971262 protocols: LlmProtocolsConfig {
11981263 openai: OpenAIProtocolConfig {
11991264 enabled: true,
@@ -1382,6 +1447,12 @@ path = "/llm"
13821447 assert_debug_snapshot ! ( & config, @r#"
13831448 LlmConfig {
13841449 enabled: true,
1450+ proxy: ProxyConfig {
1451+ anthropic: AnthropicProxyConfig {
1452+ enabled: false,
1453+ path: "/proxy/anthropic",
1454+ },
1455+ },
13851456 protocols: LlmProtocolsConfig {
13861457 openai: OpenAIProtocolConfig {
13871458 enabled: true,
@@ -1476,6 +1547,12 @@ path = "/llm"
14761547 assert_debug_snapshot ! ( & config, @r#"
14771548 LlmConfig {
14781549 enabled: true,
1550+ proxy: ProxyConfig {
1551+ anthropic: AnthropicProxyConfig {
1552+ enabled: false,
1553+ path: "/proxy/anthropic",
1554+ },
1555+ },
14791556 protocols: LlmProtocolsConfig {
14801557 openai: OpenAIProtocolConfig {
14811558 enabled: true,
@@ -1530,6 +1607,12 @@ path = "/llm"
15301607 assert_debug_snapshot ! ( & config, @r#"
15311608 LlmConfig {
15321609 enabled: true,
1610+ proxy: ProxyConfig {
1611+ anthropic: AnthropicProxyConfig {
1612+ enabled: false,
1613+ path: "/proxy/anthropic",
1614+ },
1615+ },
15331616 protocols: LlmProtocolsConfig {
15341617 openai: OpenAIProtocolConfig {
15351618 enabled: true,
0 commit comments