timeout=timeout,
            lambda_mult=lambda_mult,
        )
        return docs
[docs]    def max_marginal_relevance_search_by_vector(
        self,
        embedding: List[float],
        k: int = 4,
        fetch_k: int = 20,
        lambda_mult: float = 0.5,
        radius: float = -1.0,
        epsilon: float = 0.01,
        timeout: int = 3000000000,
        **kwargs: Any,
    ) -> List[Document]:
        try:
            import grpc
            from vald.v1.payload import payload_pb2
            from vald.v1.vald import object_pb2_grpc
        except ImportError:
            raise ValueError(
                "Could not import vald-client-python python package. "
                "Please install it with `pip install vald-client-python`."
            )
        channel = grpc.insecure_channel(self.target, options=self.grpc_options)
        # Depending on the network quality,
        # it is necessary to wait for ChannelConnectivity.READY.
        # _ = grpc.channel_ready_future(channel).result(timeout=10)
        stub = object_pb2_grpc.ObjectStub(channel)
        docs_and_scores = self.similarity_search_with_score_by_vector(
            embedding, fetch_k=fetch_k, radius=radius, epsilon=epsilon, timeout=timeout
        )
        docs = []
        embs = []
        for doc, _ in docs_and_scores:
            vec = stub.GetObject(
                payload_pb2.Object.VectorRequest(
                    id=payload_pb2.Object.ID(id=doc.page_content)
                )
            )
            embs.append(vec.vector)
            docs.append(doc)
        mmr = maximal_marginal_relevance(