From 721e1299979c0d5c2ed155a239062ea84e886204 Mon Sep 17 00:00:00 2001 From: Alfred Nutile Date: Sun, 30 Jun 2024 22:14:51 -0400 Subject: [PATCH] Tell stan it is ok should be string --- .../Transformers/DocXTransformer.php | 1 + app/Http/Controllers/CollectionController.php | 60 +++++++++---------- 2 files changed, 31 insertions(+), 30 deletions(-) diff --git a/app/Domains/Documents/Transformers/DocXTransformer.php b/app/Domains/Documents/Transformers/DocXTransformer.php index aa42b824..fac59377 100644 --- a/app/Domains/Documents/Transformers/DocXTransformer.php +++ b/app/Domains/Documents/Transformers/DocXTransformer.php @@ -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); diff --git a/app/Http/Controllers/CollectionController.php b/app/Http/Controllers/CollectionController.php index e6d4bb12..c58cb739 100644 --- a/app/Http/Controllers/CollectionController.php +++ b/app/Http/Controllers/CollectionController.php @@ -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)