replicate / replicate-go

Go client for Replicate
https://replicate.com
Apache License 2.0
65 stars 9 forks source link

Add `Stream` method for running a model and streaming its output #29

Closed mattt closed 9 months ago

mattt commented 9 months ago
r8, _ := replicate.NewClient(replicate.WithTokenFromEnv())
model := "meta/llama-2-70b-chat:02e509c789964a7ea8736978a43525956ef40397be9033abf9fd2badfe68c9e3"
input := replicate.PredictionInput{
    "prompt": "write a sea shanty about llamas",
}

events, _ := r8.Stream(context.Background(), model, input, nil)

for event := range events {
     fmt.Print(event.Data)
}