44 lines
1.5 KiB
Python
44 lines
1.5 KiB
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
"""Get agent configuration for current user"""
|
|
import json
|
|
|
|
result = {'success': False, 'config': {}}
|
|
|
|
try:
|
|
dbname = get_module_dbname('harnessed_agent')
|
|
user_id = await get_user()
|
|
|
|
sql = """SELECT * FROM harnessed_agent_config
|
|
WHERE user_id = ${user_id}$
|
|
ORDER BY updated_at DESC
|
|
LIMIT 1"""
|
|
|
|
async with DBPools().sqlorContext(dbname) as sor:
|
|
rows = await sor.sqlExe(sql, {'user_id': user_id})
|
|
if rows and len(rows) > 0:
|
|
config = dict(rows[0])
|
|
config['auto_cleanup_enabled'] = config.get('auto_cleanup_enabled', '1') == '1'
|
|
config['enable_streaming'] = config.get('enable_streaming', '1') == '1'
|
|
result['config'] = config
|
|
else:
|
|
result['config'] = {
|
|
'work_dir': './hermes_work',
|
|
'skills_path': '~/.hermes/skills',
|
|
'max_memory_tokens': 2000,
|
|
'default_priority': 50,
|
|
'high_priority_threshold': 70,
|
|
'low_priority_threshold': 30,
|
|
'auto_cleanup_enabled': True,
|
|
'min_retention_days': 30,
|
|
'default_model': 'qwen3-max',
|
|
'default_temperature': 0.7,
|
|
'enable_streaming': True
|
|
}
|
|
result['success'] = True
|
|
|
|
except Exception as e:
|
|
result['error'] = str(e)
|
|
|
|
return json.dumps(result, ensure_ascii=False, default=str)
|