Creates a CyborgVectorStore instance from a list of texts.
@classmethod
from_texts(
    texts: List[str],
    embedding: Union[str, Embeddings, SentenceTransformer],
    metadatas: Optional[List[dict]] = None,
    **kwargs
) -> CyborgVectorStore

Parameters

ParameterTypeDescription
textsList[str]List of text strings to add to the store
embeddingUnion[str, Embeddings, SentenceTransformer]Embedding model or model name
metadatasOptional[List[dict]](Optional) List of metadata dictionaries for each text
**kwargsAnyAdditional arguments passed to constructor and add_texts

Keyword Arguments

ParameterTypeDescription
idsList[str](Optional) IDs for the texts
index_namestrName of the index (default: “langchain_index”)
index_keybytes32-byte encryption key (required)
api_keystrAPI key for CyborgDB (required)
index_locationDBConfigIndex storage location (required)
config_locationDBConfigConfig storage location (required)
index_typestrIndex type (default: “ivfflat”)
metricstrDistance metric (default: “cosine”)

Returns

CyborgVectorStore: Initialized vector store with texts added

Exceptions

Example Usage

from cyborgdb_core import DBConfig

# Create store from texts
texts = [
    "Introduction to Python",
    "Advanced Python techniques",
    "Python for data science"
]
metadatas = [
    {"chapter": 1}, 
    {"chapter": 2}, 
    {"chapter": 3}
]

store = CyborgVectorStore.from_texts(
    texts=texts,
    embedding="sentence-transformers/all-MiniLM-L6-v2",
    metadatas=metadatas,
    index_name="python_docs",
    index_key=CyborgVectorStore.generate_key(),
    api_key="your-api-key",
    index_location=DBConfig("s3", bucket="my-bucket"),
    config_location=DBConfig("s3", bucket="my-bucket")
)