- accounting.py: 删除重复datetime导入, 清理未使用env变量 - failed_accounting.ui: Button text→label(规范), DatePicker→TextInput(不确定的widget) - index.ui: backgroundColor→bgcolor(规范), 3处修复 - llmusage_accounting_failed_update.dspy: 删除ServerEnv()违规(.dspy禁用), 用datetime替代 - 新增llmusage_history只读DSPY(create/update/delete返回只读提示)
26 lines
849 B
Python
26 lines
849 B
Python
#!/usr/bin/env python3
|
|
import json
|
|
from datetime import datetime
|
|
|
|
result = {'success': False, 'message': ''}
|
|
|
|
try:
|
|
dbname = get_module_dbname('llmage')
|
|
async with DBPools().sqlorContext(dbname) as sor:
|
|
data = params_kw
|
|
rid = data.pop('id', None)
|
|
if not rid:
|
|
result['message'] = '缺少id参数'
|
|
else:
|
|
data['id'] = rid
|
|
# Mark as handled - set handled_time
|
|
if data.get('handled') == '1' and not data.get('handled_time'):
|
|
data['handled_time'] = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
|
await sor.U('llmusage_accounting_failed', data)
|
|
result['success'] = True
|
|
result['message'] = '更新成功'
|
|
except Exception as e:
|
|
result['message'] = str(e)
|
|
|
|
return json.dumps(result, ensure_ascii=False, default=str)
|