|
13 | 13 |
|
14 | 14 | from common import forms |
15 | 15 | from common.exception.app_exception import AppApiException |
16 | | -from common.forms import BaseForm |
| 16 | +from common.forms import BaseForm, TooltipLabel |
17 | 17 | from models_provider.base_model_provider import BaseModelCredential, ValidCode |
18 | 18 |
|
| 19 | +class OpenAIEmbeddingModelParams(BaseForm): |
| 20 | + dimensions = forms.SingleSelect( |
| 21 | + TooltipLabel( |
| 22 | + _('Dimensions'), |
| 23 | + _('') |
| 24 | + ), |
| 25 | + required=True, |
| 26 | + default_value=1024, |
| 27 | + value_field='value', |
| 28 | + text_field='label', |
| 29 | + option_list=[ |
| 30 | + {'label': '1536', 'value': '1536'}, |
| 31 | + {'label': '1024', 'value': '1024'}, |
| 32 | + {'label': '768', 'value': '768'}, |
| 33 | + {'label': '512', 'value': '512'}, |
| 34 | + ] |
| 35 | + ) |
| 36 | + |
19 | 37 |
|
20 | 38 | class OpenAIEmbeddingCredential(BaseForm, BaseModelCredential): |
21 | 39 | def is_valid(self, model_type: str, model_name, model_credential: Dict[str, object], model_params, provider, |
@@ -49,5 +67,8 @@ def is_valid(self, model_type: str, model_name, model_credential: Dict[str, obje |
49 | 67 | def encryption_dict(self, model: Dict[str, object]): |
50 | 68 | return {**model, 'api_key': super().encryption(model.get('api_key', ''))} |
51 | 69 |
|
| 70 | + def get_model_params_setting_form(self, model_name): |
| 71 | + return OpenAIEmbeddingModelParams() |
| 72 | + |
52 | 73 | api_base = forms.TextInputField('API URL', required=True) |
53 | 74 | api_key = forms.PasswordInputField('API Key', required=True) |
0 commit comments