OpenSourceAppConfig.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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, collection_name=None, model=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 collection_name: Optional. Collection name for the database.
  13. :param host: Optional. Hostname for the database server.
  14. :param port: Optional. Port for the database server.
  15. :param model: Optional. GPT4ALL uses the model to instantiate the class.
  16. So unlike `App`, it has to be provided before querying.
  17. """
  18. self.model = model or "orca-mini-3b.ggmlv3.q4_0.bin"
  19. super().__init__(
  20. log_level=log_level,
  21. embedding_fn=OpenSourceAppConfig.default_embedding_function(),
  22. host=host,
  23. port=port,
  24. id=id,
  25. collection_name=collection_name,
  26. )
  27. @staticmethod
  28. def default_embedding_function():
  29. """
  30. Sets embedding function to default (`all-MiniLM-L6-v2`).
  31. :returns: The default embedding function
  32. """
  33. return embedding_functions.SentenceTransformerEmbeddingFunction(model_name="all-MiniLM-L6-v2")