变量函数重命名

This commit is contained in:
2026-06-29 23:52:14 +08:00
parent 8714fb07c4
commit 92497d35a5
3 changed files with 41 additions and 41 deletions
+5 -5
View File
@@ -7,7 +7,7 @@ from models import Message, SendMessageResponse, Session, TokenUsage
from storage import JsonSessionStorage
class DeepSeekUpstreamError(Exception):
class ChatProviderError(Exception):
pass
@@ -41,10 +41,10 @@ class ChatService:
)
assistant_content = completion.choices[0].message.content
except (APIError, IndexError, AttributeError) as exc:
raise DeepSeekUpstreamError("DeepSeek request failed") from exc
raise ChatProviderError("Upstream chat request failed") from exc
if assistant_content is None:
raise DeepSeekUpstreamError("DeepSeek returned an empty response")
raise ChatProviderError("Upstream chat provider returned an empty response")
assistant_message = await self._save_exchange(
session, content, user_created_at, assistant_content
@@ -94,11 +94,11 @@ class ChatService:
finally:
await stream.close()
except (APIError, AttributeError, TypeError) as exc:
raise DeepSeekUpstreamError("DeepSeek stream failed") from exc
raise ChatProviderError("Upstream chat stream failed") from exc
assistant_content = "".join(parts)
if not assistant_content:
raise DeepSeekUpstreamError("DeepSeek returned an empty response")
raise ChatProviderError("Upstream chat provider returned an empty response")
assistant_message = await self._save_exchange(
session, content, user_created_at, assistant_content