AddConfig.py 927 B

1234567891011121314151617181920212223242526272829303132
  1. from typing import Callable, Optional
  2. from embedchain.config.BaseConfig import BaseConfig
  3. class ChunkerConfig(BaseConfig):
  4. """
  5. Config for the chunker used in `add` method
  6. """
  7. def __init__(self,
  8. chunk_size: Optional[int] = 4000,
  9. chunk_overlap: Optional[int] = 200,
  10. length_function: Optional[Callable[[str], int]] = len):
  11. self.chunk_size = chunk_size
  12. self.chunk_overlap = chunk_overlap
  13. self.length_function = length_function
  14. class LoaderConfig(BaseConfig):
  15. """
  16. Config for the chunker used in `add` method
  17. """
  18. def __init__(self):
  19. pass
  20. class AddConfig(BaseConfig):
  21. """
  22. Config for the `add` method.
  23. """
  24. def __init__(self,
  25. chunker: Optional[ChunkerConfig] = None,
  26. loader: Optional[LoaderConfig] = None):
  27. self.loader = loader
  28. self.chunker = chunker