Add street people skill API and two transparent character packs
PROMPT Docker CI and deployment / verify-and-deploy (push) Successful in 13m3s
PROMPT Docker CI and deployment / verify-and-deploy (push) Successful in 13m3s
This commit is contained in:
@@ -8,6 +8,7 @@ export function apiError(res: NextApiResponse,error: unknown) {
|
||||
if(error instanceof ZodError) return res.status(400).json({error:"请检查输入内容",issues:error.issues});
|
||||
const message=error instanceof Error?error.message:"";
|
||||
const clientMessages:Record<string,string>={
|
||||
'Character PNG must have transparency':'请上传带真实透明背景的 PNG,透明区域 alpha 为 0,人物内部 alpha 至少为 250',
|
||||
'Register the coded page before creating its post':'请先在代码中注册对应的作品页面',
|
||||
'Referenced asset does not exist':'引用的素材不存在',
|
||||
'A media post needs matching content':'素材包需要包含对应类型的素材',
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
import sharp from "sharp";
|
||||
import {streetPeople} from "./street-people";
|
||||
export async function validateCharacter(path:string) {
|
||||
try {
|
||||
const input=sharp(path,{limitInputPixels:streetPeople.limits.pixels});
|
||||
const meta=await input.metadata();
|
||||
if(meta.format!=="png"||!meta.hasAlpha)throw new Error("Character PNG must have transparency");
|
||||
const stats=await input.stats();const alpha=stats.channels.at(-1)!;
|
||||
if(alpha.min!==0||alpha.max<250)throw new Error("Character PNG must have transparency");
|
||||
}catch{throw new Error("Character PNG must have transparency");}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
export const streetPeople = {
|
||||
id: "street-people", version: "1.0.0", name: "街头小人", description: "松散笔触、冬日衣着与奶油色剪纸边的街头人物。",
|
||||
prompt: "Draw ONE original full-body street person: {{subject}}. Naive observational felt-tip pen sketch; loose irregular dark plum, cobalt blue OR coral red lines; sparse facial features; adult proportions; simple winter clothes; scribbled hatching on hair and trousers. Ivory cream paper inside the silhouette and a narrow uneven cut-paper border. Center the entire figure and accessories, with transparent padding. True RGBA transparency outside the cutout. Hard die-cut edge, zero glow, zero feathering. No cast shadow, no background, no text, no other people, no polished vector, no anime.",
|
||||
workflow: ["读取本接口的风格规范,将 {{subject}} 替换为人物动作与衣着。", "使用 agent 自己的图片生成工具,明确启用 transparent background;每张只生成一个人物。", "检查人物完整、画风和 alpha 通道;最多 16 张 PNG 通过同一 POST 请求上传,组成一个素材包。", "使用返回的 url 查看 post,assets 为可复用的素材 ID。"],
|
||||
generation: { executor: "coding-agent", serverSideModel: false, reference: "/skills/street-people/reference.png", transparentBackground: true },
|
||||
upload: { method: "POST", endpoint: "/api/skills/street-people", encoding: "multipart/form-data", fields: { files: "1–16 张真实透明 PNG,每张一个完整人物;外部 alpha=0,内部 alpha≥250", title: "素材包标题(可选)", description: "提示词、生成来源和补充说明(可选)", tags: "分类 UUID 数组的 JSON(可选)", slug: "唯一小写英文网址标识(可选)" }, response: { id:"post UUID", slug:"稳定标识", url:"/p/<slug>", assets:["asset UUID"] } },
|
||||
limits: { files:16, bytesPerFile:262144000, totalBytes:1073741824, pixels:40000000 },
|
||||
errors: { 400:"PNG 格式、透明通道或表单不符合规范", 409:"slug 已存在,请查看已有 post 或更换 slug", 413:"文件数或体积超过限制", 500:"存储或服务器暂不可用" }
|
||||
} as const;
|
||||
export function skillMarkdown(){return `# ${streetPeople.name}
|
||||
|
||||
${streetPeople.description}
|
||||
|
||||
由 coding agent 使用自己的绘图工具生成,网站负责校验、存储与发布。服务器不执行模型调用。
|
||||
|
||||
## 提示词
|
||||
|
||||
${streetPeople.prompt}
|
||||
|
||||
## 流程
|
||||
|
||||
${streetPeople.workflow.map((s,i)=>`${i+1}. ${s}`).join("\n")}
|
||||
|
||||
## 上传
|
||||
|
||||
POST /api/skills/street-people(multipart/form-data)
|
||||
|
||||
${Object.entries(streetPeople.upload.fields).map(([k,v])=>`- ${k}: ${v}`).join("\n")}
|
||||
|
||||
GET /api/skills/street-people 返回完整 JSON 规范。参考图:${streetPeople.generation.reference}
|
||||
|
||||
成功返回 201:id、slug、url、assets。原图提取与新生成作品必须分成两个 post,不混入同一包。
|
||||
`;}
|
||||
Reference in New Issue
Block a user