Describe the bug
There was no problem when I used it half a month ago. I changed my account and token the day before yesterday, but this error occurred when I called it again, and the code has not been modified
calling location: POST https://ryv2xj.laf.dev/api
arguments:{
"type": "imagine",
"param": {
"question": "beautiful girl",
"msg_id": 1
}
}
Expected behavior
There should be a normal return
Screenshots
If applicable, add screenshots to help explain your problem.
error log
[2023-07-02 10:52:53]
'imagine' { question: 'beautiful girl', msg_id: 1 }
[2023-07-02 10:52:54]
'ImagineApi failed with status 400' 'Error: ImagineApi failed with status 400\n' +
' at Midjourney.Imagine (/app/node_modules/midjourney/libs/midjourney.js:47:19)\n' +
' at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n' +
' at async imagine (evalmachine.:46:17)\n' +
' at async default_1 (evalmachine.:25:20)\n' +
' at async FunctionEngine.run (/app/dist/support/function-engine/engine.js:34:24)\n' +
' at async CloudFunction.invoke (/app/dist/support/function-engine/function.js:73:23)\n' +
' at async handleDebugFunction (/app/dist/handler/debug-func.js:55:24)\n' +
' at async handleInvokeFunction (/app/dist/handler/invoke-func.js:21:16)'
the code that reproduces this issue or a replay of the bug
import cloud from '@lafjs/cloud' import { Midjourney, MidjourneyMessage } from 'midjourney' const SERVER_ID = '1120696579075080342' // Midjourney 服务 ID const CHANNEL_ID = '1120696579075080345' // Midjourney 频道 ID const SALAI_TOKEN = process.env.SALAI_TOKEN // Midjourney 服务 Token
const Limit = 100 const MaxWait = 3
const client = new Midjourney({ ServerId: SERVER_ID, ChannelId: CHANNEL_ID, SalaiToken: SALAI_TOKEN, Debug: true, SessionId: SALAI_TOKEN, Limit: Limit, MaxWait: MaxWait });
export default async function (ctx: FunctionContext) { const { type, param } = ctx.body switch (type) { case 'RetrieveMessages': return await RetrieveMessages(param) case 'imagine': return await imagine(param) case 'upscale': return await upscale(param) case 'variation': return await variation(param) }
}
// 查询最近消息 async function RetrieveMessages(param) { console.log("RetrieveMessages") const client = new MidjourneyMessage({ ChannelId: CHANNEL_ID, SalaiToken: SALAI_TOKEN, }); const msg = await client.RetrieveMessages(); console.log("RetrieveMessages success ", msg) return msg }
// 创建生图任务 async function imagine(param) { console.log("imagine", param) const { question, msg_Id } = param const msg = await client.Imagine(
[${msg_Id}] ${question}
, (uri: string, progress: string) => { console.log("loading", uri, "progress", progress); } ); console.log("imagine success ", msg) return true }// upscale 放大图片 async function upscale(param) { console.log("upscale", param) const { question, index, id, url } = param const hash = url.split("_").pop()?.split(".")[0] ?? "" console.log(hash) const msg = await client.Upscale( question, index, id, hash, (uri: string, progress: string) => { console.log("loading", uri, "progress", progress); } ); console.log("upscale success ", msg) return msg }
// variation 变换图片 async function variation(param) { console.log("variation", param) const client = new Midjourney({ ServerId: SERVER_ID, ChannelId: CHANNEL_ID, SalaiToken: SALAI_TOKEN, Debug: true, SessionId: SALAITOKEN, Limit: Limit, MaxWait: 100 }); const { question, index, id, url } = param const hash = url.split("").pop()?.split(".")[0] ?? "" const msg = await client.Variation( question, index, id, hash, (uri: string, progress: string) => { console.log("loading", uri, "progress", progress); } ); console.log("variation success ", msg) return msg }
Describe the bug
Describe the bug There was no problem when I used it half a month ago. I changed my account and token the day before yesterday, but this error occurred when I called it again, and the code has not been modified calling location: POST https://ryv2xj.laf.dev/api arguments:{ "type": "imagine", "param": { "question": "beautiful girl", "msg_id": 1 } }
Expected behavior There should be a normal return
Screenshots If applicable, add screenshots to help explain your problem.
error log
[2023-07-02 10:52:53] 'imagine' { question: 'beautiful girl', msg_id: 1 } [2023-07-02 10:52:54] 'ImagineApi failed with status 400' 'Error: ImagineApi failed with status 400\n' + ' at Midjourney.Imagine (/app/node_modules/midjourney/libs/midjourney.js:47:19)\n' + ' at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n' + ' at async imagine (evalmachine.:46:17)\n' +
' at async default_1 (evalmachine.:25:20)\n' +
' at async FunctionEngine.run (/app/dist/support/function-engine/engine.js:34:24)\n' +
' at async CloudFunction.invoke (/app/dist/support/function-engine/function.js:73:23)\n' +
' at async handleDebugFunction (/app/dist/handler/debug-func.js:55:24)\n' +
' at async handleInvokeFunction (/app/dist/handler/invoke-func.js:21:16)'