perf: Move custom ai model

This commit is contained in:
feng
2026-01-05 16:40:07 +08:00
committed by ZhaoJiSen
parent ffa8eb714a
commit a0d41314bf
6 changed files with 7 additions and 19 deletions

View File

@@ -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': '',

View File

@@ -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

View File

@@ -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,

View File

@@ -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'

View File

@@ -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

View File

@@ -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'),