Skip to content

Feature request: prediction streaming #42

Open
@daneden

Description

@daneden

Hi there! I’ve recently started playing with Replicate in SwiftUI and this library has been super helpful.

In my previous custom implementation of the Replicate HTTP API, I was doing some manual polling to get a stream of updates in predictions:

// Illustrative pseudocode
Task {
  while prediction.completedAt == nil {
    do {
      try await Task.sleep(nanoseconds: 1_000_000_000)
      prediction = try await fetchPrediction(prediction.id)
    } catch {
      print(error)
    }
  }
}

// 1 second
print(prediction.output) // ["Hello", "!", " "]

// 2 seconds
print(prediction.output) // ["Hello", "!", " ", "As", " ", "a", " ", "helpful", ...]

It'd be great if this library included a polling/streaming method alongside the wait method, especially for chat-like models.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions