diff --git a/app/Domains/Sources/EmailSource.php b/app/Domains/Sources/EmailSource.php index ee4406b7..d346e9d1 100644 --- a/app/Domains/Sources/EmailSource.php +++ b/app/Domains/Sources/EmailSource.php @@ -14,7 +14,6 @@ use Facades\App\Domains\EmailParser\Client; use Illuminate\Support\Facades\Bus; use Illuminate\Support\Facades\Log; -use Laravel\Prompts\Prompt; use LlmLaraHub\LlmDriver\LlmDriverFacade; class EmailSource extends BaseSource @@ -63,16 +62,13 @@ public function handle(Source $source): void 'prompt' => $prompt, ]); - $chat = $source->chat; - - $results = LlmDriverFacade::driver( $source->getDriver() )->completion($prompt); - if($this->ifNotActionRequired($results->content)) { + if ($this->ifNotActionRequired($results->content)) { Log::info('[LaraChain] - Email Source Skipping', [ 'prompt' => $prompt, ]); diff --git a/app/Helpers/ChatHelperTrait.php b/app/Helpers/ChatHelperTrait.php index 344e0b78..ff4f0bed 100644 --- a/app/Helpers/ChatHelperTrait.php +++ b/app/Helpers/ChatHelperTrait.php @@ -34,7 +34,8 @@ public function getUserId(Collection $collection): ?int return $collection->team?->user_id; } - public function ifNotActionRequired(string $results): bool { + public function ifNotActionRequired(string $results): bool + { // @NOTE llms sometimes do not return the right // string for example. // false becomes false, "false" or "False" etc. @@ -46,6 +47,6 @@ public function ifNotActionRequired(string $results): bool { ->remove("'") ->toString(); - return $results == "false"; + return $results == 'false'; } } diff --git a/app/Jobs/ChunkDocumentJob.php b/app/Jobs/ChunkDocumentJob.php index 336a512f..a817ee52 100644 --- a/app/Jobs/ChunkDocumentJob.php +++ b/app/Jobs/ChunkDocumentJob.php @@ -45,13 +45,14 @@ public function handle(): void return; } - Log::info('[LaraChain] - Chunking Document', [ 'document' => $this->document->id, ]); $document = $this->document; + $chunks = []; + $page_number = 0; $pageContent = $this->document->original_content; @@ -80,9 +81,7 @@ public function handle(): void ]; } - $name = sprintf($document->type->name, $document->id); - - + $name = sprintf("Chunking Document Type %s id %d ", $document->type->name, $document->id); Bus::batch($chunks) ->name($name) @@ -94,9 +93,9 @@ public function handle(): void new SummarizeDocumentJob($document), new TagDocumentJob($document), new DocumentProcessingCompleteJob($document), - ] + ], ]) - ->name(sprintf("Final Document Steps Document %s id %d", $document->type->name, $document->id)) + ->name(sprintf('Final Document Steps Document %s id %d', $document->type->name, $document->id)) ->allowFailures() ->dispatch(); }) diff --git a/tests/Feature/EmailSourceTest.php b/tests/Feature/EmailSourceTest.php index 64154f4b..ff3c69b6 100644 --- a/tests/Feature/EmailSourceTest.php +++ b/tests/Feature/EmailSourceTest.php @@ -132,7 +132,6 @@ public function tests_creates_chat_and_message() Bus::assertBatchCount(1); } - public function test_no_action_required() { Bus::fake(); @@ -170,7 +169,7 @@ public function test_no_action_required() $this->assertDatabaseCount('documents', 0); $this->assertDatabaseCount('chats', 1); - $this->assertDatabaseCount('messages', 1); + $this->assertDatabaseCount('messages', 0); $this->assertNotNull($source->chat_id); diff --git a/tests/Feature/Jobs/ChunkDocumentJobTest.php b/tests/Feature/Jobs/ChunkDocumentJobTest.php index 983fa1fc..0260f93b 100644 --- a/tests/Feature/Jobs/ChunkDocumentJobTest.php +++ b/tests/Feature/Jobs/ChunkDocumentJobTest.php @@ -20,10 +20,8 @@ public function test_chunking(): void $this->assertDatabaseCount('document_chunks', 0); - [$job, $batch] = (new ChunkDocumentJob($document))->withFakeBatch(); - $job->handle(); $this->assertDatabaseCount('document_chunks', 1);