async def chat_component(index: VectorStoreIndex, index_loader: IndexLoader):
    """Returns the chat component powering the main area of the application."""
    if not index:
        return pn.Column(
            pn.chat.ChatMessage(
                "You are a now a *GitHub Repository assistant*.",
                user="System",
            ),
            pn.chat.ChatMessage(
                "Please **load a GitHub Repository** to start chatting with me. This can take from seconds to minutes!",
                user="Assistant",
            ),
        )

    chat_engine = index.as_chat_engine(chat_mode="context", verbose=True)

    async def generate_response(contents, user, instance):
        response = await chat_engine.astream_chat(contents)
        text = ""
        async for token in response.async_response_gen():
            text += token
            yield text

    chat_interface = pn.chat.ChatInterface(
        callback=generate_response,
        sizing_mode="stretch_both",
    )
    chat_interface.send(
        pn.chat.ChatMessage(
            "You are a now a *GitHub Repository Assistant*.", user="System"
        ),
        respond=False,
    )
    chat_interface.send(
        pn.chat.ChatMessage(
            f"Hello! you can ask me anything about {index_loader.github_url()}.",
            user="Assistant",
        ),
        respond=False,
    )
    return chat_interface
Returns the chat component powering the main area of the application.
llama-index-packs/llama-index-packs-panel-chatbot/llama_index/packs/panel_chatbot/app.py