from_texts() — langchain Function Reference
Architecture documentation for the from_texts() function in vectorstores.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 8333d70f_d25a_107c_0310_d6f0ca8ca56e["from_texts()"] d25f9e94_3ec0_b9ca_7d2f_eb7ef487ccab["Chroma"] 8333d70f_d25a_107c_0310_d6f0ca8ca56e -->|defined in| d25f9e94_3ec0_b9ca_7d2f_eb7ef487ccab 47dbea0f_8a83_dbee_34f5_9406b1ac209b["from_documents()"] 47dbea0f_8a83_dbee_34f5_9406b1ac209b -->|calls| 8333d70f_d25a_107c_0310_d6f0ca8ca56e c6cde3f6_740c_9c74_569c_bdc91a7bd836["add_texts()"] 8333d70f_d25a_107c_0310_d6f0ca8ca56e -->|calls| c6cde3f6_740c_9c74_569c_bdc91a7bd836 style 8333d70f_d25a_107c_0310_d6f0ca8ca56e fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/partners/chroma/langchain_chroma/vectorstores.py lines 1273–1372
def from_texts(
cls: type[Chroma],
texts: list[str],
embedding: Embeddings | None = None,
metadatas: list[dict] | None = None,
ids: list[str] | None = None,
collection_name: str = _LANGCHAIN_DEFAULT_COLLECTION_NAME,
persist_directory: str | None = None,
host: str | None = None,
port: int | None = None,
headers: dict[str, str] | None = None,
chroma_cloud_api_key: str | None = None,
tenant: str | None = None,
database: str | None = None,
client_settings: chromadb.config.Settings | None = None,
client: chromadb.ClientAPI | None = None,
collection_metadata: dict | None = None,
collection_configuration: CreateCollectionConfiguration | None = None,
*,
ssl: bool = False,
**kwargs: Any,
) -> Chroma:
"""Create a Chroma vectorstore from a raw documents.
If a persist_directory is specified, the collection will be persisted there.
Otherwise, the data will be ephemeral in-memory.
Args:
texts: List of texts to add to the collection.
collection_name: Name of the collection to create.
persist_directory: Directory to persist the collection.
host: Hostname of a deployed Chroma server.
port: Connection port for a deployed Chroma server.
Default is 8000.
ssl: Whether to establish an SSL connection with a deployed Chroma server.
Default is False.
headers: HTTP headers to send to a deployed Chroma server.
chroma_cloud_api_key: Chroma Cloud API key.
tenant: Tenant ID. Required for Chroma Cloud connections.
Default is 'default_tenant' for local Chroma servers.
database: Database name. Required for Chroma Cloud connections.
Default is 'default_database'.
embedding: Embedding function.
metadatas: List of metadatas.
ids: List of document IDs.
client_settings: Chroma client settings.
client: Chroma client. Documentation:
https://docs.trychroma.com/reference/python/client
collection_metadata: Collection configurations.
collection_configuration: Index configuration for the collection.
kwargs: Additional keyword arguments to initialize a Chroma client.
Returns:
Chroma: Chroma vectorstore.
"""
chroma_collection = cls(
collection_name=collection_name,
embedding_function=embedding,
persist_directory=persist_directory,
host=host,
port=port,
ssl=ssl,
headers=headers,
chroma_cloud_api_key=chroma_cloud_api_key,
tenant=tenant,
database=database,
client_settings=client_settings,
client=client,
collection_metadata=collection_metadata,
collection_configuration=collection_configuration,
**kwargs,
)
if ids is None:
ids = [str(uuid.uuid4()) for _ in texts]
else:
ids = [id_ if id_ is not None else str(uuid.uuid4()) for id_ in ids]
if hasattr(
chroma_collection._client,
"get_max_batch_size",
) or hasattr( # for Chroma 0.5.1 and above
Domain
Subdomains
Calls
Called By
Source
Frequently Asked Questions
What does from_texts() do?
from_texts() is a function in the langchain codebase, defined in libs/partners/chroma/langchain_chroma/vectorstores.py.
Where is from_texts() defined?
from_texts() is defined in libs/partners/chroma/langchain_chroma/vectorstores.py at line 1273.
What does from_texts() call?
from_texts() calls 1 function(s): add_texts.
What calls from_texts()?
from_texts() is called by 1 function(s): from_documents.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free