Skip to content

Stream is not working  #5

@devops-chatai

Description

@devops-chatai

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');

  });

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions