Skip to content

Commit f9177a5

Browse files
author
Sebastian BURGIN-FIX (ext)
committed
wip
1 parent 0225c28 commit f9177a5

19 files changed

Lines changed: 119 additions & 95 deletions

File tree

app/Actions/ViewDataAction.php

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -67,30 +67,32 @@ public function technologies(string $locale): Collection
6767
public function aiModelGroups(): Collection
6868
{
6969
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);
70+
return $this->groupAiModelsByCategory(
71+
AiModel::whereNull('archived_at')->orderBy('order')->get()
72+
);
7773
});
7874
}
7975

8076
public function aiModelArchive(): Collection
8177
{
8278
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);
79+
return $this->groupAiModelsByCategory(
80+
AiModel::whereNotNull('archived_at')->with('replacedBy')->orderBy('order')->get()
81+
);
9182
});
9283
}
9384

85+
private function groupAiModelsByCategory(Collection $models): Collection
86+
{
87+
return collect(AiModelCategoryEnum::cases())
88+
->map(fn (AiModelCategoryEnum $category) => [
89+
'category' => $category,
90+
'models' => $models->where('category', $category)->values(),
91+
])
92+
->filter(fn (array $group) => $group['models']->isNotEmpty())
93+
->values();
94+
}
95+
9496
public function openSource(string $locale): Collection
9597
{
9698
$key = Str::slug("open_source_published_{$locale}");

app/Enums/AiModelCategoryEnum.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ enum AiModelCategoryEnum: string
88
case VISION_DOCUMENTS = 'vision_documents';
99
case RETRIEVAL_SEARCH = 'retrieval_search';
1010

11-
public function title(string $locale): string
11+
public function title(): string
1212
{
13-
return __('components.ai_llm.categories.'.$this->value.'.title', locale: $locale);
13+
return __('components.ai_llm.categories.'.$this->value.'.title');
1414
}
1515

16-
public function description(string $locale): string
16+
public function description(): string
1717
{
18-
return __('components.ai_llm.categories.'.$this->value.'.description', locale: $locale);
18+
return __('components.ai_llm.categories.'.$this->value.'.description');
1919
}
2020
}

app/Http/Controllers/AiLlm/AiLlmIndexController.php renamed to app/Http/Controllers/Ai/AiLlmIndexController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace App\Http\Controllers\AiLlm;
3+
namespace App\Http\Controllers\Ai;
44

