Skip to content

Commit 1f29ba3

Browse files
Make sentence_transformers an optional dependency (#674)
* fix: Make sentence_transformers an optional dependency - Move sentence_transformers to optional dependencies in pyproject.toml - Add conditional import in features.py - Update __init__.py to only export SentenceTransformerEmbed when available - Add installation instructions to examples Fixes #636 * Update examples for optional sentence_transformers dependency - Add sentence-transformers to pyproject.toml dependencies in all 7 examples - Update README files with installation instructions for SentenceTransformerEmbed - Add clear dependency notes to examples that use sentence transformers Part of #636 * docs: update installation instructions for optional sentence-transformers dependency - Update quickstart.md: change pip install command to include [sentence-transformers] extra - Update functions.md: add optional dependency note for SentenceTransformerEmbed function - Remove manual 'pip install sentence-transformers' instructions from all example README.md and main.py files * reverted the extra indents in quickstart.md * rename optional dependency group to 'embeddings' - Updated pyproject.toml to use [embeddings] instead of [sentence-transformers] for the optional dependency group - Replaced all install instructions using 'cocoindex[sentence-transformers]' with 'cocoindex[embeddings]' across docs and examples -
1 parent 8e807c1 commit 1f29ba3

File tree

12 files changed

+39
-9
lines changed

12 files changed

+39
-9
lines changed

docs/docs/getting_started/quickstart.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ We'll need to install a bunch of dependencies for this project.
2121
1. Install CocoIndex:
2222

2323
```bash
24-
pip install -U cocoindex
24+
pip install -U 'cocoindex[embeddings]'
2525
```
2626

2727
2. You can skip this step if you already have a Postgres database with pgvector extension installed.

docs/docs/ops/functions.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,15 @@ Return: [*KTable*](/docs/core/data_types#ktable), each row represents a chunk, w
7777

7878
`SentenceTransformerEmbed` embeds a text into a vector space using the [SentenceTransformer](https://huggingface.co/sentence-transformers) library.
7979

80+
:::note Optional Dependency Required
81+
82+
This function requires the 'sentence-transformers' library, which is an optional dependency. Install CocoIndex with:
83+
84+
```bash
85+
pip install 'cocoindex[embeddings]'
86+
```
87+
:::
88+
8089
The spec takes the following fields:
8190

8291
* `model` (`str`): The name of the SentenceTransformer model to use.

examples/amazon_s3_embedding/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "amazon-s3-text-embedding"
33
version = "0.1.0"
44
description = "Simple example for cocoindex: build embedding index based on Amazon S3 files."
55
requires-python = ">=3.11"
6-
dependencies = ["cocoindex>=0.1.52", "python-dotenv>=1.0.1"]
6+
dependencies = ["cocoindex[embeddings]>=0.1.52", "python-dotenv>=1.0.1"]
77

88
[tool.setuptools]
99
packages = []

examples/code_embedding/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "code-embedding"
33
version = "0.1.0"
44
description = "Simple example for cocoindex: build embedding index based on source code."
55
requires-python = ">=3.11"
6-
dependencies = ["cocoindex>=0.1.56", "python-dotenv>=1.0.1"]
6+
dependencies = ["cocoindex[embeddings]>=0.1.56", "python-dotenv>=1.0.1"]
77

88
[tool.setuptools]
99
packages = []

examples/fastapi_server_docker/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cocoindex>=0.1.52
1+
cocoindex[embeddings]>=0.1.52
22
python-dotenv>=1.0.1
33
fastapi==0.115.12
44
fastapi-cli==0.0.7

examples/gdrive_text_embedding/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "gdrive-text-embedding"
33
version = "0.1.0"
44
description = "Simple example for cocoindex: build embedding index based on Google Drive files."
55
requires-python = ">=3.11"
6-
dependencies = ["cocoindex>=0.1.52", "python-dotenv>=1.0.1"]
6+
dependencies = ["cocoindex[embeddings]>=0.1.52", "python-dotenv>=1.0.1"]
77

88
[tool.setuptools]
99
packages = []

examples/pdf_embedding/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ version = "0.1.0"
44
description = "Simple example for cocoindex: build embedding index based on local PDF files."
55
requires-python = ">=3.11"
66
dependencies = [
7-
"cocoindex>=0.1.52",
7+
"cocoindex[embeddings]>=0.1.52",
88
"python-dotenv>=1.0.1",
99
"marker-pdf>=1.5.2",
1010
]

examples/text_embedding/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ version = "0.1.0"
44
description = "Simple example for cocoindex: build embedding index based on local text files."
55
requires-python = ">=3.11"
66
dependencies = [
7-
"cocoindex>=0.1.52",
7+
"cocoindex[embeddings]>=0.1.52",
88
"python-dotenv>=1.0.1",
99
"pgvector>=0.4.1",
1010
"psycopg[binary,pool]",

examples/text_embedding_qdrant/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ We use Qdrant client to query the index, and reuse the embedding operation in th
3737
pip install -e .
3838
```
3939

40+
4041
- Setup:
4142

4243
```bash

examples/text_embedding_qdrant/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ version = "0.1.0"
44
description = "Simple example for cocoindex: build embedding index based on local text files."
55
requires-python = ">=3.11"
66
dependencies = [
7-
"cocoindex>=0.1.52",
7+
"cocoindex[embeddings]>=0.1.52",
88
"python-dotenv>=1.0.1",
99
"qdrant-client>=1.6.0",
1010
]

0 commit comments

Comments
 (0)