OpenSourceAppConfig.py 1.4 KB

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