image_task: 去掉 size 参数,图片尺寸走上游默认(AI 传错值经常报错)

This commit is contained in:
2026-09-23 08:46:09 +08:00
parent d799c4f47f
commit e54645bf62
2 changed files with 5 additions and 17 deletions
+2 -11
View File
@@ -77,9 +77,8 @@ function pickModel(headers) {
return s || null;
}
async function callZhipuImagesGenerations({ token, model, prompt, size }) {
async function callZhipuImagesGenerations({ token, model, prompt }) {
const body = { model, prompt };
if (size) body.size = size;
const resp = await fetch(ZHIPU_API_URL, {
method: "POST",
headers: {
@@ -123,14 +122,12 @@ async function handleCreate({ args, headers, token }) {
// 不存进 session,每次从本次请求的 header 读取,未设置则用默认 CogView-3-Flash。
// AI 看不到 model 参数(schema 中已删除),避免其误传。
const model = pickModel(headers) || DEFAULT_MODEL;
const size = args.size;
try {
const data = await callZhipuImagesGenerations({
token,
model,
prompt: args.prompt,
size,
});
const urls = extractUrls(data);
if (urls.length === 0) {
@@ -188,7 +185,7 @@ function buildServer() {
"image_task",
`Manages image generation. Generation is synchronous: op=create returns the image URLs directly.
op=create Generate an image from a prompt. Requires prompt; optional size.`,
op=create Generate an image from a prompt. Requires prompt.`,
{
op: z
.enum(["create"])
@@ -201,12 +198,6 @@ op=create Generate an image from a prompt. Requires prompt; optional size.`,
.describe(
"Image generation prompt; describe the desired scene in detail. Used with op=create."
),
size: z
.string()
.optional()
.describe(
"Image size, Preferred sizes: 1024x1024, 1280x1280, 1536x1024, 1024x1536, Each side must be a multiple of 32. Used with op=create."
),
},
async (args, extra) => {
// SDK 在 tool callback 的 extra.requestInfo.headers 里会透传当前 HTTP 请求的 headers