Skip to content

Commit 55dca1e

Browse files
author
Sebastian BURGIN-FIX (ext)
committed
wip
1 parent 2cfd0fa commit 55dca1e

32 files changed

Lines changed: 1049 additions & 275 deletions

app/Actions/ViewDataAction.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
namespace App\Actions;
44

55
use App\DTO\ContactDTO;
6+
use App\Enums\AiModelCategoryEnum;
67
use App\Enums\ContactSectionEnum;
8+
use App\Models\AiModel;
79
use App\Models\Configuration;
810
use App\Models\Contact;
911
use App\Models\News;
@@ -62,6 +64,33 @@ public function technologies(string $locale): Collection
6264
});
6365
}
6466

67+
public function aiModelGroups(): Collection
68+
{
69+
return Cache::rememberForever('ai_models_active', function () {
70+
$categoryOrder = array_column(AiModelCategoryEnum::cases(), 'value');
71+
72+
return AiModel::whereNull('archived_at')
73+
->orderBy('order')
74+
->get()
75+
->sortBy(fn (AiModel $model) => array_search($model->category->value, $categoryOrder))
76+
->groupBy(fn (AiModel $model) => $model->category->value);
77+
});
78+
}
79+
80+
public function aiModelArchive(): Collection
81+
{
82+
return Cache::rememberForever('ai_models_archived', function () {
83+
$categoryOrder = array_column(AiModelCategoryEnum::cases(), 'value');
84+
85+
return AiModel::whereNotNull('archived_at')
86+
->with('replacedBy')
87+
->orderBy('order')
88+
->get()
89+
->sortBy(fn (AiModel $model) => array_search($model->category->value, $categoryOrder))
90+
->groupBy(fn (AiModel $model) => $model->category->value);
91+
});
92+
}
93+
6594
public function openSource(string $locale): Collection
6695
{
6796
$key = Str::slug("open_source_published_{$locale}");

app/Enums/AiModelCategoryEnum.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
namespace App\Enums;
4+
5+
enum AiModelCategoryEnum: string
6+
{
7+
case REASONING_CODING = 'reasoning_coding';
8+
case VISION_DOCUMENTS = 'vision_documents';
9+
case RETRIEVAL_SEARCH = 'retrieval_search';
10+
11+
public function title(string $locale): string
12+
{
13+
return __('components.ai_llm.categories.'.$this->value.'.title', locale: $locale);
14+
}
15+
16+
public function description(string $locale): string
17+
{
18+
return __('components.ai_llm.categories.'.$this->value.'.description', locale: $locale);
19+
}
20+
}

app/Enums/AiModelLicenseEnum.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
namespace App\Enums;
4+
5+
enum AiModelLicenseEnum: string
6+
{
7+
case MIT = 'MIT';
8+
case APACHE_2_0 = 'Apache-2.0';
9+
case GEMMA = 'Gemma';
10+
11+
public function label(string $locale): string
12+
{
13+
return __('components.ai_llm.licenses.'.$this->key().'.label', locale: $locale);
14+
}
15+
16+
public function tooltip(string $locale): string
17+
{
18+
return __('components.ai_llm.licenses.'.$this->key().'.tooltip', locale: $locale);
19+
}
20+
21+
private function key(): string
22+
{
23+
return match ($this) {
24+
self::MIT => 'mit',
25+
self::APACHE_2_0 => 'apache',
26+
self::GEMMA => 'gemma',
27+
};
28+
}
29+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
namespace App\Http\Controllers\Ai;
4+
5+
use App\Actions\PageAction;
6+
use App\Http\Controllers\Controller;
7+
use Illuminate\View\View;
8+
9+
class AiIndexController extends Controller
10+
{
11+
public function __invoke(): View
12+
{
13+
return view('app.ai.index')->with([
14+
'page' => (new PageAction(locale: null, routeName: 'ai.index'))->default(),
15+
]);
16+
}
17+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
namespace App\Http\Controllers\AiLlm;
4+
5+
use App\Actions\PageAction;
6+
use App\Actions\ViewDataAction;
7+
use App\Http\Controllers\Controller;
8+
use Illuminate\View\View;
9+
10+
class AiLlmIndexController extends Controller
11+
{
12+
public function __invoke(): View
13+
{
14+
$viewData = new ViewDataAction;
15+
16+
return view('app.ai-llm.index')->with([
17+
'page' => (new PageAction(locale: null, routeName: 'ai.llm.index'))->default(),
18+
'groups' => $viewData->aiModelGroups(),
19+
'archive' => $viewData->aiModelArchive(),
20+
]);
21+
}
22+
}

app/Http/Controllers/Sitemap/SitemapController.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ class SitemapController extends Controller
2828
'media.index',
2929
'legal.imprint.index',
3030
'legal.privacy.index',
31+
'ai.index',
32+
'ai.llm.index',
3133
];
3234

3335
protected const array DEFAULT_LOCALES = [

app/Models/AiModel.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
namespace App\Models;
4+
5+
use App\Enums\AiModelCategoryEnum;
6+
use App\Enums\AiModelLicenseEnum;
7+
use Illuminate\Database\Eloquent\Model;
8+
use Illuminate\Database\Eloquent\Relations\BelongsTo;
9+
10+
class AiModel extends Model
11+
{
12+
protected $casts = [
13+
'category' => AiModelCategoryEnum::class,
14+
'license' => AiModelLicenseEnum::class,
15+
'role' => 'json',
16+
'in_evaluation' => 'boolean',
17+
'archived_at' => 'date',
18+
];
19+
20+
public function replacedBy(): BelongsTo
21+
{
22+
return $this->belongsTo(AiModel::class, 'replaced_by_id');
23+
}
24+
25+
public function localizedRole(string $locale): ?string
26+
{
27+
return $this->role[substr($locale, 0, 2)] ?? null;
28+
}
29+
}

app/Security/Presets/MyCspPreset.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class MyCspPreset implements Preset
1212
{
1313
public function configure(Policy $policy): void
1414
{
15-
$cdnHost = parse_url((string) env('AWS_CDN_ENDPOINT', ''), PHP_URL_HOST);
15+
$cdnHost = parse_url((string) config('filesystems.disks.s3.cdn_endpoint', ''), PHP_URL_HOST);
1616

1717
$scriptSources = array_filter([
1818
Keyword::SELF,

app/Support/CloudinaryUrl.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
class CloudinaryUrl
66
{
7-
private const CLOUDINARY_HOST = 'res.cloudinary.com';
7+
private const string CLOUDINARY_HOST = 'res.cloudinary.com';
88

9-
private const UPLOAD_MARKER = '/image/upload/';
9+
private const string UPLOAD_MARKER = '/image/upload/';
1010

1111
public static function src(string $url, int $width): string
1212
{
@@ -46,8 +46,7 @@ private static function stripExistingTransforms(string $path): string
4646
$segments = explode('/', $path);
4747

4848
if (
49-
isset($segments[0])
50-
&& preg_match('/^[a-z0-9_,.-]+$/', $segments[0])
49+
preg_match('/^[a-z0-9_,.-]+$/', $segments[0])
5150
&& preg_match('/[whcfq]_/', $segments[0])
5251
) {
5352
array_shift($segments);

0 commit comments

Comments
 (0)