Skip to content

Commit 9005a2d

Browse files
committed
COH-31299 - Add documentation for AI in Sphinx
1 parent 540571a commit 9005a2d

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

docs/api_reference.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ Modules
112112
:maxdepth: 3
113113
:titlesonly:
114114

115+
api_reference/ai.rst
115116
api_reference/aggregator.rst
116117
api_reference/comparator.rst
117118
api_reference/event.rst

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ pytest-asyncio = "~0.25"
3737
pytest-cov = "~6.0"
3838
pytest-unordered = "~0.6"
3939
pre-commit = "~4.1"
40+
docutils="~0.20"
4041
Sphinx = "~7.4"
4142
sphinx-rtd-theme = "~3.0"
4243
sphinxcontrib-napoleon = "~0.7"

src/coherence/ai.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
class Vector(ABC):
2727
"""
2828
Base class that represents a Vector
29+
30+
**NOTE:** This requires using Coherence CE 24.09.2+ on the server side
2931
"""
3032

3133
def __init__(self) -> None:
@@ -39,6 +41,8 @@ def __init__(self) -> None:
3941
class BitVector(Vector):
4042
"""
4143
Class that represents a Vector of Bits
44+
45+
**NOTE:** This requires using Coherence CE 24.09.2+ on the server side
4246
"""
4347

4448
def __init__(
@@ -73,6 +77,8 @@ def __init__(
7377
class ByteVector(Vector):
7478
"""
7579
Class that represents Vector of bytes
80+
81+
**NOTE:** This requires using Coherence CE 24.09.2+ on the server side
7682
"""
7783

7884
def __init__(self, byte_array: bytes):
@@ -89,6 +95,8 @@ def __init__(self, byte_array: bytes):
8995
class FloatVector(Vector):
9096
"""
9197
Class that represents Vector of floats
98+
99+
**NOTE:** This requires using Coherence CE 24.09.2+ on the server side
92100
"""
93101

94102
def __init__(self, float_array: List[float]):
@@ -111,12 +119,14 @@ def __init__(self, data_version: int = 0, bin_future: Optional[Any] = None):
111119
class DocumentChunk(AbstractEvolvable):
112120
"""
113121
Class that represents a chunk of text extracted from a document.
122+
123+
**NOTE:** This requires using Coherence CE 24.09.2+ on the server side
114124
"""
115125

116126
def __init__(
117127
self,
118128
text: str,
119-
metadata: Optional[Dict[str, Any] | OrderedDict[str, Any]] = None,
129+
metadata: Optional[Union[Dict[str, Any], OrderedDict[str, Any]]] = None,
120130
vector: Optional[Vector] = None,
121131
):
122132
"""
@@ -183,6 +193,8 @@ def restore(self, obj: Dict[str, Any]) -> DocumentChunk:
183193
class DistanceAlgorithm(ABC):
184194
"""
185195
Base class that represents algorithm that can calculate distance to a given vector
196+
197+
**NOTE:** This requires using Coherence CE 24.09.2+ on the server side
186198
"""
187199

188200
def __init__(self) -> None:
@@ -198,6 +210,8 @@ class CosineDistance(DistanceAlgorithm):
198210
between two vectors and determines whether two vectors are pointing in
199211
roughly the same direction. It is often used to measure document similarity
200212
in text analysis.
213+
214+
**NOTE:** This requires using Coherence CE 24.09.2+ on the server side
201215
"""
202216

203217
def __init__(self) -> None:
@@ -209,6 +223,8 @@ class InnerProductDistance(DistanceAlgorithm):
209223
"""
210224
Represents a DistanceAlgorithm that performs inner product distance
211225
calculation between two vectors.
226+
227+
**NOTE:** This requires using Coherence CE 24.09.2+ on the server side
212228
"""
213229

214230
def __init__(self) -> None:
@@ -220,6 +236,8 @@ class L2SquaredDistance(DistanceAlgorithm):
220236
"""
221237
Represents a DistanceAlgorithm that performs an L2 squared distance
222238
calculation between two vectors.
239+
240+
**NOTE:** This requires using Coherence CE 24.09.2+ on the server side
223241
"""
224242

225243
def __init__(self) -> None:
@@ -230,6 +248,8 @@ def __init__(self) -> None:
230248
class SimilaritySearch(EntryAggregator):
231249
"""
232250
This class represents an aggregator to execute a similarity query.
251+
252+
**NOTE:** This requires using Coherence CE 24.09.2+ on the server side
233253
"""
234254

235255
def __init__(
@@ -265,6 +285,8 @@ def __init__(
265285
class BaseQueryResult(ABC):
266286
"""
267287
A base class for QueryResult implementation
288+
289+
**NOTE:** This requires using Coherence CE 24.09.2+ on the server side
268290
"""
269291

270292
def __init__(self, result: float, key: K, value: V) -> None:
@@ -277,6 +299,8 @@ def __init__(self, result: float, key: K, value: V) -> None:
277299
class QueryResult(BaseQueryResult):
278300
"""
279301
QueryResult class
302+
303+
**NOTE:** This requires using Coherence CE 24.09.2+ on the server side
280304
"""
281305

282306
def __init__(self, result: float, key: K, value: V) -> None:
@@ -297,6 +321,8 @@ def __str__(self) -> str:
297321
class BinaryQuantIndex(AbstractEvolvable):
298322
"""
299323
This class represents a custom index using binary quantization of vectors
324+
325+
**NOTE:** This requires using Coherence CE 24.09.2+ on the server side
300326
"""
301327

302328
def __init__(self, extractor: Union[ValueExtractor[T, E], str], over_sampling_factor: int = 3) -> None:

0 commit comments

Comments
 (0)