From 4cad079a47ac2679ba8227df85d5f404d2bf5253 Mon Sep 17 00:00:00 2001 From: Alfred Nutile Date: Mon, 5 Aug 2024 16:15:30 -0400 Subject: [PATCH] going to back off this for a bit and get back to main branch and slowly work these things in --- Modules/LlmDriver/app/Functions/SatisfyToolsRequired.php | 4 +--- Modules/LlmDriver/app/HasDrivers.php | 1 - Modules/LlmDriver/app/HasDriversTrait.php | 2 -- Modules/LlmDriver/app/LlmServiceProvider.php | 1 - app/Domains/Tokenizer/Templatizer.php | 4 +++- app/Models/Collection.php | 2 -- database/seeders/CopySeeder.php | 7 +++---- 7 files changed, 7 insertions(+), 14 deletions(-) diff --git a/Modules/LlmDriver/app/Functions/SatisfyToolsRequired.php b/Modules/LlmDriver/app/Functions/SatisfyToolsRequired.php index 72be1b06..908491b6 100644 --- a/Modules/LlmDriver/app/Functions/SatisfyToolsRequired.php +++ b/Modules/LlmDriver/app/Functions/SatisfyToolsRequired.php @@ -3,7 +3,6 @@ namespace LlmLaraHub\LlmDriver\Functions; use App\Helpers\ChatHelperTrait; -use App\Models\Document; use App\Models\Message; use Illuminate\Support\Facades\Log; use LlmLaraHub\LlmDriver\Responses\FunctionResponse; @@ -26,9 +25,8 @@ public function handle( { Log::info('[LaraChain] SatisfyToolsRequired'); - return FunctionResponse::from([ - 'content' => "Should not be called", + 'content' => 'Should not be called', 'prompt' => $message->getPrompt(), 'requires_followup' => false, 'documentChunks' => collect([]), diff --git a/Modules/LlmDriver/app/HasDrivers.php b/Modules/LlmDriver/app/HasDrivers.php index 234d272d..d42c7621 100644 --- a/Modules/LlmDriver/app/HasDrivers.php +++ b/Modules/LlmDriver/app/HasDrivers.php @@ -19,7 +19,6 @@ public function getType(): string; public function documents(): HasMany; - public function getChatable(): HasDrivers; public function getChat(): ?Chat; diff --git a/Modules/LlmDriver/app/HasDriversTrait.php b/Modules/LlmDriver/app/HasDriversTrait.php index 910716ef..14a3f4a4 100644 --- a/Modules/LlmDriver/app/HasDriversTrait.php +++ b/Modules/LlmDriver/app/HasDriversTrait.php @@ -11,8 +11,6 @@ public function documents(): HasMany return $this->getChatable()->documents(); } - - public function systemPrompt(): string { return $this->getChatable()->systemPrompt(); diff --git a/Modules/LlmDriver/app/LlmServiceProvider.php b/Modules/LlmDriver/app/LlmServiceProvider.php index 251f3a44..6c437c8c 100644 --- a/Modules/LlmDriver/app/LlmServiceProvider.php +++ b/Modules/LlmDriver/app/LlmServiceProvider.php @@ -103,7 +103,6 @@ public function boot(): void return new SatisfyToolsRequired(); }); - } /** diff --git a/app/Domains/Tokenizer/Templatizer.php b/app/Domains/Tokenizer/Templatizer.php index b6dde5a2..8a47527d 100644 --- a/app/Domains/Tokenizer/Templatizer.php +++ b/app/Domains/Tokenizer/Templatizer.php @@ -13,6 +13,7 @@ class Templatizer protected ?string $replacement; protected bool $appendContext = false; + protected bool $addMainCollectionPrompt = false; public static function getTokens(): array @@ -49,7 +50,7 @@ public function handle( } } - if($this->addMainCollectionPrompt) { + if ($this->addMainCollectionPrompt) { $this->content = str($this->content) ->prepend(Setting::first()?->main_collection_prompt) ->toString(); @@ -94,6 +95,7 @@ public function appendContext(bool $appendContext = false): self public function setMainCollectionPromptOn(): self { $this->addMainCollectionPrompt = true; + return $this; } diff --git a/app/Models/Collection.php b/app/Models/Collection.php index a227f57f..eca93b74 100644 --- a/app/Models/Collection.php +++ b/app/Models/Collection.php @@ -9,7 +9,6 @@ use Illuminate\Database\Eloquent\Relations\MorphMany; use LlmLaraHub\LlmDriver\DriversEnum; use LlmLaraHub\LlmDriver\HasDrivers; -use LlmLaraHub\LlmDriver\HasDriversTrait; use LlmLaraHub\TagFunction\Contracts\TaggableContract; use LlmLaraHub\TagFunction\Helpers\Taggable; @@ -49,7 +48,6 @@ public function description(): string return $this->description; } - public function filters(): HasMany { return $this->hasMany(Filter::class); diff --git a/database/seeders/CopySeeder.php b/database/seeders/CopySeeder.php index b437157a..5f312101 100644 --- a/database/seeders/CopySeeder.php +++ b/database/seeders/CopySeeder.php @@ -3,7 +3,6 @@ namespace Database\Seeders; use App\Models\Setting; -use Illuminate\Database\Console\Seeds\WithoutModelEvents; use Illuminate\Database\Seeder; class CopySeeder extends Seeder @@ -15,10 +14,10 @@ public function run(): void { $setting = Setting::first(); - if($setting) { + if ($setting) { $mainPrompt = $setting->main_collection_prompt; - if(!$mainPrompt) { - $prompt = <<