stream output's type
callanwu opened this issue · 1 comments
callanwu commented
When i use the provided steam output's example code(https://github.com/replicate/replicate-python#run-a-model-and-stream-its-output), it output nothing but output blank lines.
Is this related to the type of event
?
May be the code should be
import replicate
# https://replicate.com/meta/llama-2-70b-chat
model_version = "meta/llama-2-70b-chat:02e509c789964a7ea8736978a43525956ef40397be9033abf9fd2badfe68c9e3"
tokens = []
for event in replicate.stream(
model_version,
input={
"prompt": "Please write a haiku about llamas.",
},
):
print(event.data)
tokens.append(str(event.data))
print(" ".join(tokens))
But when I use the above code, it always output a {}
at the end.
Could you provide a correct code example?