This commit is contained in:
parent
40a927aa1c
commit
d980b156d9
|
|
@ -0,0 +1,31 @@
|
||||||
|
# Makefile for running the Vet Clinic Chat Assistant locally with Ollama
|
||||||
|
|
||||||
|
.PHONY: run ollama-start ollama-stop ollama-pull ollama-status
|
||||||
|
|
||||||
|
# Start Ollama server (if not already running)
|
||||||
|
ollama-start:
|
||||||
|
ollama serve &
|
||||||
|
@echo "Ollama server started."
|
||||||
|
|
||||||
|
# Stop Ollama server
|
||||||
|
ollama-stop:
|
||||||
|
pkill -f "ollama serve" || true
|
||||||
|
@echo "Ollama server stopped."
|
||||||
|
|
||||||
|
# Pull a model (default: llama3)
|
||||||
|
ollama-pull:
|
||||||
|
ollama pull qwen3:latest
|
||||||
|
|
||||||
|
# Show Ollama status
|
||||||
|
ollama-status:
|
||||||
|
ollama list
|
||||||
|
|
||||||
|
# Run the Go server (assumes Ollama is running)
|
||||||
|
run: ollama-pull
|
||||||
|
OPENAI_API_KEY=ollama OPENAI_BASE_URL=http://localhost:11434/v1 OPENAI_MODEL=llama3 go run .
|
||||||
|
|
||||||
|
# Run tests
|
||||||
|
.PHONY: test
|
||||||
|
|
||||||
|
test:
|
||||||
|
go test ./...
|
||||||
31
ui.html
31
ui.html
|
|
@ -18,10 +18,14 @@
|
||||||
const messages = document.getElementById('messages');
|
const messages = document.getElementById('messages');
|
||||||
const input = document.getElementById('input');
|
const input = document.getElementById('input');
|
||||||
const send = document.getElementById('send');
|
const send = document.getElementById('send');
|
||||||
function appendMsg(text, who) {
|
function appendMsg(text, who, isHtml) {
|
||||||
const div = document.createElement('div');
|
const div = document.createElement('div');
|
||||||
div.className = who === 'user' ? 'text-gray-800 mb-2' : 'text-green-700 mb-2';
|
div.className = who === 'user' ? 'text-gray-800 mb-2' : 'text-green-700 mb-2';
|
||||||
|
if (isHtml) {
|
||||||
|
div.innerHTML = text;
|
||||||
|
} else {
|
||||||
div.textContent = text;
|
div.textContent = text;
|
||||||
|
}
|
||||||
messages.appendChild(div);
|
messages.appendChild(div);
|
||||||
messages.scrollTop = messages.scrollHeight;
|
messages.scrollTop = messages.scrollHeight;
|
||||||
}
|
}
|
||||||
|
|
@ -39,22 +43,25 @@
|
||||||
const data = await resp.json();
|
const data = await resp.json();
|
||||||
messages.lastChild.remove(); // remove 'Thinking...'
|
messages.lastChild.remove(); // remove 'Thinking...'
|
||||||
if (data.match) {
|
if (data.match) {
|
||||||
let txt = '';
|
let html = '';
|
||||||
txt += `Match: ${data.match}\n`;
|
html += `<div class='font-bold'>Match: <span class='text-green-800'>${data.match}</span></div>`;
|
||||||
if (data.notes) {
|
if (data.notes) {
|
||||||
txt += `\nNotes: ${data.notes}\n`;
|
html += `<div class='my-2 p-2 bg-yellow-100 border-l-4 border-yellow-400 text-yellow-900'><b>Notes:</b> ${data.notes}</div>`;
|
||||||
}
|
}
|
||||||
if (data.procedures && data.procedures.length > 0) {
|
if (data.procedures && data.procedures.length > 0) {
|
||||||
txt += `\nProcedures:\n`;
|
html += `<div class='mt-2 mb-1 font-semibold'>Procedures:</div>`;
|
||||||
data.procedures.forEach(function(p, idx) {
|
html += `<ol class='list-decimal ml-6'>`;
|
||||||
txt += ` ${idx+1}. ${p.name}\n`;
|
data.procedures.forEach(function(p) {
|
||||||
txt += ` Cost: ${p.price} Ft\n`;
|
html += `<li class='mb-2'><span class='font-bold'>${p.name}</span><br>`;
|
||||||
txt += ` Time: ${p.duration_minutes} min\n`;
|
html += `<span class='block'>Cost: <span class='font-semibold'>${p.price} Ft</span></span>`;
|
||||||
if (p.note && p.note.trim()) txt += ` Note: ${p.note}\n`;
|
html += `<span class='block'>Time: <span class='font-semibold'>${p.duration_minutes} min</span></span>`;
|
||||||
|
if (p.note && p.note.trim()) html += `<span class='block text-gray-600'>Note: ${p.note}</span>`;
|
||||||
|
html += `</li>`;
|
||||||
});
|
});
|
||||||
txt += `\nTotal: ${data.total_price} Ft, ${data.total_duration} min\n`;
|
html += `</ol>`;
|
||||||
|
html += `<div class='mt-2 font-bold'>Total: <span class='text-green-800'>${data.total_price} Ft</span>, <span class='text-green-800'>${data.total_duration} min</span></div>`;
|
||||||
}
|
}
|
||||||
appendMsg(txt, 'bot');
|
appendMsg(html, 'bot', true);
|
||||||
} else {
|
} else {
|
||||||
appendMsg(data.reply || 'No match found.', 'bot');
|
appendMsg(data.reply || 'No match found.', 'bot');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Binary file not shown.
Loading…
Reference in New Issue