def _apply_single_operation(
        self, data: Dict[str, Any], operation: PatchOperation
    ) -> None:
        """Apply a single patch operation to the data dictionary."""
        path_parts = self._parse_path(operation.path)

        # Validate path before applying operation
        if operation.op in ["add", "replace"]:
            self._validate_path_against_schema(path_parts, self.pydantic_cls)

        if operation.op == "replace":
            self._set_value_at_path(data, path_parts, operation.value)

        elif operation.op == "add":
            self._add_value_at_path(data, path_parts, operation.value)

        elif operation.op == "remove":
            self._remove_value_at_path(data, path_parts)

        elif operation.op == "move":
            if not operation.from_path:
                raise ValueError("'move' operation requires 'from_path'")
            from_parts = self._parse_path(operation.from_path)
            to_parts = path_parts
            # Validate both paths
            self._validate_path_against_schema(to_parts, self.pydantic_cls)
            value = self._get_value_at_path(data, from_parts)
            self._remove_value_at_path(data, from_parts)
            self._set_value_at_path(data, to_parts, value)

        elif operation.op == "copy":
            if not operation.from_path:
                raise ValueError("'copy' operation requires 'from_path'")
            from_parts = self._parse_path(operation.from_path)
            to_parts = path_parts
            # Validate target path
            self._validate_path_against_schema(to_parts, self.pydantic_cls)
            value = self._get_value_at_path(data, from_parts)
            self._set_value_at_path(data, to_parts, value)

        else:
            raise ValueError(f"Unknown operation: {operation.op}")
Apply a single patch operation to the data dictionary.
llama-index-integrations/tools/llama-index-tools-artifact-editor/llama_index/tools/artifact_editor/base.py