Skip to content

Panel chatbot

PanelChatPack #

Bases: BaseLlamaPack

面板聊天机器人包。

Source code in llama_index/packs/panel_chatbot/base.py
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
class PanelChatPack(BaseLlamaPack):
    """面板聊天机器人包。"""

    def get_modules(self) -> Dict[str, Any]:
        """获取模块。"""
        return {}

    def run(self, *args: Any, **kwargs: Any) -> Any:
        """运行流水线。"""
        for variable in ENVIRONMENT_VARIABLES:
            if variable not in os.environ:
                raise ValueError("%s environment variable is not set", variable)

        import panel as pn

        if __name__ == "__main__":
            # 'pytest tests' will fail if app is imported elsewhere
            from app import create_chat_ui

            pn.serve(create_chat_ui)
        elif __name__.startswith("bokeh"):
            from app import create_chat_ui

            create_chat_ui().servable()
        else:
            print(
                "To serve the Panel ChatBot please run this file with 'panel serve' or 'python'"
            )

get_modules #

get_modules() -> Dict[str, Any]

获取模块。

Source code in llama_index/packs/panel_chatbot/base.py
16
17
18
def get_modules(self) -> Dict[str, Any]:
    """获取模块。"""
    return {}

run #

run(*args: Any, **kwargs: Any) -> Any

运行流水线。

Source code in llama_index/packs/panel_chatbot/base.py
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
def run(self, *args: Any, **kwargs: Any) -> Any:
    """运行流水线。"""
    for variable in ENVIRONMENT_VARIABLES:
        if variable not in os.environ:
            raise ValueError("%s environment variable is not set", variable)

    import panel as pn

    if __name__ == "__main__":
        # 'pytest tests' will fail if app is imported elsewhere
        from app import create_chat_ui

        pn.serve(create_chat_ui)
    elif __name__.startswith("bokeh"):
        from app import create_chat_ui

        create_chat_ui().servable()
    else:
        print(
            "To serve the Panel ChatBot please run this file with 'panel serve' or 'python'"
        )