custom.mdx 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. ---
  2. title: '⚙️ Custom'
  3. ---
  4. When we say "custom", we mean that you can customize the loader and chunker to your needs. This is done by passing a custom loader and chunker to the `add` method.
  5. ```python
  6. from embedchain import App
  7. import your_loader
  8. import your_chunker
  9. app = App()
  10. loader = your_loader()
  11. chunker = your_chunker()
  12. app.add("source", data_type="custom", loader=loader, chunker=chunker)
  13. ```
  14. <Note>
  15. The custom loader and chunker must be a class that inherits from the [`BaseLoader`](https://github.com/embedchain/embedchain/blob/main/embedchain/loaders/base_loader.py) and [`BaseChunker`](https://github.com/embedchain/embedchain/blob/main/embedchain/chunkers/base_chunker.py) classes respectively.
  16. </Note>
  17. <Note>
  18. If the `data_type` is not a valid data type, the `add` method will fallback to the `custom` data type and expect a custom loader and chunker to be passed by the user.
  19. </Note>
  20. Example:
  21. ```python
  22. from embedchain import App
  23. from embedchain.loaders.github import GithubLoader
  24. app = App()
  25. loader = GithubLoader(config={"token": "ghp_xxx"})
  26. app.add("repo:embedchain/embedchain type:repo", data_type="github", loader=loader)
  27. app.query("What is Embedchain?")
  28. # Answer: Embedchain is a Data Platform for Large Language Models (LLMs). It allows users to seamlessly load, index, retrieve, and sync unstructured data in order to build dynamic, LLM-powered applications. There is also a JavaScript implementation called embedchain-js available on GitHub.
  29. ```