Skip to content

Commit

Permalink
omg this will simplify a lot of things but it sure is making a lot of…
Browse files Browse the repository at this point in the history
… changes
  • Loading branch information
alnutile committed Aug 2, 2024
1 parent 076d53b commit 16e023e
Show file tree
Hide file tree
Showing 11 changed files with 16 additions and 27 deletions.
9 changes: 1 addition & 8 deletions Modules/LlmDriver/app/Functions/CreateDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,10 @@

namespace LlmLaraHub\LlmDriver\Functions;

use App\Domains\Documents\StatusEnum;
use App\Domains\Documents\TypesEnum;
use App\Domains\Sources\WebSearch\Response\SearchResponseDto;
use App\Domains\Sources\WebSearch\WebSearchFacade;
use App\Models\Document;
use Facades\App\Domains\Tokenizer\Templatizer;
use App\Helpers\ChatHelperTrait;
use App\Models\Document;
use App\Models\Message;
use Facades\App\Domains\Sources\WebSearch\GetPage;
use Illuminate\Support\Facades\Log;
use LlmLaraHub\LlmDriver\LlmDriverFacade;
use LlmLaraHub\LlmDriver\Responses\FunctionResponse;
use LlmLaraHub\LlmDriver\ToolsHelper;

Expand Down
1 change: 0 additions & 1 deletion Modules/LlmDriver/app/OllamaClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ public function completion(string $prompt): CompletionResponse
'stream' => false,
]);


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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public function __construct(
#[WithCastable(ClaudeContentCaster::class)]
public mixed $content,
public string|Optional $stop_reason,
public string|null $tool_used = "",
public ?string $tool_used = '',
/** @var array<ToolDto> */
#[WithCastable(ClaudeToolCaster::class)]
#[MapInputName('content')]
Expand Down
2 changes: 1 addition & 1 deletion Modules/LlmDriver/app/Responses/CompletionResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class CompletionResponse extends \Spatie\LaravelData\Data
public function __construct(
public mixed $content,
public string|Optional $stop_reason,
public string|null $tool_used = "",
public ?string $tool_used = '',
/** @var array<ToolDto> */
public array $tool_calls = [],
public ?int $input_tokens = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public function __construct(
public mixed $content,
#[MapInputName('done_reason')]
public string|Optional $stop_reason,
public string|null $tool_used = "",
public ?string $tool_used = '',
/** @var array<OllamaToolDto> */
#[MapInputName('message.tool_calls')]
public array $tool_calls = [],
Expand Down
6 changes: 3 additions & 3 deletions app/Jobs/ProcessTextFilesJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ public function handle(): void
Bus::batch([
[
new TagDocumentJob($document),
new DocumentProcessingCompleteJob($document)
]
new DocumentProcessingCompleteJob($document),
],
])
->name("Finalizing Documents")
->name('Finalizing Documents')
->allowFailures()
->dispatch();
})
Expand Down
9 changes: 4 additions & 5 deletions app/Models/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
use Illuminate\Support\Facades\Bus;
use Illuminate\Support\Facades\Log;
use LlmLaraHub\LlmDriver\HasDrivers;
use LlmLaraHub\LlmDriver\LlmDriverFacade;
use LlmLaraHub\TagFunction\Contracts\TaggableContract;
use LlmLaraHub\TagFunction\Helpers\Taggable;
use LlmLaraHub\TagFunction\Jobs\TagDocumentJob;
Expand Down Expand Up @@ -164,7 +163,7 @@ public static function make(
string $content,
Collection $collection,
?string $filePath = null
) : Document {
): Document {
return Document::create([
'file_path' => $filePath,
'collection_id' => $collection->id,
Expand Down Expand Up @@ -213,10 +212,10 @@ public function vectorizeDocument(): void
[
new SummarizeDocumentJob($document),
new TagDocumentJob($document),
new DocumentProcessingCompleteJob($document)
]
new DocumentProcessingCompleteJob($document),
],
])
->name("Finalizing Documents")
->name('Finalizing Documents')
->allowFailures()
->dispatch();
})
Expand Down
1 change: 0 additions & 1 deletion app/Models/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
use App\Events\MessageCreatedEvent;
use App\Jobs\OrchestrateJob;
use App\Jobs\SimpleRetrieveRelatedOrchestrateJob;
use App\Jobs\SimpleSearchAndSummarizeOrchestrateJob;
use Facades\App\Domains\Tokenizer\Templatizer;
use Illuminate\Bus\Batch;
use Illuminate\Database\Eloquent\Factories\HasFactory;
Expand Down
3 changes: 0 additions & 3 deletions tests/Feature/Http/Controllers/ChatControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
use App\Models\User;
use Facades\App\Domains\Agents\VerifyResponseAgent;
use Facades\LlmLaraHub\LlmDriver\Orchestrate;
use Illuminate\Support\Facades\Bus;
use LlmLaraHub\LlmDriver\LlmDriverFacade;
use LlmLaraHub\LlmDriver\Responses\CompletionResponse;
use Tests\TestCase;
Expand Down Expand Up @@ -178,8 +177,6 @@ public function test_kick_off_chat_makes_system()

}



public function test_standard_checker()
{
Orchestrate::shouldReceive('handle')->once()->andReturn('Yo');
Expand Down
6 changes: 4 additions & 2 deletions tests/Feature/Models/DocumentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ public function test_parent()
$model->parent->id);
}

public function test_document_make() {
public function test_document_make()
{
$collection = \App\Models\Collection::factory()->create();
$document = Document::make('Foo bar',
$collection);
Expand All @@ -48,7 +49,8 @@ public function test_document_make() {
$this->assertNotNull($document->collection->documents()->first()->id);
}

public function test_document_vectorize() {
public function test_document_vectorize()
{
Bus::fake();
$collection = \App\Models\Collection::factory()->create();
$document = Document::make('Foo bar',
Expand Down
2 changes: 1 addition & 1 deletion tests/Feature/SearchAndSummarizeChatRepoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

use App\Domains\Agents\VerifyPromptOutputDto;
use App\Domains\Chat\MetaDataDto;
use App\Domains\Messages\RoleEnum;
use App\Domains\Messages\RetrieveRelatedChatRepo;
use App\Domains\Messages\RoleEnum;
use App\Models\Chat;
use App\Models\Collection;
use App\Models\Document;
Expand Down

0 comments on commit 16e023e

Please sign in to comment.