Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions examples/text_embedding/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def text_to_embedding(
@cocoindex.flow_def(name="TextEmbedding")
def text_embedding_flow(
flow_builder: cocoindex.FlowBuilder, data_scope: cocoindex.DataScope
):
) -> None:
"""
Define an example flow that embeds text into a vector database.
"""
Expand Down Expand Up @@ -65,7 +65,7 @@ def text_embedding_flow(
)


def search(pool: ConnectionPool, query: str, top_k: int = 5):
def search(pool: ConnectionPool, query: str, top_k: int = 5) -> list[dict[str, Any]]:
# Get the table name, for the export target in the text_embedding_flow above.
table_name = cocoindex.utils.get_target_default_name(
text_embedding_flow, "doc_embeddings"
Expand All @@ -89,7 +89,7 @@ def search(pool: ConnectionPool, query: str, top_k: int = 5):
]


def _main():
def _main() -> None:
# Initialize the database connection pool.
pool = ConnectionPool(os.getenv("COCOINDEX_DATABASE_URL"))
# Run queries in a loop to demonstrate the query capabilities.
Expand Down
2 changes: 1 addition & 1 deletion python/cocoindex/flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def for_each(self, f: Callable[[DataScope], None]) -> None:

def transform(
self, fn_spec: op.FunctionSpec, *args: Any, **kwargs: Any
) -> DataSlice[T]:
) -> DataSlice[Any]:
"""
Apply a function to the data slice.
"""
Expand Down