Open Borys520 opened 1 year ago
Hi, do you get the solution? Can you share with me? Thanks
I got the same error. Did you find a solution?
same error
do you guys get the solution ? I still facing the same error
Replicate.apiKey = dotenv.env['API_KEY']!;
try {
Prediction prediction = await Replicate.instance.predictions.create(
version:
"b96a2f33cc8e4b0aa23eacfce731b9c41a7d9466d9ed4e167375587b54db9423",
input: {
"prompt": "What is shown in the image?",
"image":
"https://cdn.freecodecamp.org/curriculum/cat-photo-app/relaxing-cat.jpg"
},
);
} catch (e) {
//nothing
}
await Future.delayed(Duration(seconds: 7));
PaginatedPredictions predictionsPageList =
await Replicate.instance.predictions.list();
Prediction prediction = await Replicate.instance.predictions.get(
id: predictionsPageList.results.elementAt(0).id,
);
print(prediction.output);
This is the code I used. You need to install the dotenv plugin and to put your Replicate API key in a .env file
Hi, if I don't use dotenv, then will it still be working ? And this is my code, can you provide me ways to debug my code ?
await Future.delayed(Duration(seconds: 7)); PaginatedPredictions predictionsPageList = await Replicate.instance.predictions.list();
Prediction prediction = await Replicate.instance.predictions.get( id: predictionsPageList.results.elementAt(0).id, ); print(prediction.output);
Yes this way it works, but the object prediction does return null right after creating it. Even after 20 seconds, the object created by
Prediction prediction = await Replicate.instance.predictions.create()
returns null making it impossible to check with a stream or in a while loop...
What if the model takes more than the 7 seconds?
I suppose we could fetch the id from the list like you do then check the status but then my question is:
Will the prediction be added to the list even thought it is not fully completed? And will it always take less than 7 seconds to be added to this list?
Thank you for the code by the way, was really confused by this null prediction!
Edit** Actualyy, if we cannot fetch the id of the first created object directly how can we ensure we have the right prediction, given that 2 users may create a prediction at the same time!
Hi, Thanks for the wonderful package! I am trying to create prediction but it always throws an error :
[Replicate] request started from/to: https://api.replicate.com/v1/predictions. [Replicate] request from/to: https://api.replicate.com/v1/predictions end. [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: type 'Null' is not a subtype of type 'Map<String, dynamic>'
0 new Prediction.fromJson prediction.dart:75
1 ReplicatePrediction.create. predictions.dart:62
2 ReplicateHttpClient.post http_client.dart:54
3 _MyHomePageState.build. main.dart:61