Update chromadb import in ChromaSearch.py and Chroma.py (#1984)
* chore: Update chromadb import in ChromaSearch.py and Chroma.py * chore: Update ChromaSearch.py and Chroma.py to use chroma_server_http_port
This commit is contained in:
parent
6491496fc0
commit
ae44092139
4 changed files with 50 additions and 31 deletions
|
|
@ -1,7 +1,7 @@
|
|||
from typing import List, Optional
|
||||
|
||||
import chromadb # type: ignore
|
||||
from langchain_community.vectorstores.chroma import Chroma
|
||||
from chromadb.config import Settings
|
||||
from langchain_chroma import Chroma
|
||||
|
||||
from langflow.components.vectorstores.base.model import LCVectorStoreComponent
|
||||
from langflow.field_typing import Embeddings, Text
|
||||
|
|
@ -39,7 +39,7 @@ class ChromaSearchComponent(LCVectorStoreComponent):
|
|||
"advanced": True,
|
||||
},
|
||||
"chroma_server_host": {"display_name": "Server Host", "advanced": True},
|
||||
"chroma_server_port": {"display_name": "Server Port", "advanced": True},
|
||||
"chroma_server_http_port": {"display_name": "Server HTTP Port", "advanced": True},
|
||||
"chroma_server_grpc_port": {
|
||||
"display_name": "Server gRPC Port",
|
||||
"advanced": True,
|
||||
|
|
@ -64,38 +64,39 @@ class ChromaSearchComponent(LCVectorStoreComponent):
|
|||
chroma_server_ssl_enabled: bool,
|
||||
number_of_results: int = 4,
|
||||
index_directory: Optional[str] = None,
|
||||
chroma_server_cors_allow_origins: Optional[str] = None,
|
||||
chroma_server_cors_allow_origins: List[str] = [],
|
||||
chroma_server_host: Optional[str] = None,
|
||||
chroma_server_port: Optional[int] = None,
|
||||
chroma_server_http_port: Optional[int] = None,
|
||||
chroma_server_grpc_port: Optional[int] = None,
|
||||
) -> List[Record]:
|
||||
"""
|
||||
Builds the Vector Store or BaseRetriever object.
|
||||
|
||||
Args:
|
||||
- input_value (Text): The input value.
|
||||
- search_type (str): The type of search.
|
||||
- collection_name (str): The name of the collection.
|
||||
- persist_directory (Optional[str]): The directory to persist the Vector Store to.
|
||||
- embedding (Embeddings): The embeddings to use for the Vector Store.
|
||||
- chroma_server_ssl_enabled (bool): Whether to enable SSL for the Chroma server.
|
||||
- persist (bool): Whether to persist the Vector Store or not.
|
||||
- embedding (Optional[Embeddings]): The embeddings to use for the Vector Store.
|
||||
- documents (Optional[Document]): The documents to use for the Vector Store.
|
||||
- chroma_server_cors_allow_origins (Optional[str]): The CORS allow origins for the Chroma server.
|
||||
- chroma_server_host (Optional[str]): The host for the Chroma server.
|
||||
- chroma_server_port (Optional[int]): The port for the Chroma server.
|
||||
- chroma_server_grpc_port (Optional[int]): The gRPC port for the Chroma server.
|
||||
- number_of_results (int, optional): The number of results to retrieve. Defaults to 4.
|
||||
- index_directory (str, optional): The directory to persist the Vector Store to. Defaults to None.
|
||||
- chroma_server_cors_allow_origins (List[str], optional): The CORS allow origins for the Chroma server. Defaults to [].
|
||||
- chroma_server_host (str, optional): The host for the Chroma server. Defaults to None.
|
||||
- chroma_server_http_port (int, optional): The HTTP port for the Chroma server. Defaults to None.
|
||||
- chroma_server_grpc_port (int, optional): The gRPC port for the Chroma server. Defaults to None.
|
||||
|
||||
Returns:
|
||||
- Union[VectorStore, BaseRetriever]: The Vector Store or BaseRetriever object.
|
||||
- List[Record]: The list of records.
|
||||
"""
|
||||
|
||||
# Chroma settings
|
||||
chroma_settings = None
|
||||
|
||||
if chroma_server_host is not None:
|
||||
chroma_settings = chromadb.config.Settings(
|
||||
chroma_server_cors_allow_origins=chroma_server_cors_allow_origins or None,
|
||||
chroma_settings = Settings(
|
||||
chroma_server_cors_allow_origins=chroma_server_cors_allow_origins or [],
|
||||
chroma_server_host=chroma_server_host,
|
||||
chroma_server_port=chroma_server_port or None,
|
||||
chroma_server_http_port=chroma_server_http_port or None,
|
||||
chroma_server_grpc_port=chroma_server_grpc_port or None,
|
||||
chroma_server_ssl_enabled=chroma_server_ssl_enabled,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
from typing import List, Optional, Union
|
||||
|
||||
import chromadb # type: ignore
|
||||
from langchain_community.vectorstores.chroma import Chroma
|
||||
from chromadb.config import Settings
|
||||
from langchain_chroma import Chroma
|
||||
from langchain_core.embeddings import Embeddings
|
||||
from langchain_core.retrievers import BaseRetriever
|
||||
from langchain_core.vectorstores import VectorStore
|
||||
|
|
@ -38,7 +38,7 @@ class ChromaComponent(CustomComponent):
|
|||
"advanced": True,
|
||||
},
|
||||
"chroma_server_host": {"display_name": "Server Host", "advanced": True},
|
||||
"chroma_server_port": {"display_name": "Server Port", "advanced": True},
|
||||
"chroma_server_http_port": {"display_name": "Server HTTP Port", "advanced": True},
|
||||
"chroma_server_grpc_port": {
|
||||
"display_name": "Server gRPC Port",
|
||||
"advanced": True,
|
||||
|
|
@ -56,9 +56,9 @@ class ChromaComponent(CustomComponent):
|
|||
chroma_server_ssl_enabled: bool,
|
||||
index_directory: Optional[str] = None,
|
||||
inputs: Optional[List[Record]] = None,
|
||||
chroma_server_cors_allow_origins: Optional[str] = None,
|
||||
chroma_server_cors_allow_origins: List[str] = [],
|
||||
chroma_server_host: Optional[str] = None,
|
||||
chroma_server_port: Optional[int] = None,
|
||||
chroma_server_http_port: Optional[int] = None,
|
||||
chroma_server_grpc_port: Optional[int] = None,
|
||||
) -> Union[VectorStore, BaseRetriever]:
|
||||
"""
|
||||
|
|
@ -66,13 +66,13 @@ class ChromaComponent(CustomComponent):
|
|||
|
||||
Args:
|
||||
- collection_name (str): The name of the collection.
|
||||
- index_directory (Optional[str]): The directory to persist the Vector Store to.
|
||||
- embedding (Embeddings): The embeddings to use for the Vector Store.
|
||||
- chroma_server_ssl_enabled (bool): Whether to enable SSL for the Chroma server.
|
||||
- embedding (Optional[Embeddings]): The embeddings to use for the Vector Store.
|
||||
- documents (Optional[Document]): The documents to use for the Vector Store.
|
||||
- chroma_server_cors_allow_origins (Optional[str]): The CORS allow origins for the Chroma server.
|
||||
- index_directory (Optional[str]): The directory to persist the Vector Store to.
|
||||
- inputs (Optional[List[Record]]): The input records to use for the Vector Store.
|
||||
- chroma_server_cors_allow_origins (List[str]): The CORS allow origins for the Chroma server.
|
||||
- chroma_server_host (Optional[str]): The host for the Chroma server.
|
||||
- chroma_server_port (Optional[int]): The port for the Chroma server.
|
||||
- chroma_server_http_port (Optional[int]): The HTTP port for the Chroma server.
|
||||
- chroma_server_grpc_port (Optional[int]): The gRPC port for the Chroma server.
|
||||
|
||||
Returns:
|
||||
|
|
@ -83,10 +83,10 @@ class ChromaComponent(CustomComponent):
|
|||
chroma_settings = None
|
||||
|
||||
if chroma_server_host is not None:
|
||||
chroma_settings = chromadb.config.Settings(
|
||||
chroma_server_cors_allow_origins=chroma_server_cors_allow_origins or None,
|
||||
chroma_settings = Settings(
|
||||
chroma_server_cors_allow_origins=chroma_server_cors_allow_origins or [],
|
||||
chroma_server_host=chroma_server_host,
|
||||
chroma_server_port=chroma_server_port or None,
|
||||
chroma_server_http_port=chroma_server_http_port or None,
|
||||
chroma_server_grpc_port=chroma_server_grpc_port or None,
|
||||
chroma_server_ssl_enabled=chroma_server_ssl_enabled,
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue