修改配置文件

This commit is contained in:
jlj 2025-05-23 19:54:32 +08:00
parent eb7884c1b5
commit a9156bf037
4 changed files with 26 additions and 13 deletions

View File

@ -11,10 +11,12 @@ import uuid
import aiohttp
from urllib.parse import parse_qs
from django.utils import timezone
from rest_framework.permissions import IsAuthenticated
from apps.user.authentication import CustomTokenAuthentication
logger = logging.getLogger(__name__)
class ChatStreamConsumer(AsyncWebsocketConsumer):
# 固定知识库ID
DEFAULT_KNOWLEDGE_BASE_ID = "b680a4fa-37be-11f0-a7cb-0242ac120002"

View File

@ -12,6 +12,7 @@ from rest_framework.decorators import action
from apps.user.models import User
from apps.chat.models import ChatHistory
from apps.chat.serializers import ChatHistorySerializer
from apps.user.authentication import CustomTokenAuthentication
from apps.common.services.chat_service import ChatService
from apps.chat.services.chat_api import (
ExternalAPIError, stream_chat_answer, get_chat_answer,
@ -22,6 +23,7 @@ logger = logging.getLogger(__name__)
class ChatHistoryViewSet(viewsets.ModelViewSet):
permission_classes = [IsAuthenticated]
authentication_classes = [CustomTokenAuthentication]
serializer_class = ChatHistorySerializer
queryset = ChatHistory.objects.all()

View File

@ -0,0 +1,14 @@
# Generated by Django 5.1.5 on 2025-05-23 11:23
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('daren_detail', '0004_creatorprofile_avatar'),
('daren_detail', '0004_creatorprofile_profile'),
]
operations = [
]

View File

@ -49,8 +49,8 @@ INSTALLED_APPS = [
"apps.brands.apps.BrandsConfig",
'rest_framework',
'rest_framework_simplejwt',
'apps.chat.apps.ChatConfig',
'apps.common.apps.CommonConfig',
"apps.chat.apps.ChatConfig",
"apps.common.apps.CommonConfig",
]
MIDDLEWARE = [
@ -102,7 +102,7 @@ DATABASES = {
'NAME': 'daren_detail',
'USER': 'root',
'PASSWORD': '123456',
'HOST': '192.168.31.138',
'HOST': 'localhost',
'PORT': '3306',
'OPTIONS': {
'charset': 'utf8mb4',
@ -215,13 +215,9 @@ MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
# REST Framework 设置
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': [
'rest_framework_simplejwt.authentication.JWTAuthentication',
'apps.user.authentication.CustomTokenAuthentication',
],
'DEFAULT_PERMISSION_CLASSES': [
'rest_framework.permissions.IsAuthenticated',
],
'DEFAULT_AUTHENTICATION_CLASSES': [], # 默认不需要认证
'DEFAULT_PERMISSION_CLASSES': [], # 默认不需要权限
'UNAUTHENTICATED_USER': None
}
# JWT 设置
@ -242,4 +238,3 @@ SIMPLE_JWT = {
API_BASE_URL = 'http://81.69.223.133:48329'
SILICON_CLOUD_API_KEY = 'sk-xqbujijjqqmlmlvkhvxeogqjtzslnhdtqxqgiyuhwpoqcjvf'