Преглед на файлове

Docs for directory data loader usage (#1016)

Sidharth Mohanty преди 1 година
родител
ревизия
54f43215cd
променени са 3 файла, в които са добавени 44 реда и са изтрити 1 реда
  1. 41 0
      docs/components/data-sources/directory.mdx
  2. 1 0
      docs/components/data-sources/overview.mdx
  3. 2 1
      docs/mint.json

+ 41 - 0
docs/components/data-sources/directory.mdx

@@ -0,0 +1,41 @@
+---
+title: '📁 Directory'
+---
+
+To use an entire directory as data source, just add `data_type` as `directory` and pass in the path of the local directory.
+
+### Without customization
+
+```python
+import os
+from embedchain import Pipeline as App
+
+os.environ["OPENAI_API_KEY"] = "sk-xxx"
+
+app = App()
+app.add("./elon-musk", data_type="directory")
+response = app.query("list all files")
+print(response)
+# Answer: Files are elon-musk-1.txt, elon-musk-2.pdf.
+```
+
+### Customization
+
+```python
+import os
+from embedchain import Pipeline as App
+from embedchain.loaders.directory_loader import DirectoryLoader
+
+os.environ["OPENAI_API_KEY"] = "sk-xxx"
+lconfig = {
+    "recursive": True,
+    "extensions": [".txt"]
+}
+loader = DirectoryLoader(config=lconfig)
+app = App()
+app.add("./elon-musk", loader=loader)
+response = app.query("what are all the files related to?")
+print(response)
+
+# Answer: The files are related to Elon Musk.
+```

+ 1 - 0
docs/components/data-sources/overview.mdx

@@ -29,6 +29,7 @@ Embedchain comes with built-in support for various data sources. We handle the c
   <Card title="⚙️ Custom" href="/components/data-sources/custom"></Card>
   <Card title="📝 Substack" href="/components/data-sources/substack"></Card>
   <Card title="🐝 Beehiiv" href="/components/data-sources/beehiiv"></Card>
+  <Card title="📁 Directory" href="/components/data-sources/directory"></Card>
 </CardGroup>
 
 <br/ >

+ 2 - 1
docs/mint.json

@@ -116,7 +116,8 @@
                 "components/data-sources/discourse",
                 "components/data-sources/substack",
                 "components/data-sources/discord",
-                "components/data-sources/beehiiv"
+                "components/data-sources/beehiiv",
+                "components/data-sources/directory"
               ]
             },
             "components/data-sources/data-type-handling"