From a04fc9e2b6a8764c5e00b9a6468fd1167f1ae691 Mon Sep 17 00:00:00 2001 From: HeatherEY Date: Wed, 14 Oct 2026 01:25:19 +0800 Subject: [PATCH] docs: guard empty choices in Text to SQL streaming example --- examples/openai-sql.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/openai-sql.mdx b/examples/openai-sql.mdx index 81dfd64..34a6abd 100644 --- a/examples/openai-sql.mdx +++ b/examples/openai-sql.mdx @@ -81,7 +81,7 @@ async def main(message: cl.Message): msg = await cl.Message(content="", language="sql").send() async for part in stream: - if token := part.choices[0].delta.content or "": + if part.choices and (token := part.choices[0].delta.content or ""): await msg.stream_token(token) await msg.update()