199 lines
4.8 KiB
Plaintext
199 lines
4.8 KiB
Plaintext
|
|
ns = params_kw.copy()
|
|
|
|
print(f'get_feelog.dspy:{ns=}')
|
|
if not ns.get('page'):
|
|
ns['page'] = 1
|
|
if not ns.get('sort'):
|
|
|
|
ns['sort'] = 'transtime desc'
|
|
|
|
filterjson = params_kw.get('data_filter')
|
|
if not filterjson:
|
|
fields = [ f['name'] for f in [
|
|
{
|
|
"name": "id",
|
|
"title": "id",
|
|
"type": "str",
|
|
"length": 32,
|
|
"nullable": "n"
|
|
},
|
|
{
|
|
"name": "transdate",
|
|
"title": "\u4ea4\u6613\u65e5\u671f",
|
|
"type": "date",
|
|
"nullable": "n"
|
|
},
|
|
{
|
|
"name": "transtime",
|
|
"title": "\u4ea4\u6613\u65f6\u95f4",
|
|
"type": "timestamp",
|
|
"nullable": "n"
|
|
},
|
|
{
|
|
"name": "modelinstanceid",
|
|
"title": "\u6a21\u578b\u5b9e\u4f8bid",
|
|
"type": "str",
|
|
"length": 32,
|
|
"nullable": "n"
|
|
},
|
|
{
|
|
"name": "modeltypeid",
|
|
"title": "\u6a21\u578b\u7c7b\u578bid",
|
|
"type": "str",
|
|
"length": 32,
|
|
"nullable": "n"
|
|
},
|
|
{
|
|
"name": "customerid",
|
|
"title": "\u5ba2\u6237id",
|
|
"type": "str",
|
|
"length": 33,
|
|
"nullable": "n"
|
|
},
|
|
{
|
|
"name": "userid",
|
|
"title": "\u7528\u6237id",
|
|
"type": "str",
|
|
"length": 32,
|
|
"nullable": "n"
|
|
},
|
|
{
|
|
"name": "pricing_mode",
|
|
"title": "\u8ba1\u8d39\u6a21\u5f0f",
|
|
"type": "str",
|
|
"length": 30
|
|
},
|
|
{
|
|
"name": "dialog_file",
|
|
"title": "\u4f1a\u8bdd\u6587\u4ef6\u540d",
|
|
"type": "str",
|
|
"length": 400
|
|
},
|
|
{
|
|
"name": "input_tokens",
|
|
"title": "\u8f93\u5165token\u6d88\u8d39\u6570",
|
|
"type": "float",
|
|
"length": 18,
|
|
"dec": 4
|
|
},
|
|
{
|
|
"name": "output_tokens",
|
|
"title": "\u8f93\u51fatoken\u6d88\u8d39\u6570",
|
|
"type": "float",
|
|
"length": 18,
|
|
"dec": 4
|
|
},
|
|
{
|
|
"name": "other_tokens",
|
|
"title": "\u5176\u4ed6tokens\u6d88\u8d39\u6570",
|
|
"type": "float",
|
|
"length": 18,
|
|
"dec": 4
|
|
},
|
|
{
|
|
"name": "token_cnt",
|
|
"title": "\u8ba1\u8d39token\u6570\u91cf",
|
|
"type": "long",
|
|
"length": 18,
|
|
"dec": 4
|
|
},
|
|
{
|
|
"name": "input_price",
|
|
"title": "\u8f93\u5165token\u4ef7\u683c",
|
|
"type": "float",
|
|
"length": 18,
|
|
"dec": 4
|
|
},
|
|
{
|
|
"name": "output_price",
|
|
"title": "\u8f93\u51fatoken\u4ef7\u683c",
|
|
"type": "float",
|
|
"length": 18,
|
|
"dec": 4
|
|
},
|
|
{
|
|
"name": "other_price",
|
|
"title": "\u5176\u4ed6token\u4ef7\u683c",
|
|
"type": "float",
|
|
"length": 18,
|
|
"dec": 4
|
|
},
|
|
{
|
|
"name": "timing_price",
|
|
"title": "\u8ba1\u6b21\u4ef7\u683c",
|
|
"type": "float",
|
|
"length": 18,
|
|
"dec": 4
|
|
},
|
|
{
|
|
"name": "timing_amout",
|
|
"title": "\u8ba1\u6b21\u91d1\u989d",
|
|
"type": "float",
|
|
"length": 18,
|
|
"dec": 4
|
|
},
|
|
{
|
|
"name": "input_amount",
|
|
"title": "\u8f93\u5165token\u91d1\u989d",
|
|
"type": "float",
|
|
"length": 18,
|
|
"dec": 4
|
|
},
|
|
{
|
|
"name": "output_amount",
|
|
"title": "\u8f93\u51fatoken\u91d1\u989d",
|
|
"type": "float",
|
|
"length": 18,
|
|
"dec": 4
|
|
},
|
|
{
|
|
"name": "accounting_status",
|
|
"title": "\u8bb0\u8d26\u72b6\u6001",
|
|
"type": "str",
|
|
"length": 30
|
|
},
|
|
{
|
|
"name": "resp_time",
|
|
"title": "\u54cd\u5e94\u65f6\u95f4",
|
|
"type": "float",
|
|
"length": 18,
|
|
"dec": 3
|
|
},
|
|
{
|
|
"name": "finish_time",
|
|
"title": "\u5b8c\u6210\u65f6\u95f4",
|
|
"type": "float",
|
|
"length": 18,
|
|
"dec": 3
|
|
},
|
|
{
|
|
"name": "estimate",
|
|
"title": "\u8bc4\u4ef7",
|
|
"type": "short"
|
|
}
|
|
] ]
|
|
filterjson = default_filterjson(fields, ns)
|
|
sql = '''select a.*, b.modelinstanceid_text, c.modeltypeid_text, d.userid_text, e.customerid_text
|
|
from (select * from feelog where 1=1{}) a left join (select id as modelinstanceid,
|
|
name as modelinstanceid_text from modelinstance where 1 = 1) b on a.modelinstanceid = b.modelinstanceid left join (select id as modeltypeid,
|
|
name as modeltypeid_text from modeltype where 1 = 1) c on a.modeltypeid = c.modeltypeid left join (select id as userid,
|
|
username as userid_text from users where 1 = 1) d on a.userid = d.userid left join (select id as customerid,
|
|
orgname as customerid_text from organization where 1 = 1) e on a.customerid = e.customerid'''
|
|
if filterjson:
|
|
dbf = DBFilter(filterjson)
|
|
conds = dbf.gen(ns)
|
|
if conds:
|
|
ns.update(dbf.consts)
|
|
sql = sql.format(' and ' + conds)
|
|
else:
|
|
sql = sql.format('')
|
|
print(f'{sql=}')
|
|
db = DBPools()
|
|
async with db.sqlorContext('sage') as sor:
|
|
r = await sor.sqlPaging(sql, ns)
|
|
return r
|
|
return {
|
|
"total":0,
|
|
"rows":[]
|
|
} |