@@ -62,7 +62,7 @@ def streaming_chat_completions(
6262class LiteLLMInterpreter (BaseOpenAIInterpreter ):
6363 SUPPORTED_ENDPOINT_TYPES = ["openai" , "azure_ai" , "azure" , "gemini" , "anthropic" , "xai" , "hosted_vllm" ]
6464
65- def __init__ (self , model_description : dict , default_sampling_params : Optional [ SamplingParams ], ** kwargs ):
65+ def __init__ (self , model_description : dict , ** kwargs ):
6666 try :
6767 import litellm
6868 except ImportError :
@@ -80,9 +80,7 @@ def __init__(self, model_description: dict, default_sampling_params: Optional[Sa
8080 # Otherwise, generation will fail for some endpoints.
8181 self .log_probs = False
8282
83- super ().__init__ (
84- model = self .model , client = self .client , default_sampling_params = default_sampling_params , ** kwargs
85- )
83+ super ().__init__ (model = self .model , client = self .client , ** kwargs )
8684
8785 def _check_model (self , model_desc : dict ) -> str :
8886 """Check if the model description is valid."""
@@ -232,24 +230,23 @@ def _grammar_vllm(self, node: GrammarNode, **kwargs) -> Iterator[OutputAttr]:
232230 yield self .state .apply_capture (name = name , value = value , log_prob = log_probs , is_append = False )
233231
234232 def _process_kwargs (self , ** kwargs ):
235- if "top_k" not in kwargs and "top_k" in self .default_sampling_params :
236- kwargs ["top_k" ] = self .default_sampling_params ["top_k" ]
233+ sampling_params = kwargs .pop ("sampling_params" , None )
234+ if sampling_params is None :
235+ return kwargs
236+
237+ kwargs ["top_p" ] = sampling_params .pop ("top_p" , None )
238+ kwargs ["top_k" ] = sampling_params .pop ("top_k" , None )
237239
238240 return kwargs
239241
240242
241243class LiteLLM (Model ):
242244 def __init__ (
243- self ,
244- model_description : dict ,
245- default_sampling_params : Optional [SamplingParams ] = None ,
246- echo : bool = True ,
247- ** kwargs ,
245+ self , model_description : dict , sampling_params : Optional [SamplingParams ] = None , echo : bool = True , ** kwargs
248246 ):
249- interpreter = LiteLLMInterpreter (
250- model_description = model_description , default_sampling_params = default_sampling_params , ** kwargs
251- )
247+ interpreter = LiteLLMInterpreter (model_description = model_description , ** kwargs )
252248 super ().__init__ (
253249 interpreter = interpreter ,
250+ sampling_params = SamplingParams () if sampling_params is None else sampling_params ,
254251 echo = echo ,
255252 )
0 commit comments