Skip to content

Commit

Permalink
this means the mock is working
Browse files Browse the repository at this point in the history
  • Loading branch information
alnutile committed Mar 26, 2024
1 parent c94b308 commit ceac4ba
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
7 changes: 5 additions & 2 deletions app/Jobs/VectorlizeDataJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use App\LlmDriver\Responses\EmbeddingsResponseDto;

class VectorlizeDataJob implements ShouldQueue
{
Expand All @@ -29,10 +30,12 @@ public function __construct(public DocumentChunk $documentChunk)
public function handle(): void
{
$content = $this->documentChunk->content;
$results = LlmDriverFacade::embedDara($content);

/** @var EmbeddingsResponseDto $results */
$results = LlmDriverFacade::embedData($content);

$this->documentChunk->update([
'embedding' => $results,
'embedding' => $results->embedding,
]);
}
}
13 changes: 10 additions & 3 deletions tests/Feature/Jobs/VectorlizeDataJobTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Tests\Feature\Jobs;

use App\Jobs\VectorlizeDataJob;
use App\Models\DocumentChunk;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithFaker;
use Tests\TestCase;
Expand All @@ -11,10 +13,15 @@ class VectorlizeDataJobTest extends TestCase
/**
* A basic feature test example.
*/
public function test_example(): void
public function test_gets_data(): void
{
$response = $this->get('/');
$documentChunk = DocumentChunk::factory()->create([
'embedding' => null
]);

$response->assertStatus(200);
$job = new VectorlizeDataJob($documentChunk);
$job->handle();

$this->assertNotEmpty($documentChunk->embedding);
}
}

0 comments on commit ceac4ba

Please sign in to comment.