opensearch.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. from typing import Optional
  2. from embedchain.config.vectordb.base import BaseVectorDbConfig
  3. from embedchain.helpers.json_serializable import register_deserializable
  4. @register_deserializable
  5. class OpenSearchDBConfig(BaseVectorDbConfig):
  6. def __init__(
  7. self,
  8. opensearch_url: str,
  9. http_auth: tuple[str, str],
  10. vector_dimension: int = 1536,
  11. collection_name: Optional[str] = None,
  12. dir: Optional[str] = None,
  13. **extra_params: dict[str, any],
  14. ):
  15. """
  16. Initializes a configuration class instance for an OpenSearch client.
  17. :param collection_name: Default name for the collection, defaults to None
  18. :type collection_name: Optional[str], optional
  19. :param opensearch_url: URL of the OpenSearch domain
  20. :type opensearch_url: str, Eg, "http://localhost:9200"
  21. :param http_auth: Tuple of username and password
  22. :type http_auth: tuple[str, str], Eg, ("username", "password")
  23. :param vector_dimension: Dimension of the vector, defaults to 1536 (openai embedding model)
  24. :type vector_dimension: int, optional
  25. :param dir: Path to the database directory, where the database is stored, defaults to None
  26. :type dir: Optional[str], optional
  27. """
  28. self.opensearch_url = opensearch_url
  29. self.http_auth = http_auth
  30. self.vector_dimension = vector_dimension
  31. self.extra_params = extra_params
  32. super().__init__(collection_name=collection_name, dir=dir)