32 lines
1.2 KiB
JavaScript
32 lines
1.2 KiB
JavaScript
import {modelData} from '../config/Config.js';
|
|
import outside from './outPlatforms/outside.js'
|
|
|
|
// 获取外部平台任务结果
|
|
export async function externalGetRequest(remoteTaskId, value) {
|
|
const info = JSON.parse(value)
|
|
console.log('info.workflowId:', info.workflowId)
|
|
console.log(info)
|
|
const url = outside[info.platform].getQueryUrl(remoteTaskId, info.workflowId)
|
|
const headers = await outside[info.platform].getQueryHeader(modelData[info.AIGC][info.platform].apikey)
|
|
const res = await fetch(url, { method: 'GET', headers });
|
|
const response = await res.json()
|
|
|
|
const result = outside[info.platform].getTaskStatus(response)
|
|
console.log(`[externalGetRequest] getTaskStatus 返回结果:`, result)
|
|
// 判断状态是否返回结果
|
|
if(result) {
|
|
const taskResult = {
|
|
result: result.result,
|
|
status: result.status,
|
|
remoteTaskId,
|
|
aigc: info.AIGC,
|
|
platform: info.platform,
|
|
name: info.AIGC + ':' + info.platform,
|
|
taskId: info.taskId
|
|
}
|
|
console.log(`[externalGetRequest] 返回任务结果:`, taskResult)
|
|
return taskResult
|
|
}
|
|
console.log(`[externalGetRequest] 任务未完成,返回 undefined`)
|
|
}
|