feat: update UUID generation to use uuid7 for improved uniqueness across models
This commit is contained in:
parent
1a60d8c972
commit
3e9c3c0602
@ -9,7 +9,7 @@
|
|||||||
import logging
|
import logging
|
||||||
import time
|
import time
|
||||||
import traceback
|
import traceback
|
||||||
import uuid
|
import uuid_utils.compat as uuid
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
from django.db.models import QuerySet
|
from django.db.models import QuerySet
|
||||||
@ -238,7 +238,7 @@ class BaseChatStep(IChatStep):
|
|||||||
model_setting=None):
|
model_setting=None):
|
||||||
chat_result, is_ai_chat = self.get_stream_result(message_list, chat_model, paragraph_list,
|
chat_result, is_ai_chat = self.get_stream_result(message_list, chat_model, paragraph_list,
|
||||||
no_references_setting, problem_text)
|
no_references_setting, problem_text)
|
||||||
chat_record_id = uuid.uuid1()
|
chat_record_id = uuid.uuid7()
|
||||||
r = StreamingHttpResponse(
|
r = StreamingHttpResponse(
|
||||||
streaming_content=event_content(chat_result, chat_id, chat_record_id, paragraph_list,
|
streaming_content=event_content(chat_result, chat_id, chat_record_id, paragraph_list,
|
||||||
post_response_handler, manage, self, chat_model, message_list, problem_text,
|
post_response_handler, manage, self, chat_model, message_list, problem_text,
|
||||||
@ -286,7 +286,7 @@ class BaseChatStep(IChatStep):
|
|||||||
reasoning_content_end = model_setting.get('reasoning_content_end', '</think>')
|
reasoning_content_end = model_setting.get('reasoning_content_end', '</think>')
|
||||||
reasoning = Reasoning(reasoning_content_start,
|
reasoning = Reasoning(reasoning_content_start,
|
||||||
reasoning_content_end)
|
reasoning_content_end)
|
||||||
chat_record_id = uuid.uuid1()
|
chat_record_id = uuid.uuid7()
|
||||||
# 调用模型
|
# 调用模型
|
||||||
try:
|
try:
|
||||||
chat_result, is_ai_chat = self.get_block_result(message_list, chat_model, paragraph_list,
|
chat_result, is_ai_chat = self.get_block_result(message_list, chat_model, paragraph_list,
|
||||||
|
|||||||
@ -90,7 +90,7 @@ class Migration(migrations.Migration):
|
|||||||
fields=[
|
fields=[
|
||||||
('create_time', models.DateTimeField(auto_now_add=True, verbose_name='创建时间')),
|
('create_time', models.DateTimeField(auto_now_add=True, verbose_name='创建时间')),
|
||||||
('update_time', models.DateTimeField(auto_now=True, verbose_name='修改时间')),
|
('update_time', models.DateTimeField(auto_now=True, verbose_name='修改时间')),
|
||||||
('id', models.UUIDField(default=uuid.uuid1, editable=False, primary_key=True, serialize=False, verbose_name='主键id')),
|
('id', models.UUIDField(default=uuid_utils.compat.uuid7, editable=False, primary_key=True, serialize=False, verbose_name='主键id')),
|
||||||
('secret_key', models.CharField(max_length=1024, unique=True, verbose_name='秘钥')),
|
('secret_key', models.CharField(max_length=1024, unique=True, verbose_name='秘钥')),
|
||||||
('workspace_id', models.CharField(db_index=True, default='default', max_length=64, verbose_name='工作空间id')),
|
('workspace_id', models.CharField(db_index=True, default='default', max_length=64, verbose_name='工作空间id')),
|
||||||
('is_active', models.BooleanField(default=True, verbose_name='是否开启')),
|
('is_active', models.BooleanField(default=True, verbose_name='是否开启')),
|
||||||
@ -162,7 +162,7 @@ class Migration(migrations.Migration):
|
|||||||
fields=[
|
fields=[
|
||||||
('create_time', models.DateTimeField(auto_now_add=True, verbose_name='创建时间')),
|
('create_time', models.DateTimeField(auto_now_add=True, verbose_name='创建时间')),
|
||||||
('update_time', models.DateTimeField(auto_now=True, verbose_name='修改时间')),
|
('update_time', models.DateTimeField(auto_now=True, verbose_name='修改时间')),
|
||||||
('id', models.UUIDField(default=uuid_utils.compat.uuid1, editable=False, primary_key=True, serialize=False, verbose_name='主键id')),
|
('id', models.UUIDField(default=uuid_utils.compat.uuid7, editable=False, primary_key=True, serialize=False, verbose_name='主键id')),
|
||||||
('vote_status', models.CharField(choices=[('-1', '未投票'), ('0', '赞同'), ('1', '反对')], default='-1', max_length=10, verbose_name='投票')),
|
('vote_status', models.CharField(choices=[('-1', '未投票'), ('0', '赞同'), ('1', '反对')], default='-1', max_length=10, verbose_name='投票')),
|
||||||
('problem_text', models.CharField(max_length=10240, verbose_name='问题')),
|
('problem_text', models.CharField(max_length=10240, verbose_name='问题')),
|
||||||
('answer_text', models.CharField(max_length=40960, verbose_name='答案')),
|
('answer_text', models.CharField(max_length=40960, verbose_name='答案')),
|
||||||
@ -185,7 +185,7 @@ class Migration(migrations.Migration):
|
|||||||
fields=[
|
fields=[
|
||||||
('create_time', models.DateTimeField(auto_now_add=True, verbose_name='创建时间')),
|
('create_time', models.DateTimeField(auto_now_add=True, verbose_name='创建时间')),
|
||||||
('update_time', models.DateTimeField(auto_now=True, verbose_name='修改时间')),
|
('update_time', models.DateTimeField(auto_now=True, verbose_name='修改时间')),
|
||||||
('id', models.UUIDField(default=uuid_utils.compat.uuid1, editable=False, primary_key=True, serialize=False, verbose_name='主键id')),
|
('id', models.UUIDField(default=uuid_utils.compat.uuid7, editable=False, primary_key=True, serialize=False, verbose_name='主键id')),
|
||||||
('workspace_id', models.CharField(db_index=True, default='default', max_length=64, verbose_name='工作空间id')),
|
('workspace_id', models.CharField(db_index=True, default='default', max_length=64, verbose_name='工作空间id')),
|
||||||
('name', models.CharField(default='', max_length=128, verbose_name='版本名称')),
|
('name', models.CharField(default='', max_length=128, verbose_name='版本名称')),
|
||||||
('publish_user_id', models.UUIDField(default=None, null=True, verbose_name='发布者id')),
|
('publish_user_id', models.UUIDField(default=None, null=True, verbose_name='发布者id')),
|
||||||
|
|||||||
@ -120,7 +120,7 @@ class ApplicationKnowledgeMapping(AppModelMixin):
|
|||||||
|
|
||||||
|
|
||||||
class WorkFlowVersion(AppModelMixin):
|
class WorkFlowVersion(AppModelMixin):
|
||||||
id = models.UUIDField(primary_key=True, max_length=128, default=uuid.uuid1, editable=False, verbose_name="主键id")
|
id = models.UUIDField(primary_key=True, max_length=128, default=uuid.uuid7, editable=False, verbose_name="主键id")
|
||||||
application = models.ForeignKey(Application, on_delete=models.CASCADE)
|
application = models.ForeignKey(Application, on_delete=models.CASCADE)
|
||||||
workspace_id = models.CharField(max_length=64, verbose_name="工作空间id", default="default", db_index=True)
|
workspace_id = models.CharField(max_length=64, verbose_name="工作空间id", default="default", db_index=True)
|
||||||
name = models.CharField(verbose_name="版本名称", max_length=128, default="")
|
name = models.CharField(verbose_name="版本名称", max_length=128, default="")
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import uuid
|
import uuid_utils.compat as uuid
|
||||||
|
|
||||||
from django.contrib.postgres.fields import ArrayField
|
from django.contrib.postgres.fields import ArrayField
|
||||||
from django.db import models
|
from django.db import models
|
||||||
@ -9,7 +9,7 @@ from users.models import User
|
|||||||
|
|
||||||
|
|
||||||
class ApplicationApiKey(AppModelMixin):
|
class ApplicationApiKey(AppModelMixin):
|
||||||
id = models.UUIDField(primary_key=True, max_length=128, default=uuid.uuid1, editable=False, verbose_name="主键id")
|
id = models.UUIDField(primary_key=True, max_length=128, default=uuid.uuid7, editable=False, verbose_name="主键id")
|
||||||
secret_key = models.CharField(max_length=1024, verbose_name="秘钥", unique=True)
|
secret_key = models.CharField(max_length=1024, verbose_name="秘钥", unique=True)
|
||||||
user = models.ForeignKey(User, on_delete=models.CASCADE, verbose_name="用户id")
|
user = models.ForeignKey(User, on_delete=models.CASCADE, verbose_name="用户id")
|
||||||
workspace_id = models.CharField(max_length=64, verbose_name="工作空间id", default="default", db_index=True)
|
workspace_id = models.CharField(max_length=64, verbose_name="工作空间id", default="default", db_index=True)
|
||||||
|
|||||||
@ -48,7 +48,7 @@ class ChatRecord(AppModelMixin):
|
|||||||
"""
|
"""
|
||||||
对话日志 详情
|
对话日志 详情
|
||||||
"""
|
"""
|
||||||
id = models.UUIDField(primary_key=True, max_length=128, default=uuid.uuid1, editable=False, verbose_name="主键id")
|
id = models.UUIDField(primary_key=True, max_length=128, default=uuid.uuid7, editable=False, verbose_name="主键id")
|
||||||
chat = models.ForeignKey(Chat, on_delete=models.CASCADE)
|
chat = models.ForeignKey(Chat, on_delete=models.CASCADE)
|
||||||
vote_status = models.CharField(verbose_name='投票', max_length=10, choices=VoteChoices.choices,
|
vote_status = models.CharField(verbose_name='投票', max_length=10, choices=VoteChoices.choices,
|
||||||
default=VoteChoices.UN_VOTE)
|
default=VoteChoices.UN_VOTE)
|
||||||
|
|||||||
@ -246,7 +246,7 @@ class ApplicationCreateSerializer(serializers.Serializer):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def to_application_model(user_id: str, application: Dict):
|
def to_application_model(user_id: str, application: Dict):
|
||||||
return Application(id=uuid.uuid1(), name=application.get('name'), desc=application.get('desc'),
|
return Application(id=uuid.uuid7(), name=application.get('name'), desc=application.get('desc'),
|
||||||
prologue=application.get('prologue'),
|
prologue=application.get('prologue'),
|
||||||
dialogue_number=application.get('dialogue_number', 0),
|
dialogue_number=application.get('dialogue_number', 0),
|
||||||
user_id=user_id, model_id=application.get('model_id'),
|
user_id=user_id, model_id=application.get('model_id'),
|
||||||
@ -429,12 +429,12 @@ class ApplicationSerializer(serializers.Serializer):
|
|||||||
application_model.save()
|
application_model.save()
|
||||||
# 插入认证信息
|
# 插入认证信息
|
||||||
ApplicationAccessToken(application_id=application_model.id,
|
ApplicationAccessToken(application_id=application_model.id,
|
||||||
access_token=hashlib.md5(str(uuid.uuid1()).encode()).hexdigest()[8:24]).save()
|
access_token=hashlib.md5(str(uuid.uuid7()).encode()).hexdigest()[8:24]).save()
|
||||||
return ApplicationCreateSerializer.ApplicationResponse(application_model).data
|
return ApplicationCreateSerializer.ApplicationResponse(application_model).data
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def to_application_knowledge_mapping(application_id: str, dataset_id: str):
|
def to_application_knowledge_mapping(application_id: str, dataset_id: str):
|
||||||
return ApplicationKnowledgeMapping(id=uuid.uuid1(), application_id=application_id, dataset_id=dataset_id)
|
return ApplicationKnowledgeMapping(id=uuid.uuid7(), application_id=application_id, dataset_id=dataset_id)
|
||||||
|
|
||||||
def insert_simple(self, instance: Dict):
|
def insert_simple(self, instance: Dict):
|
||||||
self.is_valid(raise_exception=True)
|
self.is_valid(raise_exception=True)
|
||||||
@ -449,7 +449,7 @@ class ApplicationSerializer(serializers.Serializer):
|
|||||||
application_model.save()
|
application_model.save()
|
||||||
# 插入认证信息
|
# 插入认证信息
|
||||||
ApplicationAccessToken(application_id=application_model.id,
|
ApplicationAccessToken(application_id=application_model.id,
|
||||||
access_token=hashlib.md5(str(uuid.uuid1()).encode()).hexdigest()[8:24]).save()
|
access_token=hashlib.md5(str(uuid.uuid7()).encode()).hexdigest()[8:24]).save()
|
||||||
# 插入关联数据
|
# 插入关联数据
|
||||||
QuerySet(ApplicationKnowledgeMapping).bulk_create(application_knowledge_mapping_model_list)
|
QuerySet(ApplicationKnowledgeMapping).bulk_create(application_knowledge_mapping_model_list)
|
||||||
return ApplicationCreateSerializer.ApplicationResponse(application_model).data
|
return ApplicationCreateSerializer.ApplicationResponse(application_model).data
|
||||||
@ -484,7 +484,7 @@ class ApplicationSerializer(serializers.Serializer):
|
|||||||
application_model.save()
|
application_model.save()
|
||||||
# 插入认证信息
|
# 插入认证信息
|
||||||
ApplicationAccessToken(application_id=application_model.id,
|
ApplicationAccessToken(application_id=application_model.id,
|
||||||
access_token=hashlib.md5(str(uuid.uuid1()).encode()).hexdigest()[8:24]).save()
|
access_token=hashlib.md5(str(uuid.uuid7()).encode()).hexdigest()[8:24]).save()
|
||||||
QuerySet(Tool).bulk_create(tool_model_list) if len(tool_model_list) > 0 else None
|
QuerySet(Tool).bulk_create(tool_model_list) if len(tool_model_list) > 0 else None
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@ -511,7 +511,7 @@ class ApplicationSerializer(serializers.Serializer):
|
|||||||
for node in work_flow.get('nodes', []):
|
for node in work_flow.get('nodes', []):
|
||||||
if node.get('type') == 'search-dataset-node':
|
if node.get('type') == 'search-dataset-node':
|
||||||
node.get('properties', {}).get('node_data', {})['dataset_id_list'] = []
|
node.get('properties', {}).get('node_data', {})['dataset_id_list'] = []
|
||||||
return Application(id=uuid.uuid1(),
|
return Application(id=uuid.uuid7(),
|
||||||
user_id=user_id,
|
user_id=user_id,
|
||||||
name=application.get('name'),
|
name=application.get('name'),
|
||||||
workspace_id=workspace_id,
|
workspace_id=workspace_id,
|
||||||
|
|||||||
@ -7,7 +7,7 @@
|
|||||||
@desc:
|
@desc:
|
||||||
"""
|
"""
|
||||||
import hashlib
|
import hashlib
|
||||||
import uuid
|
import uuid_utils.compat as uuid
|
||||||
|
|
||||||
from django.core.cache import cache
|
from django.core.cache import cache
|
||||||
from django.db.models import QuerySet
|
from django.db.models import QuerySet
|
||||||
@ -53,7 +53,7 @@ class AccessTokenSerializer(serializers.Serializer):
|
|||||||
if 'is_active' in instance:
|
if 'is_active' in instance:
|
||||||
application_access_token.is_active = instance.get("is_active")
|
application_access_token.is_active = instance.get("is_active")
|
||||||
if 'access_token_reset' in instance and instance.get('access_token_reset'):
|
if 'access_token_reset' in instance and instance.get('access_token_reset'):
|
||||||
application_access_token.access_token = hashlib.md5(str(uuid.uuid1()).encode()).hexdigest()[8:24]
|
application_access_token.access_token = hashlib.md5(str(uuid.uuid7()).encode()).hexdigest()[8:24]
|
||||||
if 'access_num' in instance and instance.get('access_num') is not None:
|
if 'access_num' in instance and instance.get('access_num') is not None:
|
||||||
application_access_token.access_num = instance.get("access_num")
|
application_access_token.access_num = instance.get("access_num")
|
||||||
if 'white_active' in instance and instance.get('white_active') is not None:
|
if 'white_active' in instance and instance.get('white_active') is not None:
|
||||||
@ -91,7 +91,7 @@ class AccessTokenSerializer(serializers.Serializer):
|
|||||||
if application_access_token is None:
|
if application_access_token is None:
|
||||||
application_access_token = ApplicationAccessToken(application_id=application_id,
|
application_access_token = ApplicationAccessToken(application_id=application_id,
|
||||||
access_token=hashlib.md5(
|
access_token=hashlib.md5(
|
||||||
str(uuid.uuid1()).encode()).hexdigest()[
|
str(uuid.uuid7()).encode()).hexdigest()[
|
||||||
8:24], is_active=True)
|
8:24], is_active=True)
|
||||||
application_access_token.save()
|
application_access_token.save()
|
||||||
application_setting_model = DatabaseModelManage.get_model('application_setting')
|
application_setting_model = DatabaseModelManage.get_model('application_setting')
|
||||||
|
|||||||
@ -45,8 +45,8 @@ class ApplicationKeySerializer(serializers.Serializer):
|
|||||||
self.is_valid(raise_exception=True)
|
self.is_valid(raise_exception=True)
|
||||||
application_id = self.data.get("application_id")
|
application_id = self.data.get("application_id")
|
||||||
application = QuerySet(Application).filter(id=application_id).first()
|
application = QuerySet(Application).filter(id=application_id).first()
|
||||||
secret_key = 'application-' + hashlib.md5(str(uuid.uuid1()).encode()).hexdigest()
|
secret_key = 'application-' + hashlib.md5(str(uuid.uuid7()).encode()).hexdigest()
|
||||||
application_api_key = ApplicationApiKey(id=uuid.uuid1(),
|
application_api_key = ApplicationApiKey(id=uuid.uuid7(),
|
||||||
secret_key=secret_key,
|
secret_key=secret_key,
|
||||||
user_id=application.user_id,
|
user_id=application.user_id,
|
||||||
application_id=application_id)
|
application_id=application_id)
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
@date:2025/6/10 15:10
|
@date:2025/6/10 15:10
|
||||||
@desc:
|
@desc:
|
||||||
"""
|
"""
|
||||||
import uuid
|
import uuid_utils.compat as uuid
|
||||||
from functools import reduce
|
from functools import reduce
|
||||||
from typing import Dict
|
from typing import Dict
|
||||||
|
|
||||||
@ -208,7 +208,7 @@ class ApplicationChatRecordAddKnowledgeSerializer(serializers.Serializer):
|
|||||||
problem_paragraph_mappings = []
|
problem_paragraph_mappings = []
|
||||||
for chat_record in chat_record_list:
|
for chat_record in chat_record_list:
|
||||||
paragraph = Paragraph(
|
paragraph = Paragraph(
|
||||||
id=uuid.uuid1(),
|
id=uuid.uuid7(),
|
||||||
document_id=document_id,
|
document_id=document_id,
|
||||||
content=chat_record.answer_text,
|
content=chat_record.answer_text,
|
||||||
knowledge_id=knowledge_id,
|
knowledge_id=knowledge_id,
|
||||||
@ -216,7 +216,7 @@ class ApplicationChatRecordAddKnowledgeSerializer(serializers.Serializer):
|
|||||||
)
|
)
|
||||||
problem, _ = Problem.objects.get_or_create(content=chat_record.problem_text, knowledge_id=knowledge_id)
|
problem, _ = Problem.objects.get_or_create(content=chat_record.problem_text, knowledge_id=knowledge_id)
|
||||||
problem_paragraph_mapping = ProblemParagraphMapping(
|
problem_paragraph_mapping = ProblemParagraphMapping(
|
||||||
id=uuid.uuid1(),
|
id=uuid.uuid7(),
|
||||||
knowledge_id=knowledge_id,
|
knowledge_id=knowledge_id,
|
||||||
document_id=document_id,
|
document_id=document_id,
|
||||||
problem_id=problem.id,
|
problem_id=problem.id,
|
||||||
@ -284,7 +284,7 @@ class ApplicationChatRecordImproveSerializer(serializers.Serializer):
|
|||||||
max_position=Max('position')
|
max_position=Max('position')
|
||||||
)['max_position'] or 0
|
)['max_position'] or 0
|
||||||
paragraph = Paragraph(
|
paragraph = Paragraph(
|
||||||
id=uuid.uuid1(),
|
id=uuid.uuid7(),
|
||||||
document_id=document_id,
|
document_id=document_id,
|
||||||
content=instance.get("content"),
|
content=instance.get("content"),
|
||||||
knowledge_id=knowledge_id,
|
knowledge_id=knowledge_id,
|
||||||
@ -294,7 +294,7 @@ class ApplicationChatRecordImproveSerializer(serializers.Serializer):
|
|||||||
problem_text = instance.get('problem_text') if instance.get(
|
problem_text = instance.get('problem_text') if instance.get(
|
||||||
'problem_text') is not None else chat_record.problem_text
|
'problem_text') is not None else chat_record.problem_text
|
||||||
problem, _ = QuerySet(Problem).get_or_create(content=problem_text, knowledge_id=knowledge_id)
|
problem, _ = QuerySet(Problem).get_or_create(content=problem_text, knowledge_id=knowledge_id)
|
||||||
problem_paragraph_mapping = ProblemParagraphMapping(id=uuid.uuid1(), knowledge_id=knowledge_id,
|
problem_paragraph_mapping = ProblemParagraphMapping(id=uuid.uuid7(), knowledge_id=knowledge_id,
|
||||||
document_id=document_id,
|
document_id=document_id,
|
||||||
problem_id=problem.id,
|
problem_id=problem.id,
|
||||||
paragraph_id=paragraph.id)
|
paragraph_id=paragraph.id)
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
@date:2025/6/10 11:00
|
@date:2025/6/10 11:00
|
||||||
@desc:
|
@desc:
|
||||||
"""
|
"""
|
||||||
import uuid
|
import uuid_utils.compat as uuid
|
||||||
|
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
from drf_spectacular.utils import extend_schema
|
from drf_spectacular.utils import extend_schema
|
||||||
@ -114,7 +114,7 @@ class OpenView(APIView):
|
|||||||
def get(self, request: Request, workspace_id: str, application_id: str):
|
def get(self, request: Request, workspace_id: str, application_id: str):
|
||||||
return result.success(OpenChatSerializers(
|
return result.success(OpenChatSerializers(
|
||||||
data={'workspace_id': workspace_id, 'application_id': application_id,
|
data={'workspace_id': workspace_id, 'application_id': application_id,
|
||||||
'chat_user_id': str(uuid.uuid1()), 'chat_user_type': ChatUserType.ANONYMOUS_USER,
|
'chat_user_id': str(uuid.uuid7()), 'chat_user_type': ChatUserType.ANONYMOUS_USER,
|
||||||
'debug': True}).open())
|
'debug': True}).open())
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -232,7 +232,7 @@ class ChatSerializers(serializers.Serializer):
|
|||||||
work_flow_manage = WorkflowManage(Workflow.new_instance(work_flow),
|
work_flow_manage = WorkflowManage(Workflow.new_instance(work_flow),
|
||||||
{'history_chat_record': history_chat_record, 'question': message,
|
{'history_chat_record': history_chat_record, 'question': message,
|
||||||
'chat_id': chat_info.chat_id, 'chat_record_id': str(
|
'chat_id': chat_info.chat_id, 'chat_record_id': str(
|
||||||
uuid.uuid1()) if chat_record is None else chat_record.id,
|
uuid.uuid7()) if chat_record is None else chat_record.id,
|
||||||
'stream': stream,
|
'stream': stream,
|
||||||
're_chat': re_chat,
|
're_chat': re_chat,
|
||||||
'chat_user_id': chat_user_id,
|
'chat_user_id': chat_user_id,
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
@date:2025/6/6 13:48
|
@date:2025/6/6 13:48
|
||||||
@desc:
|
@desc:
|
||||||
"""
|
"""
|
||||||
import uuid
|
import uuid_utils.compat as uuid
|
||||||
|
|
||||||
from django.core import signing
|
from django.core import signing
|
||||||
from django.core.cache import cache
|
from django.core.cache import cache
|
||||||
@ -41,7 +41,7 @@ class AnonymousAuthenticationSerializer(serializers.Serializer):
|
|||||||
access_token = self.data.get("access_token")
|
access_token = self.data.get("access_token")
|
||||||
application_access_token = QuerySet(ApplicationAccessToken).filter(access_token=access_token).first()
|
application_access_token = QuerySet(ApplicationAccessToken).filter(access_token=access_token).first()
|
||||||
if application_access_token is not None and application_access_token.is_active:
|
if application_access_token is not None and application_access_token.is_active:
|
||||||
chat_user_id = token_details.get('chat_user_id') or str(uuid.uuid1())
|
chat_user_id = token_details.get('chat_user_id') or str(uuid.uuid7())
|
||||||
_type = AuthenticationType.CHAT_ANONYMOUS_USER
|
_type = AuthenticationType.CHAT_ANONYMOUS_USER
|
||||||
return ChatUserToken(application_access_token.application_id, None, access_token, _type,
|
return ChatUserToken(application_access_token.application_id, None, access_token, _type,
|
||||||
ChatUserType.ANONYMOUS_USER,
|
ChatUserType.ANONYMOUS_USER,
|
||||||
|
|||||||
@ -7,7 +7,7 @@
|
|||||||
@desc:
|
@desc:
|
||||||
"""
|
"""
|
||||||
import os
|
import os
|
||||||
import uuid
|
import uuid_utils.compat as uuid
|
||||||
|
|
||||||
from django.db.models import QuerySet
|
from django.db.models import QuerySet
|
||||||
from django.http import HttpResponse
|
from django.http import HttpResponse
|
||||||
@ -78,7 +78,7 @@ class ChatEmbedSerializer(serializers.Serializer):
|
|||||||
'x_value': float_location.get('x', {}).get('value', 0),
|
'x_value': float_location.get('x', {}).get('value', 0),
|
||||||
'y_type': float_location.get('y', {}).get('type', 'bottom'),
|
'y_type': float_location.get('y', {}).get('type', 'bottom'),
|
||||||
'y_value': float_location.get('y', {}).get('value', 30),
|
'y_value': float_location.get('y', {}).get('value', 30),
|
||||||
'max_kb_id': str(uuid.uuid1()).replace('-', ''),
|
'max_kb_id': str(uuid.uuid7()).replace('-', ''),
|
||||||
'header_font_color': header_font_color}))
|
'header_font_color': header_font_color}))
|
||||||
response = HttpResponse(s, status=200, headers={'Content-Type': 'text/javascript'})
|
response = HttpResponse(s, status=200, headers={'Content-Type': 'text/javascript'})
|
||||||
return response
|
return response
|
||||||
|
|||||||
@ -10,7 +10,7 @@ import os
|
|||||||
import pickle
|
import pickle
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
import uuid
|
import uuid_utils.compat as uuid
|
||||||
from textwrap import dedent
|
from textwrap import dedent
|
||||||
|
|
||||||
from maxkb.const import BASE_DIR
|
from maxkb.const import BASE_DIR
|
||||||
@ -42,7 +42,7 @@ class FunctionExecutor:
|
|||||||
os.umask(old_mask)
|
os.umask(old_mask)
|
||||||
|
|
||||||
def exec_code(self, code_str, keywords):
|
def exec_code(self, code_str, keywords):
|
||||||
_id = str(uuid.uuid1())
|
_id = str(uuid.uuid7())
|
||||||
success = '{"code":200,"msg":"成功","data":exec_result}'
|
success = '{"code":200,"msg":"成功","data":exec_result}'
|
||||||
err = '{"code":500,"msg":str(e),"data":None}'
|
err = '{"code":500,"msg":str(e),"data":None}'
|
||||||
result_path = f'{self.sandbox_path}/result/{_id}.result'
|
result_path = f'{self.sandbox_path}/result/{_id}.result'
|
||||||
|
|||||||
@ -336,7 +336,7 @@ class DocumentSerializers(serializers.Serializer):
|
|||||||
problem_paragraph_mapping.problem_id = problem.id
|
problem_paragraph_mapping.problem_id = problem.id
|
||||||
return problem, False
|
return problem, False
|
||||||
else:
|
else:
|
||||||
problem = Problem(id=uuid.uuid1(), knowledge_id=target_knowledge_id, content=problem_content)
|
problem = Problem(id=uuid.uuid7(), knowledge_id=target_knowledge_id, content=problem_content)
|
||||||
target_problem_list.append(problem)
|
target_problem_list.append(problem)
|
||||||
problem_paragraph_mapping.problem_id = problem.id
|
problem_paragraph_mapping.problem_id = problem.id
|
||||||
return problem, True
|
return problem, True
|
||||||
|
|||||||
@ -548,7 +548,7 @@ class ParagraphSerializers(serializers.Serializer):
|
|||||||
problem_paragraph_mapping.problem_id = problem.id
|
problem_paragraph_mapping.problem_id = problem.id
|
||||||
return problem, False
|
return problem, False
|
||||||
else:
|
else:
|
||||||
problem = Problem(id=uuid.uuid1(), knowledge_id=target_knowledge_id, content=problem_content)
|
problem = Problem(id=uuid.uuid7(), knowledge_id=target_knowledge_id, content=problem_content)
|
||||||
target_problem_list.append(problem)
|
target_problem_list.append(problem)
|
||||||
problem_paragraph_mapping.problem_id = problem.id
|
problem_paragraph_mapping.problem_id = problem.id
|
||||||
return problem, True
|
return problem, True
|
||||||
|
|||||||
@ -13,7 +13,7 @@ import hmac
|
|||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import ssl
|
import ssl
|
||||||
import uuid
|
import uuid_utils.compat as uuid
|
||||||
import wave
|
import wave
|
||||||
from hashlib import sha256
|
from hashlib import sha256
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
@ -285,7 +285,7 @@ class VolcanicEngineSpeechToText(MaxKBBaseModel, BaseSpeechToText):
|
|||||||
return header_dicts
|
return header_dicts
|
||||||
|
|
||||||
async def segment_data_processor(self, wav_data: bytes, segment_size: int):
|
async def segment_data_processor(self, wav_data: bytes, segment_size: int):
|
||||||
reqid = str(uuid.uuid4())
|
reqid = str(uuid.uuid7())
|
||||||
# 构建 full client request,并序列化压缩
|
# 构建 full client request,并序列化压缩
|
||||||
request_params = self.construct_request(reqid)
|
request_params = self.construct_request(reqid)
|
||||||
payload_bytes = str.encode(json.dumps(request_params))
|
payload_bytes = str.encode(json.dumps(request_params))
|
||||||
|
|||||||
@ -14,7 +14,7 @@ import gzip
|
|||||||
import json
|
import json
|
||||||
import re
|
import re
|
||||||
import ssl
|
import ssl
|
||||||
import uuid
|
import uuid_utils.compat as uuid
|
||||||
from typing import Dict
|
from typing import Dict
|
||||||
|
|
||||||
import websockets
|
import websockets
|
||||||
@ -92,7 +92,7 @@ class VolcanicEngineTextToSpeech(MaxKBBaseModel, BaseTextToSpeech):
|
|||||||
"pitch_ratio": 1.0,
|
"pitch_ratio": 1.0,
|
||||||
} | self.params,
|
} | self.params,
|
||||||
"request": {
|
"request": {
|
||||||
"reqid": str(uuid.uuid4()),
|
"reqid": str(uuid.uuid7()),
|
||||||
"text": '',
|
"text": '',
|
||||||
"text_type": "plain",
|
"text_type": "plain",
|
||||||
"operation": "xxx"
|
"operation": "xxx"
|
||||||
@ -119,7 +119,7 @@ class VolcanicEngineTextToSpeech(MaxKBBaseModel, BaseTextToSpeech):
|
|||||||
for line in lines:
|
for line in lines:
|
||||||
if self.is_table_format_chars_only(line):
|
if self.is_table_format_chars_only(line):
|
||||||
continue
|
continue
|
||||||
submit_request_json["request"]["reqid"] = str(uuid.uuid4())
|
submit_request_json["request"]["reqid"] = str(uuid.uuid7())
|
||||||
submit_request_json["request"]["text"] = line
|
submit_request_json["request"]["text"] = line
|
||||||
payload_bytes = str.encode(json.dumps(submit_request_json))
|
payload_bytes = str.encode(json.dumps(submit_request_json))
|
||||||
payload_bytes = gzip.compress(payload_bytes) # if no compression, comment this line
|
payload_bytes = gzip.compress(payload_bytes) # if no compression, comment this line
|
||||||
|
|||||||
@ -22,7 +22,7 @@ class Migration(migrations.Migration):
|
|||||||
fields=[
|
fields=[
|
||||||
('create_time', models.DateTimeField(auto_now_add=True, verbose_name='创建时间')),
|
('create_time', models.DateTimeField(auto_now_add=True, verbose_name='创建时间')),
|
||||||
('update_time', models.DateTimeField(auto_now=True, verbose_name='修改时间')),
|
('update_time', models.DateTimeField(auto_now=True, verbose_name='修改时间')),
|
||||||
('id', models.UUIDField(default=uuid.uuid1, editable=False, primary_key=True, serialize=False, verbose_name='主键id')),
|
('id', models.UUIDField(default=uuid_utils.compat.uuid7, editable=False, primary_key=True, serialize=False, verbose_name='主键id')),
|
||||||
('menu', models.CharField(max_length=128, verbose_name='操作菜单')),
|
('menu', models.CharField(max_length=128, verbose_name='操作菜单')),
|
||||||
('operate', models.CharField(max_length=128, verbose_name='操作')),
|
('operate', models.CharField(max_length=128, verbose_name='操作')),
|
||||||
('operation_object', models.JSONField(default=dict, encoder=common.encoder.encoder.SystemEncoder, verbose_name='操作对象')),
|
('operation_object', models.JSONField(default=dict, encoder=common.encoder.encoder.SystemEncoder, verbose_name='操作对象')),
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
@date:2025/6/4 14:15
|
@date:2025/6/4 14:15
|
||||||
@desc:
|
@desc:
|
||||||
"""
|
"""
|
||||||
import uuid
|
import uuid_utils.compat as uuid
|
||||||
|
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
|
||||||
@ -18,7 +18,7 @@ class Log(AppModelMixin):
|
|||||||
"""
|
"""
|
||||||
审计日志
|
审计日志
|
||||||
"""
|
"""
|
||||||
id = models.UUIDField(primary_key=True, max_length=128, default=uuid.uuid1, editable=False, verbose_name="主键id")
|
id = models.UUIDField(primary_key=True, max_length=128, default=uuid.uuid7, editable=False, verbose_name="主键id")
|
||||||
|
|
||||||
menu = models.CharField(max_length=128, verbose_name="操作菜单")
|
menu = models.CharField(max_length=128, verbose_name="操作菜单")
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user