Skip to content

Commit dccf195

Browse files
authored
docs: add documents for related_arg_attr (#787)
* docs: add documents for `related_arg_attr` * refactor: one more rename
1 parent 2eba6d6 commit dccf195

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed

docs/docs/core/custom_function.mdx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,17 @@ Custom functions take the following additional parameters:
148148
When the version is changed, the function will be re-executed even if cache is enabled.
149149
It's required to be set if `cache` is `True`.
150150

151+
* `arg_relationship: tuple[ArgRelationship, str]`: It specifies the relationship between an input argument and the output,
152+
e.g. `(ArgRelationship.CHUNKS_BASE_TEXT, "content")` means the output is chunks for the text represented by the
153+
input argument with name `content`.
154+
This provides metadata for tools, e.g. CocoInsight.
155+
Currently the following attributes are supported:
156+
157+
* `ArgRelationship.CHUNKS_BASE_TEXT`:
158+
The output is chunks for the text represented by the input argument. In this case, the output is expected to be a *Table*, whose each row represents a text chunk, and the first column has type *Range*, representing the range of the text chunk.
159+
* `ArgRelationship.EMBEDDING_ORIGIN_TEXT`: The output is embedding vector for the text represented by the input argument. The output is expected to be a *Vector*.
160+
* `ArgRelationship.RECTS_BASE_IMAGE`: The output is rectangles for the image represented by the input argument. The output is expected to be a *Table*, whose each row represents a rectangle, and the first column has type *Struct*, with fields `min_x`, `min_y`, `max_x`, `max_y` to represent the coordinates of the rectangle.
161+
151162
For example:
152163

153164
<Tabs>

python/cocoindex/functions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class SentenceTransformerEmbed(op.FunctionSpec):
7070
gpu=True,
7171
cache=True,
7272
behavior_version=1,
73-
arg_relationship=(op.ArgRelationship.VECTOR_ORIGIN_TEXT, "text"),
73+
arg_relationship=(op.ArgRelationship.EMBEDDING_ORIGIN_TEXT, "text"),
7474
)
7575
class SentenceTransformerEmbedExecutor:
7676
"""Executor for SentenceTransformerEmbed."""

python/cocoindex/op.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def __call__(
9191
class ArgRelationship(Enum):
9292
"""Specifies the relationship between an input argument and the output."""
9393

94-
VECTOR_ORIGIN_TEXT = _COCOINDEX_ATTR_PREFIX + "vector_origin_text"
94+
EMBEDDING_ORIGIN_TEXT = _COCOINDEX_ATTR_PREFIX + "embedding_origin_text"
9595
CHUNKS_BASE_TEXT = _COCOINDEX_ATTR_PREFIX + "chunk_base_text"
9696
RECTS_BASE_IMAGE = _COCOINDEX_ATTR_PREFIX + "rects_base_image"
9797

src/base/field_attrs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ pub static CONTENT_MIME_TYPE: &str = concatcp!(COCOINDEX_PREFIX, "content_mime_t
1515
pub static CHUNK_BASE_TEXT: &str = concatcp!(COCOINDEX_PREFIX, "chunk_base_text");
1616

1717
/// Base text for an embedding vector.
18-
pub static _VECTOR_ORIGIN_TEXT: &str = concatcp!(COCOINDEX_PREFIX, "vector_origin_text");
18+
pub static _EMBEDDING_ORIGIN_TEXT: &str = concatcp!(COCOINDEX_PREFIX, "embedding_origin_text");

0 commit comments

Comments
 (0)