fix: DBPools() not in __init__, sqlorContext uses module name not default
This commit is contained in:
parent
f9705f3892
commit
fe6666b665
@ -57,7 +57,6 @@ class HermesAgent:
|
||||
def __init__(self, config: Optional[HermesConfig] = None):
|
||||
self.config = config or HermesConfig()
|
||||
self._ensure_paths()
|
||||
self.db = DBPools()
|
||||
self.orchestrator = None # Will be initialized when needed
|
||||
|
||||
def _ensure_paths(self):
|
||||
@ -357,7 +356,8 @@ class HermesAgent:
|
||||
selected_memories = []
|
||||
|
||||
try:
|
||||
async with self.db.sqlorContext('default') as sor:
|
||||
db = DBPools()
|
||||
async with db.sqlorContext('harnessed_agent') as sor:
|
||||
# High priority memories
|
||||
ns = {'user_id': user_id, 'priority__gte': self.config.high_priority_threshold, 'sort': 'priority desc,last_accessed desc'}
|
||||
hp_rows = await sor.R('hermes_memory', ns)
|
||||
@ -409,7 +409,8 @@ class HermesAgent:
|
||||
async def _update_memory_access_stats(self, user_id: str, memory_id: str):
|
||||
"""Update memory access statistics"""
|
||||
try:
|
||||
async with self.db.sqlorContext('default') as sor:
|
||||
db = DBPools()
|
||||
async with db.sqlorContext('harnessed_agent') as sor:
|
||||
memories = await sor.R('hermes_memory', {'id': memory_id, 'user_id': user_id})
|
||||
if memories:
|
||||
current_count = memories[0].get('access_count', 0)
|
||||
@ -430,7 +431,8 @@ class HermesAgent:
|
||||
return
|
||||
|
||||
try:
|
||||
async with self.db.sqlorContext('default') as sor:
|
||||
db = DBPools()
|
||||
async with db.sqlorContext('harnessed_agent') as sor:
|
||||
# Calculate cutoff date
|
||||
cutoff_date = datetime.now().replace(
|
||||
day=datetime.now().day - self.config.min_retention_days
|
||||
@ -534,7 +536,8 @@ class HermesAgent:
|
||||
user_id = self._get_current_user_id(context) if context else "anonymous"
|
||||
|
||||
try:
|
||||
async with self.db.sqlorContext('default') as sor:
|
||||
db = DBPools()
|
||||
async with db.sqlorContext('harnessed_agent') as sor:
|
||||
if action == "add":
|
||||
memory_id = str(uuid.uuid4())
|
||||
# Auto-classify priority if not provided
|
||||
@ -647,7 +650,8 @@ class HermesAgent:
|
||||
user_id = self._get_current_user_id(context) if context else "anonymous"
|
||||
|
||||
try:
|
||||
async with self.db.sqlorContext('default') as sor:
|
||||
db = DBPools()
|
||||
async with db.sqlorContext('harnessed_agent') as sor:
|
||||
filters = {'user_id': user_id}
|
||||
if query:
|
||||
filters['$or'] = [
|
||||
@ -689,7 +693,8 @@ class HermesAgent:
|
||||
return {"success": False, "error": "Invalid skill name", "user_id": user_id}
|
||||
|
||||
try:
|
||||
async with self.db.sqlorContext('default') as sor:
|
||||
db = DBPools()
|
||||
async with db.sqlorContext('harnessed_agent') as sor:
|
||||
if action == "view":
|
||||
filters = {'user_id': user_id, 'name': name}
|
||||
skills = await sor.R('harnessed_skills', {'user_id': user_id, 'name': name})
|
||||
@ -773,7 +778,8 @@ class HermesAgent:
|
||||
user_id = self._get_current_user_id(context) if context else "anonymous"
|
||||
|
||||
try:
|
||||
async with self.db.sqlorContext('default') as sor:
|
||||
db = DBPools()
|
||||
async with db.sqlorContext('harnessed_agent') as sor:
|
||||
if action == "create":
|
||||
# Create new remote skill configuration
|
||||
new_skill_id = str(uuid.uuid4())
|
||||
@ -1178,7 +1184,8 @@ class HermesAgent:
|
||||
"""List workflows for current user"""
|
||||
user_id = self._get_current_user_id(context) if context else "anonymous"
|
||||
try:
|
||||
async with self.db.sqlorContext('default') as sor:
|
||||
db = DBPools()
|
||||
async with db.sqlorContext('harnessed_agent') as sor:
|
||||
workflows = await sor.R('hermes_workflows', {'sort': 'created_at desc', 'user_id': user_id})
|
||||
return {"success": True, "workflows": workflows or [], "user_id": user_id}
|
||||
except Exception as e:
|
||||
@ -1190,7 +1197,8 @@ class HermesAgent:
|
||||
"""List executions for current user (optionally filtered by workflow)"""
|
||||
user_id = self._get_current_user_id(context) if context else "anonymous"
|
||||
try:
|
||||
async with self.db.sqlorContext('default') as sor:
|
||||
db = DBPools()
|
||||
async with db.sqlorContext('harnessed_agent') as sor:
|
||||
filters = {'user_id': user_id}
|
||||
if workflow_id:
|
||||
filters['workflow_id'] = workflow_id
|
||||
|
||||
@ -233,6 +233,11 @@ async def _post_chat_completions(
|
||||
content_type = resp.content_type
|
||||
if 'json' not in content_type:
|
||||
err_text = await resp.text()
|
||||
error(f"[llm_response] Non-JSON response from {url}")
|
||||
error(f"[llm_response] Status: {resp.status}")
|
||||
error(f"[llm_response] Content-Type: {content_type}")
|
||||
error(f"[llm_response] Headers: {dict(resp.headers)}")
|
||||
error(f"[llm_response] Body (first 2000 chars): {err_text[:2000]}")
|
||||
return {
|
||||
'error': {
|
||||
'message': f'LLM API returned non-JSON response (Content-Type: {content_type}). URL may be incorrect or blocked.',
|
||||
|
||||
@ -62,7 +62,6 @@ class HermesOrchestrator:
|
||||
|
||||
def __init__(self, harnessed_agent_instance):
|
||||
self.harnessed_agent = harnessed_agent_instance
|
||||
self.db = DBPools()
|
||||
|
||||
def _get_current_user_id(self, context: Dict[str, Any]) -> str:
|
||||
"""Get current user ID from request context"""
|
||||
@ -82,7 +81,8 @@ class HermesOrchestrator:
|
||||
|
||||
try:
|
||||
workflow_id = str(uuid.uuid4())
|
||||
async with self.db.sqlorContext('default') as sor:
|
||||
db = DBPools()
|
||||
async with db.sqlorContext('harnessed_agent') as sor:
|
||||
data = {
|
||||
'id': workflow_id,
|
||||
'user_id': user_id,
|
||||
@ -114,7 +114,8 @@ class HermesOrchestrator:
|
||||
|
||||
try:
|
||||
# Verify workflow exists and belongs to user
|
||||
async with self.db.sqlorContext('default') as sor:
|
||||
db = DBPools()
|
||||
async with db.sqlorContext('harnessed_agent') as sor:
|
||||
workflows = await sor.R('hermes_workflows', {
|
||||
'id': workflow_id,
|
||||
'user_id': user_id
|
||||
@ -177,7 +178,8 @@ class HermesOrchestrator:
|
||||
async def _load_workflow_definition(self, workflow_id: str, user_id: str) -> Dict[str, Any]:
|
||||
"""Load complete workflow definition with all tasks"""
|
||||
try:
|
||||
async with self.db.sqlorContext('default') as sor:
|
||||
db = DBPools()
|
||||
async with db.sqlorContext('harnessed_agent') as sor:
|
||||
# Load workflow
|
||||
workflows = await sor.R('hermes_workflows', {
|
||||
'id': workflow_id,
|
||||
@ -471,7 +473,8 @@ class HermesOrchestrator:
|
||||
task: TaskDefinition, context: Dict[str, Any]):
|
||||
"""Record execution start in database"""
|
||||
try:
|
||||
async with self.db.sqlorContext('default') as sor:
|
||||
db = DBPools()
|
||||
async with db.sqlorContext('harnessed_agent') as sor:
|
||||
data = {
|
||||
'id': execution_id,
|
||||
'user_id': user_id,
|
||||
@ -491,7 +494,8 @@ class HermesOrchestrator:
|
||||
result: Dict[str, Any], error: str, retry_count: int):
|
||||
"""Record execution end in database"""
|
||||
try:
|
||||
async with self.db.sqlorContext('default') as sor:
|
||||
db = DBPools()
|
||||
async with db.sqlorContext('harnessed_agent') as sor:
|
||||
end_time = datetime.now()
|
||||
data = {
|
||||
'id': execution_id,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user