mirror of
https://github.com/AstrBotDevs/AstrBot
synced 2026-07-16 01:40:15 +08:00
* fix: improve knowledge base upload error messages * fix: deduplicate knowledge base upload logs * fix: handle type errors in kb embedding validation
33 lines
819 B
Python
33 lines
819 B
Python
from __future__ import annotations
|
|
|
|
|
|
class AstrBotError(Exception):
|
|
"""Base exception for all AstrBot errors."""
|
|
|
|
|
|
class ProviderNotFoundError(AstrBotError):
|
|
"""Raised when a specified provider is not found."""
|
|
|
|
|
|
class EmptyModelOutputError(AstrBotError):
|
|
"""Raised when the model response contains no usable assistant output."""
|
|
|
|
|
|
class KnowledgeBaseUploadError(AstrBotError):
|
|
"""Raised when knowledge base upload fails with a user-facing message."""
|
|
|
|
def __init__(
|
|
self,
|
|
*,
|
|
stage: str,
|
|
user_message: str,
|
|
details: dict | None = None,
|
|
) -> None:
|
|
super().__init__(user_message)
|
|
self.stage = stage
|
|
self.user_message = user_message
|
|
self.details = details or {}
|
|
|
|
def __str__(self) -> str:
|
|
return self.user_message
|