custom_app_config.py 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. from typing import Optional
  2. from dotenv import load_dotenv
  3. from embedchain.helper.json_serializable import register_deserializable
  4. from embedchain.vectordb.base import BaseVectorDB
  5. from .base_app_config import BaseAppConfig
  6. load_dotenv()
  7. @register_deserializable
  8. class CustomAppConfig(BaseAppConfig):
  9. """
  10. Config to initialize an embedchain custom `App` instance, with extra config options.
  11. """
  12. def __init__(
  13. self,
  14. log_level: str = "WARNING",
  15. db: Optional[BaseVectorDB] = None,
  16. id: Optional[str] = None,
  17. collect_metrics: Optional[bool] = None,
  18. collection_name: Optional[str] = None,
  19. ):
  20. """
  21. Initializes a configuration class instance for an Custom App.
  22. Most of the configuration is done in the `CustomApp` class itself.
  23. :param log_level: Debug level ['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'], defaults to "WARNING"
  24. :type log_level: str, optional
  25. :param db: A database class. It is recommended to set this directly in the `CustomApp` class, not this config,
  26. defaults to None
  27. :type db: Optional[BaseVectorDB], optional
  28. :param id: ID of the app. Document metadata will have this id., defaults to None
  29. :type id: Optional[str], optional
  30. :param collect_metrics: Send anonymous telemetry to improve embedchain, defaults to True
  31. :type collect_metrics: Optional[bool], optional
  32. :param collection_name: Default collection name. It's recommended to use app.db.set_collection_name() instead,
  33. defaults to None
  34. :type collection_name: Optional[str], optional
  35. """
  36. super().__init__(
  37. log_level=log_level, db=db, id=id, collect_metrics=collect_metrics, collection_name=collection_name
  38. )