From 5c021b81cba6da9c08954d2c5e075cd1e83f45cf Mon Sep 17 00:00:00 2001 From: yumoqing Date: Sun, 31 May 2026 15:59:21 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20llm=5Flist.dspy=E7=94=A8JOIN=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E8=BF=94=E5=9B=9Eupappid=5Ftext=E5=92=8Cproviderid=5F?= =?UTF-8?q?text=E4=BE=9B=E5=89=8D=E7=AB=AFcode=E5=88=97=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wwwroot/api/llm_list.dspy | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/wwwroot/api/llm_list.dspy b/wwwroot/api/llm_list.dspy index a13b467..e4e8441 100644 --- a/wwwroot/api/llm_list.dspy +++ b/wwwroot/api/llm_list.dspy @@ -41,12 +41,27 @@ try: count_rows = await sor.sqlExe(count_sql, filterdic) total = count_rows[0]['cnt'] if count_rows else 0 - # Paginated data + # Paginated data - JOIN with organization and upapp to get display names + # Prefix field references in WHERE clause with table alias 'l.' + join_where = '' + if where_clause: + import re + conds_text = where_clause.replace(' WHERE ', '', 1) + # Add l. prefix to field names (name, model, providerid, upappid, status) + conds_text = re.sub(r'\b(name|model|description|providerid|upappid|status|ownerid)\b', r'l.\1', conds_text) + join_where = f' WHERE {conds_text}' + data_sql = f""" - select id, name, model, description, iconid, upappid, providerid, - ownerid, enabled_date, expired_date, min_balance, status - from llm{where_clause} - order by model + select l.id, l.name, l.model, l.description, l.iconid, + l.upappid, l.providerid, l.ownerid, l.enabled_date, + l.expired_date, l.min_balance, l.status, + u.name as upappid_text, + o.orgname as providerid_text + from llm l + left join uapi.upapp u on l.upappid = u.id + left join rbac.organization o on l.providerid = o.id + {join_where} + order by l.model limit ${limit}$ offset ${offset}$ """ rows = await sor.sqlExe(data_sql, {**filterdic, 'limit': rows_per_page, 'offset': offset})