fix(llmage): 规范检查修复
- 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返回只读提示)
This commit is contained in:
parent
07b4893252
commit
1e335d35cb
@ -242,7 +242,6 @@ async def llm_accoung_failed(luid, reason=None):
|
||||
async def backup_accounted_llmusage():
|
||||
"""Backup yesterday's accounted records to history table and remove from llmusage."""
|
||||
env = ServerEnv()
|
||||
from datetime import datetime, timedelta
|
||||
yesterday = (datetime.now() - timedelta(days=1)).strftime('%Y-%m-%d')
|
||||
ts = env.timestampstr()
|
||||
batched = 0
|
||||
@ -295,8 +294,7 @@ async def get_failed_accounting_records(filters=None, page=1, page_size=50):
|
||||
- start_date: filter use_date >= start_date
|
||||
- end_date: filter use_date <= end_date
|
||||
"""
|
||||
env = ServerEnv()
|
||||
async with get_sor_context(env, 'llmage') as sor:
|
||||
async with get_sor_context(ServerEnv(), 'llmage') as sor:
|
||||
conditions = []
|
||||
ns = {}
|
||||
if filters:
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env python3
|
||||
import json
|
||||
from ahserver.serverenv import ServerEnv
|
||||
from datetime import datetime
|
||||
|
||||
result = {'success': False, 'message': ''}
|
||||
|
||||
@ -15,8 +15,7 @@ try:
|
||||
data['id'] = rid
|
||||
# Mark as handled - set handled_time
|
||||
if data.get('handled') == '1' and not data.get('handled_time'):
|
||||
env = ServerEnv()
|
||||
data['handled_time'] = env.timestampstr()
|
||||
data['handled_time'] = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
||||
await sor.U('llmusage_accounting_failed', data)
|
||||
result['success'] = True
|
||||
result['message'] = '更新成功'
|
||||
|
||||
4
wwwroot/api/llmusage_history_create.dspy
Normal file
4
wwwroot/api/llmusage_history_create.dspy
Normal file
@ -0,0 +1,4 @@
|
||||
#!/usr/bin/env python3
|
||||
import json
|
||||
result = {'success': False, 'message': '历史数据为只读,不可新增'}
|
||||
return json.dumps(result, ensure_ascii=False, default=str)
|
||||
4
wwwroot/api/llmusage_history_delete.dspy
Normal file
4
wwwroot/api/llmusage_history_delete.dspy
Normal file
@ -0,0 +1,4 @@
|
||||
#!/usr/bin/env python3
|
||||
import json
|
||||
result = {'success': False, 'message': '历史数据为只读,不可删除'}
|
||||
return json.dumps(result, ensure_ascii=False, default=str)
|
||||
4
wwwroot/api/llmusage_history_update.dspy
Normal file
4
wwwroot/api/llmusage_history_update.dspy
Normal file
@ -0,0 +1,4 @@
|
||||
#!/usr/bin/env python3
|
||||
import json
|
||||
result = {'success': False, 'message': '历史数据为只读,不可修改'}
|
||||
return json.dumps(result, ensure_ascii=False, default=str)
|
||||
@ -27,7 +27,7 @@
|
||||
"options": {"spacing": 4},
|
||||
"subwidgets": [
|
||||
{"widgettype": "Text", "options": {"text": "开始日期", "fontSize": "12px"}},
|
||||
{"widgettype": "DatePicker", "id": "start_date", "options": {"width": "150px"}}
|
||||
{"widgettype": "TextInput", "id": "start_date", "options": {"width": "150px", "placeholder": "YYYY-MM-DD"}}
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -35,7 +35,7 @@
|
||||
"options": {"spacing": 4},
|
||||
"subwidgets": [
|
||||
{"widgettype": "Text", "options": {"text": "结束日期", "fontSize": "12px"}},
|
||||
{"widgettype": "DatePicker", "id": "end_date", "options": {"width": "150px"}}
|
||||
{"widgettype": "TextInput", "id": "end_date", "options": {"width": "150px", "placeholder": "YYYY-MM-DD"}}
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -66,7 +66,7 @@
|
||||
"widgettype": "Button",
|
||||
"id": "search_btn",
|
||||
"options": {
|
||||
"text": "查询",
|
||||
"label": "查询",
|
||||
"bgcolor": "#1976d2",
|
||||
"color": "#ffffff",
|
||||
"width": "80px"
|
||||
|
||||
@ -24,7 +24,7 @@
|
||||
{
|
||||
"widgettype": "VBox",
|
||||
"options": {
|
||||
"backgroundColor": "#1e3a5f",
|
||||
"bgcolor": "#1e3a5f",
|
||||
"padding": "24px",
|
||||
"cursor": "pointer",
|
||||
"borderRadius": "8px"
|
||||
@ -71,7 +71,7 @@
|
||||
{
|
||||
"widgettype": "VBox",
|
||||
"options": {
|
||||
"backgroundColor": "#1e3a5f",
|
||||
"bgcolor": "#1e3a5f",
|
||||
"padding": "24px",
|
||||
"cursor": "pointer",
|
||||
"borderRadius": "8px"
|
||||
@ -118,7 +118,7 @@
|
||||
{
|
||||
"widgettype": "VBox",
|
||||
"options": {
|
||||
"backgroundColor": "#1e3a5f",
|
||||
"bgcolor": "#1e3a5f",
|
||||
"padding": "24px",
|
||||
"cursor": "pointer",
|
||||
"borderRadius": "8px"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user