From 08bebcd257e9ea91d06a585b5bb3e3ea8b024bf6 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Sat, 30 May 2026 16:22:21 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20v1=20API=20=E7=BB=9F=E4=B8=80?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=20catelogid=20=E5=8F=82=E6=95=B0=E6=9B=BF?= =?UTF-8?q?=E4=BB=A3=20lctype/llmcatelogid?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/API.md | 17 +++++++++++------ wwwroot/v1/chat/completions/index.dspy | 6 +++--- wwwroot/v1/image/generations/index.dspy | 10 +++++----- wwwroot/v1/models/index.dspy | 6 +++--- wwwroot/v1/video/generations/index.dspy | 10 +++++----- 5 files changed, 27 insertions(+), 22 deletions(-) diff --git a/docs/API.md b/docs/API.md index 9dcfd47..aa1c4f2 100644 --- a/docs/API.md +++ b/docs/API.md @@ -21,6 +21,7 @@ Base Path: `/llmage/v1` | 参数 | 类型 | 说明 | |------|------|------| +| `catelogid` | string | 目录类型,默认 `"文生文"` | | `stream` | boolean | 是否启用流式输出 | | `off_peak` | boolean | 是否使用非高峰时段 | | `transno` | string | 交易流水号(不传则自动生成) | @@ -82,7 +83,7 @@ data: [DONE] | 参数 | 类型 | 说明 | |------|------|------| | `model` | string | 模型名称,如 `"keling-2.1"` | -| `llmcatelogid` | string | 目录类型,如 `"文生视频"` / `"图生视频"` | +| `catelogid` | string | 目录类型,如 `"文生视频"` / `"图生视频"` | | `prompt` | string | 生成提示词 | ### 可选参数 @@ -100,7 +101,7 @@ data: [DONE] ```json { "model": "keling-2.1", - "llmcatelogid": "文生视频", + "catelogid": "文生视频", "prompt": "A beautiful sunset over the ocean", "duration": "5s", "resolution": "1080p" @@ -135,7 +136,7 @@ data: [DONE] | 参数 | 类型 | 说明 | |------|------|------| | `model` | string | 模型名称,如 `"jimeng-4.0"` | -| `llmcatelogid` | string | 目录类型,如 `"文生图"` / `"图生图"` | +| `catelogid` | string | 目录类型,如 `"文生图"` / `"图生图"` | | `prompt` | string | 生成提示词 | ### 可选参数 @@ -154,7 +155,7 @@ data: [DONE] ```json { "model": "jimeng-4.0", - "llmcatelogid": "文生图", + "catelogid": "文生图", "prompt": "A beautiful sunset over the ocean", "size": "1024x1024", "n": 1 @@ -218,7 +219,7 @@ GET /llmage/v1/tasks?taskid=task_xxx | 参数 | 类型 | 说明 | |------|------|------| -| `lctype` | string | 按目录类型过滤 | +| `catelogid` | string | 按目录类型过滤 | | `orderby` | string | 排序字段 | ### 请求示例 @@ -247,12 +248,16 @@ GET /llmage/v1/models ## 通用说明 +### 参数统一 + +所有 v1 接口统一使用 `catelogid` 参数标识目录类型,替代原有的 `lctype` / `llmcatelogid`。 + ### 认证 所有接口需要 Bearer Token 认证,请求头中携带: ``` -Authorization: Bearer +Authorization: Bearer *** ``` ### 余额检查 diff --git a/wwwroot/v1/chat/completions/index.dspy b/wwwroot/v1/chat/completions/index.dspy index 46b0ddc..bfe1905 100644 --- a/wwwroot/v1/chat/completions/index.dspy +++ b/wwwroot/v1/chat/completions/index.dspy @@ -10,7 +10,7 @@ async def gen(): yield l debug_params('params_kw', params_kw) -lctype='文生文' +catelogid = params_kw.catelogid or '文生文' if params_kw.off_peak: off_peak = params_kw.off_peak if off_peak in [True, "Y" "y", 1, "1"]: @@ -33,11 +33,11 @@ async with get_sor_context(env, 'llmage') as sor: sql = """select distinct a.* from llm a join llm_api_map m on a.id = m.llmid join llmcatelog b on m.llmcatelogid = b.id -where b.name = ${lctype}$ +where b.name = ${catelogid}$ and a.model=${model}$ and a.status = 'published'""" recs = await sor.sqlExe(sql, { - 'lctype': lctype, + 'catelogid': catelogid, 'model': params_kw.model or 'qwen3-max' }) if len(recs) == 0: diff --git a/wwwroot/v1/image/generations/index.dspy b/wwwroot/v1/image/generations/index.dspy index a1d68cb..3161df4 100644 --- a/wwwroot/v1/image/generations/index.dspy +++ b/wwwroot/v1/image/generations/index.dspy @@ -1,12 +1,12 @@ # OpenAI-compatible Image Generation API # POST /v1/image/generations -# Required params: model, llmcatelogid +# Required params: model, catelogid # Optional params: prompt, image_url, n, size, style, quality, etc. # # Example request: # { # "model": "jimeng-4.0", -# "llmcatelogid": "文生图", +# "catelogid": "文生图", # "prompt": "A beautiful sunset over the ocean", # "size": "1024x1024", # "n": 1 @@ -36,15 +36,15 @@ if not params_kw.model: d = return_error('Missing required parameter: model') return json_response(d, status=400) -if not params_kw.llmcatelogid: - d = return_error('Missing required parameter: llmcatelogid') +if not params_kw.catelogid: + d = return_error('Missing required parameter: catelogid') return json_response(d, status=400) if not params_kw.prompt: d = return_error('Missing required parameter: prompt') return json_response(d, status=400) -lctype = params_kw.llmcatelogid +lctype = params_kw.catelogid env = request._run_ns async with get_sor_context(env, 'llmage') as sor: diff --git a/wwwroot/v1/models/index.dspy b/wwwroot/v1/models/index.dspy index 4c44023..5fb8d94 100644 --- a/wwwroot/v1/models/index.dspy +++ b/wwwroot/v1/models/index.dspy @@ -6,9 +6,9 @@ def get_time_in_seconds(datestr): timestamp = dt_obj.timestamp() return timestamp -lctype=params_kw.lctype -orderby=params_kw.orderby or 'model' -rets = await get_llms_by_catelog_to_customer(catelogid=lctype, orderby=orderby) +catelogid = params_kw.catelogid +orderby = params_kw.orderby or 'model' +rets = await get_llms_by_catelog_to_customer(catelogid=catelogid, orderby=orderby) ret = { "object": "list", "data": [] diff --git a/wwwroot/v1/video/generations/index.dspy b/wwwroot/v1/video/generations/index.dspy index e81ff42..1d84476 100644 --- a/wwwroot/v1/video/generations/index.dspy +++ b/wwwroot/v1/video/generations/index.dspy @@ -1,12 +1,12 @@ # OpenAI-compatible Video Generation API # POST /v1/video/generations -# Required params: model, llmcatelogid +# Required params: model, catelogid # Optional params: prompt, image_url, duration, resolution, n, etc. # # Example request: # { # "model": "keling-2.1", -# "llmcatelogid": "文生视频", +# "catelogid": "文生视频", # "prompt": "A beautiful sunset over the ocean", # "duration": "5s", # "resolution": "1080p" @@ -44,15 +44,15 @@ if not params_kw.model: d = return_error('Missing required parameter: model') return json_response(d, status=400) -if not params_kw.llmcatelogid: - d = return_error('Missing required parameter: llmcatelogid') +if not params_kw.catelogid: + d = return_error('Missing required parameter: catelogid') return json_response(d, status=400) if not params_kw.prompt: d = return_error('Missing required parameter: prompt') return json_response(d, status=400) -lctype = params_kw.llmcatelogid +lctype = params_kw.catelogid env = request._run_ns async with get_sor_context(env, 'llmage') as sor: