变量函数重命名
This commit is contained in:
+5
-5
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user