1
This commit is contained in:
parent
5a8ef123f8
commit
081768b7a4
@ -293,3 +293,333 @@ export async function getTokenLiveStatus(refreshToken: string) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export function image3Options(
|
||||||
|
model,
|
||||||
|
componentId,
|
||||||
|
prompt,
|
||||||
|
sampleStrength,
|
||||||
|
height,
|
||||||
|
width,
|
||||||
|
negativePrompt = '',
|
||||||
|
resolutionType = "1k",
|
||||||
|
generateCount = 4
|
||||||
|
){
|
||||||
|
const min_version = "3.0.2"
|
||||||
|
const version = "3.0.2"
|
||||||
|
return {
|
||||||
|
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: generateCount,
|
||||||
|
promptSource: "custom",
|
||||||
|
templateSource: "",
|
||||||
|
lastRequestId: "",
|
||||||
|
originRequestId: "",
|
||||||
|
}),
|
||||||
|
draft_content: JSON.stringify({
|
||||||
|
type: "draft",
|
||||||
|
id: util.uuid(),
|
||||||
|
min_version: min_version,
|
||||||
|
is_from_tsn: true,
|
||||||
|
version: version,
|
||||||
|
main_component_id: componentId,
|
||||||
|
component_list: [
|
||||||
|
{
|
||||||
|
type: "image_base_component",
|
||||||
|
id: componentId,
|
||||||
|
min_version: min_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: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),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export function image4Options_0302(
|
||||||
|
model,
|
||||||
|
componentId,
|
||||||
|
prompt,
|
||||||
|
sampleStrength,
|
||||||
|
height,
|
||||||
|
width,
|
||||||
|
negativePrompt = '',
|
||||||
|
resolutionType = "2k",
|
||||||
|
generateCount = 4
|
||||||
|
){
|
||||||
|
const min_version = "3.0.2"
|
||||||
|
const version = "3.0.2"
|
||||||
|
const submit_id = util.uuid()
|
||||||
|
return {
|
||||||
|
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,
|
||||||
|
},
|
||||||
|
submit_id: submit_id,
|
||||||
|
metrics_extra: JSON.stringify({
|
||||||
|
promptSource: "custom",
|
||||||
|
generateCount: generateCount,
|
||||||
|
enterFrom: "click",
|
||||||
|
sceneOptions:JSON.stringify([
|
||||||
|
{
|
||||||
|
"type": "image",
|
||||||
|
"scene": "ImageBasicGenerate",
|
||||||
|
"modelReqKey": model,
|
||||||
|
"resolutionType": resolutionType,
|
||||||
|
"abilityList": [],
|
||||||
|
"benefitCount": 4,
|
||||||
|
"reportParams": {
|
||||||
|
"enterSource": "generate",
|
||||||
|
"vipSource": "generate",
|
||||||
|
"extraVipFunctionKey": model+"-"+resolutionType,
|
||||||
|
"useVipFunctionDetailsReporterHoc": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]),
|
||||||
|
isBoxSelect: false,
|
||||||
|
isCutout: false,
|
||||||
|
generateId: submit_id,
|
||||||
|
isRegenerate: false
|
||||||
|
}),
|
||||||
|
draft_content: JSON.stringify({
|
||||||
|
type: "draft",
|
||||||
|
id: util.uuid(),
|
||||||
|
min_version: min_version,
|
||||||
|
is_from_tsn: true,
|
||||||
|
version: version,
|
||||||
|
main_component_id: componentId,
|
||||||
|
component_list: [
|
||||||
|
{
|
||||||
|
type: "image_base_component",
|
||||||
|
id: componentId,
|
||||||
|
min_version: min_version,
|
||||||
|
generate_type: "generate",
|
||||||
|
aigc_mode: "workbench",
|
||||||
|
metadata: {
|
||||||
|
"type": "",
|
||||||
|
"id": util.uuid(),
|
||||||
|
"created_platform": 3,
|
||||||
|
"created_platform_version": "",
|
||||||
|
"created_time_in_ms": Math.floor(Date.now()/1000),
|
||||||
|
"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: 5,
|
||||||
|
large_image_info: {
|
||||||
|
type: "",
|
||||||
|
id: util.uuid(),
|
||||||
|
height,
|
||||||
|
width,
|
||||||
|
resolution_type: resolutionType,
|
||||||
|
},
|
||||||
|
intelligent_ratio: false
|
||||||
|
},
|
||||||
|
},
|
||||||
|
gen_option: {
|
||||||
|
"type": "",
|
||||||
|
"id": util.uuid(),
|
||||||
|
"gen_count": generateCount,
|
||||||
|
"generate_all": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
http_common_info: {
|
||||||
|
aid: Number(DEFAULT_ASSISTANT_ID),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function image4Options(
|
||||||
|
model,
|
||||||
|
DRAFT_VERSION,
|
||||||
|
componentId,
|
||||||
|
prompt,
|
||||||
|
sampleStrength,
|
||||||
|
height,
|
||||||
|
width,
|
||||||
|
negativePrompt = '',
|
||||||
|
resolutionType = "2k",
|
||||||
|
generateCount = 4
|
||||||
|
){
|
||||||
|
const min_version = "3.0.2"
|
||||||
|
const version = "3.3.7"
|
||||||
|
const submit_id = util.uuid()
|
||||||
|
return {
|
||||||
|
params: {
|
||||||
|
da_version:version,
|
||||||
|
web_component_open_flag:1,
|
||||||
|
web_version:"7.5.0",
|
||||||
|
aigc_features:"app_lip_sync",
|
||||||
|
msToken:"",
|
||||||
|
a_bogus:"",
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
extend: {
|
||||||
|
root_model: model,
|
||||||
|
},
|
||||||
|
submit_id: submit_id,
|
||||||
|
metrics_extra: JSON.stringify({
|
||||||
|
promptSource: "custom",
|
||||||
|
generateCount: generateCount,
|
||||||
|
enterFrom: "click",
|
||||||
|
sceneOptions:JSON.stringify([
|
||||||
|
{
|
||||||
|
"type": "image",
|
||||||
|
"scene": "ImageBasicGenerate",
|
||||||
|
"modelReqKey": model,
|
||||||
|
"resolutionType": resolutionType,
|
||||||
|
"abilityList": [],
|
||||||
|
"benefitCount": 4,
|
||||||
|
"reportParams": {
|
||||||
|
"enterSource": "generate",
|
||||||
|
"vipSource": "generate",
|
||||||
|
"extraVipFunctionKey": model+"-"+resolutionType,
|
||||||
|
"useVipFunctionDetailsReporterHoc": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]),
|
||||||
|
isBoxSelect: false,
|
||||||
|
isCutout: false,
|
||||||
|
generateId: submit_id,
|
||||||
|
isRegenerate: false
|
||||||
|
}),
|
||||||
|
draft_content: JSON.stringify({
|
||||||
|
type: "draft",
|
||||||
|
id: util.uuid(),
|
||||||
|
min_version: min_version,
|
||||||
|
is_from_tsn: true,
|
||||||
|
version: version,
|
||||||
|
main_component_id: componentId,
|
||||||
|
component_list: [
|
||||||
|
{
|
||||||
|
type: "image_base_component",
|
||||||
|
id: componentId,
|
||||||
|
min_version: min_version,
|
||||||
|
generate_type: "generate",
|
||||||
|
aigc_mode: "workbench",
|
||||||
|
metadata: {
|
||||||
|
"type": "",
|
||||||
|
"id": util.uuid(),
|
||||||
|
"created_platform": 3,
|
||||||
|
"created_platform_version": "",
|
||||||
|
"created_time_in_ms": Math.floor(Date.now()/1000),
|
||||||
|
"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: 5,
|
||||||
|
large_image_info: {
|
||||||
|
type: "",
|
||||||
|
id: util.uuid(),
|
||||||
|
height,
|
||||||
|
width,
|
||||||
|
resolution_type: resolutionType,
|
||||||
|
},
|
||||||
|
intelligent_ratio: false
|
||||||
|
},
|
||||||
|
},
|
||||||
|
gen_option: {
|
||||||
|
"type": "",
|
||||||
|
"id": util.uuid(),
|
||||||
|
"gen_count": 4,
|
||||||
|
"generate_all": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
http_common_info: {
|
||||||
|
aid: Number(DEFAULT_ASSISTANT_ID),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -23,6 +23,7 @@ export interface IGenerationTask {
|
|||||||
duration?: number; // 时长(毫秒)
|
duration?: number; // 时长(毫秒)
|
||||||
ratio?: string; // 比例
|
ratio?: string; // 比例
|
||||||
response_format?: string; // 响应格式
|
response_format?: string; // 响应格式
|
||||||
|
generate_count?: number; // 生成数量
|
||||||
};
|
};
|
||||||
|
|
||||||
// 生成过程中的内部参数
|
// 生成过程中的内部参数
|
||||||
|
|||||||
@ -8,7 +8,7 @@ import logger from '@/lib/logger.js';
|
|||||||
import TOSService from '@/lib/tos/tos-service.js';
|
import TOSService from '@/lib/tos/tos-service.js';
|
||||||
import { generateImages as originalGenerateImages } from '@/api/controllers/images.js';
|
import { generateImages as originalGenerateImages } from '@/api/controllers/images.js';
|
||||||
import { generateVideo as originalGenerateVideo } from '@/api/controllers/video.js';
|
import { generateVideo as originalGenerateVideo } from '@/api/controllers/video.js';
|
||||||
import { request } from '@/api/controllers/core.js';
|
import { request, image4Options_0302, image3Options, image4Options } from '@/api/controllers/core.js';
|
||||||
import EX from "@/api/consts/exceptions.ts";
|
import EX from "@/api/consts/exceptions.ts";
|
||||||
|
|
||||||
const timeZone = 'Asia/Shanghai';
|
const timeZone = 'Asia/Shanghai';
|
||||||
@ -766,7 +766,8 @@ export class TaskPollingService {
|
|||||||
* 调用图片生成API
|
* 调用图片生成API
|
||||||
*/
|
*/
|
||||||
private async callImageGeneration(task: IGenerationTask): Promise<string> {
|
private async callImageGeneration(task: IGenerationTask): Promise<string> {
|
||||||
const { model, prompt, width = 1024, height = 1024, sample_strength = 0.5, negative_prompt = "" } = task.original_params;
|
const { model, prompt, width = 1024, height = 1024, sample_strength = 0.5,
|
||||||
|
negative_prompt = "", generate_count = 4 } = task.original_params;
|
||||||
const refreshToken = task.internal_params.refresh_token;
|
const refreshToken = task.internal_params.refresh_token;
|
||||||
|
|
||||||
// 映射模型
|
// 映射模型
|
||||||
@ -784,87 +785,113 @@ export class TaskPollingService {
|
|||||||
|
|
||||||
const componentId = this.generateUUID();
|
const componentId = this.generateUUID();
|
||||||
const submitId = this.generateUUID();
|
const submitId = this.generateUUID();
|
||||||
|
let isModel4 = model.startsWith("jimeng-4");
|
||||||
|
let options:any = image3Options(
|
||||||
|
mappedModel,
|
||||||
|
componentId,
|
||||||
|
prompt,
|
||||||
|
sample_strength,
|
||||||
|
height,
|
||||||
|
width,
|
||||||
|
negative_prompt,
|
||||||
|
'1k',
|
||||||
|
generate_count,
|
||||||
|
);
|
||||||
|
if(isModel4){
|
||||||
|
options = image4Options_0302(
|
||||||
|
mappedModel,
|
||||||
|
componentId,
|
||||||
|
prompt,
|
||||||
|
sample_strength,
|
||||||
|
height,
|
||||||
|
width,
|
||||||
|
negative_prompt,
|
||||||
|
'1k',
|
||||||
|
generate_count,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
logger.info("生成图片 发起请求", options);
|
||||||
const { aigc_data } = await request(
|
const { aigc_data } = await request(
|
||||||
"post",
|
"post",
|
||||||
"/mweb/v1/aigc_draft/generate",
|
"/mweb/v1/aigc_draft/generate",
|
||||||
refreshToken,
|
refreshToken,
|
||||||
{
|
options,
|
||||||
params: {
|
// {
|
||||||
babi_param: encodeURIComponent(
|
// params: {
|
||||||
JSON.stringify({
|
// babi_param: encodeURIComponent(
|
||||||
scenario: "image_video_generation",
|
// JSON.stringify({
|
||||||
feature_key: "aigc_to_image",
|
// scenario: "image_video_generation",
|
||||||
feature_entrance: "to_image",
|
// feature_key: "aigc_to_image",
|
||||||
feature_entrance_detail: "to_image-" + mappedModel,
|
// feature_entrance: "to_image",
|
||||||
})
|
// feature_entrance_detail: "to_image-" + mappedModel,
|
||||||
),
|
// })
|
||||||
},
|
// ),
|
||||||
data: {
|
// },
|
||||||
extend: {
|
// data: {
|
||||||
root_model: mappedModel,
|
// extend: {
|
||||||
template_id: "",
|
// root_model: mappedModel,
|
||||||
},
|
// template_id: "",
|
||||||
submit_id: submitId,
|
// },
|
||||||
metrics_extra: JSON.stringify({
|
// submit_id: submitId,
|
||||||
templateId: "",
|
// metrics_extra: JSON.stringify({
|
||||||
generateCount: 1,
|
// templateId: "",
|
||||||
promptSource: "custom",
|
// generateCount: 1,
|
||||||
templateSource: "",
|
// promptSource: "custom",
|
||||||
lastRequestId: "",
|
// templateSource: "",
|
||||||
originRequestId: "",
|
// lastRequestId: "",
|
||||||
}),
|
// originRequestId: "",
|
||||||
draft_content: JSON.stringify({
|
// }),
|
||||||
type: "draft",
|
// draft_content: JSON.stringify({
|
||||||
id: this.generateUUID(),
|
// type: "draft",
|
||||||
min_version: "3.0.2",
|
// id: this.generateUUID(),
|
||||||
is_from_tsn: true,
|
// min_version: "3.0.2",
|
||||||
version: "3.0.2",
|
// is_from_tsn: true,
|
||||||
main_component_id: componentId,
|
// version: "3.0.2",
|
||||||
component_list: [
|
// main_component_id: componentId,
|
||||||
{
|
// component_list: [
|
||||||
type: "image_base_component",
|
// {
|
||||||
id: componentId,
|
// type: "image_base_component",
|
||||||
min_version: "3.0.2",
|
// id: componentId,
|
||||||
generate_type: "generate",
|
// min_version: "3.0.2",
|
||||||
aigc_mode: "workbench",
|
// generate_type: "generate",
|
||||||
abilities: {
|
// aigc_mode: "workbench",
|
||||||
type: "",
|
// abilities: {
|
||||||
id: this.generateUUID(),
|
// type: "",
|
||||||
generate: {
|
// id: this.generateUUID(),
|
||||||
type: "",
|
// generate: {
|
||||||
id: this.generateUUID(),
|
// type: "",
|
||||||
core_param: {
|
// id: this.generateUUID(),
|
||||||
type: "",
|
// core_param: {
|
||||||
id: this.generateUUID(),
|
// type: "",
|
||||||
model: mappedModel,
|
// id: this.generateUUID(),
|
||||||
prompt,
|
// model: mappedModel,
|
||||||
negative_prompt,
|
// prompt,
|
||||||
seed: Math.floor(Math.random() * 100000000) + 2500000000,
|
// negative_prompt,
|
||||||
sample_strength,
|
// seed: Math.floor(Math.random() * 100000000) + 2500000000,
|
||||||
image_ratio: 1,
|
// sample_strength,
|
||||||
large_image_info: {
|
// image_ratio: 1,
|
||||||
type: "",
|
// large_image_info: {
|
||||||
id: this.generateUUID(),
|
// type: "",
|
||||||
height,
|
// id: this.generateUUID(),
|
||||||
width,
|
// height,
|
||||||
resolution_type: "1k",
|
// width,
|
||||||
},
|
// resolution_type: "1k",
|
||||||
},
|
// },
|
||||||
history_option: {
|
// },
|
||||||
type: "",
|
// history_option: {
|
||||||
id: this.generateUUID(),
|
// type: "",
|
||||||
},
|
// id: this.generateUUID(),
|
||||||
},
|
// },
|
||||||
},
|
// },
|
||||||
},
|
// },
|
||||||
],
|
// },
|
||||||
}),
|
// ],
|
||||||
http_common_info: {
|
// }),
|
||||||
aid: Number(process.env.DEFAULT_ASSISTANT_ID || "513695"),
|
// http_common_info: {
|
||||||
},
|
// aid: Number(process.env.DEFAULT_ASSISTANT_ID || "513695"),
|
||||||
},
|
// },
|
||||||
}
|
// },
|
||||||
|
// }
|
||||||
);
|
);
|
||||||
|
|
||||||
const historyId = aigc_data.history_record_id;
|
const historyId = aigc_data.history_record_id;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user