@@ -0,0 +1,457 @@
|
||||
import { Link, router, useForm } from "@inertiajs/react";
|
||||
import { useState } from "react";
|
||||
import { Management, Field, control, button } from "../management/shared";
|
||||
import { capabilities, purposes, states } from "./labels";
|
||||
|
||||
type Source = {
|
||||
id: string;
|
||||
title: string;
|
||||
language: string;
|
||||
status: string;
|
||||
nature: string;
|
||||
valid_until: string;
|
||||
};
|
||||
type Props = {
|
||||
controls: { capability: string; suspended: boolean }[];
|
||||
sources: Source[];
|
||||
documents: { id: string; file_name: string }[];
|
||||
runs: {
|
||||
id: string;
|
||||
capability: string;
|
||||
review_status: string;
|
||||
review_requested: boolean;
|
||||
created_at: string;
|
||||
}[];
|
||||
today: string;
|
||||
};
|
||||
export default function Index({ controls, sources, documents, runs, today }: Props) {
|
||||
const [language, setLanguage] = useState<"pt" | "en">("pt");
|
||||
const t = (pt: string, en: string) => (language === "pt" ? pt : en);
|
||||
const query = useForm({
|
||||
capability: "assistant",
|
||||
language: "pt",
|
||||
purpose: "investment_information",
|
||||
query: "",
|
||||
source_id: "",
|
||||
interest_id: "",
|
||||
province: "",
|
||||
maturity_level: "",
|
||||
});
|
||||
const upload = useForm<{ file: File | null; authorised: boolean }>({
|
||||
file: null,
|
||||
authorised: false,
|
||||
});
|
||||
const source = useForm({
|
||||
document_id: "",
|
||||
title: "",
|
||||
language: "pt",
|
||||
nature: "pending",
|
||||
source_url: "",
|
||||
source_owner: "",
|
||||
evidence_reference: "",
|
||||
source_date: today,
|
||||
valid_until: "",
|
||||
authorised: false,
|
||||
});
|
||||
const [actionError, setActionError] = useState("");
|
||||
const post = (url: string, data: Record<string, string | boolean>) => {
|
||||
setActionError("");
|
||||
router.post(url, data, {
|
||||
onError: (errors) => setActionError(Object.values(errors).join(" ")),
|
||||
});
|
||||
};
|
||||
return (
|
||||
<Management title={t("Assistência, fontes e revisão", "Assistance, sources and review")}>
|
||||
<Field label="Idioma / Language">
|
||||
<select
|
||||
className={control}
|
||||
value={language}
|
||||
onChange={(e) => setLanguage(e.target.value as "pt" | "en")}
|
||||
>
|
||||
<option value="pt">Português</option>
|
||||
<option value="en">English</option>
|
||||
</select>
|
||||
</Field>
|
||||
<p className="rounded border p-4">
|
||||
{t(
|
||||
"Ferramentas assistivas com fontes e regras. Não há modelo generativo activo. Os resultados não são decisões oficiais nem garantias de retorno ou aprovação.",
|
||||
"Assistive tools using sources and rules. No generative model is active. Results are not official decisions or guarantees of return or approval.",
|
||||
)}
|
||||
</p>
|
||||
<form
|
||||
className="grid gap-4 md:grid-cols-2"
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
query.transform((data) => ({
|
||||
...data,
|
||||
language,
|
||||
purpose: purposes[data.capability] ?? "investment_information",
|
||||
}));
|
||||
query.post("/management/ai/runs");
|
||||
}}
|
||||
>
|
||||
<Field label={t("Capacidade", "Capability")}>
|
||||
<select
|
||||
className={control}
|
||||
value={query.data.capability}
|
||||
onChange={(e) => query.setData("capability", e.target.value)}
|
||||
>
|
||||
{controls.map((c) => (
|
||||
<option key={c.capability} value={c.capability} disabled={c.suspended}>
|
||||
{capabilities[c.capability]?.[language === "pt" ? 0 : 1]}
|
||||
{c.suspended ? t(" (suspensa)", " (suspended)") : ""}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</Field>
|
||||
{["assistant", "search"].includes(query.data.capability) && (
|
||||
<Field label={t("Pergunta ou termos de pesquisa", "Question or search terms")}>
|
||||
<textarea
|
||||
required
|
||||
maxLength={1000}
|
||||
minLength={3}
|
||||
className={control}
|
||||
value={query.data.query}
|
||||
onChange={(e) => query.setData("query", e.target.value)}
|
||||
/>
|
||||
</Field>
|
||||
)}
|
||||
{["assistant", "search", "summary"].includes(query.data.capability) && (
|
||||
<Field label={t("Fonte autorizada", "Authorised source")}>
|
||||
<select
|
||||
required={query.data.capability === "summary"}
|
||||
className={control}
|
||||
value={query.data.source_id}
|
||||
onChange={(e) => query.setData("source_id", e.target.value)}
|
||||
>
|
||||
<option value="">
|
||||
{t("Todas as fontes elegíveis", "All eligible sources")}
|
||||
</option>
|
||||
{sources
|
||||
.filter((s) => s.status === "approved")
|
||||
.map((s) => (
|
||||
<option key={s.id} value={s.id}>
|
||||
{s.title}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</Field>
|
||||
)}
|
||||
{query.data.capability === "classify" && (
|
||||
<Field
|
||||
label={t(
|
||||
"Número interno do pedido (requer consentimento específico)",
|
||||
"Internal request number (specific consent required)",
|
||||
)}
|
||||
>
|
||||
<input
|
||||
required
|
||||
type="number"
|
||||
min={1}
|
||||
className={control}
|
||||
value={query.data.interest_id}
|
||||
onChange={(e) => query.setData("interest_id", e.target.value)}
|
||||
/>
|
||||
</Field>
|
||||
)}
|
||||
{query.data.capability === "recommend" && (
|
||||
<>
|
||||
<Field label={t("Província declarada", "Declared province")}>
|
||||
<input
|
||||
className={control}
|
||||
value={query.data.province}
|
||||
onChange={(e) => query.setData("province", e.target.value)}
|
||||
/>
|
||||
</Field>
|
||||
<Field label={t("Maturidade pretendida", "Desired maturity")}>
|
||||
<select
|
||||
className={control}
|
||||
value={query.data.maturity_level}
|
||||
onChange={(e) => query.setData("maturity_level", e.target.value)}
|
||||
>
|
||||
<option value="">{t("Não indicada", "Not specified")}</option>
|
||||
{[1, 2, 3, 4, 5, 6].map((n) => (
|
||||
<option key={n}>{n}</option>
|
||||
))}
|
||||
</select>
|
||||
</Field>
|
||||
</>
|
||||
)}
|
||||
<div>
|
||||
{Object.entries(query.errors).map(([k, v]) => (
|
||||
<p role="alert" key={k}>
|
||||
{v}
|
||||
</p>
|
||||
))}
|
||||
<button
|
||||
disabled={
|
||||
query.processing ||
|
||||
controls.find((c) => c.capability === query.data.capability)?.suspended
|
||||
}
|
||||
className={button}
|
||||
>
|
||||
{t("Consultar", "Run assistance")}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
<section className="space-y-3">
|
||||
<h2 className="text-xl font-semibold">
|
||||
{t("Suspensão imediata", "Immediate suspension")}
|
||||
</h2>
|
||||
{actionError && <p role="alert">{actionError}</p>}
|
||||
<div className="flex flex-wrap gap-3">
|
||||
{controls.map((c) => (
|
||||
<button
|
||||
className={button}
|
||||
key={c.capability}
|
||||
onClick={() =>
|
||||
post(`/management/ai/controls/${c.capability}`, {
|
||||
suspended: !c.suspended,
|
||||
})
|
||||
}
|
||||
>
|
||||
{t(
|
||||
c.suspended ? "Retomar" : "Suspender",
|
||||
c.suspended ? "Resume" : "Suspend",
|
||||
)}{" "}
|
||||
· {capabilities[c.capability]?.[language === "pt" ? 0 : 1]}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</section>
|
||||
<section className="space-y-3">
|
||||
<h2 className="text-xl font-semibold">
|
||||
{t("Resultados recentes e revisão humana", "Recent results and human review")}
|
||||
</h2>
|
||||
{runs.length === 0 && <p>{t("Ainda sem consultas.", "No runs yet.")}</p>}
|
||||
{runs.map((r) => (
|
||||
<p key={r.id}>
|
||||
<Link className="underline" href={`/management/ai/runs/${r.id}`}>
|
||||
{capabilities[r.capability]?.[language === "pt" ? 0 : 1]} ·{" "}
|
||||
{r.created_at}
|
||||
</Link>{" "}
|
||||
— {language === "pt" ? states[r.review_status] : r.review_status}
|
||||
{r.review_requested && t(" · revisão solicitada", " · review requested")}
|
||||
</p>
|
||||
))}
|
||||
</section>
|
||||
<section className="space-y-3">
|
||||
<h2 className="text-xl font-semibold">
|
||||
{t("Fontes documentais", "Document sources")}
|
||||
</h2>
|
||||
<p>
|
||||
{t(
|
||||
"Apenas ficheiros de texto UTF-8 do cadastro documental privado, activos e não confidenciais. A autorização de uso deve ser confirmada por outra pessoa.",
|
||||
"Only active, non-confidential UTF-8 text files from the private document registry. Another person must confirm permission to use the source.",
|
||||
)}
|
||||
</p>
|
||||
{sources.map((s) => (
|
||||
<article className="space-y-2 rounded border p-3" key={s.id}>
|
||||
<p>
|
||||
{s.title} · {s.language.toUpperCase()} ·{" "}
|
||||
{language === "pt" ? states[s.status] : s.status} · {s.valid_until}
|
||||
</p>
|
||||
<p>{language === "pt" ? states[s.nature] : s.nature}</p>
|
||||
<div className="flex gap-3">
|
||||
<button
|
||||
className={button}
|
||||
onClick={() =>
|
||||
post(`/management/ai/sources/${s.id}/review`, {
|
||||
status: "approved",
|
||||
expected_status: s.status,
|
||||
})
|
||||
}
|
||||
>
|
||||
{t("Confirmar autorização", "Confirm authorisation")}
|
||||
</button>
|
||||
<button
|
||||
className={button}
|
||||
onClick={() =>
|
||||
post(`/management/ai/sources/${s.id}/review`, {
|
||||
status: "revoked",
|
||||
expected_status: s.status,
|
||||
})
|
||||
}
|
||||
>
|
||||
{t("Revogar", "Revoke")}
|
||||
</button>
|
||||
</div>
|
||||
</article>
|
||||
))}
|
||||
</section>
|
||||
<details className="rounded border p-4">
|
||||
<summary>
|
||||
{t(
|
||||
"Adicionar documento de texto autorizado",
|
||||
"Add an authorised text document",
|
||||
)}
|
||||
</summary>
|
||||
<form
|
||||
className="mt-4 space-y-3"
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
upload.post("/management/ai/documents", {
|
||||
forceFormData: true,
|
||||
onSuccess: () => upload.reset(),
|
||||
});
|
||||
}}
|
||||
>
|
||||
<Field
|
||||
label={t(
|
||||
"Ficheiro .txt UTF-8 (até 195 KiB)",
|
||||
"UTF-8 .txt file (up to 195 KiB)",
|
||||
)}
|
||||
>
|
||||
<input
|
||||
required
|
||||
type="file"
|
||||
accept=".txt,text/plain"
|
||||
className={control}
|
||||
onChange={(e) => upload.setData("file", e.target.files?.[0] ?? null)}
|
||||
/>
|
||||
</Field>
|
||||
<label className="flex gap-2">
|
||||
<input
|
||||
required
|
||||
type="checkbox"
|
||||
checked={upload.data.authorised}
|
||||
onChange={(e) => upload.setData("authorised", e.target.checked)}
|
||||
/>
|
||||
{t(
|
||||
"Tenho autorização e confirmei a ausência de dados confidenciais ou pessoais desnecessários.",
|
||||
"I am authorised and have confirmed there is no confidential or unnecessary personal data.",
|
||||
)}
|
||||
</label>
|
||||
{Object.entries(upload.errors).map(([key, value]) => (
|
||||
<p role="alert" key={key}>
|
||||
{value}
|
||||
</p>
|
||||
))}
|
||||
<button className={button} disabled={upload.processing}>
|
||||
{t("Guardar documento", "Save document")}
|
||||
</button>
|
||||
</form>
|
||||
</details>
|
||||
<details className="rounded border p-4">
|
||||
<summary>
|
||||
{t(
|
||||
"Registar fonte existente para revisão",
|
||||
"Register an existing source for review",
|
||||
)}
|
||||
</summary>
|
||||
<form
|
||||
className="mt-4 grid gap-4 md:grid-cols-2"
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
source.post("/management/ai/sources", { onSuccess: () => source.reset() });
|
||||
}}
|
||||
>
|
||||
<Field label={t("Documento", "Document")}>
|
||||
<select
|
||||
required
|
||||
className={control}
|
||||
value={source.data.document_id}
|
||||
onChange={(e) => source.setData("document_id", e.target.value)}
|
||||
>
|
||||
<option value="">{t("Seleccionar", "Select")}</option>
|
||||
{documents.map((d) => (
|
||||
<option key={d.id} value={d.id}>
|
||||
{d.file_name}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</Field>
|
||||
{(
|
||||
[
|
||||
"title",
|
||||
"source_url",
|
||||
"source_owner",
|
||||
"evidence_reference",
|
||||
"source_date",
|
||||
"valid_until",
|
||||
] as const
|
||||
).map((key) => (
|
||||
<Field
|
||||
key={key}
|
||||
label={
|
||||
{
|
||||
title: t("Título", "Title"),
|
||||
source_url: t("Fonte HTTPS", "HTTPS source"),
|
||||
source_owner: t("Entidade proprietária", "Source owner"),
|
||||
evidence_reference: t(
|
||||
"Referência da evidência e autorização",
|
||||
"Evidence and authorisation reference",
|
||||
),
|
||||
source_date: t("Data da fonte", "Source date"),
|
||||
valid_until: t("Válida até", "Valid until"),
|
||||
}[key]
|
||||
}
|
||||
>
|
||||
<input
|
||||
required
|
||||
type={
|
||||
["source_date", "valid_until"].includes(key)
|
||||
? "date"
|
||||
: key === "source_url"
|
||||
? "url"
|
||||
: "text"
|
||||
}
|
||||
className={control}
|
||||
value={source.data[key]}
|
||||
onChange={(e) => source.setData(key, e.target.value)}
|
||||
/>
|
||||
</Field>
|
||||
))}
|
||||
<Field label={t("Idioma da fonte", "Source language")}>
|
||||
<select
|
||||
className={control}
|
||||
value={source.data.language}
|
||||
onChange={(e) => source.setData("language", e.target.value)}
|
||||
>
|
||||
<option value="pt">Português</option>
|
||||
<option value="en">English</option>
|
||||
</select>
|
||||
</Field>
|
||||
<Field label={t("Natureza declarada", "Declared nature")}>
|
||||
<select
|
||||
className={control}
|
||||
value={source.data.nature}
|
||||
onChange={(e) => source.setData("nature", e.target.value)}
|
||||
>
|
||||
{["pending", "official", "historical", "illustrative"].map((n) => (
|
||||
<option key={n} value={n}>
|
||||
{language === "pt" ? states[n] : n}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</Field>
|
||||
<label className="flex items-start gap-2">
|
||||
<input
|
||||
required
|
||||
type="checkbox"
|
||||
checked={source.data.authorised}
|
||||
onChange={(e) => source.setData("authorised", e.target.checked)}
|
||||
/>
|
||||
{t(
|
||||
"Confirmo autorização para consulta interna e ausência de dados confidenciais ou pessoais desnecessários.",
|
||||
"I confirm authorisation for internal use and the absence of confidential or unnecessary personal data.",
|
||||
)}
|
||||
</label>
|
||||
<div>
|
||||
{Object.entries(source.errors).map(([k, v]) => (
|
||||
<p role="alert" key={k}>
|
||||
{v}
|
||||
</p>
|
||||
))}
|
||||
<button
|
||||
disabled={source.processing || documents.length === 0}
|
||||
className={button}
|
||||
>
|
||||
{t("Submeter fonte", "Submit source")}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</details>
|
||||
</Management>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
export const capabilities: Record<string, [string, string]> = {
|
||||
assistant: ["Assistente com fontes", "Evidence assistant"],
|
||||
search: ["Pesquisa documental", "Document search"],
|
||||
recommend: ["Correspondência de oportunidades", "Opportunity matching"],
|
||||
classify: ["Triagem de pedidos", "Interest triage"],
|
||||
quality: ["Qualidade dos dados", "Data quality"],
|
||||
sla: ["Prazos e tarefas", "Deadlines and tasks"],
|
||||
summary: ["Excertos de documentos", "Document excerpts"],
|
||||
};
|
||||
export const purposes: Record<string, string> = {
|
||||
classify: "interest_triage",
|
||||
quality: "data_quality",
|
||||
sla: "execution_monitoring",
|
||||
};
|
||||
export const states: Record<string, string> = {
|
||||
pending: "Pendente",
|
||||
approved: "Autorizada para consulta interna",
|
||||
revoked: "Revogada",
|
||||
accepted: "Aceite na revisão interna",
|
||||
rejected: "Rejeitado",
|
||||
official: "Oficial — natureza declarada da fonte",
|
||||
historical: "Histórica",
|
||||
illustrative: "Ilustrativa",
|
||||
};
|
||||
@@ -0,0 +1,279 @@
|
||||
import { Link, useForm } from "@inertiajs/react";
|
||||
import { Management, Field, control, button } from "../management/shared";
|
||||
import { capabilities, states } from "./labels";
|
||||
type Item = {
|
||||
[key: string]: unknown;
|
||||
content?: string;
|
||||
title?: string;
|
||||
source_url?: string;
|
||||
source_date?: string;
|
||||
nature?: string;
|
||||
record_id?: string | number;
|
||||
rule?: string;
|
||||
score?: number;
|
||||
score_max?: number;
|
||||
favourable_factors?: string[];
|
||||
missing_data?: string[];
|
||||
};
|
||||
type Result = {
|
||||
items: Item[];
|
||||
mode: string;
|
||||
language: string;
|
||||
computed_at: string;
|
||||
status: string;
|
||||
};
|
||||
type Props = {
|
||||
run: {
|
||||
id: string;
|
||||
capability: string;
|
||||
mode: string;
|
||||
rules_version: string;
|
||||
prompt_version: string;
|
||||
latency_ms: number;
|
||||
version_no: number;
|
||||
review_status: string;
|
||||
};
|
||||
result: Result | null;
|
||||
unavailable: boolean;
|
||||
};
|
||||
const safeLink = (value: string) => /^https:\/\//i.test(value) || /^\/(?!\/)/.test(value);
|
||||
export default function ResultPage({ run, result, unavailable }: Props) {
|
||||
const en = result?.language === "en";
|
||||
const t = (pt: string, english: string) => (en ? english : pt);
|
||||
const feedback = useForm({ rating: "helpful", review_requested: true });
|
||||
const review = useForm({ status: "accepted", version_no: run.version_no });
|
||||
return (
|
||||
<Management
|
||||
title={
|
||||
capabilities[run.capability]?.[en ? 1 : 0] ??
|
||||
t("Resultado assistivo", "Assistive result")
|
||||
}
|
||||
>
|
||||
<Link className="underline" href="/management/ai">
|
||||
{t("Voltar às consultas e fontes", "Back to assistance and sources")}
|
||||
</Link>
|
||||
<p>
|
||||
{t(
|
||||
"Resultado assistivo, sujeito a revisão. Não constitui decisão oficial ou garantia de retorno ou aprovação.",
|
||||
"Assistive result requiring review. Not an official decision or a guarantee of return or approval.",
|
||||
)}
|
||||
</p>
|
||||
<p>
|
||||
{t(
|
||||
"Confiança não calibrada. Não foram produzidas previsões ou afirmações por um modelo generativo.",
|
||||
"Confidence is not calibrated. No forecasts or claims were generated by a generative model.",
|
||||
)}
|
||||
</p>
|
||||
<p>
|
||||
{t("Estado da revisão", "Review status")}:{" "}
|
||||
{en ? run.review_status : states[run.review_status]}
|
||||
</p>
|
||||
{unavailable ? (
|
||||
<p role="alert">
|
||||
{t(
|
||||
"Conteúdo indisponível: capacidade suspensa, fonte alterada, expirada, revogada ou sem consentimento vigente.",
|
||||
"Content unavailable: suspended capability, changed, expired or revoked source, or withdrawn consent.",
|
||||
)}
|
||||
</p>
|
||||
) : (
|
||||
<>
|
||||
{result?.items.length === 0 && (
|
||||
<p className="rounded border p-4">
|
||||
{t(
|
||||
"Não há evidência ou correspondências suficientes nesta consulta. Não é possível formular uma conclusão. Pode solicitar revisão humana abaixo.",
|
||||
"No sufficient evidence or matches for this query. A conclusion cannot be provided. You may request human review below.",
|
||||
)}
|
||||
</p>
|
||||
)}
|
||||
{run.mode === "extractive_preview" && (
|
||||
<p>
|
||||
{t(
|
||||
"Pré-visualização dos primeiros excertos; não é um resumo completo do documento.",
|
||||
"Preview of the first excerpts; not a complete document summary.",
|
||||
)}
|
||||
</p>
|
||||
)}
|
||||
{result?.items.map((item, index) => (
|
||||
<article className="space-y-3 rounded border p-4" key={index}>
|
||||
<h2 className="text-lg font-semibold">
|
||||
{item.title ??
|
||||
item.rule?.replaceAll("_", " ") ??
|
||||
`${t("Resultado", "Result")} ${index + 1}`}
|
||||
</h2>
|
||||
{item.content && (
|
||||
<blockquote className="whitespace-pre-wrap border-l-4 pl-4">
|
||||
{item.content}
|
||||
</blockquote>
|
||||
)}
|
||||
{item.source_url && safeLink(item.source_url) && (
|
||||
<a className="underline" href={item.source_url} rel="noreferrer">
|
||||
{t(
|
||||
"Consultar fonte / registo original",
|
||||
"View source / original record",
|
||||
)}
|
||||
</a>
|
||||
)}
|
||||
{item.source_date && (
|
||||
<p>
|
||||
{t("Data da fonte", "Source date")}: {item.source_date}
|
||||
</p>
|
||||
)}
|
||||
{item.nature && (
|
||||
<p>
|
||||
{t("Natureza declarada", "Declared nature")}:{" "}
|
||||
{en ? item.nature : states[item.nature]}
|
||||
</p>
|
||||
)}
|
||||
{item.score !== undefined && (
|
||||
<p>
|
||||
{t(
|
||||
"Filtros declarados correspondentes",
|
||||
"Matching declared filters",
|
||||
)}
|
||||
: {item.score}/{item.score_max}.{" "}
|
||||
{t(
|
||||
"Esta pontuação não mede rentabilidade ou probabilidade de aprovação.",
|
||||
"This score does not measure profitability or likelihood of approval.",
|
||||
)}
|
||||
</p>
|
||||
)}
|
||||
{item.favourable_factors && (
|
||||
<p>
|
||||
{t("Factores correspondentes", "Matching factors")}:{" "}
|
||||
{item.favourable_factors.join(", ")}
|
||||
</p>
|
||||
)}
|
||||
{item.missing_data && (
|
||||
<p>
|
||||
{t("Dados ainda necessários", "Missing information")}:{" "}
|
||||
{item.missing_data.join(", ")}
|
||||
</p>
|
||||
)}
|
||||
{!item.content && (
|
||||
<dl className="grid gap-2 md:grid-cols-2">
|
||||
{Object.entries(item)
|
||||
.filter(
|
||||
([key]) =>
|
||||
![
|
||||
"title",
|
||||
"source_url",
|
||||
"source_date",
|
||||
"score",
|
||||
"score_max",
|
||||
"score_meaning",
|
||||
"favourable_factors",
|
||||
"missing_data",
|
||||
"semantic_similarity",
|
||||
].includes(key),
|
||||
)
|
||||
.map(([key, value]) => (
|
||||
<div key={key}>
|
||||
<dt className="font-medium">
|
||||
{key.replaceAll("_", " ")}
|
||||
</dt>
|
||||
<dd>
|
||||
{Array.isArray(value)
|
||||
? value.join(", ")
|
||||
: value === null
|
||||
? t("Não determinado", "Undetermined")
|
||||
: String(value)}
|
||||
</dd>
|
||||
</div>
|
||||
))}
|
||||
</dl>
|
||||
)}
|
||||
</article>
|
||||
))}
|
||||
</>
|
||||
)}
|
||||
<p>
|
||||
{t("Regras", "Rules")}: {run.rules_version} · {t("Calculado em", "Computed at")}:{" "}
|
||||
{result?.computed_at ?? "—"} · {run.latency_ms} ms
|
||||
</p>
|
||||
<form
|
||||
className="space-y-3 rounded border p-4"
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
feedback.post(`/management/ai/runs/${run.id}/feedback`);
|
||||
}}
|
||||
>
|
||||
<h2 className="text-xl font-semibold">
|
||||
{t("Feedback e atendimento humano", "Feedback and human review")}
|
||||
</h2>
|
||||
<Field label={t("Avaliação", "Rating")}>
|
||||
<select
|
||||
className={control}
|
||||
value={feedback.data.rating}
|
||||
onChange={(e) => feedback.setData("rating", e.target.value)}
|
||||
>
|
||||
<option value="helpful">{t("Útil", "Helpful")}</option>
|
||||
<option value="unhelpful">{t("Pouco útil", "Unhelpful")}</option>
|
||||
<option value="unsafe">
|
||||
{t(
|
||||
"Risco detectado — suspender capacidade",
|
||||
"Risk detected — suspend capability",
|
||||
)}
|
||||
</option>
|
||||
</select>
|
||||
</Field>
|
||||
<label className="flex gap-2">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={feedback.data.review_requested}
|
||||
onChange={(e) => feedback.setData("review_requested", e.target.checked)}
|
||||
/>
|
||||
{t(
|
||||
"Solicitar revisão por uma pessoa autorizada",
|
||||
"Request review by an authorised person",
|
||||
)}
|
||||
</label>
|
||||
{Object.entries(feedback.errors).map(([k, v]) => (
|
||||
<p role="alert" key={k}>
|
||||
{v}
|
||||
</p>
|
||||
))}
|
||||
<button disabled={feedback.processing} className={button}>
|
||||
{t("Enviar feedback", "Submit feedback")}
|
||||
</button>
|
||||
</form>
|
||||
<form
|
||||
className="space-y-3 rounded border p-4"
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
review.transform((data) => ({ ...data, version_no: run.version_no }));
|
||||
review.post(`/management/ai/runs/${run.id}/review`);
|
||||
}}
|
||||
>
|
||||
<h2 className="text-xl font-semibold">
|
||||
{t("Revisão independente", "Independent review")}
|
||||
</h2>
|
||||
<p>
|
||||
{t(
|
||||
"Uma pessoa diferente deve rever o resultado. Aceitar não altera registos oficiais nem envia conteúdo ao CRM.",
|
||||
"A different person must review the result. Acceptance does not change official records or send content to CRM.",
|
||||
)}
|
||||
</p>
|
||||
<Field label={t("Parecer interno", "Internal review")}>
|
||||
<select
|
||||
className={control}
|
||||
value={review.data.status}
|
||||
onChange={(e) => review.setData("status", e.target.value)}
|
||||
>
|
||||
<option value="accepted">
|
||||
{t("Aceitar para análise interna", "Accept for internal analysis")}
|
||||
</option>
|
||||
<option value="rejected">{t("Rejeitar", "Reject")}</option>
|
||||
</select>
|
||||
</Field>
|
||||
{Object.entries(review.errors).map(([k, v]) => (
|
||||
<p role="alert" key={k}>
|
||||
{v}
|
||||
</p>
|
||||
))}
|
||||
<button disabled={review.processing} className={button}>
|
||||
{t("Registar revisão", "Record review")}
|
||||
</button>
|
||||
</form>
|
||||
</Management>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user