mirror of https://github.com/jumpserver/jumpserver
perf: Gpt3 to gpt-4o-mini
parent
45291aba0c
commit
3d4fc56592
|
@ -295,23 +295,17 @@ class Protocol(ChoicesMixin, models.TextChoices):
|
|||
'setting': {
|
||||
'api_mode': {
|
||||
'type': 'choice',
|
||||
'default': 'gpt-3.5-turbo',
|
||||
'default': 'gpt-4o-mini',
|
||||
'label': _('API mode'),
|
||||
'choices': [
|
||||
('gpt-3.5-turbo', 'GPT-3.5 Turbo'),
|
||||
('gpt-3.5-turbo-1106', 'GPT-3.5 Turbo 1106'),
|
||||
('gpt-4o-mini', 'GPT-4o-mini'),
|
||||
('gpt-4o', 'GPT-4o'),
|
||||
('gpt-4-turbo', 'GPT-4 Turbo'),
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if settings.XPACK_LICENSE_IS_VALID:
|
||||
choices = protocols[cls.chatgpt]['setting']['api_mode']['choices']
|
||||
choices.extend([
|
||||
('gpt-4', 'GPT-4'),
|
||||
('gpt-4-turbo', 'GPT-4 Turbo'),
|
||||
('gpt-4o', 'GPT-4o'),
|
||||
])
|
||||
return protocols
|
||||
|
||||
@classmethod
|
||||
|
|
|
@ -69,7 +69,9 @@ class VaultSettingSerializer(serializers.Serializer):
|
|||
|
||||
class ChatAISettingSerializer(serializers.Serializer):
|
||||
PREFIX_TITLE = _('Chat AI')
|
||||
GPT_MODEL_CHOICES = []
|
||||
API_MODEL = Protocol.gpt_protocols()[Protocol.chatgpt]['setting']['api_mode']
|
||||
GPT_MODEL_CHOICES = API_MODEL['choices']
|
||||
GPT_MODEL_DEFAULT = API_MODEL['default']
|
||||
|
||||
CHAT_AI_ENABLED = serializers.BooleanField(
|
||||
required=False, label=_('Enable Chat AI')
|
||||
|
@ -84,26 +86,9 @@ class ChatAISettingSerializer(serializers.Serializer):
|
|||
allow_blank=True, required=False, label=_('Proxy')
|
||||
)
|
||||
GPT_MODEL = serializers.ChoiceField(
|
||||
default='', choices=GPT_MODEL_CHOICES, label=_("GPT Model"), required=False,
|
||||
default=GPT_MODEL_DEFAULT, choices=GPT_MODEL_CHOICES, label=_("GPT Model"), required=False,
|
||||
)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.set_GPT_MODEL_choices()
|
||||
|
||||
def set_GPT_MODEL_choices(self):
|
||||
field_gpt_model = self.fields.get("GPT_MODEL")
|
||||
if not field_gpt_model:
|
||||
return
|
||||
gpt_api_model = Protocol.gpt_protocols()[Protocol.chatgpt]['setting']['api_mode']
|
||||
choices = gpt_api_model['choices']
|
||||
field_gpt_model.choices = choices
|
||||
field_gpt_model.default = gpt_api_model['default']
|
||||
cls = self.__class__
|
||||
if cls.GPT_MODEL_CHOICES:
|
||||
return
|
||||
cls.GPT_MODEL_CHOICES.extend(choices)
|
||||
|
||||
|
||||
class TicketSettingSerializer(serializers.Serializer):
|
||||
PREFIX_TITLE = _('Ticket')
|
||||
|
|
Loading…
Reference in New Issue