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
191
resources/js/pages/Ask/Index.vue
Normal file
191
resources/js/pages/Ask/Index.vue
Normal file
|
|
@ -0,0 +1,191 @@
|
|||
<script setup>
|
||||
import { computed, nextTick, onMounted, ref } from 'vue';
|
||||
import { ArrowUpRight, LoaderCircle, MessageCircleQuestion, SearchX, Sparkles } from '@lucide/vue';
|
||||
import AppLayout from '@/layouts/AppLayout.vue';
|
||||
import PageHeader from '@/components/PageHeader.vue';
|
||||
import Panel from '@/components/Panel.vue';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { http } from '@/lib/http';
|
||||
|
||||
const props = defineProps({
|
||||
question: { type: String, default: '' },
|
||||
sources: { type: Array, default: () => [] },
|
||||
provider: { type: String, default: null },
|
||||
});
|
||||
|
||||
const input = ref(props.question);
|
||||
const asked = ref('');
|
||||
const loading = ref(false);
|
||||
const error = ref('');
|
||||
const result = ref(null);
|
||||
const field = ref(null);
|
||||
|
||||
const examples = ['Wie beantrage ich Urlaub?', 'Was mache ich bei einem Arbeitsunfall?', 'Wer ist in der Mitarbeitervertretung?'];
|
||||
|
||||
async function ask(question = input.value) {
|
||||
const text = question.trim();
|
||||
if (text.length < 3 || loading.value) return;
|
||||
|
||||
input.value = text;
|
||||
asked.value = text;
|
||||
loading.value = true;
|
||||
error.value = '';
|
||||
result.value = null;
|
||||
|
||||
// Frage in der Adresse, damit man sie teilen und zurückkehren kann
|
||||
window.history.replaceState(window.history.state, '', `/frag-das-portal?frage=${encodeURIComponent(text)}`);
|
||||
|
||||
try {
|
||||
result.value = await http.post('/frag-das-portal', { question: text });
|
||||
} catch (e) {
|
||||
error.value = e.status === 429 ? 'Sie haben gerade viele Fragen gestellt. Bitte einen Moment warten.' : (e.data?.errors?.question?.[0] ?? e.message);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Antwort als Absätze und Listenpunkte; [2] wird zum Verweis auf die Quelle
|
||||
const blocks = computed(() => {
|
||||
if (!result.value?.found) return [];
|
||||
const known = new Set(result.value.sources.map((s) => s.n));
|
||||
const segments = (line) => line.split(/(\[\d+\])/).filter(Boolean).map((part) => {
|
||||
const cite = part.match(/^\[(\d+)\]$/);
|
||||
return cite && known.has(Number(cite[1])) ? { cite: Number(cite[1]) } : { text: part };
|
||||
});
|
||||
const out = [];
|
||||
for (const raw of result.value.answer.split('\n')) {
|
||||
const line = raw.trim();
|
||||
if (!line) continue;
|
||||
if (/^[-•*]\s+/.test(line)) {
|
||||
const last = out[out.length - 1];
|
||||
const item = segments(line.replace(/^[-•*]\s+/, ''));
|
||||
last?.type === 'list' ? last.items.push(item) : out.push({ type: 'list', items: [item] });
|
||||
} else {
|
||||
out.push({ type: 'p', segments: segments(line) });
|
||||
}
|
||||
}
|
||||
return out;
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
if (props.question) ask(props.question);
|
||||
else nextTick(() => field.value?.focus());
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<AppLayout title="Frag das Portal" width="medium">
|
||||
<PageHeader
|
||||
title="Frag das Portal"
|
||||
:description="`Stellen Sie eine Frage – die Antwort kommt aus ${sources.length ? sources.join(', ') : 'den Inhalten des Portals'}.`"
|
||||
icon="message-circle-question"
|
||||
/>
|
||||
|
||||
<div class="grid min-w-0 grid-cols-1 gap-5">
|
||||
<form class="grid min-w-0 gap-3" @submit.prevent="ask()">
|
||||
<label for="ask-question" class="sr-only">Ihre Frage</label>
|
||||
<div class="flex flex-col gap-2 rounded-xl border bg-card p-2 shadow-xs focus-within:border-brand-400 focus-within:ring-3 focus-within:ring-ring/30 sm:flex-row sm:items-end">
|
||||
<textarea
|
||||
id="ask-question"
|
||||
ref="field"
|
||||
v-model="input"
|
||||
rows="2"
|
||||
maxlength="300"
|
||||
placeholder="z. B. Wie beantrage ich eine Fortbildung?"
|
||||
class="min-h-14 w-full min-w-0 flex-1 resize-none bg-transparent px-2 py-1.5 text-base outline-none placeholder:text-muted-foreground"
|
||||
@keydown.enter.exact.prevent="ask()"
|
||||
/>
|
||||
<Button type="submit" :disabled="loading || input.trim().length < 3" class="shrink-0">
|
||||
<LoaderCircle v-if="loading" class="animate-spin" />
|
||||
<Sparkles v-else />
|
||||
Fragen
|
||||
</Button>
|
||||
</div>
|
||||
<div v-if="!asked" class="flex flex-wrap gap-2">
|
||||
<button
|
||||
v-for="example in examples"
|
||||
:key="example"
|
||||
type="button"
|
||||
class="rounded-pill border bg-card px-3.5 py-1.5 text-[13px] text-muted-foreground hover:bg-accent hover:text-foreground"
|
||||
@click="ask(example)"
|
||||
>{{ example }}</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div aria-live="polite" class="grid min-w-0 grid-cols-1 gap-5">
|
||||
<Panel v-if="loading">
|
||||
<div class="flex items-center gap-3 text-muted-foreground">
|
||||
<LoaderCircle class="size-5 animate-spin text-brand" />
|
||||
Ich suche im Portal nach einer Antwort …
|
||||
</div>
|
||||
</Panel>
|
||||
|
||||
<p v-else-if="error" class="rounded-lg border border-destructive/30 bg-destructive/5 px-4 py-3 text-sm text-destructive">{{ error }}</p>
|
||||
|
||||
<template v-else-if="result">
|
||||
<Panel v-if="result.found">
|
||||
<p class="mb-3 text-sm font-medium text-muted-foreground">{{ asked }}</p>
|
||||
<div class="grid grid-cols-1 gap-3 text-base leading-relaxed">
|
||||
<template v-for="(block, i) in blocks" :key="i">
|
||||
<p v-if="block.type === 'p'">
|
||||
<template v-for="(seg, j) in block.segments" :key="j">
|
||||
<a v-if="seg.cite" :href="`#quelle-${seg.cite}`" class="mx-0.5 align-super text-xs font-semibold text-brand-text hover:underline" :aria-label="`Quelle ${seg.cite}`">[{{ seg.cite }}]</a>
|
||||
<template v-else>{{ seg.text }}</template>
|
||||
</template>
|
||||
</p>
|
||||
<ul v-else class="grid list-disc gap-1.5 pl-5">
|
||||
<li v-for="(item, k) in block.items" :key="k">
|
||||
<template v-for="(seg, j) in item" :key="j">
|
||||
<a v-if="seg.cite" :href="`#quelle-${seg.cite}`" class="mx-0.5 align-super text-xs font-semibold text-brand-text hover:underline" :aria-label="`Quelle ${seg.cite}`">[{{ seg.cite }}]</a>
|
||||
<template v-else>{{ seg.text }}</template>
|
||||
</template>
|
||||
</li>
|
||||
</ul>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<h2 class="mt-6 mb-2 text-sm font-semibold">Quellen</h2>
|
||||
<ol class="grid grid-cols-1 gap-2">
|
||||
<li v-for="source in result.sources" :id="`quelle-${source.n}`" :key="source.n">
|
||||
<a :href="source.url" class="group flex items-start gap-3 rounded-lg border bg-background px-3 py-2.5 hover:border-brand-300 hover:bg-accent">
|
||||
<span class="grid size-6 shrink-0 place-items-center rounded-full bg-brand-soft text-xs font-semibold text-brand-text">{{ source.n }}</span>
|
||||
<span class="min-w-0 flex-1">
|
||||
<span class="block font-medium group-hover:underline">{{ source.title }}</span>
|
||||
<span class="block truncate text-xs text-muted-foreground">{{ source.label }}<template v-if="source.meta"> · {{ source.meta }}</template></span>
|
||||
</span>
|
||||
<ArrowUpRight class="mt-0.5 size-4 shrink-0 text-muted-foreground" />
|
||||
</a>
|
||||
</li>
|
||||
</ol>
|
||||
<p class="mt-4 text-xs text-muted-foreground">Automatisch zusammengefasst – im Zweifel gilt, was in den Quellen steht.</p>
|
||||
</Panel>
|
||||
|
||||
<Panel v-else>
|
||||
<div class="flex items-start gap-3">
|
||||
<SearchX class="mt-0.5 size-5 shrink-0 text-muted-foreground" />
|
||||
<div class="grid gap-1">
|
||||
<p class="font-medium">{{ result.answer }}</p>
|
||||
<p class="text-sm text-muted-foreground">Versuchen Sie es mit anderen Worten – oder fragen Sie direkt Ihre Ansprechpersonen.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="result.suggestions.length" class="mt-4 grid grid-cols-1 gap-2">
|
||||
<p class="text-sm font-medium">Vielleicht hilft Ihnen das weiter:</p>
|
||||
<a v-for="item in result.suggestions" :key="item.url" :href="item.url" class="flex items-center justify-between gap-3 rounded-lg border bg-background px-3 py-2 text-sm hover:bg-accent">
|
||||
<span class="min-w-0 truncate">{{ item.title }} <span class="text-muted-foreground">· {{ item.label }}</span></span>
|
||||
<ArrowUpRight class="size-4 shrink-0 text-muted-foreground" />
|
||||
</a>
|
||||
</div>
|
||||
</Panel>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<p class="flex items-start gap-2 text-xs text-muted-foreground">
|
||||
<MessageCircleQuestion class="mt-px size-3.5 shrink-0" />
|
||||
<span>
|
||||
Gesucht wird nur in Inhalten, die Sie sehen dürfen. Fragen werden ohne Ihren Namen gespeichert, damit die Redaktion fehlende Inhalte ergänzen kann.
|
||||
<template v-if="provider"> Die Frage und passende Textstellen werden zur Beantwortung an {{ provider }} übermittelt.</template>
|
||||
</span>
|
||||
</p>
|
||||
</div>
|
||||
</AppLayout>
|
||||
</template>
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
<script setup>
|
||||
import { ref } from 'vue';
|
||||
import { router } from '@inertiajs/vue3';
|
||||
import { BookOpen, Search } from '@lucide/vue';
|
||||
import { computed, ref } from 'vue';
|
||||
import { router, usePage } from '@inertiajs/vue3';
|
||||
import { BookOpen, Search, Sparkles } from '@lucide/vue';
|
||||
import AppLayout from '@/layouts/AppLayout.vue';
|
||||
import EmptyState from '@/components/EmptyState.vue';
|
||||
import HubTile from '@/components/hubs/HubTile.vue';
|
||||
|
|
@ -11,19 +11,26 @@ defineProps({
|
|||
});
|
||||
|
||||
const query = ref('');
|
||||
// Mit „Frag das Portal“ beantwortet das Feld die Frage direkt, sonst sucht es
|
||||
const canAsk = computed(() => !!usePage().props.ask);
|
||||
const search = () => query.value.trim() && router.get('/suche', { q: query.value.trim() });
|
||||
const submit = () => (canAsk.value && query.value.trim() ? router.get('/frag-das-portal', { frage: query.value.trim() }) : search());
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<AppLayout title="Wissen" :header="false">
|
||||
<section class="grid justify-items-center gap-5 py-6 text-center sm:py-10">
|
||||
<h1 class="text-3xl font-bold tracking-tight text-balance sm:text-4xl">Was möchten Sie wissen?</h1>
|
||||
<form role="search" class="flex w-full max-w-2xl items-center gap-2 rounded-pill border bg-card p-1.5 pl-5 shadow-sm focus-within:ring-3 focus-within:ring-ring/30" @submit.prevent="search">
|
||||
<Search class="size-5 shrink-0 text-muted-foreground" />
|
||||
<label for="wissen-suche" class="sr-only">Portal durchsuchen</label>
|
||||
<form role="search" class="flex w-full max-w-2xl items-center gap-2 rounded-pill border bg-card p-1.5 pl-5 shadow-sm focus-within:ring-3 focus-within:ring-ring/30" @submit.prevent="submit">
|
||||
<component :is="canAsk ? Sparkles : Search" class="size-5 shrink-0 text-muted-foreground" />
|
||||
<label for="wissen-suche" class="sr-only">{{ canAsk ? 'Frage an das Portal' : 'Portal durchsuchen' }}</label>
|
||||
<input id="wissen-suche" v-model="query" type="search" placeholder="z. B. „Wie beantrage ich eine Fortbildung?“" class="h-11 min-w-0 flex-1 bg-transparent text-base outline-none" />
|
||||
<button type="submit" class="h-11 rounded-pill bg-brand px-5 text-sm font-semibold text-brand-foreground hover:opacity-90">Suchen</button>
|
||||
<button type="submit" class="h-11 rounded-pill bg-brand px-5 text-sm font-semibold text-brand-foreground hover:opacity-90">{{ canAsk ? 'Fragen' : 'Suchen' }}</button>
|
||||
</form>
|
||||
<p v-if="canAsk" class="text-sm text-muted-foreground">
|
||||
Kurze Antwort mit Quellen aus Handbuch, Dokumenten und Neuigkeiten –
|
||||
<button type="button" class="text-brand-text underline-offset-2 hover:underline" @click="search">lieber nur suchen</button>
|
||||
</p>
|
||||
</section>
|
||||
|
||||
<div v-if="entries.length" class="grid gap-5 sm:grid-cols-2 xl:grid-cols-3">
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
<script setup>
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import { Link, router } from '@inertiajs/vue3';
|
||||
import { Link, router, usePage } from '@inertiajs/vue3';
|
||||
import { useDebounceFn } from '@vueuse/core';
|
||||
import { Search, SearchX } from '@lucide/vue';
|
||||
import { ChevronRight, Search, SearchX, Sparkles } from '@lucide/vue';
|
||||
import AppIcon from '@/components/AppIcon.vue';
|
||||
import EmptyState from '@/components/EmptyState.vue';
|
||||
import FileIcon from '@/components/FileIcon.vue';
|
||||
|
|
@ -17,6 +17,8 @@ const props = defineProps({
|
|||
});
|
||||
|
||||
const search = ref(props.query);
|
||||
// „Frag das Portal“ anbieten, wenn es eingeschaltet ist und eine Suche läuft
|
||||
const canAsk = computed(() => !!usePage().props.ask);
|
||||
const total = computed(() => props.groups.reduce((sum, g) => sum + g.items.length, 0));
|
||||
|
||||
watch(
|
||||
|
|
@ -48,6 +50,16 @@ watch(
|
|||
/>
|
||||
</label>
|
||||
|
||||
<Link
|
||||
v-if="canAsk && query.length >= minLength"
|
||||
:href="`/frag-das-portal?frage=${encodeURIComponent(query)}`"
|
||||
class="group flex items-center gap-3 rounded-lg border border-brand-200 bg-brand-soft/60 px-4 py-3 text-sm hover:bg-brand-soft"
|
||||
>
|
||||
<Sparkles class="size-5 shrink-0 text-brand-text" />
|
||||
<span class="min-w-0 flex-1"><strong class="font-semibold">Frag das Portal:</strong> „{{ query }}“ – kurze Antwort mit Quellen</span>
|
||||
<ChevronRight class="size-4 shrink-0 text-muted-foreground group-hover:text-foreground" />
|
||||
</Link>
|
||||
|
||||
<section v-for="group in groups" :id="`treffer-${group.key}`" :key="group.key" class="overflow-hidden rounded-lg border bg-card">
|
||||
<header class="flex items-center gap-2.5 border-b px-5 py-3">
|
||||
<span class="grid size-8 place-items-center rounded-md bg-brand-soft text-brand-text"><AppIcon :name="group.icon" class="size-4" /></span>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue