Find answers from the community

Updated 6 months ago

Generator

At a glance

The community member is trying to stream the output of an LLM (Large Language Model) but is getting a generator object instead. The comments suggest that the solution is to iterate over the generator in a for loop, but the community member is unsure how to do that. Another community member suggests that the solution might be to simply print each chunk of the output, like for chunk in output print(chunk, end=""). However, there is no explicitly marked answer in the comments.

I'm trying to have the llm stream the output but get this message:
<generator object llm_chat_callback.<locals>.wrap.<locals>.wrapped_llm_chat.<locals>.wrapped_gen at 0x766381b12340>

How should I have properly done it? (without the selected code in the script the code runs fine.
Attachment
Screenshot_from_2024-08-12_14-00-58.png
L
M
3 comments
You need to iterate over the generator in a for loop
How do I iterate over the generator? (forgive me for being a bit more inexperienced here, and thanks for your help!)
I thhiiink it should be just

Plain Text
for chunk in output
  print(chunk, end="")
Add a reply
Sign up and join the conversation on Discord