55
use App\Actions\PageAction;
66
use App\Actions\ViewDataAction;
@@ -13,7 +13,7 @@ public function __invoke(): View
1313
{
1414
$viewData = new ViewDataAction;
1515

16-
return view('app.ai-llm.index')->with([
16+
return view('app.ai.llm.index')->with([
1717
'page' => (new PageAction(locale: null, routeName: 'ai.llm.index'))->default(),
1818
'groups' => $viewData->aiModelGroups(),
1919
'archive' => $viewData->aiModelArchive(),

app/Models/AiModel.php

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,27 +19,32 @@ public function replacedBy(): BelongsTo
1919
return $this->belongsTo(AiModel::class, 'replaced_by_id');
2020
}
2121

22-
public function localizedRole(string $locale): ?string
22+
public function localizedRole(): ?string
2323
{
24-
return $this->role[substr($locale, 0, 2)] ?? null;
24+
return $this->role[substr(app()->getLocale(), 0, 2)] ?? null;
2525
}
2626

27-
public function licenseLabel(string $locale): ?string
27+
public function licenseLabel(): ?string
2828
{
29-
return $this->license ? __('components.ai_llm.licenses.'.$this->licenseKey().'.label', locale: $locale) : null;
29+
$key = $this->licenseKey();
30+
31+
return $key ? __('components.ai_llm.licenses.'.$key.'.label') : $this->license;
3032
}
3133

32-
public function licenseTooltip(string $locale): ?string
34+
public function licenseTooltip(): ?string
3335
{
34-
return $this->license ? __('components.ai_llm.licenses.'.$this->licenseKey().'.tooltip', locale: $locale) : null;
36+
$key = $this->licenseKey();
37+
38+
return $key ? __('components.ai_llm.licenses.'.$key.'.tooltip') : null;
3539
}
3640

37-
private function licenseKey(): string
41+
private function licenseKey(): ?string
3842
{
3943
return match ($this->license) {
4044
'MIT' => 'mit',
4145
'Apache-2.0' => 'apache',
4246
'Gemma' => 'gemma',
47+
default => null,
4348
};
4449
}
4550
}

database/seeders/Codebar/PagesTableSeeder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ private function enCH()
149149
[
150150
'robots' => 'index,follow',
151151
'title' => 'Our local LLMs in action',
152-
'description' => 'These are the local open-source models we currently rely on — all of them run on our own infrastructure, in our office.',
152+
'description' => 'These are the local open-source models we currently rely on — all of them run on our own infrastructure, in our very own office basement.',
153153
]
154154
);
155155
}

lang/de_CH/components.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,19 +78,19 @@
7878
],
7979
'infrastructure' => [
8080
'title' => 'Unsere Infrastruktur',
81-
'intro' => 'Unsere Modelle laufen vollständig auf eigener, lokaler Infrastruktur — bei uns im Büro, nicht in der Cloud. Alle Daten bleiben im Haus.',
81+
'intro' => 'Hier laufen unsere lokalen Modelle.',
8282
'items' => [
8383
'hardware' => [
8484
'label' => 'Hardware',
8585
'text' => 'MacBook Pro 16" M5 Max, 128 GB RAM.',
8686
],
8787
'management' => [
8888
'label' => 'Modellverwaltung',
89-
'text' => 'LiteLLM Studio für Verwaltung und Autorisierung, Ollama betreibt die Modelle.',
89+
'text' => 'LiteLLM für Verwaltung und Autorisierung, Ollama betreibt die Modelle.',
9090
],
9191
'access' => [
9292
'label' => 'Zugang & Sicherheit',
93-
'text' => 'Cloudinary-Tunnel auf das lokale MacBook.',
93+
'text' => 'Cloudflare Tunnel auf das lokale MacBook.',
9494
],
9595
'power' => [
9696
'label' => 'Strom',

lang/en_CH/components.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,19 +76,19 @@
7676
],
7777
'infrastructure' => [
7878
'title' => 'Our infrastructure',
79-
'intro' => 'Our models run entirely on our own local infrastructure — in our office, not in the cloud. All data stays in-house.',
79+
'intro' => 'This is where our local models run.',
8080
'items' => [
8181
'hardware' => [
8282
'label' => 'Hardware',
8383
'text' => 'MacBook Pro 16" M5 Max, 128 GB RAM.',
8484
],
8585
'management' => [
8686
'label' => 'Model management',
87-
'text' => 'LiteLLM Studio for management and authorization, Ollama runs the models.',
87+
'text' => 'LiteLLM for management and authorization, Ollama runs the models.',
8888
],
8989
'access' => [
9090
'label' => 'Access & security',
91-
'text' => 'Cloudinary tunnel to the local MacBook.',
91+
'text' => 'Cloudflare Tunnel to the local MacBook.',
9292
],
9393
'power' => [
9494
'label' => 'Power',

resources/views/app/ai/index.blade.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
<x-h1 :title="__('components.ai.title')"/>
33
<p class="text-gray-800">{{ __('components.ai.intro') }}</p>
44

5-
<div class="mt-8">
5+
<x-section>
66
<x-h2 :title="__('components.ai_llm.title')"/>
77
<p class="text-gray-600">{{ __('components.ai.llm_teaser') }}</p>
88
<x-a :href="localized_route('ai.llm.index')" label="{{ __('components.ai.more_info') }}"
9-
classAttributes="mt-2 inline-block text-base"/>
10-
</div>
9+
class-attributes="mt-2 inline-block text-base"/>
10+
</x-section>
1111
</x-app-layout>
Lines changed: 27 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,21 @@
1-
@php
2-
$locale = app()->getLocale();
3-
@endphp
4-
51
<x-app-layout :page="$page">
62
<x-h1 :title="__('components.ai_llm.title')"/>
73
<p class="text-gray-800">{{ __('components.ai_llm.intro') }}</p>
84

9-
@foreach ($groups as $category => $models)
10-
@php
11-
$categoryEnum = \App\Enums\AiModelCategoryEnum::from($category);
12-
@endphp
13-
<x-ai-llm.card>
14-
<x-h2 :title="$categoryEnum->title($locale)"/>
15-
<p class="text-gray-600 mb-4">{{ $categoryEnum->description($locale) }}</p>
16-
17-
@foreach ($models as $model)
18-
<x-ai-llm.model-row :model="$model"/>
19-
@endforeach
20-
</x-ai-llm.card>
5+
@foreach ($groups as $group)
6+
<x-section>
7+
<x-ai-llm.card>
8+
<x-h2 :title="$group['category']->title()"/>
9+
<p class="text-gray-600 mb-4">{{ $group['category']->description() }}</p>
10+
11+
@foreach ($group['models'] as $model)
12+
<x-ai-llm.model-row :model="$model"/>
13+
@endforeach
14+
</x-ai-llm.card>
15+
</x-section>
2116
@endforeach
2217

23-
<div class="mt-8">
18+
<x-section>
2419
<x-h2 :title="__('components.ai_llm.infrastructure.title')"/>
2520
<p class="text-gray-600 mb-4">{{ __('components.ai_llm.infrastructure.intro') }}</p>
2621

@@ -46,20 +41,19 @@
4641
<x-ai-llm.infra-row
4742
:label="__('components.ai_llm.infrastructure.items.power.label')"
4843
:text="__('components.ai_llm.infrastructure.items.power.text')"/>
49-
</div>
50-
51-
<x-ai-llm.card id="archiv">
52-
<x-h2 :title="__('components.ai_llm.archive.title')"/>
53-
<p class="text-gray-600 mb-4">{{ __('components.ai_llm.archive.intro') }}</p>
54-
55-
@foreach ($archive as $category => $models)
56-
@php
57-
$categoryEnum = \App\Enums\AiModelCategoryEnum::from($category);
58-
@endphp
59-
<div class="{{ $loop->first ? '' : 'mt-8' }}">
60-
<x-h3 :title="$categoryEnum->title($locale)"/>
61-
<x-ai-llm.archive-table :models="$models"/>
62-
</div>
63-
@endforeach
64-
</x-ai-llm.card>
44+
</x-section>
45+
46+
<x-section>
47+
<x-ai-llm.card id="archiv">
48+
<x-h2 :title="__('components.ai_llm.archive.title')"/>
49+
<p class="text-gray-600 mb-4">{{ __('components.ai_llm.archive.intro') }}</p>
50+
51+
@foreach ($archive as $group)
52+
<div class="{{ $loop->first ? '' : 'mt-8' }}">
53+
<x-h3 :title="$group['category']->title()"/>
54+
<x-ai-llm.archive-table :models="$group['models']"/>
55+
</div>
56+
@endforeach
57+
</x-ai-llm.card>
58+
</x-section>
6559
</x-app-layout>

resources/views/app/start/index.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<x-list-card
1010
:url="localized_route('ai.llm.index')"
1111
:title="__('components.ai_llm.title')"
12-
:teaser="__('components.ai_llm.intro')"/>
12+
:teaser="__('components.ai.llm_teaser')"/>
1313
</x-list>
1414
</x-section>
1515

0 commit comments

Comments
 (0)