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():
|
async def backup_accounted_llmusage():
|
||||||
"""Backup yesterday's accounted records to history table and remove from llmusage."""
|
"""Backup yesterday's accounted records to history table and remove from llmusage."""
|
||||||
env = ServerEnv()
|
env = ServerEnv()
|
||||||
from datetime import datetime, timedelta
|
|
||||||
yesterday = (datetime.now() - timedelta(days=1)).strftime('%Y-%m-%d')
|
yesterday = (datetime.now() - timedelta(days=1)).strftime('%Y-%m-%d')
|
||||||
ts = env.timestampstr()
|
ts = env.timestampstr()
|
||||||
batched = 0
|
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
|
- start_date: filter use_date >= start_date
|
||||||
- end_date: filter use_date <= end_date
|
- end_date: filter use_date <= end_date
|
||||||
"""
|
"""
|
||||||
env = ServerEnv()
|
async with get_sor_context(ServerEnv(), 'llmage') as sor:
|
||||||
async with get_sor_context(env, 'llmage') as sor:
|
|
||||||
conditions = []
|
conditions = []
|
||||||
ns = {}
|
ns = {}
|
||||||
if filters:
|
if filters:
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import json
|
import json
|
||||||
from ahserver.serverenv import ServerEnv
|
from datetime import datetime
|
||||||
|
|
||||||
result = {'success': False, 'message': ''}
|
result = {'success': False, 'message': ''}
|
||||||
|
|
||||||
@ -15,8 +15,7 @@ try:
|
|||||||
data['id'] = rid
|
data['id'] = rid
|
||||||
# Mark as handled - set handled_time
|
# Mark as handled - set handled_time
|
||||||
if data.get('handled') == '1' and not data.get('handled_time'):
|
if data.get('handled') == '1' and not data.get('handled_time'):
|
||||||
env = ServerEnv()
|
data['handled_time'] = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
||||||
data['handled_time'] = env.timestampstr()
|
|
||||||
await sor.U('llmusage_accounting_failed', data)
|
await sor.U('llmusage_accounting_failed', data)
|
||||||
result['success'] = True
|
result['success'] = True
|
||||||
result['message'] = '更新成功'
|
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},
|
"options": {"spacing": 4},
|
||||||
"subwidgets": [
|
"subwidgets": [
|
||||||
{"widgettype": "Text", "options": {"text": "开始日期", "fontSize": "12px"}},
|
{"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},
|
"options": {"spacing": 4},
|
||||||
"subwidgets": [
|
"subwidgets": [
|
||||||
{"widgettype": "Text", "options": {"text": "结束日期", "fontSize": "12px"}},
|
{"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",
|
"widgettype": "Button",
|
||||||
"id": "search_btn",
|
"id": "search_btn",
|
||||||
"options": {
|
"options": {
|
||||||
"text": "查询",
|
"label": "查询",
|
||||||
"bgcolor": "#1976d2",
|
"bgcolor": "#1976d2",
|
||||||
"color": "#ffffff",
|
"color": "#ffffff",
|
||||||
"width": "80px"
|
"width": "80px"
|
||||||
|
|||||||
@ -24,7 +24,7 @@
|
|||||||
{
|
{
|
||||||
"widgettype": "VBox",
|
"widgettype": "VBox",
|
||||||
"options": {
|
"options": {
|
||||||
"backgroundColor": "#1e3a5f",
|
"bgcolor": "#1e3a5f",
|
||||||
"padding": "24px",
|
"padding": "24px",
|
||||||
"cursor": "pointer",
|
"cursor": "pointer",
|
||||||
"borderRadius": "8px"
|
"borderRadius": "8px"
|
||||||
@ -71,7 +71,7 @@
|
|||||||
{
|
{
|
||||||
"widgettype": "VBox",
|
"widgettype": "VBox",
|
||||||
"options": {
|
"options": {
|
||||||
"backgroundColor": "#1e3a5f",
|
"bgcolor": "#1e3a5f",
|
||||||
"padding": "24px",
|
"padding": "24px",
|
||||||
"cursor": "pointer",
|
"cursor": "pointer",
|
||||||
"borderRadius": "8px"
|
"borderRadius": "8px"
|
||||||
@ -118,7 +118,7 @@
|
|||||||
{
|
{
|
||||||
"widgettype": "VBox",
|
"widgettype": "VBox",
|
||||||
"options": {
|
"options": {
|
||||||
"backgroundColor": "#1e3a5f",
|
"bgcolor": "#1e3a5f",
|
||||||
"padding": "24px",
|
"padding": "24px",
|
||||||
"cursor": "pointer",
|
"cursor": "pointer",
|
||||||
"borderRadius": "8px"
|
"borderRadius": "8px"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user