dsh-mo-image 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/README.md +4 -3
- package/lib/adapters.js +5 -3
- package/lib/model-rules.js +25 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# 更新日志
|
|
2
2
|
|
|
3
|
+
## v1.0.1
|
|
4
|
+
|
|
5
|
+
- **修复 Stability AI 生图报错。** 使用 Core 生图或 SD3.5 生图、改图时,插件会自动发送接口要求的图片返回格式。已有预设无需重新配置。
|
|
6
|
+
- **智谱 BigModel 支持选择画质。** CogView-4、CogView-4-250304 和 CogView-3-Flash 可选标准或高清。GLM-Image 只支持高清。关闭「质量」时,由智谱使用模型的默认设置。
|
|
7
|
+
- **GLM-Image 默认请求关闭水印。** 去水印需要在智谱开放平台开通对应权限。
|
|
8
|
+
- **更新通义万相的官网入口。** 从预设点击「官网」会打开[千问 AI 平台](https://www.qianwenai.com/)。
|
|
9
|
+
|
|
3
10
|
## v1.0.0
|
|
4
11
|
|
|
5
12
|
经过多日的暴肝,正式版终于出来了qwq!
|
package/README.md
CHANGED
|
@@ -179,14 +179,15 @@ npm run release -- minor --dry-run # 只看会做什么
|
|
|
179
179
|
| Stability AI | 隐藏 | 没有 quality |
|
|
180
180
|
| Together AI | 隐藏 | 没有 quality |
|
|
181
181
|
| Fireworks / Novita | 隐藏 | 取决于网关;默认不显示 |
|
|
182
|
-
|
|
|
182
|
+
| 智谱 BigModel | 显示 | GLM-Image 只支持 HD。CogView-4、CogView-4-250304 和 CogView-3-Flash 提供 Standard / HD |
|
|
183
|
+
| SiliconFlow / 火山方舟 / 百炼 | 隐藏 | 没有统一的 quality 参数 |
|
|
183
184
|
| A1111 / ComfyUI / SwarmUI / 本地 OpenAI 兼容 | 隐藏 | 没有统一 quality;用各自的 steps/cfg |
|
|
184
185
|
|
|
185
186
|
切换模型时,选择器会从目标模型的档位里选一个合法默认值;旧配置里的 `max`、`high` 等值会收敛到目标模型支持的最近档位(例如 GPT-Image 的 `max` → `High`),不会再由对话模型填 `Max`。
|
|
186
187
|
|
|
187
188
|
模型选项的「质量」方框可以覆盖这张表的判断:勾上 / 取消「支持质量参数」、改参数名(支持 `a.b.c` 嵌套路径)或自定义档位表,都能让一个模型从「隐藏」变成可选,或反过来明确「这个模型不发质量参数」。一键配置不会重新打开你明确关掉的质量开关。
|
|
188
189
|
|
|
189
|
-
依据:[OpenAI Images API](https://platform.openai.com/docs/api-reference/images/create)(GPT-Image 的 `low/medium/high/auto`、DALL·E 3 的 `standard/hd`)、[Ideogram 3 API](https://developer.ideogram.ai/v2/api-reference/images/generate/ideogram-3)(`rendering_speed`)。Gemini、xAI、Recraft、Stability、Together、本地后端没有统一的官方 quality 字段,所以隐藏质量行。
|
|
190
|
+
依据:[OpenAI Images API](https://platform.openai.com/docs/api-reference/images/create)(GPT-Image 的 `low/medium/high/auto`、DALL·E 3 的 `standard/hd`)、[Ideogram 3 API](https://developer.ideogram.ai/v2/api-reference/images/generate/ideogram-3)(`rendering_speed`)和[智谱图像生成 API](https://docs.bigmodel.cn/api-reference/模型-api/图像生成)(`quality`)。Gemini、xAI、Recraft、Stability、Together、本地后端没有统一的官方 quality 字段,所以隐藏质量行。
|
|
190
191
|
|
|
191
192
|
## 提示词优化
|
|
192
193
|
|
|
@@ -294,7 +295,7 @@ $DSH_HOME/.credentials.yaml
|
|
|
294
295
|
| 阿里云百炼 · Qwen-Image | `dashscope-qwen-image` | `qwen-image-3.0-pro`、`qwen-image-3.0` | 原生多模态同步接口 |
|
|
295
296
|
| 阿里云百炼 · 通义万相 | `dashscope-wanx` | `wan2.6-t2i`、`wan2.7-image-pro`、`wan2.7-image`、`wanx2.1-t2i-turbo` | 按模型选择异步接口,Wan 2.7 支持参考图 |
|
|
296
297
|
| 硅基流动 | `openai-images`(`edit:'same'`) | 手动/获取 | 生成 + 单图编辑 |
|
|
297
|
-
| 智谱 BigModel | `openai-images`(`edit:'none'`) | `cogview-4`、`
|
|
298
|
+
| 智谱 BigModel | `openai-images`(`edit:'none'`) | `glm-image`、`cogview-4`、`cogview-4-250304`、`cogview-3-flash` | 只支持文生图。拉取列表找不到时可手动填写模型 ID |
|
|
298
299
|
| **MiniMax**(国际站 `api.minimax.io`) | `openai-images` | `MiniMax-H3-Image`、`MiniMax-H3-Image-Highspeed` | H3-Image 就是 OpenAI Images 形状(生成 + `/images/edits` 收 1–16 张参考图);`aspect_ratio` + `area`(`1K/2K/4K`),不发 `size` |
|
|
299
300
|
| MiniMax 中国 | `openai-images` | `MiniMax-H3-Image`、`MiniMax-H3-Image-Highspeed` | 同一套接口,基础地址换成 `api.minimax.cn`(现行官方域名) |
|
|
300
301
|
|
package/lib/adapters.js
CHANGED
|
@@ -2139,6 +2139,7 @@ const ADAPTERS = [
|
|
|
2139
2139
|
endpoints: { generate: STABILITY_CORE_PATH, edit: STABILITY_SD3_PATH },
|
|
2140
2140
|
routes: { generate: STABILITY_CORE_PATH, edit: STABILITY_SD3_PATH, models: '' },
|
|
2141
2141
|
transport: { generate: 'multipart', edit: 'multipart' },
|
|
2142
|
+
headers: { Accept: 'image/*' },
|
|
2142
2143
|
// 这个 `binary: true` 是**请求常量**(protocolConstants 据此发 output_format:'png'),
|
|
2143
2144
|
// 不是响应读法——响应侧由下面的 output 描述符负责。两者同名但不是同一件事。
|
|
2144
2145
|
binary: true,
|
|
@@ -2952,7 +2953,7 @@ export const PROVIDER_PRESETS = definePresets([
|
|
|
2952
2953
|
{
|
|
2953
2954
|
id: 'dashscope-wanx', name: '阿里云百炼 · 通义万相',
|
|
2954
2955
|
baseUrl: 'https://dashscope.aliyuncs.com/api/v1', adapter: 'dashscope-wanx',
|
|
2955
|
-
website: 'https://
|
|
2956
|
+
website: 'https://www.qianwenai.com/',
|
|
2956
2957
|
models: ['wan2.6-t2i', 'wan2.7-image-pro', 'wan2.7-image', 'wanx2.1-t2i-turbo'],
|
|
2957
2958
|
// 老模型使用 input.prompt。2.6 文生图与 2.7 图像模型由协议按模型切换成多模态消息。
|
|
2958
2959
|
fields: {
|
|
@@ -3963,12 +3964,13 @@ function fieldValues(adapter, provider, input) {
|
|
|
3963
3964
|
* 规则没命中时回落到协议自己声明的静态值(stability 的 binary 这类还带着)。
|
|
3964
3965
|
*/
|
|
3965
3966
|
function protocolConstants(adapter, provider, input) {
|
|
3966
|
-
const rule = detectConstantRule(input && input.model, baseUrlOf(provider));
|
|
3967
|
+
const rule = detectConstantRule(input && input.model, baseUrlOf(provider), adapter.id);
|
|
3967
3968
|
const fixed = rule && rule.constants && typeof rule.constants === 'object' ? rule.constants : null;
|
|
3968
3969
|
const picked = (name, fallback) => (fixed && fixed[name] !== undefined ? fixed[name] : fallback);
|
|
3969
3970
|
return {
|
|
3970
3971
|
response_format: picked('response_format', adapter.responseFormat),
|
|
3971
3972
|
watermark: picked('watermark', adapter.watermark),
|
|
3973
|
+
watermark_enabled: picked('watermark_enabled'),
|
|
3972
3974
|
output_format: picked('output_format', adapter.binary ? 'png' : adapter.outputFormat)
|
|
3973
3975
|
};
|
|
3974
3976
|
}
|
|
@@ -4220,7 +4222,7 @@ function composeBody(adapter, provider, input, drops, kind) {
|
|
|
4220
4222
|
const protectedPaths = Object.values(declaredFields).flatMap((spec) => [spec?.path, spec?.numbered, spec?.multipart].filter(Boolean))
|
|
4221
4223
|
.concat(sizeParamPaths(sizePolicy));
|
|
4222
4224
|
applyHttpParams(body, provider, input, {
|
|
4223
|
-
blocked, protectedPaths, adjustable: ['response_format', 'watermark', 'output_format']
|
|
4225
|
+
blocked, protectedPaths, adjustable: ['response_format', 'watermark', 'watermark_enabled', 'output_format']
|
|
4224
4226
|
});
|
|
4225
4227
|
}
|
|
4226
4228
|
return { body, fields };
|
package/lib/model-rules.js
CHANGED
|
@@ -142,6 +142,8 @@ const GEMINI_IMAGE_SIZE = {
|
|
|
142
142
|
second: { from: 'tier', field: 'generationConfig.imageConfig.imageSize' }
|
|
143
143
|
};
|
|
144
144
|
const GPT_IMAGE = /gpt[-_.]?image/i;
|
|
145
|
+
const GLM_IMAGE = /glm-?image/i;
|
|
146
|
+
const BIGMODEL_HOST = '^open\\.bigmodel\\.cn$';
|
|
145
147
|
const GEMINI_IMAGE = /gemini[^ ]*image|nano[-_.]banana/i;
|
|
146
148
|
export const GEMINI_25_IMAGE = /2[._-]5[-_.]flash[-_.]image/i;
|
|
147
149
|
export const isGeminiImageModel = (model) => GEMINI_IMAGE.test(model);
|
|
@@ -552,7 +554,7 @@ export const SIZE_RULES = [
|
|
|
552
554
|
domain: { allowCustom: true, multiple: 16, minSide: 512, maxSide: 2048, maxPixels: 2097152 }
|
|
553
555
|
},
|
|
554
556
|
{
|
|
555
|
-
match:
|
|
557
|
+
match: GLM_IMAGE,
|
|
556
558
|
size: { mode: 'wh-string', field: 'size' },
|
|
557
559
|
domain: { allowCustom: true, multiple: 32, minSide: 1024, maxSide: 2048, maxPixels: 4194304 }
|
|
558
560
|
},
|
|
@@ -648,6 +650,18 @@ export const SIZE_RULES = [
|
|
|
648
650
|
/* ------------------------------------------------------------ 质量规则 */
|
|
649
651
|
|
|
650
652
|
export const QUALITY_RULES = [
|
|
653
|
+
{
|
|
654
|
+
match: GLM_IMAGE,
|
|
655
|
+
host: BIGMODEL_HOST,
|
|
656
|
+
adapters: ['openai-images'],
|
|
657
|
+
quality: { field: 'quality', options: ['hd'], default: 'hd' }
|
|
658
|
+
},
|
|
659
|
+
{
|
|
660
|
+
match: /cogview[-_.]?(?:4(?!\d)|3[-_.]flash)/i,
|
|
661
|
+
host: BIGMODEL_HOST,
|
|
662
|
+
adapters: ['openai-images'],
|
|
663
|
+
quality: { field: 'quality', options: ['standard', 'hd'], default: 'standard' }
|
|
664
|
+
},
|
|
651
665
|
/* ---- Azure OpenAI:主机决定用哪套质量枚举(没有 xhigh / max) ---- */
|
|
652
666
|
{
|
|
653
667
|
match: /.*/,
|
|
@@ -796,7 +810,8 @@ export const FIELD_RULES = [
|
|
|
796
810
|
negative: { appendToPrompt: '\n\nAvoid: ' },
|
|
797
811
|
model: { path: 'model' },
|
|
798
812
|
n: null,
|
|
799
|
-
image: null
|
|
813
|
+
image: null,
|
|
814
|
+
quality: { path: 'quality' }
|
|
800
815
|
}
|
|
801
816
|
},
|
|
802
817
|
|
|
@@ -978,6 +993,12 @@ export const FIELD_RULES = [
|
|
|
978
993
|
* 与 FIELD_RULES 一样**没有兜底条目**:认不出的模型不额外发常量。
|
|
979
994
|
*/
|
|
980
995
|
export const CONSTANT_RULES = [
|
|
996
|
+
{
|
|
997
|
+
match: GLM_IMAGE,
|
|
998
|
+
host: BIGMODEL_HOST,
|
|
999
|
+
adapters: ['openai-images'],
|
|
1000
|
+
constants: { watermark_enabled: false }
|
|
1001
|
+
},
|
|
981
1002
|
{
|
|
982
1003
|
match: /.*/,
|
|
983
1004
|
host: 'volces\\.com',
|
|
@@ -1029,6 +1050,6 @@ export function detectFieldRule(model, baseUrl, adapterId) {
|
|
|
1029
1050
|
* 按模型名 + 可选主机找请求常量规则;都没有返回 null(调用方不额外发常量)。
|
|
1030
1051
|
* 与尺寸/质量不同,这里没有兜底条目:常量是网关个性,认不出就别乱发。
|
|
1031
1052
|
*/
|
|
1032
|
-
export function detectConstantRule(model, baseUrl) {
|
|
1033
|
-
return detect(CONSTANT_RULES, model, baseUrl);
|
|
1053
|
+
export function detectConstantRule(model, baseUrl, adapterId) {
|
|
1054
|
+
return detect(CONSTANT_RULES, model, baseUrl, adapterId);
|
|
1034
1055
|
}
|
package/package.json
CHANGED