Skip to content

Commit c20725d

Browse files
committed
update ai command
1 parent 108f4c7 commit c20725d

58 files changed

Lines changed: 319 additions & 250 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<?php
2+
3+
namespace App\Console\Commands;
4+
5+
use App\Jobs\GenerateThemeMetadataJob;
6+
use App\Models\Theme;
7+
use Illuminate\Console\Attributes\Description;
8+
use Illuminate\Console\Attributes\Signature;
9+
use Illuminate\Console\Command;
10+
11+
#[Signature('themes:generate-missing-metadata')]
12+
#[Description('Find incomplete themes and generate missing metadata using AI')]
13+
class GenerateMissingThemeMetadata extends Command
14+
{
15+
public function handle(): void
16+
{
17+
$themes = Theme::where(function ($query) {
18+
$query->whereDoesntHave('tags')
19+
->orWhereNull('description')
20+
->orWhere('description', '');
21+
})->oldest()->get();
22+
23+
if ($themes->isEmpty()) {
24+
$this->info('No incomplete themes found.');
25+
26+
return;
27+
}
28+
29+
$this->line("Found {$themes->count()} incomplete theme(s).");
30+
31+
foreach ($themes as $theme) {
32+
$hadDescription = (bool) $theme->description;
33+
$hadTags = $theme->tags->isNotEmpty();
34+
35+
$missing = [];
36+
if (! $hadDescription) {
37+
$missing[] = 'description';
38+
}
39+
if (! $hadTags) {
40+
$missing[] = 'tags';
41+
}
42+
43+
$this->line(" Processing: {$theme->name} (ID: {$theme->id})");
44+
$this->line(' Missing: '.implode(', ', $missing));
45+
46+
GenerateThemeMetadataJob::dispatchSync($theme);
47+
48+
$theme->refresh()->load('tags');
49+
50+
$descriptionStatus = match (true) {
51+
! $hadDescription && (bool) $theme->description => 'added',
52+
$hadDescription => 'already present',
53+
default => 'failed',
54+
};
55+
56+
$tagsStatus = match (true) {
57+
! $hadTags && $theme->tags->isNotEmpty() => 'added: '.$theme->tags->pluck('name')->implode(', '),
58+
$hadTags => 'already present',
59+
default => 'failed (AI returned no tags)',
60+
};
61+
62+
$this->line(" <info>✓</info> Description: {$descriptionStatus}");
63+
$this->line(" <info>✓</info> Tags: {$tagsStatus}");
64+
}
65+
}
66+
}

bootstrap/app.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@
3434
})
3535
->withExceptions(function (Exceptions $exceptions): void {
3636
//
37-
})->create();
37+
})->withCommands()->create();

config/services.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848

4949
'openrouter' => [
5050
'key' => env('OPENROUTER_API_KEY'),
51-
'model' => env('OPENROUTER_MODEL', 'nvidia/nemotron-3-super-120b-a12b:free'),
51+
'model' => env('OPENROUTER_MODEL', 'openrouter/free'),
5252
],
5353

5454
];

public/build/assets/animate-css-DIxn22Sl.js renamed to public/build/assets/animate-css-CdG7zNQP.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/build/assets/appearance-DkF4xOip.js renamed to public/build/assets/appearance-DOeYMxjV.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/build/assets/appearance-tabs-Bbh38TuS.js renamed to public/build/assets/appearance-tabs-DAXo8Fnp.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/build/assets/check-C57qd05Q.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)