Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions astrbot/core/db/vec_db/faiss_impl/document_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,29 @@ def __init__(self, db_path: str):
"sqlite_init.sql",
)

@property
def connection(self):
"""Compatibility property for old code trying to access .connection attribute.

This was removed in AstrBot 4.5.0 when the database was migrated to async operations.
External plugins or cached bytecode may still reference this attribute.
"""
raise AttributeError(
"DocumentStorage.connection attribute was removed in AstrBot 4.5.0. "
"The database now uses async operations with self.engine and async context managers. "
"\n\nIf you're seeing this error, please: "
"\n1. Clear Python cache files:"
"\n - On Unix/macOS: find data/plugins -name '*.pyc' -delete && find data/plugins -type d -name '__pycache__' -prune -exec rm -rf {} \\; 2>/dev/null || true"
"\n - On Windows: Delete all .pyc files and __pycache__ folders in data\\plugins manually, or run:"
"\n del /s data\\plugins\\*.pyc"
"\n rmdir /s /q data\\plugins\\__pycache__"
"\n2. Update any custom plugins that use DocumentStorage:"
"\n - Replace 'self.connection' with 'self.engine'"
"\n - Use 'async with self.get_session() as session' for database operations"
"\n - See DocumentStorage source code for examples"
"\n3. Restart AstrBot"
)

async def initialize(self):
"""Initialize the SQLite database and create the documents table if it doesn't exist."""
await self.connect()
Expand Down
1 change: 1 addition & 0 deletions changelogs/v4.5.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
3. 新增: xAI Grok Live Search
4. 优化: 插件卡片左下角恢复 文档 按钮并新增 插件配置 按钮。
5. 优化: 更好地适配 Class 方式注册 LLM Tool。
6. 修复: 知识库日志中出现的 `'DocumentStorage' object has no attribute 'connection'` 错误 ([#3191](https://github.com/AstrBotDevs/AstrBot/issues/3191))