fix: text completion replaced with chat completion

This commit is contained in:
Timothy J. Baek 2024-03-02 13:14:14 -08:00
parent 2379e94cbf
commit 06ce5aed4a

View file

@ -8,7 +8,7 @@
import { WEBUI_API_BASE_URL } from '$lib/constants';
import { WEBUI_NAME, config, user, models } from '$lib/stores';
import { cancelChatCompletion, generateTextCompletion } from '$lib/apis/ollama';
import { cancelChatCompletion, generateChatCompletion } from '$lib/apis/ollama';
import { splitStream } from '$lib/utils';
let mode = 'complete';
@ -44,7 +44,15 @@
if (selectedModel) {
loading = true;
const res = await generateTextCompletion(localStorage.token, selectedModel, text);
const [res, controller] = await generateChatCompletion(localStorage.token, {
model: selectedModel,
messages: [
{
role: 'assistant',
content: text
}
]
});
if (res && res.ok) {
const reader = res.body
@ -80,7 +88,7 @@
currentRequestId = data.id;
} else {
if (data.done == false) {
text += data.response;
text += data.message.content;
} else {
console.log('done');
}