From fa0a9452895e839e76088d7638c2b01688871152 Mon Sep 17 00:00:00 2001 From: Alfred Nutile Date: Thu, 25 Jul 2024 22:35:00 -0400 Subject: [PATCH] add section prompt info --- .../Functions/GatherInfoToolMakeSections.php | 11 ++++++-- database/factories/SectionFactory.php | 1 + ...24_07_26_023241_add_prompt_to_sections.php | 28 +++++++++++++++++++ 3 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 database/migrations/2024_07_26_023241_add_prompt_to_sections.php diff --git a/Modules/LlmDriver/app/Functions/GatherInfoToolMakeSections.php b/Modules/LlmDriver/app/Functions/GatherInfoToolMakeSections.php index 9667ff11..86e5be59 100644 --- a/Modules/LlmDriver/app/Functions/GatherInfoToolMakeSections.php +++ b/Modules/LlmDriver/app/Functions/GatherInfoToolMakeSections.php @@ -35,7 +35,12 @@ protected function poolPrompt(array $prompts, Report $report, Document $document foreach ($results as $resultIndex => $result) { $content = $result->content; - $this->makeSectionFromContent($content, $document, $report); + $prompt = data_get($prompts, $resultIndex, 'no prompt found'); + $this->makeSectionFromContent( + $content, + $document, + $report, + $prompt); } notify_ui($report->getChat(), 'Done gathering info'); @@ -45,7 +50,8 @@ protected function poolPrompt(array $prompts, Report $report, Document $document protected function makeSectionFromContent( string $content, Document $document, - Report $report): void + Report $report, + string $prompt): void { try { @@ -56,6 +62,7 @@ protected function makeSectionFromContent( ], [ 'subject' => str($content)->limit(128)->toString(), 'content' => $content, + 'prompt' => $prompt, ]); } catch (\Exception $e) { diff --git a/database/factories/SectionFactory.php b/database/factories/SectionFactory.php index df0f06b4..4e82af7b 100644 --- a/database/factories/SectionFactory.php +++ b/database/factories/SectionFactory.php @@ -25,6 +25,7 @@ public function definition(): array 'sort_order' => $this->faker->numberBetween(0, 100), 'document_id' => Document::factory(), 'report_id' => Report::factory(), + 'prompt' => $this->faker->sentence(), ]; } } diff --git a/database/migrations/2024_07_26_023241_add_prompt_to_sections.php b/database/migrations/2024_07_26_023241_add_prompt_to_sections.php new file mode 100644 index 00000000..698fc560 --- /dev/null +++ b/database/migrations/2024_07_26_023241_add_prompt_to_sections.php @@ -0,0 +1,28 @@ +longText('prompt')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('sections', function (Blueprint $table) { + // + }); + } +};