Skip to content

Commit

Permalink
Tell stan it is ok should be string
Browse files Browse the repository at this point in the history
  • Loading branch information
alnutile committed Jul 1, 2024
1 parent 6f2c6a8 commit 721e129
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 30 deletions.
1 change: 1 addition & 0 deletions app/Domains/Documents/Transformers/DocXTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ public function handle(Document $document): array
}
}

/** @phpstan-ignore-next-line */
$content_flattened = implode('', $content);
$size = config('llmdriver.chunking.default_size');
$chunked_chunks = TextChunker::handle($content_flattened, $size);
Expand Down
60 changes: 30 additions & 30 deletions app/Http/Controllers/CollectionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,45 +89,45 @@ public function filesUpload(Collection $collection)
'files' => 'required',
]);

try {
foreach ($validated['files'] as $file) {
$mimetype = $file->getMimeType();
try {
foreach ($validated['files'] as $file) {
$mimetype = $file->getMimeType();

//if pptx
Log::info('[LaraChain] - Mimetype', [
'mimetype' => $mimetype,
]);
//if pptx
Log::info('[LaraChain] - Mimetype', [
'mimetype' => $mimetype,
]);

$mimeType = TypesEnum::mimeTypeToType($mimetype);
$mimeType = TypesEnum::mimeTypeToType($mimetype);

$document = Document::create([
'collection_id' => $collection->id,
'file_path' => $file->getClientOriginalName(),
'type' => $mimeType,
]);
$document = Document::create([
'collection_id' => $collection->id,
'file_path' => $file->getClientOriginalName(),
'type' => $mimeType,
]);

$file->storeAs(
path: $collection->id,
name: $file->getClientOriginalName(),
options: ['disk' => 'collections']
);
$file->storeAs(
path: $collection->id,
name: $file->getClientOriginalName(),
options: ['disk' => 'collections']
);

ProcessFileJob::dispatch($document);
}
ProcessFileJob::dispatch($document);
}

request()->session()->flash('flash.banner', 'Files uploaded successfully!');
request()->session()->flash('flash.banner', 'Files uploaded successfully!');

return back();
} catch (\Exception $e) {
Log::error('Error processing file', [
'error' => $e->getMessage(),
]);
return back();
} catch (\Exception $e) {
Log::error('Error processing file', [
'error' => $e->getMessage(),
]);

request()->session()->flash('flash.banner', 'Error processing file');
request()->session()->flash('flash.bannerStyle', 'danger');
request()->session()->flash('flash.banner', 'Error processing file');
request()->session()->flash('flash.bannerStyle', 'danger');

return back();
}
return back();
}
}

public function resetCollectionDocument(Collection $collection, Document $document)
Expand Down

0 comments on commit 721e129

Please sign in to comment.