Skip to content

Commit 29b184f

Browse files
committed
extend data loader
1 parent 8180418 commit 29b184f

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/RAG/DataLoader/FileDataLoader.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace NeuronAI\RAG\DataLoader;
44

55
use NeuronAI\RAG\Document;
6+
use NeuronAI\RAG\Splitters\DocumentSplitter;
67

78
class FileDataLoader implements DataLoaderInterface
89
{
@@ -79,7 +80,7 @@ protected function getDocumentsFromDirectory(string $directory): array
7980
closedir($handle);
8081
}
8182

82-
return $documents;
83+
return DocumentSplitter::splitDocuments($documents);
8384
}
8485

8586
/**
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
namespace NeuronAI\RAG\DataLoader;
4+
5+
use NeuronAI\RAG\Document;
6+
use NeuronAI\RAG\Splitters\DocumentSplitter;
7+
8+
class StringDataLoader implements DataLoaderInterface
9+
{
10+
public function __construct(protected string $content) {}
11+
12+
public function getDocuments(): array
13+
{
14+
return DocumentSplitter::splitDocument(new Document($this->content));
15+
}
16+
}

0 commit comments

Comments
 (0)