Skip to content

Commit

Permalink
fix: text completion replaced with chat completion
Browse files Browse the repository at this point in the history
  • Loading branch information
tjbck committed Mar 2, 2024
1 parent 2379e94 commit 06ce5ae
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/routes/(app)/playground/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -80,7 +88,7 @@
currentRequestId = data.id;
} else {
if (data.done == false) {
text += data.response;
text += data.message.content;
} else {
console.log('done');
}
Expand Down

0 comments on commit 06ce5ae

Please sign in to comment.