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
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Inhaus\Plugins\Glossar;
|
||||
|
||||
use App\Ask\Knowledge;
|
||||
use App\Plugins\Plugin;
|
||||
use App\Search\GlobalSearch;
|
||||
use App\Support\Abilities;
|
||||
|
|
@ -14,5 +15,6 @@ class GlossarPlugin extends Plugin
|
|||
$this->app->make(Navigation::class)->add('glossar', 'Glossar', '/glossar', active: 'glossary.*', sort: 75, icon: 'book-a');
|
||||
$this->app->make(Abilities::class)->define('glossary.manage', 'Glossar pflegen', 'Glossar', portal: true);
|
||||
$this->app->make(GlobalSearch::class)->add('glossar', 'Glossar', 'book-open', fn (...$args) => app(GlossarySearch::class)(...$args), sort: 45);
|
||||
$this->app->make(Knowledge::class)->add('glossar', 'Glossar', fn (...$args) => app(GlossaryKnowledge::class)(...$args));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
28
plugins-core/glossar/src/GlossaryKnowledge.php
Normal file
28
plugins-core/glossar/src/GlossaryKnowledge.php
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
namespace Inhaus\Plugins\Glossar;
|
||||
|
||||
use App\Ask\Knowledge;
|
||||
use App\Models\User;
|
||||
use Inhaus\Plugins\Glossar\Models\GlossaryEntry;
|
||||
|
||||
/** Wissensquelle für „Frag das Portal“: Begriffe und Abkürzungen */
|
||||
class GlossaryKnowledge
|
||||
{
|
||||
/**
|
||||
* @param list<string> $terms
|
||||
* @return list<array<string, mixed>>
|
||||
*/
|
||||
public function __invoke(User $user, array $terms, int $limit): array
|
||||
{
|
||||
$query = GlossaryEntry::query();
|
||||
Knowledge::whereAny($query, ['term', 'aliases', 'description'], $terms);
|
||||
|
||||
return $query->orderBy('sort_key')->limit($limit)->get()->map(fn (GlossaryEntry $entry) => [
|
||||
'title' => $entry->term.($entry->aliases ? ' ('.$entry->aliases.')' : ''),
|
||||
'url' => '/glossar#'.$entry->anchor(),
|
||||
'text' => Knowledge::plain((string) $entry->description),
|
||||
'meta' => null,
|
||||
])->all();
|
||||
}
|
||||
}
|
||||
33
plugins-core/news/src/NewsKnowledge.php
Normal file
33
plugins-core/news/src/NewsKnowledge.php
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
namespace Inhaus\Plugins\News;
|
||||
|
||||
use App\Ask\Knowledge;
|
||||
use App\Models\User;
|
||||
use App\Pagebuilder\Content;
|
||||
use Inhaus\Plugins\News\Models\NewsPost;
|
||||
|
||||
/** Wissensquelle für „Frag das Portal“: veröffentlichte Neuigkeiten, die die Person sieht */
|
||||
class NewsKnowledge
|
||||
{
|
||||
public function __construct(private readonly Content $content) {}
|
||||
|
||||
/**
|
||||
* @param list<string> $terms
|
||||
* @return list<array<string, mixed>>
|
||||
*/
|
||||
public function __invoke(User $user, array $terms, int $limit): array
|
||||
{
|
||||
// Inhalt aus dem Baukasten liegt als JSON vor (Umlaute als ü) – auch diese Schreibweise suchen
|
||||
$encoded = array_map(fn (string $t) => trim((string) json_encode($t), '"'), $terms);
|
||||
$query = NewsPost::query()->published()->visibleTo($user)->with('category');
|
||||
Knowledge::whereAny($query, ['title', 'teaser', 'body', 'content'], array_values(array_unique([...$terms, ...$encoded])));
|
||||
|
||||
return $query->latest('published_at')->limit($limit)->get()->map(fn (NewsPost $post) => [
|
||||
'title' => $post->title,
|
||||
'url' => route('news.show', $post->slug),
|
||||
'text' => trim($post->teaser."\n".$this->content->plainText($this->content->render($post->blocks(), $user, ['news_id' => $post->id]))),
|
||||
'meta' => collect([$post->category?->name, $post->published_at?->translatedFormat('j. F Y')])->filter()->implode(', '),
|
||||
])->all();
|
||||
}
|
||||
}
|
||||
|
|
@ -3,6 +3,7 @@
|
|||
namespace Inhaus\Plugins\News;
|
||||
|
||||
use App\Accessibility\EasyLanguage;
|
||||
use App\Ask\Knowledge;
|
||||
use App\Dashboard\Widgets;
|
||||
use App\Digest\Digest;
|
||||
use App\Editorial\Editorial;
|
||||
|
|
@ -61,6 +62,7 @@ class NewsPlugin extends Plugin
|
|||
])->all());
|
||||
|
||||
$this->app->make(GlobalSearch::class)->add('news', 'Neuigkeiten', 'newspaper', fn (...$args) => app(NewsSearch::class)(...$args), sort: 10);
|
||||
$this->app->make(Knowledge::class)->add('news', 'Neuigkeiten', fn (...$args) => app(NewsKnowledge::class)(...$args));
|
||||
|
||||
$this->app->make(Navigation::class)->add('news', 'Neuigkeiten', '/neuigkeiten', active: ['news.index', 'news.show'], sort: 20, icon: 'newspaper');
|
||||
|
||||
|
|
|
|||
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);
|
||||
|
||||
|
|
|
|||
66
plugins-core/qm/src/QmKnowledge.php
Normal file
66
plugins-core/qm/src/QmKnowledge.php
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
<?php
|
||||
|
||||
namespace Inhaus\Plugins\Qm;
|
||||
|
||||
use App\Ask\Knowledge;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Inhaus\Plugins\Qm\Models\QmEntry;
|
||||
|
||||
/**
|
||||
* Wissensquelle für „Frag das Portal“: QM-Dokumente in Ordnern, die die Person sieht –
|
||||
* mit dem Text der aktuellen Fassung (auch aus PDF und Office-Dateien).
|
||||
*/
|
||||
class QmKnowledge
|
||||
{
|
||||
public function __construct(private readonly QmTree $tree, private readonly QmAccess $access, private readonly Presenter $presenter) {}
|
||||
|
||||
/**
|
||||
* @param list<string> $terms
|
||||
* @return list<array<string, mixed>>
|
||||
*/
|
||||
public function __invoke(User $user, array $terms, int $limit): array
|
||||
{
|
||||
if (! $this->access->allows($user)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$folders = $this->tree->visibleIds($user) ?: [0];
|
||||
|
||||
$byMeta = QmEntry::query()->whereIn('folder_id', $folders);
|
||||
Knowledge::whereAny($byMeta, ['title', 'description'], $terms);
|
||||
$ids = $byMeta->limit($limit)->pluck('id')->all();
|
||||
|
||||
$byText = DB::table('qm_files')->join('qm_entries', 'qm_entries.id', '=', 'qm_files.entry_id')
|
||||
->whereIn('qm_entries.folder_id', $folders)->whereNull('qm_files.archived_at')->whereNotNull('qm_files.text');
|
||||
Knowledge::whereAny($byText, ['qm_files.text'], $terms);
|
||||
$ids = array_values(array_unique([...$ids, ...$byText->limit($limit * 2)->pluck('qm_files.entry_id')->map(fn ($id) => (int) $id)->all()]));
|
||||
|
||||
if ($ids === []) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// Je Eintrag ein Text – die Lesefassung vor der Vorlage
|
||||
$texts = [];
|
||||
|
||||
foreach (DB::table('qm_files')->whereIn('entry_id', $ids)->whereNull('archived_at')->whereNotNull('text')->get(['entry_id', 'kind', 'text']) as $row) {
|
||||
if (! isset($texts[(int) $row->entry_id]) || $row->kind === 'reading') {
|
||||
$texts[(int) $row->entry_id] = (string) $row->text;
|
||||
}
|
||||
}
|
||||
|
||||
return QmEntry::query()->whereIn('id', $ids)->with(['readingFile', 'editableFile'])->get()
|
||||
->map(function (QmEntry $entry) use ($texts) {
|
||||
$shown = $this->presenter->entry($entry);
|
||||
$folder = $this->presenter->folderLabel($entry->folder_id);
|
||||
|
||||
return [
|
||||
'title' => $entry->title,
|
||||
'url' => $shown['open_url'] ?? $folder['url'],
|
||||
'text' => trim(Knowledge::plain((string) $entry->description)."\n".($texts[$entry->id] ?? '')),
|
||||
'meta' => collect([$folder['path'], $entry->version ? 'Version '.$entry->version : null])->filter()->implode(', ') ?: null,
|
||||
];
|
||||
})
|
||||
->all();
|
||||
}
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Inhaus\Plugins\Qm;
|
||||
|
||||
use App\Ask\Knowledge;
|
||||
use App\Dashboard\Widgets;
|
||||
use App\Models\User;
|
||||
use App\Plugins\Plugin;
|
||||
|
|
@ -19,6 +20,7 @@ class QmPlugin extends Plugin
|
|||
public function register(): void
|
||||
{
|
||||
$this->app->make(GlobalSearch::class)->add('qm', 'Qualitätsmanagement', 'shield-check', fn (...$args) => app(QmSearch::class)(...$args), sort: 50);
|
||||
$this->app->make(Knowledge::class)->add('qm', 'Qualitätsmanagement', fn (...$args) => app(QmKnowledge::class)(...$args));
|
||||
|
||||
foreach ([QmTree::class, QmAccess::class, Presenter::class, Search::class, Library::class, Reviews::class, Acknowledgements::class, Indexer::class, TextExtractor::class, Ocr::class] as $class) {
|
||||
$this->app->singleton($class);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue