OpenSourceAppConfig.py 1.4 KB

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