Skip to content

Commit

Permalink
need to go fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
alnutile committed Aug 2, 2024
1 parent c4d1ff3 commit 24d5461
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
1 change: 0 additions & 1 deletion Modules/LlmDriver/app/Functions/Chat.php
Original file line number Diff line number Diff line change
Expand Up @@ -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\LlmDriverFacade;
Expand Down
11 changes: 5 additions & 6 deletions Modules/LlmDriver/app/OllamaClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public function chat(array $messages): CompletionResponse

$response = $this->getClient()->post('/chat', $payload);

if($response->failed()){
if ($response->failed()) {
Log::error('Ollama API Error ', [
'error' => $response->body(),
]);
Expand Down Expand Up @@ -195,8 +195,6 @@ public function completion(string $prompt): CompletionResponse
'stream' => false,
]);



return OllamaCompletionResponse::from($response->json());
}

Expand Down Expand Up @@ -279,14 +277,15 @@ public function remapMessages(array $messages): array
})->toArray();

if (in_array($this->getConfig('ollama')['models']['completion_model'], [
'llama3.1',
'llama3'
])) {
'llama3.1',
'llama3',
])) {
Log::info('[LaraChain] LlmDriver::OllamaClient::remapMessages');
$messages = collect($messages)->reverse();
}

put_fixture('ollama_messages_after_remap.json', $messages->values()->toArray());

return $messages->values()->toArray();

}
Expand Down
3 changes: 2 additions & 1 deletion Modules/LlmDriver/tests/Feature/OllamaClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ public function test_functions()

}

public function test_remap_functions() {
public function test_remap_functions()
{
$functions = LlmDriverFacade::getFunctions();
$results = (new OllamaClient)->remapFunctions($functions);
put_fixture('ollama_functions.json', $results);
Expand Down
6 changes: 3 additions & 3 deletions app/Domains/Orchestration/OrchestrateVersionTwo.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@

class OrchestrateVersionTwo
{

use ToolsHelper;
use CreateReferencesTrait;
use ToolsHelper;

public function handle(
Chat $chat,
Message $message)
Expand Down Expand Up @@ -156,6 +156,7 @@ public function handle(
$response = LlmDriverFacade::driver($chat->getDriver())->chat($messages);

put_fixture('orchestrate_messages_fist_send.json', $response);

$assistantMessage = $chat->addInput(
message: $response->content,
role: RoleEnum::Assistant,
Expand All @@ -168,7 +169,6 @@ public function handle(
'prompt' => $message->getPrompt(),
'chat_id' => $chat->id,
'message_id' => $assistantMessage->id,
/** @phpstan-ignore-next-line */
'collection_id' => $chat->chatable_id,
]);
notify_ui_complete($chat);
Expand Down

0 comments on commit 24d5461

Please sign in to comment.