API responds 422 when input contains string[]
KeThang-V opened this issue · 4 comments
Hi,
When I send an array of string in a parameter of the input of a new prediction I'm getting a code 422 (Unprocessable Entity) from the API. The error is input.style_images: Invalid type. Expected: array, given: string.
So I tried to find out why and found this by adding a console.log directly to the request in the replicate lib:
My original input sent to replicate.predictions.create:
{
"input": {
"style_images": ["string1", "string2"]
},
...
}
The API request body sent from the lib is transformed like this:
{
"body": {
"source": '{"input":{"style_images":"string2"},...}',
...
}
}
I also tried to make the same request with curl or replicate-python and it works.
Thank you
Hi @KeThang-V. Can you please share a link to the model you're running and the full code you tried for JS / Python / curl?
The link to our private model: https://replicate.com/scenario-labs/style-transfer
JS code:
import Replicate from 'replicate';
export async function runReplicate(props) {
const replicate = new Replicate({
auth: "***",
});
return replicate.predictions.create({
model: "scenario-labs/style-transfer",
version: "96fec4bad5f8231d89b4b7b5721cb66f8a76858b0469b909d5f21e42538e136e",
input: {
image: "signed_url_1",
style_images: ["signed_url_2", "signed_url_3"]
},
webhook: 'https://***',
webhook_events_filter: [
"start",
"output",
"logs",
"completed"
]
});
}
@KeThang-V Thanks so much for reporting this! I found the problem and merged a fix with #266. Please upgrade to v0.30.1 and let me know if you have any other issues.