Skip to content

Commit

Permalink
feat(Conversations): Added basic manager to list, delete and show con…
Browse files Browse the repository at this point in the history
…versations.

Refactoring to come
  • Loading branch information
PapaRascal2020 committed Sep 1, 2024
1 parent b39e351 commit 31dd66f
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/SidekickManager.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace PapaRascalDev\Sidekick;

use Illuminate\Database\Eloquent\Collection;
use PapaRascalDev\Sidekick\Models\Conversation;
class SidekickManager
{
public function listConversations(): Collection
{
return Conversation::all();
}

public function showConversation(string $conversationId): array
{
$conversation = Conversation::findOrFail($conversationId);

return [
'conversation_id' => $conversationId,
'messages' => $conversation->messages()->get(['role', 'content'])->toArray()
];
}

public function deleteConversation(string $conversationId): void
{
$conversation = Conversation::findOrFail($conversationId);
$conversation->delete();
}
}

0 comments on commit 31dd66f

Please sign in to comment.