Completions api (#8) (#29)

This commit is contained in:
2026-02-16 17:00:11 +00:00
parent d83217504c
commit d9ab162dfb
13 changed files with 1885 additions and 113 deletions

View File

@@ -237,10 +237,13 @@ async function sendMessage() {
if (!message || State.isGenerating) return;
if (!State.settings.apiEndpoint || !State.settings.apiKey) {
showToast('⚠️ Configure API settings first', 'warning');
openSettings();
return;
// In managed mode, backend has the keys. In unmanaged, user must configure.
if (!Backend.isManaged) {
if (!State.settings.apiEndpoint || !State.settings.apiKey) {
showToast('⚠️ Configure API settings first', 'warning');
openSettings();
return;
}
}
input.value = '';
@@ -270,8 +273,11 @@ async function sendMessage() {
State.currentChatId = chat.id;
} else {
await updateChat(State.currentChatId, { messages });
// Persist user message to backend
await persistMessage(State.currentChatId, 'user', message);
// In unmanaged mode, persist user message to backend (if connected)
// In managed mode, the completion proxy persists both messages
if (!Backend.isManaged) {
await persistMessage(State.currentChatId, 'user', message);
}
}
renderMessages(messages);