fix: notification on erro

This commit is contained in:
2026-04-29 12:20:07 +02:00
parent 07731e888c
commit 11b5e6929a
2 changed files with 52 additions and 23 deletions
+3 -3
View File
@@ -64,12 +64,12 @@ function DesktopSidebar({
return ( return (
<div <div
className={` className={`
flex transition-all duration-300 ease-in-out overflow-hidden flex transition-[transform,opacity] duration-300 ease-in-out overflow-hidden
${isOpen ? 'w-64 opacity-100' : 'w-0 opacity-0'} ${isOpen ? 'w-64 opacity-100' : 'w-0 opacity-0'}
`} `}
> >
{activePanel && ( {activePanel && (
<div className="w-64 flex flex-col border-r border-muted"> <div className="w-64 flex flex-col border-r border-muted transition-theme">
<div className="flex items-center justify-between px-4 py-3 border-b border-muted shrink-0"> <div className="flex items-center justify-between px-4 py-3 border-b border-muted shrink-0">
<span className="text-sm font-semibold text-accent"> <span className="text-sm font-semibold text-accent">
{activePanel.label} {activePanel.label}
@@ -165,7 +165,7 @@ export default function Sidebar({ panels }: { panels: SidebarPanel[] }) {
const isOpen = !!activePanel; const isOpen = !!activePanel;
return ( return (
<div className="flex border-r border-t border-muted"> <div className="flex border-r border-t border-muted transition-theme">
{/* Desktop */} {/* Desktop */}
{isWide && ( {isWide && (
<DesktopSidebar <DesktopSidebar
+49 -20
View File
@@ -47,22 +47,22 @@ export default function ChatUI({
setInput(''); setInput('');
setLoading(true); setLoading(true);
try { const body: ChatRequest = {
const body: ChatRequest = { model: selectedModel!,
model: selectedModel!, messages: newMessages,
messages: newMessages, temperature: settings.temp,
temperature: settings.temp, top_p: settings.topP,
top_p: settings.topP, top_k: settings.topK,
top_k: settings.topK, num_predict: settings.maxTokens,
num_predict: settings.maxTokens, num_ctx: settings.numCtx,
num_ctx: settings.numCtx, repeat_penalty: settings.repeatPenalty,
repeat_penalty: settings.repeatPenalty, seed: settings.seed,
seed: settings.seed, stream: settings.stream,
stream: settings.stream, keep_alive: settings.keepAlive,
keep_alive: settings.keepAlive, stop: settings.stop,
stop: settings.stop, };
};
try {
const res = await fetch( const res = await fetch(
process.env.NEXT_PUBLIC_API_URL + '/chat/completions', process.env.NEXT_PUBLIC_API_URL + '/chat/completions',
{ {
@@ -74,14 +74,43 @@ export default function ChatUI({
body: JSON.stringify(body), body: JSON.stringify(body),
}, },
); );
const data = await res.json();
const data = await res.json().catch(() => null);
if (!res.ok) {
let message = "Request failed";
if (res.status === 500) {
message = "Server error (likely model too large or OOM)";
} else if (res.status === 401) {
message = "Unauthorized";
} else {
message = data?.message || data?.error || message;
}
throw new Error(message);
}
const assistant = data?.choices?.[0]?.message; const assistant = data?.choices?.[0]?.message;
if (assistant) setMessages((prev) => [...prev, assistant]); if (assistant) {
setMessages((prev) => [...prev, assistant]);
}
} catch (err: any) { } catch (err: any) {
console.error(err); console.error(err);
setNotification(
err?.message || 'Something went wrong while sending request', const message =
); err?.message || 'Something went wrong while sending request';
setMessages((prev) => [
...prev,
{
role: 'assistant',
content: `❌ ${message}`,
},
]);
setNotification(message);
setTimeout(() => setNotification(null), 3000); setTimeout(() => setNotification(null), 3000);
} finally { } finally {