From 026fc7f33ad2bb74e4fa81c71b365e7185d034d0 Mon Sep 17 00:00:00 2001 From: alnutile Date: Fri, 19 Apr 2024 07:05:09 -0400 Subject: [PATCH] this will now get llama3 as default --- Modules/LlmDriver/app/OllamaClient.php | 14 +++++++------- .../Documents/Transformers/PdfTransformer.php | 1 - app/Http/Controllers/ChatController.php | 4 ++-- app/Jobs/ProcessFileJob.php | 2 ++ 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/Modules/LlmDriver/app/OllamaClient.php b/Modules/LlmDriver/app/OllamaClient.php index 3fb49270..170cefd7 100644 --- a/Modules/LlmDriver/app/OllamaClient.php +++ b/Modules/LlmDriver/app/OllamaClient.php @@ -127,15 +127,15 @@ public function chat(array $messages): CompletionResponse $messages = $this->remapMessages($messages); - put_fixture("messages_llama3.json", $messages); - + put_fixture('messages_llama3.json', $messages); + $response = $this->getClient()->post('/chat', [ 'model' => $this->getConfig('ollama')['models']['completion_model'], 'messages' => $messages, 'stream' => false, ]); - put_fixture("ollama_chat_results.json", $response->json()); + put_fixture('ollama_chat_results.json', $response->json()); $results = $response->json()['message']['content']; @@ -225,13 +225,13 @@ protected function remapMessages(array $messages): array return $message->toArray(); }); - if(in_array('llama3', [ + if (in_array('llama3', [ $this->getConfig('ollama')['models']['completion_model']])) { - Log::info('[LaraChain] LlmDriver::OllamaClient::remapMessages'); - $messages = collect($messages)->reverse(); + Log::info('[LaraChain] LlmDriver::OllamaClient::remapMessages'); + $messages = collect($messages)->reverse(); } return $messages->values()->toArray(); - + } } diff --git a/app/Domains/Documents/Transformers/PdfTransformer.php b/app/Domains/Documents/Transformers/PdfTransformer.php index 0ddd0597..d96cae23 100644 --- a/app/Domains/Documents/Transformers/PdfTransformer.php +++ b/app/Domains/Documents/Transformers/PdfTransformer.php @@ -13,7 +13,6 @@ use Illuminate\Support\Facades\Bus; use Illuminate\Support\Facades\Log; use LlmLaraHub\LlmDriver\LlmDriverFacade; -use LlmLaraHub\TagFunction\Database\Seeders\TagFunctionDatabaseSeeder; use LlmLaraHub\TagFunction\Functions\TaggingFunction; use Smalot\PdfParser\Parser; diff --git a/app/Http/Controllers/ChatController.php b/app/Http/Controllers/ChatController.php index 82540848..7b3c92ed 100644 --- a/app/Http/Controllers/ChatController.php +++ b/app/Http/Controllers/ChatController.php @@ -47,7 +47,7 @@ public function chat(Chat $chat) { $validated = request()->validate([ 'input' => 'required|string', - 'completion' => 'boolean' + 'completion' => 'boolean', ]); $chat->addInput( @@ -62,7 +62,7 @@ public function chat(Chat $chat) 'role' => 'user', ]); - if(data_get($validated, 'completion', false)) { + if (data_get($validated, 'completion', false)) { Log::info('[LaraChain] Running Simple Completion'); $prompt = $validated['input']; $response = LlmDriverFacade::driver($chat->getDriver())->completion($prompt); diff --git a/app/Jobs/ProcessFileJob.php b/app/Jobs/ProcessFileJob.php index 95502fc9..057a0798 100644 --- a/app/Jobs/ProcessFileJob.php +++ b/app/Jobs/ProcessFileJob.php @@ -57,12 +57,14 @@ public function handle(): void throw new \Exception('Can not read the document '.$filePath); } + /** @phpstan-ignore-next-line */ $writer = IOFactory::createReader($filePath, 'PDF'); $filePath = $this->document->pathToFile(); $filePath = str_replace('.pptx', '.pdf', $filePath); + /** @phpstan-ignore-next-line */ $writer->save($filePath); }