Add LLM provider switch, markdown chat UI, and update README
- Dual RAG instances (Ollama + OpenAI) for on-the-fly provider switching - Provider dropdown in chat UI, /api/providers endpoint - Markdown rendering for assistant responses - Server logs include provider and model name for each LLM response - README: OpenAI setup, add_pdfs, API docs, provider switch Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+44
-1
@@ -112,6 +112,24 @@
|
||||
border-top: 1px solid #27272a;
|
||||
background: #18181b;
|
||||
}
|
||||
#provider-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
margin-bottom: 0.5rem;
|
||||
font-size: 0.8rem;
|
||||
color: #71717a;
|
||||
}
|
||||
#provider-row label { flex-shrink: 0; }
|
||||
#provider {
|
||||
padding: 0.25rem 0.5rem;
|
||||
font: inherit;
|
||||
font-size: 0.85rem;
|
||||
color: #e4e4e7;
|
||||
background: #27272a;
|
||||
border: 1px solid #3f3f46;
|
||||
border-radius: 6px;
|
||||
}
|
||||
#input-row {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
@@ -168,6 +186,13 @@
|
||||
<div id="messages"></div>
|
||||
|
||||
<div id="input-area">
|
||||
<div id="provider-row">
|
||||
<label for="provider">LLM provider:</label>
|
||||
<select id="provider">
|
||||
<option value="ollama">Ollama</option>
|
||||
<option value="openai">OpenAI</option>
|
||||
</select>
|
||||
</div>
|
||||
<div id="input-row">
|
||||
<textarea id="input" rows="1" placeholder="Ask a question…" autofocus></textarea>
|
||||
<button type="button" id="send">Send</button>
|
||||
@@ -178,8 +203,22 @@
|
||||
const messagesEl = document.getElementById('messages');
|
||||
const inputEl = document.getElementById('input');
|
||||
const sendBtn = document.getElementById('send');
|
||||
const providerEl = document.getElementById('provider');
|
||||
const chatHistory = [];
|
||||
|
||||
(async function initProviders() {
|
||||
try {
|
||||
const res = await fetch('/api/providers');
|
||||
const data = await res.json();
|
||||
if (!data.openai) {
|
||||
const opt = providerEl.querySelector('option[value="openai"]');
|
||||
opt.disabled = true;
|
||||
opt.textContent = 'OpenAI (not configured)';
|
||||
if (providerEl.value === 'openai') providerEl.value = 'ollama';
|
||||
}
|
||||
} catch (_) {}
|
||||
})();
|
||||
|
||||
function appendMessage(role, text, isError = false) {
|
||||
text = text ?? '';
|
||||
const div = document.createElement('div');
|
||||
@@ -231,7 +270,11 @@
|
||||
const res = await fetch('/api/chat', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ message: text, history: history })
|
||||
body: JSON.stringify({
|
||||
message: text,
|
||||
history: history,
|
||||
llm_provider: providerEl.value
|
||||
})
|
||||
});
|
||||
const data = await res.json();
|
||||
setLoading(false);
|
||||
|
||||
Reference in New Issue
Block a user