async def astream_chat(
        self, messages: Sequence[ChatMessage], **kwargs: Any
    ) -> ChatResponseAsyncGen:
        """
        Send an asynchronous streaming chat request to the Reka API.

        Args:
            messages (Sequence[ChatMessage]): A sequence of chat messages.
            **kwargs: Additional keyword arguments for the API call.

        Returns:
            ChatResponseAsyncGen: An asynchronous generator yielding chat responses.

        Raises:
            ValueError: If there's an error with the Reka API call.

        Example:
            >>> import asyncio
            >>> from llama_index.llms.reka import RekaLLM
            >>> from llama_index.core.base.llms.types import ChatMessage, MessageRole
            >>>
            >>> async def main():
            ...     reka_llm = RekaLLM(api_key="your-api-key-here")
            ...     messages = [
            ...         ChatMessage(role=MessageRole.SYSTEM, content="You are a helpful assistant."),
            ...         ChatMessage(role=MessageRole.USER, content="Tell me a short story about a robot.")
            ...     ]
            ...     async for chunk in await reka_llm.astream_chat(messages):
            ...         print(chunk.delta, end="", flush=True)
            ...     print()  # New line after the story is complete
            >>>
            >>> asyncio.run(main())

        """
        all_kwargs = self._get_all_kwargs(**kwargs)
        reka_messages = process_messages_for_reka(messages)

        try:
            stream = self._aclient.chat.create_stream(
                messages=reka_messages, **all_kwargs
            )
        except ApiError as e:
            raise ValueError(f"Reka API error: {e.status_code} - {e.body}")

        async def gen() -> ChatResponseAsyncGen:
            prev_content = ""
            async for chunk in stream:
                content = chunk.responses[0].chunk.content
                content_delta = content[len(prev_content) :]
                prev_content = content
                yield ChatResponse(
                    message=ChatMessage(
                        role=MessageRole.ASSISTANT,
                        content=content,
                    ),
                    delta=content_delta,
                    raw=chunk.__dict__,
                )

        return gen()

        Send an asynchronous streaming chat request to the Reka API.

        Args:
            messages (Sequence[ChatMessage]): A sequence of chat messages.
            **kwargs: Additional keyword arguments for the API call.

        Returns:
            ChatResponseAsyncGen: An asynchronous generator yielding chat responses.

        Raises:
            ValueError: If there's an error with the Reka API call.

        Example:
            >>> import asyncio
            >>> from llama_index.llms.reka import RekaLLM
            >>> from llama_index.core.base.llms.types import ChatMessage, MessageRole
            >>>
            >>> async def main():
            ...     reka_llm = RekaLLM(api_key="your-api-key-here")
            ...     messages = [
            ...         ChatMessage(role=MessageRole.SYSTEM, content="You are a helpful assistant."),
            ...         ChatMessage(role=MessageRole.USER, content="Tell me a short story about a robot.")
            ...     ]
            ...     async for chunk in await reka_llm.astream_chat(messages):
            ...         print(chunk.delta, end="", flush=True)
            ...     print()  # New line after the story is complete
            >>>
            >>> asyncio.run(main())

        
llama-index-integrations/llms/llama-index-llms-reka/llama_index/llms/reka/base.py