From d487da78030ca62e479dd4ccf36c969ebd53ec28 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Wed, 8 Apr 2026 10:59:33 +0800 Subject: [PATCH] bugfix --- llmage/accounting.py | 1 - llmage/llmclient.py | 24 ------------------------ llmage/utils.py | 24 ++++++++++++++++++++++++ 3 files changed, 24 insertions(+), 25 deletions(-) diff --git a/llmage/accounting.py b/llmage/accounting.py index bfdeddc..2ede10c 100644 --- a/llmage/accounting.py +++ b/llmage/accounting.py @@ -203,7 +203,6 @@ async def backend_accounting(): except Exception as e: exception(f'{e}') lus = [] - debug(f'get accounting {len(lus)} lus') for lu in lus: try: debug(f'backend_accounting(): {lu.id=} handleing...') diff --git a/llmage/llmclient.py b/llmage/llmclient.py index a608040..908a12f 100644 --- a/llmage/llmclient.py +++ b/llmage/llmclient.py @@ -128,30 +128,6 @@ async def uapi_request(request, llm, sor, callerid, callerorgid, params_kw=None) # await write_llmusage(luid, llm, callerid, None, params_kw, outlines, sor) return -def b64media2url(request, mediafile): - env = request._run_ns - entire_url = env.entire_url - if mediafile.startswith('data:'): - try: - fs = FileStorage() - fname = getFilenameFromBase64(mediafile) - fpath = fs._name2path(fname) - base64_to_file(mediafile, fpath) - path = fs.webpath(fpath) - return entire_url('/idfile?path=') + env.quote(path) - except Exception as e: - e = Exception(f'{e}\n{format_exc()}') - exception(f'{e}') - return '' - elif len(mediafile) > 8000: - e = Exception(f'mediafile is not a media file') - exception(f'{e}') - return '' - if mediafile.startswith('http://') or mediafile.startswith('https://'): - return mediafile - url = entire_url('/idfile?path=') + env.quote(mediafile) - return url - async def inference_generator(request, *args, params_kw=None, **kw): env = request._run_ns.copy() callerorgid = await env.get_userorgid() diff --git a/llmage/utils.py b/llmage/utils.py index c350226..435e14b 100644 --- a/llmage/utils.py +++ b/llmage/utils.py @@ -14,6 +14,30 @@ from uapi.appapi import UAPI, sor_get_callerid, sor_get_uapi from ahserver.serverenv import get_serverenv, ServerEnv from ahserver.filestorage import FileStorage +def b64media2url(request, mediafile): + env = request._run_ns + entire_url = env.entire_url + if mediafile.startswith('data:'): + try: + fs = FileStorage() + fname = getFilenameFromBase64(mediafile) + fpath = fs._name2path(fname) + base64_to_file(mediafile, fpath) + path = fs.webpath(fpath) + return entire_url('/idfile?path=') + env.quote(path) + except Exception as e: + e = Exception(f'{e}\n{format_exc()}') + exception(f'{e}') + return '' + elif len(mediafile) > 8000: + e = Exception(f'mediafile is not a media file') + exception(f'{e}') + return '' + if mediafile.startswith('http://') or mediafile.startswith('https://'): + return mediafile + url = entire_url('/idfile?path=') + env.quote(mediafile) + return url + async def llm_query_orders(userorgid, page, pagerows=80): env = ServerEnv() async with get_sor_context(env, 'llmage') as sor: