-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error during deployment #19
Comments
Potential solutionTo solve the bug, we need to address the type mismatch issue in the What is causing this bug?The bug is caused by the fact that CodeTo fix the type mismatch, we can modify the assignment of the const replicate = new Replicate({
auth: Array.isArray(req.headers['x-api-key']) ? req.headers['x-api-key'][0] : req.headers['x-api-key'],
userAgent: 'https://www.npmjs.com/package/create-replicate'
}); To correctly extract the URL from the response, we should directly access the const response = await replicate.run(model, { input });
const outputUrl = response.output; // Assuming `response` has a field `output` which is a string URL
console.log({ outputUrl });
res.status(200).json({ success: true, output: outputUrl }); How to replicate the bugTo replicate the bug, attempt to build and deploy the application with the original code. The type mismatch error will occur during the compilation step, and the incorrect handling of the response will prevent the correct URL from being sent back to the client. TaskThe task involves fixing the type error during deployment and ensuring that the correct URL is extracted from the response and sent back to the client. The solution provided above addresses both parts of the task. Click here to create a Pull Request with the proposed solution Files used for this task: Changes on pages/api/realvision.tsBased on the error message provided in the ticket description, the issue seems to be with the assignment of the To resolve this issue, we need to ensure that the Here's the modified code snippet that addresses the type error: const replicate = new Replicate({
auth: Array.isArray(req.headers['x-api-key']) ? req.headers['x-api-key'][0] : req.headers['x-api-key'], // Ensure auth is a string
userAgent: 'https://www.npmjs.com/package/create-replicate'
}) Regarding the second part of the task, which involves parsing the JSON response to extract the 'output' URL, the current code seems to be attempting to handle the output with the To fix this, we should remove the const output = await replicate.run(model, { input }) as string[];
const setGeneratedPhoto = output.find((output) => output.includes('http'));
console.log({setGeneratedPhoto})
res.status(200).json({ success: true, output: setGeneratedPhoto }); This code assumes that the const output = await replicate.run(model, { input }) as string;
console.log({output})
res.status(200).json({ success: true, output: output }); Please note that the above code assumes that the Disclaimer: This comment was entirely generated using AI. Be aware that the information provided may be incorrect. Current plan usage: 101.16% Have feedback or need help? |
Check the code based on the error upon deployment.
[14:32:08] Running build in Washington, D.C., USA (East) – iad1
[14:32:08] Cloning github.com/MrPutzi/design-ai-toolkit (Branch: autopilot/17-20240408123157565, Commit: 6a2d2fa)
[14:32:08] Cloning completed: 413.783ms
[14:32:13] Restored build cache
[14:32:13] Running "vercel build"
[14:32:13] Vercel CLI 33.6.3
[14:32:14] Installing dependencies...
[14:32:16]
[14:32:16] changed 1 package in 2s
[14:32:16]
[14:32:16] 36 packages are looking for funding
[14:32:16] run
npm fund
for details[14:32:16] Detected Next.js version: 13.1.6
[14:32:16] Detected
package-lock.json
generated by npm 7+[14:32:16] Running "npm run build"
[14:32:17]
[14:32:17] > build
[14:32:17] > next build
[14:32:17]
[14:32:17] info - Linting and checking validity of types...
[14:32:21] Failed to compile.
[14:32:21]
[14:32:21] ./pages/api/realvision.ts:45:9
[14:32:21] Type error: Type 'string | string[] | undefined' is not assignable to type 'string | undefined'.
[14:32:21] Type 'string[]' is not assignable to type 'string'.
[14:32:21]
[14:32:21] �[0m �[90m 43 | �[39m�[0m
[14:32:21] �[0m �[90m 44 | �[39m �[36mconst�[39m replicate �[33m=�[39m �[36mnew�[39m �[33mReplicate�[39m({�[0m
[14:32:21] �[0m�[31m�[1m>�[22m�[39m�[90m 45 | �[39m auth�[33m:�[39m req�[33m.�[39mheaders[�[32m'x-api-key'�[39m]�[33m,�[39m �[90m// Replace with the API key provided by the user�[39m�[0m
[14:32:21] �[0m �[90m | �[39m �[31m�[1m^�[22m�[39m�[0m
[14:32:21] �[0m �[90m 46 | �[39m userAgent�[33m:�[39m �[32m'https://www.npmjs.com/package/create-replicate'�[39m�[0m
[14:32:21] �[0m �[90m 47 | �[39m })�[0m
[14:32:21] �[0m �[90m 48 | �[39m �[36mconst�[39m model �[33m=�[39m �[32m'lucataco/realistic-vision-v5:8aeee50b868f06a1893e3b95a8bb639a8342e846836f3e0211d6a13c158505b1'�[39m�[0m
[14:32:21] Error: Command "npm run build" exited with 1
[14:32:21]
Also try to get the right url from the response with real vision generation. The response look like this:
{
"completed_at": "2023-07-28T12:54:35.866109Z",
"created_at": "2023-07-28T12:54:33.533109Z",
"error": null,
"id": "exol3grbmex2jvqhsmzm7h5htq",
"input": {
"steps": 20,
"width": 512,
"height": 728,
"prompt": "RAW photo, a portrait photo of a latina woman in casual clothes, natural skin, 8k uhd, high quality, film grain, Fujifilm XT3",
"guidance": 5,
"negative_prompt": "(deformed iris, deformed pupils, semi-realistic, cgi, 3d, render, sketch, cartoon, drawing, anime:1.4), text, close up, cropped, out of frame, worst quality, low quality, jpeg artifacts, ugly, duplicate, morbid, mutilated, extra fingers, mutated hands, poorly drawn hands, poorly drawn face, mutation, deformed, blurry, dehydrated, bad anatomy, bad proportions, extra limbs, cloned face, disfigured, gross proportions, malformed limbs, missing arms, missing legs, extra arms, extra legs, fused fingers, too many fingers, long neck"
},
"logs": "0%| | 0/20 [00:00<?, ?it/s]\n 10%|█ | 2/20 [00:00<00:01, 14.66it/s]\n 20%|██ | 4/20 [00:00<00:01, 14.70it/s]\n 30%|███ | 6/20 [00:00<00:00, 14.85it/s]\n 40%|████ | 8/20 [00:00<00:00, 14.65it/s]\n 50%|█████ | 10/20 [00:00<00:00, 14.86it/s]\n 60%|██████ | 12/20 [00:00<00:00, 15.01it/s]\n 70%|███████ | 14/20 [00:00<00:00, 15.10it/s]\n 80%|████████ | 16/20 [00:01<00:00, 15.19it/s]\n 90%|█████████ | 18/20 [00:01<00:00, 15.23it/s]\n100%|██████████| 20/20 [00:01<00:00, 15.19it/s]\n100%|██████████| 20/20 [00:01<00:00, 15.03it/s]",
"metrics": {
"predict_time": 2.363836,
"total_time": 2.333
},
"output": "https://replicate.delivery/pbxt/6GzgXMQEnfRiGirhuRhZjsMQypDQQ7AcfQasxbewWLQWktoiA/ai.png",
"started_at": "2023-07-28T12:54:33.502273Z",
"status": "succeeded",
"urls": {
"get": "https://api.replicate.com/v1/predictions/exol3grbmex2jvqhsmzm7h5htq",
"cancel": "https://api.replicate.com/v1/predictions/exol3grbmex2jvqhsmzm7h5htq/cancel"
},
"version": "c0259010b93e7a4102a4ba946d70e06d7d0c7dc007201af443cfc8f943ab1d3c"
}
The output url is the one I need from the reply to be loaded as the generated image.
The text was updated successfully, but these errors were encountered: