Skip to content

Commit df3658c

Browse files
committed
🐛 Fix ID verification exception when updating the model #1311
1 parent a28385d commit df3658c

File tree

5 files changed

+11
-9
lines changed

5 files changed

+11
-9
lines changed

backend/services/model_management_service.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,13 +195,15 @@ async def list_provider_models_for_tenant(tenant_id: str, provider: str, model_t
195195
async def update_single_model_for_tenant(user_id: str, tenant_id: str, model_data: Dict[str, Any]):
196196
"""Update a single model by its model_id, ensuring display_name uniqueness."""
197197
try:
198-
existing_model_by_display = get_model_by_display_name(
199-
model_data["display_name"], tenant_id)
200-
if existing_model_by_display and existing_model_by_display["model_id"] != model_data["model_id"]:
198+
existing_model_by_display = get_model_by_display_name(model_data["display_name"], tenant_id)
199+
current_model_id = int(model_data["model_id"])
200+
existing_model_id = existing_model_by_display["model_id"] if existing_model_by_display else None
201+
202+
if existing_model_by_display and existing_model_id != current_model_id:
201203
raise ValueError(
202204
f"Name {model_data['display_name']} is already in use, please choose another display name")
203205

204-
update_model_record(model_data["model_id"], model_data, user_id)
206+
update_model_record(current_model_id, model_data, user_id)
205207
logging.debug(
206208
f"Model {model_data['display_name']} updated successfully")
207209
except Exception as e:

frontend/app/[locale]/chat/internal/chatInterface.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1402,7 +1402,7 @@ export function ChatInterface() {
14021402
);
14031403
if (preprocessStep) {
14041404
const stoppedMessage =
1405-
(t("chatInterface.filePreprocessingStopped") as string) ||
1405+
(t("chatInterface.fileProcessingStopped") as string) ||
14061406
"File preprocessing stopped";
14071407
preprocessStep.content = stoppedMessage;
14081408
if (

frontend/public/locales/en/common.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"chatInterface.truncationSeparator": "; ",
3030
"chatInterface.fileParsingFailed": "File parsing failed",
3131
"chatInterface.fileSizeExceeded": "File size exceeds the limit, please upload smaller files",
32-
"chatInterface.filePreprocessingStopped": "File parsing stopped",
32+
"chatInterface.fileProcessingStopped": "File parsing stopped",
3333
"chatInterface.conversationStopped": "Conversation stopped",
3434
"chatInterface.errorProcessingRequest": "An error occurred while processing the request",
3535
"chatInterface.errorFetchingConversationList": "Failed to fetch conversation list during initialization:",

frontend/public/locales/zh/common.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"chatInterface.truncationSeparator": "",
3030
"chatInterface.fileParsingFailed": "文件解析失败",
3131
"chatInterface.fileSizeExceeded": "文件大小超出限制,请上传更小的文件",
32-
"chatInterface.filePreprocessingStopped": "文件解析已停止",
32+
"chatInterface.fileProcessingStopped": "文件解析已停止",
3333
"chatInterface.conversationStopped": "对话已停止",
3434
"chatInterface.errorProcessingRequest": "处理请求时发生错误",
3535
"chatInterface.errorFetchingConversationList": "初始化时获取对话列表失败:",

test/backend/services/test_model_management_service.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -484,12 +484,12 @@ async def test_list_provider_models_for_tenant_exception():
484484
async def test_update_single_model_for_tenant_success():
485485
svc = import_svc()
486486

487-
model = {"model_id": "m1", "display_name": "name"}
487+
model = {"model_id": "1", "display_name": "name"}
488488
with mock.patch.object(svc, "get_model_by_display_name", return_value=None) as mock_get, \
489489
mock.patch.object(svc, "update_model_record") as mock_update:
490490
await svc.update_single_model_for_tenant("u1", "t1", model)
491491
mock_get.assert_called_once_with("name", "t1")
492-
mock_update.assert_called_once_with("m1", model, "u1")
492+
mock_update.assert_called_once_with(1, model, "u1")
493493

494494

495495
async def test_update_single_model_for_tenant_conflict():

0 commit comments

Comments
 (0)