Frag das Portal (0.64.0)
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Has been skipped
CI / PHP 8.4 / mariadb:10.6 (pull_request) Has been skipped
CI / PHP 8.3 / mariadb:11.4 (pull_request) Has been skipped
CI / PHP 8.4 / mariadb:11.4 (pull_request) Has been skipped
CI / PHP 8.3 / mysql:8.0 (pull_request) Has been skipped
CI / PHP 8.4 / mysql:8.0 (pull_request) Has been skipped
CI / PHP 8.3 / mysql:8.4 (pull_request) Has been skipped
CI / PHP 8.4 / mysql:8.4 (pull_request) Has been skipped
CI / Browser-Tests (pull_request) Failing after 19m38s
CI / PHP 8.3 / mysql:8.4-1 (pull_request) Successful in 24m17s
CI / Bekannte Sicherheitslücken in Paketen (pull_request) Successful in 9m13s
CI / Build-Artefakte aktuell (pull_request) Successful in 6m4s
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Has been skipped
CI / PHP 8.4 / mariadb:10.6 (pull_request) Has been skipped
CI / PHP 8.3 / mariadb:11.4 (pull_request) Has been skipped
CI / PHP 8.4 / mariadb:11.4 (pull_request) Has been skipped
CI / PHP 8.3 / mysql:8.0 (pull_request) Has been skipped
CI / PHP 8.4 / mysql:8.0 (pull_request) Has been skipped
CI / PHP 8.3 / mysql:8.4 (pull_request) Has been skipped
CI / PHP 8.4 / mysql:8.4 (pull_request) Has been skipped
CI / Browser-Tests (pull_request) Failing after 19m38s
CI / PHP 8.3 / mysql:8.4-1 (pull_request) Successful in 24m17s
CI / Bekannte Sicherheitslücken in Paketen (pull_request) Successful in 9m13s
CI / Build-Artefakte aktuell (pull_request) Successful in 6m4s
Antworten mit Quellen aus Seiten, QM-Dokumenten, Glossar und Neuigkeiten – nur aus Sichtbarem, über den KI-Assistenten (Anthropic, OpenAI, Ollama). Wissensquellen als Registry für Plugins, Auswertung ohne Personenbezug. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
372f0656f9
commit
9d8bdc08ce
168 changed files with 1751 additions and 383 deletions
50
plugins-core/pages/src/PageKnowledge.php
Normal file
50
plugins-core/pages/src/PageKnowledge.php
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
|
||||
namespace Inhaus\Plugins\Pages;
|
||||
|
||||
use App\Ask\Knowledge;
|
||||
use App\Models\User;
|
||||
use App\Pagebuilder\Content;
|
||||
use Inhaus\Plugins\Pages\Models\Page;
|
||||
|
||||
/** Wissensquelle für „Frag das Portal“: veröffentlichte Seiten (Handbuch, Gremien …), die die Person sieht */
|
||||
class PageKnowledge
|
||||
{
|
||||
public function __construct(private readonly PageTree $tree, private readonly Content $content) {}
|
||||
|
||||
/**
|
||||
* @param list<string> $terms
|
||||
* @return list<array<string, mixed>>
|
||||
*/
|
||||
public function __invoke(User $user, array $terms, int $limit): array
|
||||
{
|
||||
$encoded = array_map(fn (string $t) => trim((string) json_encode($t), '"'), $terms);
|
||||
$query = Page::query()->whereNotNull('published_at');
|
||||
Knowledge::whereAny($query, ['title', 'content'], array_values(array_unique([...$terms, ...$encoded])));
|
||||
|
||||
$results = [];
|
||||
|
||||
foreach ($query->orderBy('title')->limit($limit * 4)->get() as $page) {
|
||||
if (count($results) >= $limit || ! $this->tree->isVisible($page->id, $user)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Nur, was diese Person auf der Seite sieht (Blöcke für andere Zielgruppen fallen weg)
|
||||
$text = $this->content->plainText($this->content->render($page->content, $user, ['page_id' => $page->id]));
|
||||
$haystack = mb_strtolower($page->title.' '.$text);
|
||||
|
||||
if (! collect($terms)->contains(fn (string $term) => str_contains($haystack, $term))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$results[] = [
|
||||
'title' => $page->title,
|
||||
'url' => $page->url(),
|
||||
'text' => $text,
|
||||
'meta' => collect($this->tree->ancestors($page->id))->pluck('title')->filter()->implode(' › ') ?: null,
|
||||
];
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
}
|
||||
|
|
@ -3,6 +3,7 @@
|
|||
namespace Inhaus\Plugins\Pages;
|
||||
|
||||
use App\Accessibility\EasyLanguage;
|
||||
use App\Ask\Knowledge;
|
||||
use App\Editorial\Editorial;
|
||||
use App\Media\ImagePaths;
|
||||
use App\Media\MediaUsages;
|
||||
|
|
@ -28,6 +29,7 @@ class PagesPlugin extends Plugin
|
|||
public function register(): void
|
||||
{
|
||||
$this->app->make(GlobalSearch::class)->add('pages', 'Seiten', 'file-text', fn (...$args) => app(PageSearch::class)(...$args), sort: 30);
|
||||
$this->app->make(Knowledge::class)->add('pages', 'Seiten', fn (...$args) => app(PageKnowledge::class)(...$args));
|
||||
|
||||
$this->app->singleton(PageTree::class);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue