Abmacode12's picture
Architecture “Rosalinda” (100% propriétaire)
6ce9b06 verified
raw
history blame contribute delete
619 Bytes
```typescript
type Msg = { role: "system" | "user" | "assistant"; content: string };
export async function llmChat(messages: Msg[]) {
const res = await fetch("http://localhost:11434/api/chat", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
model: "llama3.1",
messages,
stream: false
})
});
if (!res.ok) {
const txt = await res.text().catch(() => "");
return `Rosalinda: erreur LLM local (${res.status}). ${txt}`;
}
const data: any = await res.json();
return data?.message?.content ?? "Rosalinda: (réponse vide)";
}
```