3.0.2
This commit is contained in:
parent
af4abb772e
commit
ee875ac5c2
@ -50,7 +50,8 @@ export async function generateImages(
|
|||||||
try {
|
try {
|
||||||
const model = getModel(_model);
|
const model = getModel(_model);
|
||||||
const isV4 = _model.startsWith('jimeng-4');
|
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';
|
const resolutionType = isV4 ? '2k' : '1k';
|
||||||
logger.info(`使用模型: ${_model} 映射模型: ${model} ${width}x${height} 精细度: ${sampleStrength}`);
|
logger.info(`使用模型: ${_model} 映射模型: ${model} ${width}x${height} 精细度: ${sampleStrength}`);
|
||||||
|
|
||||||
@ -59,11 +60,39 @@ export async function generateImages(
|
|||||||
await receiveCredit(refreshToken);
|
await receiveCredit(refreshToken);
|
||||||
|
|
||||||
const componentId = util.uuid();
|
const componentId = util.uuid();
|
||||||
const draftContent = {
|
const { aigc_data } = await request(
|
||||||
|
"post",
|
||||||
|
"/mweb/v1/aigc_draft/generate",
|
||||||
|
refreshToken,
|
||||||
|
{
|
||||||
|
params: {
|
||||||
|
babi_param: encodeURIComponent(
|
||||||
|
JSON.stringify({
|
||||||
|
scenario: "image_video_generation",
|
||||||
|
feature_key: "aigc_to_image",
|
||||||
|
feature_entrance: "to_image",
|
||||||
|
feature_entrance_detail: "to_image-" + model,
|
||||||
|
})
|
||||||
|
),
|
||||||
|
},
|
||||||
|
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",
|
type: "draft",
|
||||||
id: util.uuid(),
|
id: util.uuid(),
|
||||||
min_version: DRAFT_VERSION,
|
min_version: DRAFT_VERSION,
|
||||||
min_features: [],
|
|
||||||
is_from_tsn: true,
|
is_from_tsn: true,
|
||||||
version: currentVersion,
|
version: currentVersion,
|
||||||
main_component_id: componentId,
|
main_component_id: componentId,
|
||||||
@ -72,17 +101,8 @@ export async function generateImages(
|
|||||||
type: "image_base_component",
|
type: "image_base_component",
|
||||||
id: componentId,
|
id: componentId,
|
||||||
min_version: DRAFT_VERSION,
|
min_version: DRAFT_VERSION,
|
||||||
gen_type: 1,
|
|
||||||
generate_type: "generate",
|
generate_type: "generate",
|
||||||
aigc_mode: "workbench",
|
aigc_mode: "workbench",
|
||||||
metadata: {
|
|
||||||
type: "",
|
|
||||||
id: util.uuid(),
|
|
||||||
created_platform: 3,
|
|
||||||
created_platform_version: "",
|
|
||||||
created_time_in_ms: Date.now().toString(),
|
|
||||||
created_did: ""
|
|
||||||
},
|
|
||||||
abilities: {
|
abilities: {
|
||||||
type: "",
|
type: "",
|
||||||
id: util.uuid(),
|
id: util.uuid(),
|
||||||
@ -105,69 +125,22 @@ export async function generateImages(
|
|||||||
width,
|
width,
|
||||||
resolution_type: resolutionType,
|
resolution_type: resolutionType,
|
||||||
},
|
},
|
||||||
intelligent_ratio: false
|
|
||||||
},
|
},
|
||||||
history_option: {
|
history_option: {
|
||||||
type: "",
|
type: "",
|
||||||
id: util.uuid(),
|
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: {
|
http_common_info: {
|
||||||
aid: Number(DEFAULT_ASSISTANT_ID),
|
aid: Number(DEFAULT_ASSISTANT_ID),
|
||||||
},
|
},
|
||||||
};
|
|
||||||
|
|
||||||
logger.info(`Jimeng Request Payload: ${JSON.stringify(payloadData)}`);
|
|
||||||
|
|
||||||
const { aigc_data } = await request(
|
|
||||||
"post",
|
|
||||||
"/mweb/v1/aigc_draft/generate",
|
|
||||||
refreshToken,
|
|
||||||
{
|
|
||||||
params: {
|
|
||||||
babi_param: encodeURIComponent(
|
|
||||||
JSON.stringify({
|
|
||||||
scenario: "image_video_generation",
|
|
||||||
feature_key: "aigc_to_image",
|
|
||||||
feature_entrance: "to_image",
|
|
||||||
feature_entrance_detail: "to_image-" + model,
|
|
||||||
})
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
data: payloadData,
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
logger.info(`Jimeng Response Data: ${JSON.stringify(aigc_data)}`);
|
|
||||||
const historyId = aigc_data.history_record_id;
|
const historyId = aigc_data.history_record_id;
|
||||||
if (!historyId)
|
if (!historyId)
|
||||||
throw new APIException(EX.API_IMAGE_GENERATION_FAILED, "记录ID不存在");
|
throw new APIException(EX.API_IMAGE_GENERATION_FAILED, "记录ID不存在");
|
||||||
|
|||||||
@ -786,17 +786,46 @@ export class TaskPollingService {
|
|||||||
|
|
||||||
// 4.x 模型特殊参数
|
// 4.x 模型特殊参数
|
||||||
const isV4 = model.startsWith('jimeng-4');
|
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 resolutionType = isV4 ? '2k' : '1k';
|
||||||
|
|
||||||
const componentId = this.generateUUID();
|
const componentId = this.generateUUID();
|
||||||
const submitId = this.generateUUID();
|
const submitId = this.generateUUID();
|
||||||
|
|
||||||
const draftContent = {
|
const { aigc_data } = await request(
|
||||||
|
"post",
|
||||||
|
"/mweb/v1/aigc_draft/generate",
|
||||||
|
refreshToken,
|
||||||
|
{
|
||||||
|
params: {
|
||||||
|
babi_param: encodeURIComponent(
|
||||||
|
JSON.stringify({
|
||||||
|
scenario: "image_video_generation",
|
||||||
|
feature_key: "aigc_to_image",
|
||||||
|
feature_entrance: "to_image",
|
||||||
|
feature_entrance_detail: "to_image-" + mappedModel,
|
||||||
|
})
|
||||||
|
),
|
||||||
|
},
|
||||||
|
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",
|
type: "draft",
|
||||||
id: this.generateUUID(),
|
id: this.generateUUID(),
|
||||||
min_version: "3.0.2",
|
min_version: "3.0.2",
|
||||||
min_features: [],
|
|
||||||
is_from_tsn: true,
|
is_from_tsn: true,
|
||||||
version: currentVersion,
|
version: currentVersion,
|
||||||
main_component_id: componentId,
|
main_component_id: componentId,
|
||||||
@ -805,17 +834,8 @@ export class TaskPollingService {
|
|||||||
type: "image_base_component",
|
type: "image_base_component",
|
||||||
id: componentId,
|
id: componentId,
|
||||||
min_version: "3.0.2",
|
min_version: "3.0.2",
|
||||||
gen_type: 1,
|
|
||||||
generate_type: "generate",
|
generate_type: "generate",
|
||||||
aigc_mode: "workbench",
|
aigc_mode: "workbench",
|
||||||
metadata: {
|
|
||||||
type: "",
|
|
||||||
id: this.generateUUID(),
|
|
||||||
created_platform: 3,
|
|
||||||
created_platform_version: "",
|
|
||||||
created_time_in_ms: Date.now().toString(),
|
|
||||||
created_did: ""
|
|
||||||
},
|
|
||||||
abilities: {
|
abilities: {
|
||||||
type: "",
|
type: "",
|
||||||
id: this.generateUUID(),
|
id: this.generateUUID(),
|
||||||
@ -838,71 +858,23 @@ export class TaskPollingService {
|
|||||||
width,
|
width,
|
||||||
resolution_type: resolutionType,
|
resolution_type: resolutionType,
|
||||||
},
|
},
|
||||||
intelligent_ratio: false
|
|
||||||
},
|
},
|
||||||
history_option: {
|
history_option: {
|
||||||
type: "",
|
type: "",
|
||||||
id: this.generateUUID(),
|
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: {
|
http_common_info: {
|
||||||
aid: Number(process.env.DEFAULT_ASSISTANT_ID || "513695"),
|
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",
|
|
||||||
refreshToken,
|
|
||||||
{
|
|
||||||
params: {
|
|
||||||
babi_param: encodeURIComponent(
|
|
||||||
JSON.stringify({
|
|
||||||
scenario: "image_video_generation",
|
|
||||||
feature_key: "aigc_to_image",
|
|
||||||
feature_entrance: "to_image",
|
|
||||||
feature_entrance_detail: "to_image-" + mappedModel,
|
|
||||||
})
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
data: payloadData,
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
taskLog(`Jimeng Response Data: ${JSON.stringify(aigc_data)}`);
|
|
||||||
|
|
||||||
const historyId = aigc_data.history_record_id;
|
const historyId = aigc_data.history_record_id;
|
||||||
if (!historyId) {
|
if (!historyId) {
|
||||||
throw new Error('Failed to get history_record_id from image generation API');
|
throw new Error('Failed to get history_record_id from image generation API');
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user