From 6890af76385221e44d79987461e79c40aa5a44b3 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Tue, 30 Jun 2026 17:38:37 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=B8=85=E7=90=86=E6=89=80=E6=9C=89=20d?= =?UTF-8?q?spy=20=E6=96=87=E4=BB=B6=E7=9A=84=20import=20=E8=AF=AD=E5=8F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 删除已在 ahserver/ServerEnv 预加载的模块: json, datetime, getID, debug, curDateString, timestampstr, get_sor_context, time, DictObject, partial, FileStorage, os 删除模块内部 import: from llmage.utils import get_llmusage_by_id, read_ioinfo_content 同步将 get_llmusage_by_id, read_ioinfo_content 加入 load_llmage() 导出, dspy 中通过 ServerEnv 全局调用。 --- llmage/init.py | 4 ++++ wwwroot/api/get_apis.dspy | 1 - wwwroot/api/get_catelogs.dspy | 1 - wwwroot/api/get_ppids.dspy | 1 - wwwroot/api/llm_api_map_create.dspy | 1 - wwwroot/api/llm_api_map_delete.dspy | 1 - wwwroot/api/llm_api_map_list.dspy | 1 - wwwroot/api/llm_api_map_options.dspy | 1 - wwwroot/api/llm_catelog_options.dspy | 1 - wwwroot/api/llm_create.dspy | 2 -- wwwroot/api/llm_delete.dspy | 1 - wwwroot/api/llm_update.dspy | 1 - wwwroot/api/llmcatelog_create.dspy | 1 - wwwroot/api/llmcatelog_delete.dspy | 1 - wwwroot/api/llmcatelog_list.dspy | 1 - wwwroot/api/llmcatelog_update.dspy | 1 - wwwroot/api/llmusage_accounting_failed_create.dspy | 2 -- wwwroot/api/llmusage_accounting_failed_delete.dspy | 1 - wwwroot/api/llmusage_accounting_failed_update.dspy | 2 -- wwwroot/api/llmusage_create.dspy | 2 -- wwwroot/api/llmusage_delete.dspy | 1 - wwwroot/api/llmusage_history_create.dspy | 1 - wwwroot/api/llmusage_history_delete.dspy | 1 - wwwroot/api/llmusage_history_update.dspy | 1 - wwwroot/api/llmusage_update.dspy | 1 - wwwroot/api/uapi_options.dspy | 1 - wwwroot/llmusage_accounting_failed/recover_usages.dspy | 2 -- wwwroot/llmusage_ioinfo_display.dspy | 2 -- wwwroot/llmusage_usages_display.dspy | 2 -- wwwroot/v1/image/generations/index.dspy | 8 -------- wwwroot/v1/video/generations/index.dspy | 8 -------- 31 files changed, 4 insertions(+), 51 deletions(-) diff --git a/llmage/init.py b/llmage/init.py index e60f05f..4a50aff 100644 --- a/llmage/init.py +++ b/llmage/init.py @@ -21,6 +21,8 @@ from .utils import ( get_llmage_llm, get_llm_catelogs, invalidate_uapi_cache, + get_llmusage_by_id, + read_ioinfo_content, ) from .llmclient import ( @@ -153,6 +155,8 @@ def load_llmage(): 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.read_ioinfo_content = read_ioinfo_content + env.get_llmusage_by_id = get_llmusage_by_id env.get_failed_accounting_records = get_failed_accounting_records env.get_llmage_stats = get_llmage_stats # Product module standard interface diff --git a/wwwroot/api/get_apis.dspy b/wwwroot/api/get_apis.dspy index 1594761..eae8d95 100644 --- a/wwwroot/api/get_apis.dspy +++ b/wwwroot/api/get_apis.dspy @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -import json result = [] diff --git a/wwwroot/api/get_catelogs.dspy b/wwwroot/api/get_catelogs.dspy index 8a5bd44..46bb3d8 100644 --- a/wwwroot/api/get_catelogs.dspy +++ b/wwwroot/api/get_catelogs.dspy @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -import json result = [] diff --git a/wwwroot/api/get_ppids.dspy b/wwwroot/api/get_ppids.dspy index d7c22f0..7700c4d 100644 --- a/wwwroot/api/get_ppids.dspy +++ b/wwwroot/api/get_ppids.dspy @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -import json result = [] diff --git a/wwwroot/api/llm_api_map_create.dspy b/wwwroot/api/llm_api_map_create.dspy index 46a5739..29d168e 100644 --- a/wwwroot/api/llm_api_map_create.dspy +++ b/wwwroot/api/llm_api_map_create.dspy @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -import json result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': 'Invalid', 'type': 'error'}} diff --git a/wwwroot/api/llm_api_map_delete.dspy b/wwwroot/api/llm_api_map_delete.dspy index 66b8ace..f860cd3 100644 --- a/wwwroot/api/llm_api_map_delete.dspy +++ b/wwwroot/api/llm_api_map_delete.dspy @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -import json result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': 'Invalid', 'type': 'error'}} diff --git a/wwwroot/api/llm_api_map_list.dspy b/wwwroot/api/llm_api_map_list.dspy index e43129e..c4e9a0c 100644 --- a/wwwroot/api/llm_api_map_list.dspy +++ b/wwwroot/api/llm_api_map_list.dspy @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -import json result = {'success': False, 'rows': [], 'total': 0} diff --git a/wwwroot/api/llm_api_map_options.dspy b/wwwroot/api/llm_api_map_options.dspy index f5b3209..2805e83 100644 --- a/wwwroot/api/llm_api_map_options.dspy +++ b/wwwroot/api/llm_api_map_options.dspy @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -import json result = {'success': False, 'data': {'llms': [], 'catelogs': [], 'apis': [], 'ppids': []}} diff --git a/wwwroot/api/llm_catelog_options.dspy b/wwwroot/api/llm_catelog_options.dspy index 7703a7c..54f4ffe 100644 --- a/wwwroot/api/llm_catelog_options.dspy +++ b/wwwroot/api/llm_catelog_options.dspy @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -import json result = {'success': False, 'data': {'llms': [], 'catelogs': []}} diff --git a/wwwroot/api/llm_create.dspy b/wwwroot/api/llm_create.dspy index e45f74a..aebb723 100644 --- a/wwwroot/api/llm_create.dspy +++ b/wwwroot/api/llm_create.dspy @@ -1,6 +1,4 @@ #!/usr/bin/env python3 -import json -from appPublic.uniqueID import getID result = {'success': False, 'message': ''} diff --git a/wwwroot/api/llm_delete.dspy b/wwwroot/api/llm_delete.dspy index 21793b8..1887c58 100644 --- a/wwwroot/api/llm_delete.dspy +++ b/wwwroot/api/llm_delete.dspy @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -import json result = {'success': False, 'message': ''} diff --git a/wwwroot/api/llm_update.dspy b/wwwroot/api/llm_update.dspy index cffcba7..9d5d712 100644 --- a/wwwroot/api/llm_update.dspy +++ b/wwwroot/api/llm_update.dspy @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -import json result = {'success': False, 'message': ''} diff --git a/wwwroot/api/llmcatelog_create.dspy b/wwwroot/api/llmcatelog_create.dspy index 2d01e1f..732c768 100644 --- a/wwwroot/api/llmcatelog_create.dspy +++ b/wwwroot/api/llmcatelog_create.dspy @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -import json result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': 'Invalid', 'type': 'error'}} diff --git a/wwwroot/api/llmcatelog_delete.dspy b/wwwroot/api/llmcatelog_delete.dspy index 4f92555..68b2c93 100644 --- a/wwwroot/api/llmcatelog_delete.dspy +++ b/wwwroot/api/llmcatelog_delete.dspy @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -import json result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': 'Invalid', 'type': 'error'}} diff --git a/wwwroot/api/llmcatelog_list.dspy b/wwwroot/api/llmcatelog_list.dspy index 8bed755..64cfb66 100644 --- a/wwwroot/api/llmcatelog_list.dspy +++ b/wwwroot/api/llmcatelog_list.dspy @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -import json result = {'success': False, 'rows': [], 'total': 0} diff --git a/wwwroot/api/llmcatelog_update.dspy b/wwwroot/api/llmcatelog_update.dspy index 487c2c0..5e30900 100644 --- a/wwwroot/api/llmcatelog_update.dspy +++ b/wwwroot/api/llmcatelog_update.dspy @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -import json result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': 'Invalid', 'type': 'error'}} diff --git a/wwwroot/api/llmusage_accounting_failed_create.dspy b/wwwroot/api/llmusage_accounting_failed_create.dspy index ae87374..ca4266b 100644 --- a/wwwroot/api/llmusage_accounting_failed_create.dspy +++ b/wwwroot/api/llmusage_accounting_failed_create.dspy @@ -1,6 +1,4 @@ #!/usr/bin/env python3 -import json -from appPublic.uniqueID import getID result = {'success': False, 'message': ''} diff --git a/wwwroot/api/llmusage_accounting_failed_delete.dspy b/wwwroot/api/llmusage_accounting_failed_delete.dspy index 2a09928..0b27c7f 100644 --- a/wwwroot/api/llmusage_accounting_failed_delete.dspy +++ b/wwwroot/api/llmusage_accounting_failed_delete.dspy @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -import json result = {'success': False, 'message': ''} diff --git a/wwwroot/api/llmusage_accounting_failed_update.dspy b/wwwroot/api/llmusage_accounting_failed_update.dspy index 40b9ba5..549a4ba 100644 --- a/wwwroot/api/llmusage_accounting_failed_update.dspy +++ b/wwwroot/api/llmusage_accounting_failed_update.dspy @@ -1,6 +1,4 @@ #!/usr/bin/env python3 -import json -from datetime import datetime result = {'success': False, 'message': ''} diff --git a/wwwroot/api/llmusage_create.dspy b/wwwroot/api/llmusage_create.dspy index 466e806..b2193b3 100644 --- a/wwwroot/api/llmusage_create.dspy +++ b/wwwroot/api/llmusage_create.dspy @@ -1,6 +1,4 @@ #!/usr/bin/env python3 -import json -from appPublic.uniqueID import getID result = {'success': False, 'message': ''} diff --git a/wwwroot/api/llmusage_delete.dspy b/wwwroot/api/llmusage_delete.dspy index 58cb1f1..11f9459 100644 --- a/wwwroot/api/llmusage_delete.dspy +++ b/wwwroot/api/llmusage_delete.dspy @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -import json result = {'success': False, 'message': ''} diff --git a/wwwroot/api/llmusage_history_create.dspy b/wwwroot/api/llmusage_history_create.dspy index 3f307aa..55543f6 100644 --- a/wwwroot/api/llmusage_history_create.dspy +++ b/wwwroot/api/llmusage_history_create.dspy @@ -1,4 +1,3 @@ #!/usr/bin/env python3 -import json result = {'success': False, 'message': '历史数据为只读,不可新增'} return json.dumps(result, ensure_ascii=False, default=str) diff --git a/wwwroot/api/llmusage_history_delete.dspy b/wwwroot/api/llmusage_history_delete.dspy index c2b4fc5..aef1dc3 100644 --- a/wwwroot/api/llmusage_history_delete.dspy +++ b/wwwroot/api/llmusage_history_delete.dspy @@ -1,4 +1,3 @@ #!/usr/bin/env python3 -import json result = {'success': False, 'message': '历史数据为只读,不可删除'} return json.dumps(result, ensure_ascii=False, default=str) diff --git a/wwwroot/api/llmusage_history_update.dspy b/wwwroot/api/llmusage_history_update.dspy index e4578b0..220a62c 100644 --- a/wwwroot/api/llmusage_history_update.dspy +++ b/wwwroot/api/llmusage_history_update.dspy @@ -1,4 +1,3 @@ #!/usr/bin/env python3 -import json result = {'success': False, 'message': '历史数据为只读,不可修改'} return json.dumps(result, ensure_ascii=False, default=str) diff --git a/wwwroot/api/llmusage_update.dspy b/wwwroot/api/llmusage_update.dspy index 5d77ba8..1adee52 100644 --- a/wwwroot/api/llmusage_update.dspy +++ b/wwwroot/api/llmusage_update.dspy @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -import json result = {'success': False, 'message': ''} diff --git a/wwwroot/api/uapi_options.dspy b/wwwroot/api/uapi_options.dspy index 09d2f7a..f90e3b4 100644 --- a/wwwroot/api/uapi_options.dspy +++ b/wwwroot/api/uapi_options.dspy @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -import json result = [] diff --git a/wwwroot/llmusage_accounting_failed/recover_usages.dspy b/wwwroot/llmusage_accounting_failed/recover_usages.dspy index 549fbee..95de239 100644 --- a/wwwroot/llmusage_accounting_failed/recover_usages.dspy +++ b/wwwroot/llmusage_accounting_failed/recover_usages.dspy @@ -3,8 +3,6 @@ ns = params_kw.copy() limit = int(ns.get('limit') or 200) single_id = ns.get('id') or None -from ahserver.filestorage import FileStorage -import os db = DBPools() dbname = get_module_dbname('llmage') diff --git a/wwwroot/llmusage_ioinfo_display.dspy b/wwwroot/llmusage_ioinfo_display.dspy index 8844b4f..ded6161 100644 --- a/wwwroot/llmusage_ioinfo_display.dspy +++ b/wwwroot/llmusage_ioinfo_display.dspy @@ -1,5 +1,3 @@ -import json -from llmage.utils import get_llmusage_by_id, read_ioinfo_content usage_id = params_kw.get('id') if not usage_id: diff --git a/wwwroot/llmusage_usages_display.dspy b/wwwroot/llmusage_usages_display.dspy index 100f729..2379d57 100644 --- a/wwwroot/llmusage_usages_display.dspy +++ b/wwwroot/llmusage_usages_display.dspy @@ -1,5 +1,3 @@ -import json -from llmage.utils import get_llmusage_by_id usage_id = params_kw.get('id') if not usage_id: diff --git a/wwwroot/v1/image/generations/index.dspy b/wwwroot/v1/image/generations/index.dspy index 0f56890..e39fc8e 100644 --- a/wwwroot/v1/image/generations/index.dspy +++ b/wwwroot/v1/image/generations/index.dspy @@ -14,14 +14,6 @@ # # Response format depends on the upstream model (sync returns image data, async returns task info) -import json -import time -from functools import partial -from appPublic.log import debug -from appPublic.dictObject import DictObject -from appPublic.uniqueID import getID -from appPublic.timeUtils import curDateString, timestampstr -from sqlor.dbpools import get_sor_context debug_params('params_kw', params_kw) diff --git a/wwwroot/v1/video/generations/index.dspy b/wwwroot/v1/video/generations/index.dspy index 6d503c8..235199d 100644 --- a/wwwroot/v1/video/generations/index.dspy +++ b/wwwroot/v1/video/generations/index.dspy @@ -22,14 +22,6 @@ # "created": 1234567890 # } -import json -import time -from functools import partial -from appPublic.log import debug -from appPublic.dictObject import DictObject -from appPublic.uniqueID import getID -from appPublic.timeUtils import curDateString, timestampstr -from sqlor.dbpools import get_sor_context debug_params('params_kw', params_kw)