fix: DBPools() not in __init__, sqlorContext uses module name not default

This commit is contained in:
yumoqing 2026-05-08 11:41:54 +08:00
parent 906c037920
commit ba59b43268
2 changed files with 13 additions and 7 deletions

View File

@ -111,7 +111,7 @@ class HermesReasoningEngine:
}
def __init__(self):
self.db = DBPools()
pass
# --------------------------------------------------------
# Config helpers
@ -126,7 +126,8 @@ class HermesReasoningEngine:
dbname = 'default'
try:
async with self.db.sqlorContext(dbname) as sor:
db = DBPools()
async with db.sqlorContext(dbname) as sor:
where = {}
if user_id:
where['user_id'] = user_id
@ -196,7 +197,8 @@ class HermesReasoningEngine:
skills = []
try:
async with self.db.sqlorContext('default') as sor:
db = DBPools()
async with db.sqlorContext('harnessed_reasoning') as sor:
for kw in list(keywords)[:3]:
rows = await sor.R('hermes_skills', {
'user_id': user_id,
@ -628,7 +630,8 @@ class HermesReasoningEngine:
'created_at': datetime.now(),
'updated_at': datetime.now(),
}
async with self.db.sqlorContext('default') as sor:
db = DBPools()
async with db.sqlorContext('harnessed_reasoning') as sor:
res = await sor.C('harnessed_reasoning_sessions', data)
info(f"Session stored: {session_id}, result={res}")
except Exception as e:
@ -639,7 +642,8 @@ class HermesReasoningEngine:
async def _update_session_status(self, session_id: str, status: str):
"""Update session status."""
try:
async with self.db.sqlorContext('default') as sor:
db = DBPools()
async with db.sqlorContext('harnessed_reasoning') as sor:
await sor.U('harnessed_reasoning_sessions', {
'id': session_id,
'status': status,
@ -661,7 +665,8 @@ class HermesReasoningEngine:
pass
try:
async with self.db.sqlorContext('default') as sor:
db = DBPools()
async with db.sqlorContext('harnessed_reasoning') as sor:
filters = {'id': session_id}
if user_id:
filters['user_id'] = user_id
@ -697,7 +702,8 @@ class HermesReasoningEngine:
pass
try:
async with self.db.sqlorContext('default') as sor:
db = DBPools()
async with db.sqlorContext('harnessed_reasoning') as sor:
rows = await sor.R('harnessed_reasoning_sessions', {'user_id': user_id, 'sort': 'created_at desc'})
rows = rows or []
rows = rows[offset:offset + limit]