3.0.2
This commit is contained in:
parent
af4abb772e
commit
ee875ac5c2
@ -50,7 +50,8 @@ export async function generateImages(
|
||||
try {
|
||||
const model = getModel(_model);
|
||||
const isV4 = _model.startsWith('jimeng-4');
|
||||
const currentVersion = isV4 ? '3.3.7' : DRAFT_VERSION;
|
||||
// const currentVersion = isV4 ? '3.3.7' : DRAFT_VERSION;
|
||||
const currentVersion = DRAFT_VERSION;
|
||||
const resolutionType = isV4 ? '2k' : '1k';
|
||||
logger.info(`使用模型: ${_model} 映射模型: ${model} ${width}x${height} 精细度: ${sampleStrength}`);
|
||||
|
||||
@ -59,96 +60,6 @@ export async function generateImages(
|
||||
await receiveCredit(refreshToken);
|
||||
|
||||
const componentId = util.uuid();
|
||||
const draftContent = {
|
||||
type: "draft",
|
||||
id: util.uuid(),
|
||||
min_version: DRAFT_VERSION,
|
||||
min_features: [],
|
||||
is_from_tsn: true,
|
||||
version: currentVersion,
|
||||
main_component_id: componentId,
|
||||
component_list: [
|
||||
{
|
||||
type: "image_base_component",
|
||||
id: componentId,
|
||||
min_version: DRAFT_VERSION,
|
||||
gen_type: 1,
|
||||
generate_type: "generate",
|
||||
aigc_mode: "workbench",
|
||||
metadata: {
|
||||
type: "",
|
||||
id: util.uuid(),
|
||||
created_platform: 3,
|
||||
created_platform_version: "",
|
||||
created_time_in_ms: Date.now().toString(),
|
||||
created_did: ""
|
||||
},
|
||||
abilities: {
|
||||
type: "",
|
||||
id: util.uuid(),
|
||||
generate: {
|
||||
type: "",
|
||||
id: util.uuid(),
|
||||
core_param: {
|
||||
type: "",
|
||||
id: util.uuid(),
|
||||
model,
|
||||
prompt,
|
||||
negative_prompt: negativePrompt,
|
||||
seed: Math.floor(Math.random() * 100000000) + 2500000000,
|
||||
sample_strength: sampleStrength,
|
||||
image_ratio: 1,
|
||||
large_image_info: {
|
||||
type: "",
|
||||
id: util.uuid(),
|
||||
height,
|
||||
width,
|
||||
resolution_type: resolutionType,
|
||||
},
|
||||
intelligent_ratio: false
|
||||
},
|
||||
history_option: {
|
||||
type: "",
|
||||
id: util.uuid(),
|
||||
},
|
||||
},
|
||||
gen_option: {
|
||||
type: "",
|
||||
id: util.uuid(),
|
||||
gen_count: 1,
|
||||
generate_all: false
|
||||
}
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const payloadData = {
|
||||
extend: {
|
||||
root_model: model,
|
||||
template_id: "",
|
||||
},
|
||||
submit_id: util.uuid(),
|
||||
metrics_extra: JSON.stringify({
|
||||
templateId: "0",
|
||||
generateCount: 1,
|
||||
promptSource: "custom",
|
||||
templateSource: "",
|
||||
lastRequestId: "",
|
||||
originRequestId: "",
|
||||
enterFrom: "use_bgimage_prompt",
|
||||
isRegenerate: false,
|
||||
isBoxSelect: false,
|
||||
isCutout: false
|
||||
}),
|
||||
draft_content: JSON.stringify(draftContent),
|
||||
http_common_info: {
|
||||
aid: Number(DEFAULT_ASSISTANT_ID),
|
||||
},
|
||||
};
|
||||
|
||||
logger.info(`Jimeng Request Payload: ${JSON.stringify(payloadData)}`);
|
||||
|
||||
const { aigc_data } = await request(
|
||||
"post",
|
||||
"/mweb/v1/aigc_draft/generate",
|
||||
@ -164,10 +75,72 @@ export async function generateImages(
|
||||
})
|
||||
),
|
||||
},
|
||||
data: payloadData,
|
||||
data: {
|
||||
extend: {
|
||||
root_model: model,
|
||||
template_id: "",
|
||||
},
|
||||
submit_id: util.uuid(),
|
||||
metrics_extra: JSON.stringify({
|
||||
templateId: "",
|
||||
generateCount: 1,
|
||||
promptSource: "custom",
|
||||
templateSource: "",
|
||||
lastRequestId: "",
|
||||
originRequestId: "",
|
||||
}),
|
||||
draft_content: JSON.stringify({
|
||||
type: "draft",
|
||||
id: util.uuid(),
|
||||
min_version: DRAFT_VERSION,
|
||||
is_from_tsn: true,
|
||||
version: currentVersion,
|
||||
main_component_id: componentId,
|
||||
component_list: [
|
||||
{
|
||||
type: "image_base_component",
|
||||
id: componentId,
|
||||
min_version: DRAFT_VERSION,
|
||||
generate_type: "generate",
|
||||
aigc_mode: "workbench",
|
||||
abilities: {
|
||||
type: "",
|
||||
id: util.uuid(),
|
||||
generate: {
|
||||
type: "",
|
||||
id: util.uuid(),
|
||||
core_param: {
|
||||
type: "",
|
||||
id: util.uuid(),
|
||||
model,
|
||||
prompt,
|
||||
negative_prompt: negativePrompt,
|
||||
seed: Math.floor(Math.random() * 100000000) + 2500000000,
|
||||
sample_strength: sampleStrength,
|
||||
image_ratio: 1,
|
||||
large_image_info: {
|
||||
type: "",
|
||||
id: util.uuid(),
|
||||
height,
|
||||
width,
|
||||
resolution_type: resolutionType,
|
||||
},
|
||||
},
|
||||
history_option: {
|
||||
type: "",
|
||||
id: util.uuid(),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
}),
|
||||
http_common_info: {
|
||||
aid: Number(DEFAULT_ASSISTANT_ID),
|
||||
},
|
||||
},
|
||||
}
|
||||
);
|
||||
logger.info(`Jimeng Response Data: ${JSON.stringify(aigc_data)}`);
|
||||
const historyId = aigc_data.history_record_id;
|
||||
if (!historyId)
|
||||
throw new APIException(EX.API_IMAGE_GENERATION_FAILED, "记录ID不存在");
|
||||
|
||||
@ -786,102 +786,13 @@ export class TaskPollingService {
|
||||
|
||||
// 4.x 模型特殊参数
|
||||
const isV4 = model.startsWith('jimeng-4');
|
||||
const currentVersion = isV4 ? '3.3.7' : "3.0.2";
|
||||
// const currentVersion = isV4 ? '3.3.7' : "3.0.2";
|
||||
const currentVersion = "3.0.2";
|
||||
const resolutionType = isV4 ? '2k' : '1k';
|
||||
|
||||
const componentId = this.generateUUID();
|
||||
const submitId = this.generateUUID();
|
||||
|
||||
const draftContent = {
|
||||
type: "draft",
|
||||
id: this.generateUUID(),
|
||||
min_version: "3.0.2",
|
||||
min_features: [],
|
||||
is_from_tsn: true,
|
||||
version: currentVersion,
|
||||
main_component_id: componentId,
|
||||
component_list: [
|
||||
{
|
||||
type: "image_base_component",
|
||||
id: componentId,
|
||||
min_version: "3.0.2",
|
||||
gen_type: 1,
|
||||
generate_type: "generate",
|
||||
aigc_mode: "workbench",
|
||||
metadata: {
|
||||
type: "",
|
||||
id: this.generateUUID(),
|
||||
created_platform: 3,
|
||||
created_platform_version: "",
|
||||
created_time_in_ms: Date.now().toString(),
|
||||
created_did: ""
|
||||
},
|
||||
abilities: {
|
||||
type: "",
|
||||
id: this.generateUUID(),
|
||||
generate: {
|
||||
type: "",
|
||||
id: this.generateUUID(),
|
||||
core_param: {
|
||||
type: "",
|
||||
id: this.generateUUID(),
|
||||
model: mappedModel,
|
||||
prompt,
|
||||
negative_prompt,
|
||||
seed: Math.floor(Math.random() * 100000000) + 2500000000,
|
||||
sample_strength,
|
||||
image_ratio: 1,
|
||||
large_image_info: {
|
||||
type: "",
|
||||
id: this.generateUUID(),
|
||||
height,
|
||||
width,
|
||||
resolution_type: resolutionType,
|
||||
},
|
||||
intelligent_ratio: false
|
||||
},
|
||||
history_option: {
|
||||
type: "",
|
||||
id: this.generateUUID(),
|
||||
},
|
||||
},
|
||||
gen_option: {
|
||||
type: "",
|
||||
id: this.generateUUID(),
|
||||
gen_count: 1,
|
||||
generate_all: false
|
||||
}
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const payloadData = {
|
||||
extend: {
|
||||
root_model: mappedModel,
|
||||
template_id: "",
|
||||
},
|
||||
submit_id: submitId,
|
||||
metrics_extra: JSON.stringify({
|
||||
templateId: "0",
|
||||
generateCount: 1,
|
||||
promptSource: "custom",
|
||||
templateSource: "",
|
||||
lastRequestId: "",
|
||||
originRequestId: "",
|
||||
enterFrom: "use_bgimage_prompt",
|
||||
isRegenerate: false,
|
||||
isBoxSelect: false,
|
||||
isCutout: false
|
||||
}),
|
||||
draft_content: JSON.stringify(draftContent),
|
||||
http_common_info: {
|
||||
aid: Number(process.env.DEFAULT_ASSISTANT_ID || "513695"),
|
||||
},
|
||||
};
|
||||
|
||||
taskLog(`Jimeng Request Payload: ${JSON.stringify(payloadData)}`);
|
||||
|
||||
const { aigc_data } = await request(
|
||||
"post",
|
||||
"/mweb/v1/aigc_draft/generate",
|
||||
@ -897,12 +808,73 @@ export class TaskPollingService {
|
||||
})
|
||||
),
|
||||
},
|
||||
data: payloadData,
|
||||
data: {
|
||||
extend: {
|
||||
root_model: mappedModel,
|
||||
template_id: "",
|
||||
},
|
||||
submit_id: submitId,
|
||||
metrics_extra: JSON.stringify({
|
||||
templateId: "",
|
||||
generateCount: 1,
|
||||
promptSource: "custom",
|
||||
templateSource: "",
|
||||
lastRequestId: "",
|
||||
originRequestId: "",
|
||||
}),
|
||||
draft_content: JSON.stringify({
|
||||
type: "draft",
|
||||
id: this.generateUUID(),
|
||||
min_version: "3.0.2",
|
||||
is_from_tsn: true,
|
||||
version: currentVersion,
|
||||
main_component_id: componentId,
|
||||
component_list: [
|
||||
{
|
||||
type: "image_base_component",
|
||||
id: componentId,
|
||||
min_version: "3.0.2",
|
||||
generate_type: "generate",
|
||||
aigc_mode: "workbench",
|
||||
abilities: {
|
||||
type: "",
|
||||
id: this.generateUUID(),
|
||||
generate: {
|
||||
type: "",
|
||||
id: this.generateUUID(),
|
||||
core_param: {
|
||||
type: "",
|
||||
id: this.generateUUID(),
|
||||
model: mappedModel,
|
||||
prompt,
|
||||
negative_prompt,
|
||||
seed: Math.floor(Math.random() * 100000000) + 2500000000,
|
||||
sample_strength,
|
||||
image_ratio: 1,
|
||||
large_image_info: {
|
||||
type: "",
|
||||
id: this.generateUUID(),
|
||||
height,
|
||||
width,
|
||||
resolution_type: resolutionType,
|
||||
},
|
||||
},
|
||||
history_option: {
|
||||
type: "",
|
||||
id: this.generateUUID(),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
}),
|
||||
http_common_info: {
|
||||
aid: Number(process.env.DEFAULT_ASSISTANT_ID || "513695"),
|
||||
},
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
taskLog(`Jimeng Response Data: ${JSON.stringify(aigc_data)}`);
|
||||
|
||||
const historyId = aigc_data.history_record_id;
|
||||
if (!historyId) {
|
||||
throw new Error('Failed to get history_record_id from image generation API');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user