File tree Expand file tree Collapse file tree 5 files changed +22
-28
lines changed
index/operations/embed_text Expand file tree Collapse file tree 5 files changed +22
-28
lines changed Original file line number Diff line number Diff line change 2626
2727from graphrag .config .embeddings import (
2828 community_full_content_embedding ,
29+ create_collection_name ,
2930 entity_description_embedding ,
3031 text_unit_text_embedding ,
3132)
4748 read_indexer_text_units ,
4849)
4950from graphrag .utils .cli import redact
50- from graphrag .utils .embeddings import create_collection_name
5151from graphrag .vector_stores .base import BaseVectorStore
5252from graphrag .vector_stores .factory import VectorStoreFactory
5353
Original file line number Diff line number Diff line change @@ -75,3 +75,22 @@ def get_embedding_settings(
7575 return {
7676 "strategy" : strategy ,
7777 }
78+
79+
80+ def create_collection_name (
81+ container_name : str , embedding_name : str , validate : bool = True
82+ ) -> str :
83+ """
84+ Create a collection name for the embedding store.
85+
86+ Within any given vector store, we can have multiple sets of embeddings organized into projects.
87+ The `container` param is used for this partitioning, and is added as a prefix to the collection name for differentiation.
88+
89+ The embedding name is fixed, with the available list defined in graphrag.index.config.embeddings
90+
91+ Note that we use dot notation in our names, but many vector stores do not support this - so we convert to dashes.
92+ """
93+ if validate and embedding_name not in all_embeddings :
94+ msg = f"Invalid embedding name: { embedding_name } "
95+ raise KeyError (msg )
96+ return f"{ container_name } -{ embedding_name } " .replace ("." , "-" )
Original file line number Diff line number Diff line change 1212
1313from graphrag .cache .pipeline_cache import PipelineCache
1414from graphrag .callbacks .workflow_callbacks import WorkflowCallbacks
15+ from graphrag .config .embeddings import create_collection_name
1516from graphrag .index .operations .embed_text .strategies .typing import TextEmbeddingStrategy
16- from graphrag .utils .embeddings import create_collection_name
1717from graphrag .vector_stores .base import BaseVectorStore , VectorStoreDocument
1818from graphrag .vector_stores .factory import VectorStoreFactory
1919
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 33
44import pytest
55
6- from graphrag .utils .embeddings import create_collection_name
6+ from graphrag .config .embeddings import create_collection_name
77
88
99def test_create_collection_name ():
You can’t perform that action at this time.
0 commit comments