Skip to content

Example with stream = True? #319

Discussion options

You must be logged in to vote

Here is a one way to do it.

prompt = """
# Task
Name the planets in the solar system?

# Answer
"""

# With stream=True, the output is of type `Iterator[CompletionChunk]`.
output = llm.create_completion(prompt, stop=["# Question"], echo=True, stream=True)

# Iterate over the output and print it.
for item in output:
    print(item['choices'][0]['text'], end='')

Replies: 4 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@kerrickchan
Comment options

Answer selected by matthiasgeihs
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants