Skip to content

Commit 382965c

Browse files
committed
feat: 更新glm5的真实chat_id改动。至此GLM已不支持多条messages会话。
1 parent 7500e89 commit 382965c

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

app/providers/zai_provider.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ async def _create_upstream_chat(
319319
user_message_id: Optional[str] = None,
320320
mcp_servers: Optional[List[str]] = None,
321321
) -> str:
322-
"""为 GLM-4.7 创建真实 chat,并返回上游 chat_id。"""
322+
"""为需要真实会话的模型创建上游 chat,并返回 chat_id。"""
323323
init_content = (prompt or "")[:500]
324324
if prompt and len(prompt) > 500:
325325
init_content = init_content + "..."
@@ -397,7 +397,7 @@ async def _delete_upstream_chat(
397397
token: str,
398398
headers: Dict[str, str],
399399
) -> None:
400-
"""删除已创建的 GLM-4.7 上游 chat。"""
400+
"""删除已创建的上游 chat。"""
401401
if not chat_id or not token:
402402
return
403403

@@ -607,8 +607,9 @@ async def transform_request(self, request: OpenAIRequest) -> Dict[str, Any]:
607607

608608
# 9. 构建上游请求体
609609
current_user_message_id = self._generate_uuid()
610-
self.logger.warning(f"请求模型:{requested_model},上游模型ID:{upstream_model_id},思考模式:{is_thinking},搜索模式:{is_search}")
611-
if upstream_model_id == "glm-4.7":
610+
requires_real_chat = upstream_model_id in {"glm-4.7", "glm-5", "GLM-4-6-API-V1"}
611+
self.logger.debug(f"请求模型:{requested_model},上游模型ID:{upstream_model_id},思考模式:{is_thinking},搜索模式:{is_search}")
612+
if requires_real_chat:
612613
chat_id = await self._create_upstream_chat(
613614
prompt=user_message_content or "",
614615
model=upstream_model_id,
@@ -623,7 +624,7 @@ async def transform_request(self, request: OpenAIRequest) -> Dict[str, Any]:
623624
params["current_url"] = f"{self.base_url}/c/{chat_id}"
624625
params["pathname"] = f"/c/{chat_id}"
625626
current_user_message_parent_id = None
626-
self.logger.warning(f"已创建GLM-4.7聊天会话,ChatID:{chat_id}")
627+
self.logger.info(f"已创建真实聊天会话,模型:{upstream_model_id},ChatID:{chat_id}")
627628
else:
628629
chat_id = self._generate_uuid()
629630
current_user_message_parent_id = self._generate_uuid()
@@ -718,7 +719,7 @@ async def transform_request(self, request: OpenAIRequest) -> Dict[str, Any]:
718719
"token": token,
719720
"chat_id": chat_id,
720721
"model": requested_model,
721-
"should_delete_chat": upstream_model_id == "glm-4.7",
722+
"should_delete_chat": requires_real_chat,
722723
}
723724

724725
@staticmethod

0 commit comments

Comments
 (0)