Skip to content

Commit 800ceb2

Browse files
authored
example: switch from storages to targets (#626)
* example: switch from `storages` to `targets` * examples: bump cocoindex version number
1 parent 9a97191 commit 800ceb2

File tree

27 files changed

+73
-73
lines changed

27 files changed

+73
-73
lines changed

examples/amazon_s3_embedding/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def amazon_s3_text_embedding_flow(
6161

6262
doc_embeddings.export(
6363
"doc_embeddings",
64-
cocoindex.storages.Postgres(),
64+
cocoindex.targets.Postgres(),
6565
primary_key_fields=["filename", "location"],
6666
vector_indexes=[
6767
cocoindex.VectorIndexDef(
@@ -74,7 +74,7 @@ def amazon_s3_text_embedding_flow(
7474

7575
def search(pool: ConnectionPool, query: str, top_k: int = 5):
7676
# Get the table name, for the export target in the amazon_s3_text_embedding_flow above.
77-
table_name = cocoindex.utils.get_target_storage_default_name(
77+
table_name = cocoindex.utils.get_target_default_name(
7878
amazon_s3_text_embedding_flow, "doc_embeddings"
7979
)
8080
# Evaluate the transform flow defined above with the input query, to get the embedding.

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.42", "python-dotenv>=1.0.1"]
6+
dependencies = ["cocoindex>=0.1.52", "python-dotenv>=1.0.1"]
77

88
[tool.setuptools]
99
packages = []

examples/code_embedding/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def code_embedding_flow(
6060

6161
code_embeddings.export(
6262
"code_embeddings",
63-
cocoindex.storages.Postgres(),
63+
cocoindex.targets.Postgres(),
6464
primary_key_fields=["filename", "location"],
6565
vector_indexes=[
6666
cocoindex.VectorIndexDef(
@@ -73,7 +73,7 @@ def code_embedding_flow(
7373

7474
def search(pool: ConnectionPool, query: str, top_k: int = 5):
7575
# Get the table name, for the export target in the code_embedding_flow above.
76-
table_name = cocoindex.utils.get_target_storage_default_name(
76+
table_name = cocoindex.utils.get_target_default_name(
7777
code_embedding_flow, "code_embeddings"
7878
)
7979
# Evaluate the transform flow defined above with the input query, to get the embedding.

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.42", "python-dotenv>=1.0.1"]
6+
dependencies = ["cocoindex>=0.1.52", "python-dotenv>=1.0.1"]
77

88
[tool.setuptools]
99
packages = []

examples/docs_to_knowledge_graph/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ Please drop [Cocoindex on Github](https://github.com/cocoindex-io/cocoindex) a s
1414

1515
## Prerequisite
1616
* [Install Postgres](https://cocoindex.io/docs/getting_started/installation#-install-postgres) if you don't have one.
17-
* Install [Neo4j](https://cocoindex.io/docs/ops/storages#neo4j-dev-instance) or [Kuzu](https://cocoindex.io/docs/ops/storages#kuzu-dev-instance) if you don't have one.
17+
* Install [Neo4j](https://cocoindex.io/docs/ops/targets#neo4j-dev-instance) or [Kuzu](https://cocoindex.io/docs/ops/targets#kuzu-dev-instance) if you don't have one.
1818
* The example uses Neo4j by default for now. If you want to use Kuzu, find out the "SELECT ONE GRAPH DATABASE TO USE" section and switch the active branch.
1919
* [Configure your OpenAI API key](https://cocoindex.io/docs/ai/llm#openai).
2020

2121
## Documentation
22-
You can read the official CocoIndex Documentation for Property Graph Targets [here](https://cocoindex.io/docs/ops/storages#property-graph-targets).
22+
You can read the official CocoIndex Documentation for Property Graph Targets [here](https://cocoindex.io/docs/ops/targets#property-graph-targets).
2323

2424
## Run
2525

@@ -48,7 +48,7 @@ cocoindex update main.py
4848
After the knowledge graph is built, you can explore the knowledge graph.
4949

5050
* If you're using Neo4j, you can open the explorer at [http://localhost:7474](http://localhost:7474), with username `neo4j` and password `cocoindex`.
51-
* If you're using Kuzu, you can start a Kuzu explorer locally. See [Kuzu dev instance](https://cocoindex.io/docs/ops/storages#kuzu-dev-instance) for more details.
51+
* If you're using Kuzu, you can start a Kuzu explorer locally. See [Kuzu dev instance](https://cocoindex.io/docs/ops/targets#kuzu-dev-instance) for more details.
5252

5353
You can run the following Cypher query to get all relationships:
5454

examples/docs_to_knowledge_graph/main.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77

88
neo4j_conn_spec = cocoindex.add_auth_entry(
99
"Neo4jConnection",
10-
cocoindex.storages.Neo4jConnection(
10+
cocoindex.targets.Neo4jConnection(
1111
uri="bolt://localhost:7687",
1212
user="neo4j",
1313
password="cocoindex",
1414
),
1515
)
1616
kuzu_conn_spec = cocoindex.add_auth_entry(
1717
"KuzuConnection",
18-
cocoindex.storages.KuzuConnection(
18+
cocoindex.targets.KuzuConnection(
1919
api_server_url="http://localhost:8123",
2020
),
2121
)
@@ -25,15 +25,15 @@
2525
# Please make sure only one branch is live and others are commented out.
2626

2727
# Use Neo4j
28-
GraphDbSpec = cocoindex.storages.Neo4j
29-
GraphDbConnection = cocoindex.storages.Neo4jConnection
30-
GraphDbDeclaration = cocoindex.storages.Neo4jDeclaration
28+
GraphDbSpec = cocoindex.targets.Neo4j
29+
GraphDbConnection = cocoindex.targets.Neo4jConnection
30+
GraphDbDeclaration = cocoindex.targets.Neo4jDeclaration
3131
conn_spec = neo4j_conn_spec
3232

3333
# Use Kuzu
34-
# GraphDbSpec = cocoindex.storages.Kuzu
35-
# GraphDbConnection = cocoindex.storages.KuzuConnection
36-
# GraphDbDeclaration = cocoindex.storages.KuzuDeclaration
34+
# GraphDbSpec = cocoindex.targets.Kuzu
35+
# GraphDbConnection = cocoindex.targets.KuzuConnection
36+
# GraphDbDeclaration = cocoindex.targets.KuzuDeclaration
3737
# conn_spec = kuzu_conn_spec
3838

3939

@@ -134,7 +134,7 @@ def docs_to_kg_flow(
134134
document_node.export(
135135
"document_node",
136136
GraphDbSpec(
137-
connection=conn_spec, mapping=cocoindex.storages.Nodes(label="Document")
137+
connection=conn_spec, mapping=cocoindex.targets.Nodes(label="Document")
138138
),
139139
primary_key_fields=["filename"],
140140
)
@@ -150,20 +150,20 @@ def docs_to_kg_flow(
150150
"entity_relationship",
151151
GraphDbSpec(
152152
connection=conn_spec,
153-
mapping=cocoindex.storages.Relationships(
153+
mapping=cocoindex.targets.Relationships(
154154
rel_type="RELATIONSHIP",
155-
source=cocoindex.storages.NodeFromFields(
155+
source=cocoindex.targets.NodeFromFields(
156156
label="Entity",
157157
fields=[
158-
cocoindex.storages.TargetFieldMapping(
158+
cocoindex.targets.TargetFieldMapping(
159159
source="subject", target="value"
160160
),
161161
],
162162
),
163-
target=cocoindex.storages.NodeFromFields(
163+
target=cocoindex.targets.NodeFromFields(
164164
label="Entity",
165165
fields=[
166-
cocoindex.storages.TargetFieldMapping(
166+
cocoindex.targets.TargetFieldMapping(
167167
source="object", target="value"
168168
),
169169
],
@@ -176,16 +176,16 @@ def docs_to_kg_flow(
176176
"entity_mention",
177177
GraphDbSpec(
178178
connection=conn_spec,
179-
mapping=cocoindex.storages.Relationships(
179+
mapping=cocoindex.targets.Relationships(
180180
rel_type="MENTION",
181-
source=cocoindex.storages.NodeFromFields(
181+
source=cocoindex.targets.NodeFromFields(
182182
label="Document",
183-
fields=[cocoindex.storages.TargetFieldMapping("filename")],
183+
fields=[cocoindex.targets.TargetFieldMapping("filename")],
184184
),
185-
target=cocoindex.storages.NodeFromFields(
185+
target=cocoindex.targets.NodeFromFields(
186186
label="Entity",
187187
fields=[
188-
cocoindex.storages.TargetFieldMapping(
188+
cocoindex.targets.TargetFieldMapping(
189189
source="entity", target="value"
190190
)
191191
],

examples/docs_to_knowledge_graph/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "manuals-to-kg"
33
version = "0.1.0"
44
description = "Simple example for cocoindex: extract triples from files and build knowledge graph."
55
requires-python = ">=3.11"
6-
dependencies = ["cocoindex>=0.1.42"]
6+
dependencies = ["cocoindex>=0.1.52"]
77

88
[tool.setuptools]
99
packages = []

examples/fastapi_server_docker/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def markdown_embedding_flow(
5454

5555
doc_embeddings.export(
5656
"doc_embeddings",
57-
cocoindex.storages.Postgres(),
57+
cocoindex.targets.Postgres(),
5858
primary_key_fields=["filename", "location"],
5959
vector_indexes=[
6060
cocoindex.VectorIndexDef(
@@ -67,7 +67,7 @@ def markdown_embedding_flow(
6767

6868
def search(pool: ConnectionPool, query: str, top_k: int = 5):
6969
# Get the table name, for the export target in the text_embedding_flow above.
70-
table_name = cocoindex.utils.get_target_storage_default_name(
70+
table_name = cocoindex.utils.get_target_default_name(
7171
markdown_embedding_flow, "doc_embeddings"
7272
)
7373
# Evaluate the transform flow defined above with the input query, to get the embedding.

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.42
1+
cocoindex>=0.1.52
22
python-dotenv>=1.0.1
33
fastapi==0.115.12
44
fastapi-cli==0.0.7

examples/gdrive_text_embedding/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def gdrive_text_embedding_flow(
6060

6161
doc_embeddings.export(
6262
"doc_embeddings",
63-
cocoindex.storages.Postgres(),
63+
cocoindex.targets.Postgres(),
6464
primary_key_fields=["filename", "location"],
6565
vector_indexes=[
6666
cocoindex.VectorIndexDef(
@@ -73,7 +73,7 @@ def gdrive_text_embedding_flow(
7373

7474
def search(pool: ConnectionPool, query: str, top_k: int = 5):
7575
# Get the table name, for the export target in the gdrive_text_embedding_flow above.
76-
table_name = cocoindex.utils.get_target_storage_default_name(
76+
table_name = cocoindex.utils.get_target_default_name(
7777
gdrive_text_embedding_flow, "doc_embeddings"
7878
)
7979
# Evaluate the transform flow defined above with the input query, to get the embedding.

0 commit comments

Comments
 (0)