OpenSourceAppConfig.py 1.1 KB

123456789101112131415161718192021222324252627282930
  1. from chromadb.utils import embedding_functions
  2. from .BaseAppConfig import BaseAppConfig
  3. class OpenSourceAppConfig(BaseAppConfig):
  4. """
  5. Config to initialize an embedchain custom `OpenSourceApp` instance, with extra config options.
  6. """
  7. def __init__(self, log_level=None, host=None, port=None, id=None):
  8. """
  9. :param log_level: Optional. (String) Debug level
  10. ['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'].
  11. :param id: Optional. ID of the app. Document metadata will have this id.
  12. :param host: Optional. Hostname for the database server.
  13. :param port: Optional. Port for the database server.
  14. """
  15. super().__init__(
  16. log_level=log_level, ef=OpenSourceAppConfig.default_embedding_function(), host=host, port=port, id=id
  17. )
  18. @staticmethod
  19. def default_embedding_function():
  20. """
  21. Sets embedding function to default (`all-MiniLM-L6-v2`).
  22. :returns: The default embedding function
  23. """
  24. return embedding_functions.SentenceTransformerEmbeddingFunction(model_name="all-MiniLM-L6-v2")