async def astream_chat(
        self, messages: Sequence[ChatMessage], **kwargs: Any
    ) -> ChatResponseAsyncGen:
        """
        Override astream_chat to handle ASI's unique streaming format.

        ASI's streaming format includes many empty content chunks during
        the "thinking" phase before delivering the final response.

        This implementation filters out empty chunks and only yields
        chunks with actual content.
        """

        async def gen() -> ChatResponseAsyncGen:
            raw_stream = await super(OpenAILike, self).astream_chat(messages, **kwargs)
            accumulated_content = ""
            async for chunk in raw_stream:
                delta_content = ""
                # Extract content from the chunk
                if hasattr(chunk, "raw") and chunk.raw:
                    # Check for content in choices array
                    if "choices" in chunk.raw and chunk.raw["choices"]:
                        choice = chunk.raw["choices"][0]
                        if isinstance(choice, dict):
                            if "delta" in choice and isinstance(choice["delta"], dict):
                                if (
                                    "content" in choice["delta"]
                                    and choice["delta"]["content"]
                                ):
                                    delta_content = choice["delta"]["content"]
                # Check for content in delta directly
                if not delta_content and hasattr(chunk, "delta"):
                    if hasattr(chunk.delta, "content") and chunk.delta.content:
                        delta_content = chunk.delta.content
                    elif isinstance(chunk.delta, str) and chunk.delta:
                        delta_content = chunk.delta
                if delta_content:
                    response = ChatResponse(
                        message=ChatMessage(
                            role=MessageRole.ASSISTANT,
                            content=accumulated_content + delta_content,
                        ),
                        delta=delta_content,
                        raw=chunk.raw if hasattr(chunk, "raw") else {},
                    )
                    accumulated_content += delta_content
                    yield response

        # Return the async generator function as a coroutine to match OpenAI's pattern
        return gen()

        Override astream_chat to handle ASI's unique streaming format.

        ASI's streaming format includes many empty content chunks during
        the "thinking" phase before delivering the final response.

        This implementation filters out empty chunks and only yields
        chunks with actual content.
        
llama-index-integrations/llms/llama-index-llms-asi/llama_index/llms/asi/base.py