- 新增 llmusage_history 表:定时备份已记账(use_date<today)的历史记录 - 新增 llmusage_accounting_failed 表:记录记账失败详情,支持检索 - 新增 backup_accounted_llmusage() 函数:备份+清理历史数据 - 新增 get_failed_accounting_records() 函数:按条件检索失败记录 - 更新 llm_accoung_failed():同时写入失败表记录 - 新增 failed_accounting.ui 页面和 failed_accounting_list.dspy API - 新增 llmusage CRUD API (create/update/delete) - 新增表索引优化查询性能 - 更新 setup_llmage_perms.sh 添加新端点权限 - 生成生产迁移SQL: scripts/migrate_llmusage_history.sql
69 lines
1.9 KiB
Python
69 lines
1.9 KiB
Python
import asyncio
|
|
from appPublic.registerfunction import RegisterFunction
|
|
from sqlor.dbpools import DBPools
|
|
from ahserver.serverenv import ServerEnv
|
|
from appPublic.log import debug
|
|
from .keling import keling_token
|
|
from .jimeng import jimeng_auth_headers
|
|
from .utils import (
|
|
llm_query_orders,
|
|
read_webpath,
|
|
llm_query_price,
|
|
get_llm_by_model,
|
|
get_llms_by_catelog,
|
|
get_llms_sort_by_provider,
|
|
get_llmcatelogs,
|
|
get_llms_by_catelog_to_customer,
|
|
get_llmproviders,
|
|
get_llm,
|
|
)
|
|
|
|
from .llmclient import (
|
|
inference_generator,
|
|
inference
|
|
)
|
|
from .accounting import (
|
|
checkCustomerBalance,
|
|
llm_charging,
|
|
get_accounting_llmusages,
|
|
backend_accounting,
|
|
llm_accounting,
|
|
backup_accounted_llmusage,
|
|
get_failed_accounting_records,
|
|
llm_accoung_failed
|
|
)
|
|
|
|
from .asyncinference import (
|
|
get_asynctask_status,
|
|
query_task_status,
|
|
get_today_asynctask_list
|
|
)
|
|
|
|
def load_llmage():
|
|
env = ServerEnv()
|
|
env.llm_query_orders = llm_query_orders
|
|
env.read_webpath = read_webpath
|
|
env.get_llm_by_model = get_llm_by_model
|
|
env.llm_charging = llm_charging
|
|
env.get_accounting_llmusages = get_accounting_llmusages
|
|
env.llm_accounting = llm_accounting
|
|
env.get_today_asynctask_list = get_today_asynctask_list
|
|
env.get_asynctask_status = get_asynctask_status
|
|
env.query_task_status = query_task_status
|
|
env.get_llm = get_llm
|
|
env.inference = inference
|
|
env.inference_generator = inference_generator
|
|
env.get_llms_by_catelog = get_llms_by_catelog
|
|
env.get_llmcatelogs = get_llmcatelogs
|
|
env.checkCustomerBalance = checkCustomerBalance
|
|
env.get_llmproviders = get_llmproviders
|
|
env.get_llms_sort_by_provider = get_llms_sort_by_provider
|
|
env.keling_token = keling_token
|
|
env.llm_query_price = llm_query_price
|
|
env.get_llms_by_catelog_to_customer = get_llms_by_catelog_to_customer
|
|
env.backup_accounted_llmusage = backup_accounted_llmusage
|
|
env.get_failed_accounting_records = get_failed_accounting_records
|
|
rf = RegisterFunction()
|
|
rf.register('jimeng_auth_headers', jimeng_auth_headers)
|
|
|