def init_client()

in hugegraph-llm/src/hugegraph_llm/operators/hugegraph_op/graph_rag_query.py [0:0]


    def init_client(self, context):
        """Initialize the HugeGraph client from context or default settings."""
        # pylint: disable=R0915 (too-many-statements)
        if self._client is None:
            if isinstance(context.get("graph_client"), PyHugeClient):
                self._client = context["graph_client"]
            else:
                ip = context.get("ip") or "localhost"
                port = context.get("port") or "8080"
                graph = context.get("graph") or "hugegraph"
                user = context.get("user") or "admin"
                pwd = context.get("pwd") or "admin"
                gs = context.get("graphspace") or None
                self._client = PyHugeClient(ip, port, graph, user, pwd, gs)
        assert self._client is not None, "No valid graph to search."