"Please install it with `pip install langsmith`"
            ) from e
        self.dataset_name = dataset_name
        self.client = client or Client()
[docs]    def lazy_load(self) -> Iterator[ChatSession]:
        """
        Lazy load the chat sessions from the specified LangSmith dataset.
        This method fetches the chat data from the dataset and
        converts each data point to chat sessions on-the-fly,
        yielding one session at a time.
        :return: Iterator of chat sessions containing messages.
        """
        from langchain_community.adapters import openai as oai_adapter  # noqa: E402
        data = self.client.read_dataset_openai_finetuning(
            dataset_name=self.dataset_name
        )
        for data_point in data:
            yield ChatSession(
                messages=[
                    oai_adapter.convert_dict_to_message(m)
                    for m in data_point.get("messages", [])
                ],
                functions=data_point.get("functions"),
            )