Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/Commands/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ class InstallCommand extends Command

public function handle(QdrantService $qdrant): int
{
$project = $this->option('project');
/** @var string $project */
$project = is_string($this->option('project')) ? $this->option('project') : 'default';

note("Initializing collection: knowledge_{$project}");

Expand Down
34 changes: 21 additions & 13 deletions app/Commands/KnowledgeArchiveCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,25 +56,29 @@ public function handle(QdrantService $qdrant): int
*/
private function archiveEntry(QdrantService $qdrant, array $entry): int
{
if ($entry['status'] === 'deprecated') {
$this->warn("Entry #{$entry['id']} is already archived.");
$entryId = is_scalar($entry['id']) ? (int) $entry['id'] : 0;
$entryTitle = is_scalar($entry['title']) ? (string) $entry['title'] : '';
$entryStatus = is_scalar($entry['status']) ? (string) $entry['status'] : '';

if ($entryStatus === 'deprecated') {
$this->warn("Entry #{$entryId} is already archived.");

return self::SUCCESS;
}

$oldStatus = $entry['status'];
$oldStatus = $entryStatus;

$qdrant->updateFields((int) $entry['id'], [
$qdrant->updateFields($entryId, [
'status' => 'deprecated',
'confidence' => 0,
]);

$this->info("Entry #{$entry['id']} has been archived.");
$this->info("Entry #{$entryId} has been archived.");
$this->newLine();
$this->line("Title: {$entry['title']}");
$this->line("Title: {$entryTitle}");
$this->line("Status: {$oldStatus} -> deprecated");
$this->newLine();
$this->comment('Restore with: knowledge:archive '.$entry['id'].' --restore');
$this->comment('Restore with: knowledge:archive '.$entryId.' --restore');

return self::SUCCESS;
}
Expand All @@ -86,24 +90,28 @@ private function archiveEntry(QdrantService $qdrant, array $entry): int
*/
private function restoreEntry(QdrantService $qdrant, array $entry): int
{
if ($entry['status'] !== 'deprecated') {
$this->warn("Entry #{$entry['id']} is not archived (status: {$entry['status']}).");
$entryId = is_scalar($entry['id']) ? (int) $entry['id'] : 0;
$entryTitle = is_scalar($entry['title']) ? (string) $entry['title'] : '';
$entryStatus = is_scalar($entry['status']) ? (string) $entry['status'] : '';

if ($entryStatus !== 'deprecated') {
$this->warn("Entry #{$entryId} is not archived (status: {$entryStatus}).");

return self::SUCCESS;
}

$qdrant->updateFields((int) $entry['id'], [
$qdrant->updateFields($entryId, [
'status' => 'draft',
'confidence' => 50,
]);

$this->info("Entry #{$entry['id']} has been restored.");
$this->info("Entry #{$entryId} has been restored.");
$this->newLine();
$this->line("Title: {$entry['title']}");
$this->line("Title: {$entryTitle}");
$this->line('Status: deprecated -> draft');
$this->line('Confidence: 50%');
$this->newLine();
$this->comment('Validate with: knowledge:validate '.$entry['id']);
$this->comment('Validate with: knowledge:validate '.$entryId);

return self::SUCCESS;
}
Expand Down
Loading
Loading