fix: replace invalid sor.R(orderby/limit) calls with sqlExe

- Config lookup uses raw SQL for ordering
- Skill search uses raw SQL for  and limit
- Session listing uses raw SQL for order/limit/offset
This commit is contained in:
yumoqing 2026-05-07 15:32:59 +08:00
parent c36477c9cb
commit bb420a6471
2 changed files with 13 additions and 12 deletions

View File

@ -127,8 +127,8 @@ class HermesReasoningEngine:
try: try:
async with self.db.sqlorContext(dbname) as sor: async with self.db.sqlorContext(dbname) as sor:
rows = await sor.R('harnessed_reasoning_config', {}, sql = "SELECT * FROM harnessed_reasoning_config ORDER BY updated_at DESC LIMIT 1"
orderby='updated_at DESC', limit=1) rows = await sor.sqlExe(sql, {})
if rows: if rows:
return rows[0] return rows[0]
except Exception as e: except Exception as e:
@ -196,13 +196,15 @@ class HermesReasoningEngine:
try: try:
async with self.db.sqlorContext('default') as sor: async with self.db.sqlorContext('default') as sor:
for kw in list(keywords)[:3]: for kw in list(keywords)[:3]:
rows = await sor.R('hermes_skills', { sql = """SELECT * FROM hermes_skills
'user_id': user_id, WHERE user_id = :user_id
'$or': [ AND (name LIKE :kw1 OR description LIKE :kw2)
{'name': {'$like': f'%{kw}%'}}, LIMIT 2"""
{'description': {'$like': f'%{kw}%'}}, rows = await sor.sqlExe(sql, {
] 'user_id': user_id,
}, limit=2) 'kw1': f'%{kw}%',
'kw2': f'%{kw}%'
})
skills.extend(rows) skills.extend(rows)
# Deduplicate # Deduplicate
@ -687,9 +689,8 @@ class HermesReasoningEngine:
try: try:
async with self.db.sqlorContext('default') as sor: async with self.db.sqlorContext('default') as sor:
rows = await sor.R('harnessed_reasoning_sessions', sql = f"SELECT * FROM harnessed_reasoning_sessions WHERE user_id = :user_id ORDER BY created_at DESC LIMIT {limit} OFFSET {offset}"
{'user_id': user_id}, rows = await sor.sqlExe(sql, {'user_id': user_id})
orderby='created_at DESC', limit=limit, offset=offset)
sessions = [] sessions = []
for s in rows: for s in rows: