aboutsummaryrefslogtreecommitdiff
path: root/R2R/r2r/vecs/adapter/noop.py
diff options
context:
space:
mode:
authorS. Solomon Darnell2025-03-28 21:52:21 -0500
committerS. Solomon Darnell2025-03-28 21:52:21 -0500
commit4a52a71956a8d46fcb7294ac71734504bb09bcc2 (patch)
treeee3dc5af3b6313e921cd920906356f5d4febc4ed /R2R/r2r/vecs/adapter/noop.py
parentcc961e04ba734dd72309fb548a2f97d67d578813 (diff)
downloadgn-ai-master.tar.gz
two version of R2R are hereHEADmaster
Diffstat (limited to 'R2R/r2r/vecs/adapter/noop.py')
-rwxr-xr-xR2R/r2r/vecs/adapter/noop.py55
1 files changed, 55 insertions, 0 deletions
diff --git a/R2R/r2r/vecs/adapter/noop.py b/R2R/r2r/vecs/adapter/noop.py
new file mode 100755
index 00000000..b587a552
--- /dev/null
+++ b/R2R/r2r/vecs/adapter/noop.py
@@ -0,0 +1,55 @@
+"""
+The `vecs.experimental.adapter.noop` module provides a default no-op (no operation) adapter
+that passes the inputs through without any modification. This can be useful when no specific
+adapter processing is required.
+
+All public classes, enums, and functions are re-exported by `vecs.adapters` module.
+"""
+
+from typing import Any, Dict, Generator, Iterable, Optional, Tuple
+
+from .base import AdapterContext, AdapterStep
+
+
+class NoOp(AdapterStep):
+ """
+ NoOp is a no-operation AdapterStep. It is a default adapter that passes through
+ the input records without any modifications.
+ """
+
+ def __init__(self, dimension: int):
+ """
+ Initializes the NoOp adapter with a dimension.
+
+ Args:
+ dimension (int): The dimension of the input vectors.
+ """
+ self._dimension = dimension
+
+ @property
+ def exported_dimension(self) -> Optional[int]:
+ """
+ Returns the dimension of the adapter.
+
+ Returns:
+ int: The dimension of the input vectors.
+ """
+ return self._dimension
+
+ def __call__(
+ self,
+ records: Iterable[Tuple[str, Any, Optional[Dict]]],
+ adapter_context: AdapterContext,
+ ) -> Generator[Tuple[str, Any, Dict], None, None]:
+ """
+ Yields the input records without any modification.
+
+ Args:
+ records: Iterable of tuples each containing an id, a media and an optional dict.
+ adapter_context: Context of the adapter.
+
+ Yields:
+ Tuple[str, Any, Dict]: The input record.
+ """
+ for id, media, metadata in records:
+ yield (id, media, metadata or {})