Skip to content
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

Stream is not working #5

Open
devops-chatai opened this issue Apr 23, 2024 · 0 comments
Open

Stream is not working #5

devops-chatai opened this issue Apr 23, 2024 · 0 comments

Comments

@devops-chatai
Copy link

devops-chatai commented Apr 23, 2024

The code snippet related to streaming isn't functioning as expected. It seems that despite using examplePredictionId, which is supposed to be the ID of the prediction generated by Replicate.instance.predictions.create, no events are being triggered.

Is it possible that streaming isn't supported? It seems that the stream codes have been commented out. I already uncomment and run the stream, however no event is never triggered.

  Stream<Prediction> stream = Replicate.instance.predictions.snapshots(
      id: examplePredictionId!,
      pollingInterval: Duration(seconds: 2),
      shouldTriggerOnlyStatusChanges: true,
      stopPollingRequestsOnPredictionTermination: true,
    );

  expect(stream, isA<Stream<Prediction>>());

  stream.listen((event) {
    print('Received event: $event');
    expect(event, isA<Prediction>());
    expect(event.id, examplePredictionId!);
    print(event.status);
  }, onError: (e) {
    print('Error in stream: $e');
    fail('should not throw an exception');
  }, onDone: () async {
    print('Stream closed');
    print('done');
    FetchedPrediction prediction = await Replicate.instance.predictions.get(
      id: examplePredictionId!,
    );
    final imageUrlList = prediction.output;
    await saveImageFromUrl(imageUrlList, 'outputs');

  });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant