Spaces:
Configuration error
Configuration error
File size: 619 Bytes
6ce9b06 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | ```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)";
}
``` |