Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/DocumentProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,11 @@ enum DocumentProcessor: string
* Uses LLamaCloud https://cloud.llamaindex.ai/ as document processor to extract text
*/
case LLAMAPARSE = 'llama';

/**
* The Unstructured processor
*
* Uses Unstructored https://unstructured.io/ as document processor to extract text
*/
case UNSTRUCTURED = 'unstructured';
}
31 changes: 31 additions & 0 deletions tests/ParseProcessorSelectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,34 @@

$mockClient->assertSentCount(1);
});

test('unstructured can be selected as processor', function () {
$mockClient = MockClient::global([
ExtractTextRequest::class => MockResponse::fixture('extract-text-empty'),
]);

$connector = new ParseConnector('fake', 'http://localhost:5002');
$connector->withMockClient($mockClient);

$connector->parse(
url: 'http://localhost/empty.pdf',
options: new ParseOption(DocumentProcessor::UNSTRUCTURED),
);

$mockClient->assertSent(ExtractTextRequest::class);

$mockClient->assertSent(function (Request $request, Response $response) {
if (! $request instanceof ExtractTextRequest) {
return false;
}

/** @var array */
$body = $request->body()->all();

return $body['url'] === 'http://localhost/empty.pdf'
&& $body['mime_type'] === 'application/pdf'
&& $body['driver'] === 'unstructured';
});

$mockClient->assertSentCount(1);
});