mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
Refa: create new name for duplicated dialog name (#9558)
### What problem does this PR solve? Create new name for duplicated dialog name. ### Type of change - [x] Refactoring
This commit is contained in:
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
from flask import request
|
from flask import request
|
||||||
from flask_login import login_required, current_user
|
from flask_login import login_required, current_user
|
||||||
|
from api.db.services import duplicate_name
|
||||||
from api.db.services.dialog_service import DialogService
|
from api.db.services.dialog_service import DialogService
|
||||||
from api.db import StatusEnum
|
from api.db import StatusEnum
|
||||||
from api.db.services.tenant_llm_service import TenantLLMService
|
from api.db.services.tenant_llm_service import TenantLLMService
|
||||||
@ -42,8 +43,14 @@ def set_dialog():
|
|||||||
if len(name.encode("utf-8")) > 255:
|
if len(name.encode("utf-8")) > 255:
|
||||||
return get_data_error_result(message=f"Dialog name length is {len(name)} which is larger than 255")
|
return get_data_error_result(message=f"Dialog name length is {len(name)} which is larger than 255")
|
||||||
|
|
||||||
if DialogService.get_or_none(tenant_id=current_user.id, name=name):
|
if is_create and DialogService.query(tenant_id=current_user.id, name=name.strip()):
|
||||||
return get_data_error_result(message=f"Duplicated Dialog name {name}.")
|
name = name.strip()
|
||||||
|
name = duplicate_name(
|
||||||
|
DialogService.query,
|
||||||
|
name=name,
|
||||||
|
tenant_id=current_user.id,
|
||||||
|
status=StatusEnum.VALID.value)
|
||||||
|
|
||||||
description = req.get("description", "A helpful dialog")
|
description = req.get("description", "A helpful dialog")
|
||||||
icon = req.get("icon", "")
|
icon = req.get("icon", "")
|
||||||
top_n = req.get("top_n", 6)
|
top_n = req.get("top_n", 6)
|
||||||
|
|||||||
Reference in New Issue
Block a user