mirror of https://github.com/jumpserver/jumpserver
perf: Gpt3 to gpt-4o-mini
parent
83c1f8e4d3
commit
6a7896b712
|
@ -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
|
||||
|
|
|
@ -71,7 +71,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=_('Chat AI')
|
||||
|
@ -88,38 +90,21 @@ class ChatAISettingSerializer(serializers.Serializer):
|
|||
help_text=_('The proxy server address of the GPT service. For example: http://ip:port')
|
||||
)
|
||||
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')
|
||||
|
||||
TICKETS_ENABLED = serializers.BooleanField(required=False, default=True, label=_("Ticket"))
|
||||
TICKETS_DIRECT_APPROVE = serializers.BooleanField(
|
||||
required=False, default=False, label=_("Approval without login"),
|
||||
required=False, default=False, label=_("Approval without login"),
|
||||
help_text=_('Allow direct approval ticket without login')
|
||||
)
|
||||
TICKET_AUTHORIZE_DEFAULT_TIME = serializers.IntegerField(
|
||||
min_value=1, max_value=999999, required=False,
|
||||
label=_("Period"),
|
||||
label=_("Period"),
|
||||
help_text=_("The default authorization time period when applying for assets via a ticket")
|
||||
)
|
||||
TICKET_AUTHORIZE_DEFAULT_TIME_UNIT = serializers.ChoiceField(
|
||||
|
@ -146,7 +131,7 @@ class VirtualAppSerializer(serializers.Serializer):
|
|||
PREFIX_TITLE = _('Virtual app')
|
||||
|
||||
VIRTUAL_APP_ENABLED = serializers.BooleanField(
|
||||
required=False, label=_('Virtual App'),
|
||||
required=False, label=_('Virtual App'),
|
||||
help_text=_(
|
||||
'Virtual applications, you can use the Linux operating system as an application server '
|
||||
'in remote applications.'
|
||||
|
|
Loading…
Reference in New Issue