Skip to content

Commit

Permalink
this will now get llama3 as default
Browse files Browse the repository at this point in the history
  • Loading branch information
alnutile committed Apr 19, 2024
1 parent 8de30c8 commit 026fc7f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
14 changes: 7 additions & 7 deletions Modules/LlmDriver/app/OllamaClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];

Expand Down Expand Up @@ -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();

}
}
1 change: 0 additions & 1 deletion app/Domains/Documents/Transformers/PdfTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions app/Http/Controllers/ChatController.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function chat(Chat $chat)
{
$validated = request()->validate([
'input' => 'required|string',
'completion' => 'boolean'
'completion' => 'boolean',
]);

$chat->addInput(
Expand All @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions app/Jobs/ProcessFileJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

}
Expand Down

0 comments on commit 026fc7f

Please sign in to comment.