Skip to content

Commit

Permalink
fix the data var
Browse files Browse the repository at this point in the history
  • Loading branch information
alnutile committed Jul 27, 2024
1 parent dde89e4 commit 1f803d5
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
1 change: 1 addition & 0 deletions Modules/LlmDriver/app/ClaudeClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ public function completion(string $prompt): CompletionResponse

public function getContentAndToolTypeFromResults(Response $results): array
{
$data = 'No results found';
$results = $results->json();
$tool_used = null;
$stop_reason = data_get($results, 'stop_reason', 'end_turn');
Expand Down
9 changes: 9 additions & 0 deletions app/Http/Controllers/CollectionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,4 +142,13 @@ public function resetCollectionDocument(Collection $collection, Document $docume

return back();
}

public function delete(Collection $collection)
{
$collection->delete();

request()->session()->flash('flash.banner', 'Collection deleted!');

return back();
}
}
1 change: 1 addition & 0 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ function () {
->name('collections.documents.reset');
Route::post('/collections', 'store')->name('collections.store');
Route::put('/collections/{collection}', 'update')->name('collections.update');
Route::delete('/collections/{collection}', 'delete')->name('collections.delete');
Route::get('/collections/{collection}', 'show')->name('collections.show');
Route::any('/collections/{collection}/upload', 'filesUpload')->name('collections.upload');
});
Expand Down
25 changes: 25 additions & 0 deletions tests/Feature/Http/Controllers/CollectionControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
namespace Tests\Feature\Http\Controllers;

use App\Jobs\ProcessFileJob;
use App\Models\Chat;
use App\Models\Collection;
use App\Models\Document;
use App\Models\DocumentChunk;
use App\Models\Message;
use App\Models\User;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\Queue;
Expand All @@ -16,6 +18,29 @@

class CollectionControllerTest extends TestCase
{
public function test_delete(): void
{
$user = User::factory()->create();
$collection = Collection::factory()->create();

$document = Document::factory(4)
->has(DocumentChunk::factory(4), 'document_chunks')->create([
'collection_id' => $collection->id,
]);

$chat = Chat::factory(3)
->has(Message::factory(3))->create([
'chatable_id' => $collection->id,
'chatable_type' => Collection::class,
]);

$this->actingAs($user)
->delete(route('collections.delete', $collection));
$this->assertDatabaseMissing('collections', [
'id' => $collection->id,
]);
}

/**
* A basic feature test example.
*/
Expand Down

0 comments on commit 1f803d5

Please sign in to comment.