Updated .env.example to improve clarity and added new configuration options for memory and reliability settings. Refactored main.py to streamline the bot's entry point and improved error handling. Enhanced README to reflect new features and command structure. Removed deprecated cmd_zip_skill and skills_creator modules to clean up the codebase. Updated AIClient and MemorySystem for better performance and flexibility in handling user interactions.
61 lines
1.4 KiB
Python
61 lines
1.4 KiB
Python
"""
|
|
Project entrypoint.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
project_root = Path(__file__).parent
|
|
sys.path.insert(0, str(project_root))
|
|
|
|
|
|
def _sqlite_supports_trigram(sqlite_module) -> bool:
|
|
conn = None
|
|
try:
|
|
conn = sqlite_module.connect(":memory:")
|
|
conn.execute("create virtual table t using fts5(content, tokenize='trigram')")
|
|
return True
|
|
except Exception:
|
|
return False
|
|
finally:
|
|
if conn is not None:
|
|
conn.close()
|
|
|
|
|
|
def _ensure_sqlite_for_chroma():
|
|
try:
|
|
import sqlite3
|
|
except Exception:
|
|
return
|
|
|
|
if _sqlite_supports_trigram(sqlite3):
|
|
return
|
|
|
|
try:
|
|
import pysqlite3
|
|
except Exception as exc:
|
|
print(
|
|
"[WARN] sqlite3 does not support trigram tokenizer and pysqlite3 is unavailable: "
|
|
f"{exc}"
|
|
)
|
|
print("[WARN] Chroma may fail and fallback to JSON storage.")
|
|
return
|
|
|
|
if _sqlite_supports_trigram(pysqlite3):
|
|
sys.modules["sqlite3"] = pysqlite3
|
|
print("[INFO] sqlite3 switched to pysqlite3 for Chroma trigram support.")
|
|
else:
|
|
print("[WARN] pysqlite3 is installed but still lacks trigram tokenizer support.")
|
|
print("[WARN] Chroma may fail and fallback to JSON storage.")
|
|
|
|
|
|
_ensure_sqlite_for_chroma()
|
|
|
|
from src.core.bot import main as run_bot_main
|
|
|
|
|
|
if __name__ == "__main__":
|
|
run_bot_main()
|