From f31c435e303ec6ccded5adfa569304d0106d7839 Mon Sep 17 00:00:00 2001 From: Alfred Nutile Date: Mon, 22 Jul 2024 07:42:11 -0400 Subject: [PATCH] add new prompt template for event data --- app/Jobs/GetWebContentJob.php | 11 +++++------ tests/Feature/Jobs/GetWebContentJobTest.php | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/app/Jobs/GetWebContentJob.php b/app/Jobs/GetWebContentJob.php index 83f0b0c9..62f08c3a 100644 --- a/app/Jobs/GetWebContentJob.php +++ b/app/Jobs/GetWebContentJob.php @@ -63,6 +63,7 @@ public function handle(): void ! $this->source->force && SourceTask::where('source_id', $this->source->id)->where('task_key', $key)->exists()) { Log::info('[LaraChain] GetWebContentJob - Skipping - already ran'); + return; } @@ -111,15 +112,15 @@ public function handle(): void $promptResults = json_decode($promptResultsOriginal, true); - if(is_null($promptResults)) { - $promptResults = Arr::wrap($promptResultsOriginal); + if (is_null($promptResults)) { + $promptResults = Arr::wrap($promptResultsOriginal); } /** * @NOTE all the user to build array results * Like Events from a webpage */ - foreach($promptResults as $promptResultIndex => $promptResult) { + foreach ($promptResults as $promptResultIndex => $promptResult) { $promptResult = json_encode($promptResult); @@ -184,7 +185,7 @@ 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)) ->allowFailures() @@ -195,7 +196,6 @@ public function handle(): void ->dispatch(); } - /** * @NOTE * I could move this into the loop if it is not @@ -215,7 +215,6 @@ public function handle(): void message: $assistantMessage, prompt: $prompt); - } } } diff --git a/tests/Feature/Jobs/GetWebContentJobTest.php b/tests/Feature/Jobs/GetWebContentJobTest.php index a04fa688..f65d88c0 100644 --- a/tests/Feature/Jobs/GetWebContentJobTest.php +++ b/tests/Feature/Jobs/GetWebContentJobTest.php @@ -85,7 +85,7 @@ public function test_array(): void LlmDriverFacade::shouldReceive('driver->completion') ->once() ->andReturn(CompletionResponse::from([ - 'content' => "[{\"content\":\"Test 1\"},{\"content\":\"Test 2\"}]", + 'content' => '[{"content":"Test 1"},{"content":"Test 2"}]', ])); $this->assertDatabaseCount('documents', 0);