1010from typing import Dict
1111
1212from langchain_core .messages import HumanMessage
13+ from openai import BadRequestError
1314
1415from common import forms
1516from common .exception .app_exception import AppApiException
@@ -37,6 +38,17 @@ class AzureLLMModelParams(BaseForm):
3738 precision = 0 )
3839
3940
41+ class o3MiniLLMModelParams (BaseForm ):
42+ max_completion_tokens = forms .SliderField (
43+ TooltipLabel (_ ('Output the maximum Tokens' ),
44+ _ ('Specify the maximum number of tokens that the model can generate' )),
45+ required = True , default_value = 800 ,
46+ _min = 1 ,
47+ _max = 5000 ,
48+ _step = 1 ,
49+ precision = 0 )
50+
51+
4052class AzureLLMModelCredential (BaseForm , BaseModelCredential ):
4153
4254 def is_valid (self , model_type : str , model_name , model_credential : Dict [str , object ], model_params , provider ,
@@ -57,7 +69,7 @@ def is_valid(self, model_type: str, model_name, model_credential: Dict[str, obje
5769 model .invoke ([HumanMessage (content = gettext ('Hello' ))])
5870 except Exception as e :
5971 traceback .print_exc ()
60- if isinstance (e , AppApiException ):
72+ if isinstance (e , AppApiException ) or isinstance ( e , BadRequestError ) :
6173 raise e
6274 if raise_exception :
6375 raise AppApiException (ValidCode .valid_error .value ,
@@ -79,4 +91,6 @@ def encryption_dict(self, model: Dict[str, object]):
7991 deployment_name = forms .TextInputField ("Deployment name" , required = True )
8092
8193 def get_model_params_setting_form (self , model_name ):
94+ if 'o3' in model_name or 'o1' in model_name :
95+ return o3MiniLLMModelParams ()
8296 return AzureLLMModelParams ()
0 commit comments