@@ -6,7 +6,7 @@ use serde::Deserialize;
66
77use crate :: caps:: {
88 BaseModelRecord , ChatModelRecord , CodeAssistantCaps , CompletionModelRecord , DefaultModels ,
9- EmbeddingModelRecord , default_chat_scratchpad, default_completion_scratchpad,
9+ EmbeddingModelRecord , CapsMetadata , default_chat_scratchpad, default_completion_scratchpad,
1010 default_completion_scratchpad_patch, default_embedding_batch, default_hf_tokenizer_template,
1111 default_rejection_threshold, relative_to_full_url, normalize_string, resolve_relative_urls
1212} ;
@@ -59,6 +59,10 @@ pub struct SelfHostedCapsChat {
5959 pub endpoint : String ,
6060 pub models : IndexMap < String , SelfHostedCapsModelRecord > ,
6161 pub default_model : String ,
62+ #[ serde( default ) ]
63+ pub default_light_model : String ,
64+ #[ serde( default ) ]
65+ pub default_thinking_model : String ,
6266}
6367
6468#[ derive( Debug , Deserialize , Clone , Default ) ]
@@ -88,7 +92,12 @@ pub struct SelfHostedCaps {
8892
8993 #[ serde( default ) ]
9094 pub customization : String ,
95+ #[ serde( default ) ]
9196 pub caps_version : i64 ,
97+ #[ serde( default ) ]
98+ pub support_metadata : bool ,
99+ #[ serde( default ) ]
100+ pub metadata : CapsMetadata ,
92101}
93102
94103fn configure_base_model (
@@ -99,6 +108,7 @@ fn configure_base_model(
99108 tokenizer_endpoints : & HashMap < String , String > ,
100109 caps_url : & String ,
101110 cmdline_api_key : & str ,
111+ support_metadata : & bool ,
102112) -> Result < ( ) , String > {
103113 base_model. name = model_name. to_string ( ) ;
104114 base_model. id = format ! ( "{}/{}" , cloud_name, model_name) ;
@@ -108,6 +118,7 @@ fn configure_base_model(
108118 if let Some ( tokenizer) = tokenizer_endpoints. get ( & base_model. name ) {
109119 base_model. tokenizer = relative_to_full_url ( caps_url, & tokenizer) ?;
110120 }
121+ base_model. support_metadata = support_metadata. clone ( ) ;
111122 base_model. api_key = cmdline_api_key. to_string ( ) ;
112123 base_model. endpoint_style = "openai" . to_string ( ) ;
113124 Ok ( ( ) )
@@ -155,6 +166,7 @@ impl SelfHostedCapsModelRecord {
155166 & self_hosted_caps. tokenizer_endpoints ,
156167 caps_url,
157168 cmdline_api_key,
169+ & self_hosted_caps. support_metadata ,
158170 ) ?;
159171
160172 let ( scratchpad, scratchpad_patch) = self . get_completion_scratchpad ( ) ;
@@ -199,6 +211,7 @@ impl SelfHostedCapsModelRecord {
199211 & self_hosted_caps. tokenizer_endpoints ,
200212 caps_url,
201213 cmdline_api_key,
214+ & self_hosted_caps. support_metadata ,
202215 ) ?;
203216
204217 Ok ( ChatModelRecord {
@@ -239,6 +252,7 @@ impl SelfHostedCapsEmbeddingModelRecord {
239252 & self_hosted_caps. tokenizer_endpoints ,
240253 caps_url,
241254 cmdline_api_key,
255+ & self_hosted_caps. support_metadata ,
242256 ) ?;
243257
244258 Ok ( embedding_model)
@@ -261,15 +275,23 @@ impl SelfHostedCaps {
261275 defaults : DefaultModels {
262276 completion_default_model : format ! ( "{}/{}" , self . cloud_name, self . completion. default_model) ,
263277 chat_default_model : format ! ( "{}/{}" , self . cloud_name, self . chat. default_model) ,
264- chat_thinking_model : String :: new ( ) ,
265- chat_light_model : format ! ( "{}/{}" , self . cloud_name, self . chat. default_model) ,
278+ chat_thinking_model : if self . chat . default_thinking_model . is_empty ( ) {
279+ String :: new ( )
280+ } else {
281+ format ! ( "{}/{}" , self . cloud_name, self . chat. default_thinking_model)
282+ } ,
283+ chat_light_model : if self . chat . default_light_model . is_empty ( ) {
284+ String :: new ( )
285+ } else {
286+ format ! ( "{}/{}" , self . cloud_name, self . chat. default_light_model)
287+ } ,
266288 } ,
267289 customization : self . customization . clone ( ) ,
268290 caps_version : self . caps_version ,
269291
270292 hf_tokenizer_template : default_hf_tokenizer_template ( ) ,
271293
272- metadata : crate :: caps :: CapsMetadata :: default ( ) ,
294+ metadata : self . metadata . clone ( ) ,
273295 } ;
274296
275297 for ( model_name, model_rec) in & self . completion . models {
@@ -319,16 +341,24 @@ impl SelfHostedCaps {
319341 api_key : cmdline_api_key. to_string ( ) ,
320342 tokenizer_api_key : cmdline_api_key. to_string ( ) ,
321343 code_completion_n_ctx : 0 ,
322- support_metadata : false ,
344+ support_metadata : self . support_metadata ,
323345 completion_models : IndexMap :: new ( ) ,
324346 chat_models : IndexMap :: new ( ) ,
325347 embedding_model : EmbeddingModelRecord :: default ( ) ,
326348 models_dict_patch : IndexMap :: new ( ) ,
327349 defaults : DefaultModels {
328350 completion_default_model : self . completion . default_model . clone ( ) ,
329351 chat_default_model : self . chat . default_model . clone ( ) ,
330- chat_thinking_model : String :: new ( ) ,
331- chat_light_model : String :: new ( ) ,
352+ chat_thinking_model : if self . chat . default_thinking_model . is_empty ( ) {
353+ String :: new ( )
354+ } else {
355+ format ! ( "{}/{}" , self . cloud_name, self . chat. default_thinking_model)
356+ } ,
357+ chat_light_model : if self . chat . default_light_model . is_empty ( ) {
358+ String :: new ( )
359+ } else {
360+ format ! ( "{}/{}" , self . cloud_name, self . chat. default_light_model)
361+ } ,
332362 } ,
333363 running_models : Vec :: new ( ) ,
334364 } ;
0 commit comments