diff --git a/apps/jumpserver/conf.py b/apps/jumpserver/conf.py index 879d12fc2..d39f62292 100644 --- a/apps/jumpserver/conf.py +++ b/apps/jumpserver/conf.py @@ -13,11 +13,11 @@ import json import logging import os import re +import sys import types from importlib import import_module from urllib.parse import urljoin, urlparse, quote -import sys import yaml from django.urls import reverse_lazy from django.utils.translation import gettext_lazy as _ @@ -699,7 +699,6 @@ class Config(dict): 'LIMIT_SUPER_PRIV': False, # Chat AI - 'IS_CUSTOM_MODEL': False, 'CHAT_AI_ENABLED': False, 'CHAT_AI_METHOD': 'api', 'CHAT_AI_EMBED_URL': '', diff --git a/apps/jumpserver/settings/custom.py b/apps/jumpserver/settings/custom.py index dec51af85..a3990ff0d 100644 --- a/apps/jumpserver/settings/custom.py +++ b/apps/jumpserver/settings/custom.py @@ -239,7 +239,6 @@ LIMIT_SUPER_PRIV = CONFIG.LIMIT_SUPER_PRIV ASSET_SIZE = 'small' # Chat AI -IS_CUSTOM_MODEL = CONFIG.IS_CUSTOM_MODEL CUSTOM_GPT_MODEL = CONFIG.CUSTOM_GPT_MODEL CUSTOM_DEEPSEEK_MODEL = CONFIG.CUSTOM_DEEPSEEK_MODEL CHAT_AI_ENABLED = CONFIG.CHAT_AI_ENABLED diff --git a/apps/settings/api/chat.py b/apps/settings/api/chat.py index 3b9fadd18..c42fa3f46 100644 --- a/apps/settings/api/chat.py +++ b/apps/settings/api/chat.py @@ -42,22 +42,18 @@ class ChatAITestingAPI(GenericAPIView): ) tp = config['CHAT_AI_TYPE'] - is_custom_model = config['IS_CUSTOM_MODEL'] if tp == ChatAITypeChoices.gpt: url = config['GPT_BASE_URL'] api_key = config['GPT_API_KEY'] proxy = config['GPT_PROXY'] model = config['GPT_MODEL'] - custom_model = config['CUSTOM_GPT_MODEL'] + model = model if config['GPT_MODEL'] != 'custom' else config['CUSTOM_GPT_MODEL'] else: url = config['DEEPSEEK_BASE_URL'] api_key = config['DEEPSEEK_API_KEY'] proxy = config['DEEPSEEK_PROXY'] model = config['DEEPSEEK_MODEL'] - custom_model = config['CUSTOM_DEEPSEEK_MODEL'] - - model = custom_model or model \ - if is_custom_model else model + model = model if config['DEEPSEEK_MODEL'] != 'custom' else config['CUSTOM_DEEPSEEK_MODEL'] kwargs = { 'base_url': url or None, diff --git a/apps/settings/const.py b/apps/settings/const.py index 7ad3d3b34..dd17fc123 100644 --- a/apps/settings/const.py +++ b/apps/settings/const.py @@ -19,6 +19,7 @@ class ChatAITypeChoices(TextChoices): class GPTModelChoices(TextChoices): + custom = 'custom', _('Custom gpt model') # 🚀 Latest flagship dialogue model GPT_5_2 = 'gpt-5.2', 'gpt-5.2' GPT_5_2_PRO = 'gpt-5.2-pro', 'gpt-5.2-pro' @@ -39,5 +40,6 @@ class GPTModelChoices(TextChoices): class DeepSeekModelChoices(TextChoices): + custom = 'custom', _('Custom DeepSeek model') deepseek_chat = 'deepseek-chat', 'DeepSeek-V3' deepseek_reasoner = 'deepseek-reasoner', 'DeepSeek-R1' diff --git a/apps/settings/models.py b/apps/settings/models.py index c461680cb..a30db92f2 100644 --- a/apps/settings/models.py +++ b/apps/settings/models.py @@ -201,18 +201,14 @@ def get_chatai_data(): 'url': settings.GPT_BASE_URL, 'api_key': settings.GPT_API_KEY, 'proxy': settings.GPT_PROXY, - 'model': settings.GPT_MODEL, + 'model': settings.GPT_MODEL if settings.GPT_MODEL != 'custom' else settings.CUSTOM_GPT_MODEL, } - custom_model = settings.CUSTOM_GPT_MODEL if settings.CHAT_AI_TYPE != ChatAITypeChoices.gpt: data['url'] = settings.DEEPSEEK_BASE_URL data['api_key'] = settings.DEEPSEEK_API_KEY data['proxy'] = settings.DEEPSEEK_PROXY - data['model'] = settings.DEEPSEEK_MODEL - custom_model = settings.CUSTOM_DEEPSEEK_MODEL + data['model'] = settings.DEEPSEEK_MODEL if settings.DEEPSEEK_MODEL != 'custom' else settings.CUSTOM_DEEPSEEK_MODEL - data['model'] = custom_model or data['model'] \ - if settings.IS_CUSTOM_MODEL else data['model'] return data diff --git a/apps/settings/serializers/feature.py b/apps/settings/serializers/feature.py index 249acc1e9..f1253af17 100644 --- a/apps/settings/serializers/feature.py +++ b/apps/settings/serializers/feature.py @@ -168,10 +168,6 @@ class ChatAISettingSerializer(serializers.Serializer): default=DeepSeekModelChoices.deepseek_chat, choices=DeepSeekModelChoices.choices, label=_("DeepSeek Model"), required=False, ) - IS_CUSTOM_MODEL = serializers.BooleanField( - required=False, default=False, label=_("Custom Model"), - help_text=_("Whether to use a custom model") - ) CUSTOM_GPT_MODEL = serializers.CharField( max_length=256, allow_blank=True, required=False, label=_('Custom gpt model'),