Hi LiveKit team, I'm using openai.LLM(model="gpt-4...
# ask-ai
s
Hi LiveKit team, I'm using openai.LLM(model="gpt-4o").chat(chat_ctx=chat_ctx) in LiveKit agents and getting ChatChunk objects, but I'm getting this error: text Apply AttributeError: 'ChatChunk' object has no attribute 'choices' You previously told me to use chunk.choices[0].delta.content, but LiveKit's ChatChunk doesn't have a choices attribute. What's the correct attribute name for LiveKit's ChatChunk objects specifically? python Apply async for chunk in llm_stream: text_content = chunk.??? # What's the correct attribute for LiveKit ChatChunk? Thanks!
t
Thanks for reaching out, Jason. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Just a quick heads-up: to get the text content from LiveKit
ChatChunk
objects, you'll want to use the attribute
delta.content
. Here's a little code snippet to help you out:
Copy code
async for chunk in llm_stream:
    text_content = chunk.delta.content  # Access the text content here
If you have any more questions or need a hand with anything else, don’t hesitate to reach out—I’m here to help! Sources: livekit-plugins/livekit-plugins-langchain/livekit/plugins/langchain/langgra...