mirror of
https://github.com/open-webui/open-webui
synced 2025-05-29 17:52:48 +00:00
commit
8204f06485
@ -106,7 +106,7 @@ This will start the Open WebUI server, which you can access at [http://localhost
|
|||||||
docker run -d -p 3000:8080 -e OLLAMA_BASE_URL=https://example.com -v open-webui:/app/backend/data --name open-webui --restart always ghcr.io/open-webui/open-webui:main
|
docker run -d -p 3000:8080 -e OLLAMA_BASE_URL=https://example.com -v open-webui:/app/backend/data --name open-webui --restart always ghcr.io/open-webui/open-webui:main
|
||||||
```
|
```
|
||||||
|
|
||||||
- **To run Open WebUI with Nvidia GPU support**, use this command:
|
- **To run Open WebUI with Nvidia GPU support**, use this command:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker run -d -p 3000:8080 --gpus all --add-host=host.docker.internal:host-gateway -v open-webui:/app/backend/data --name open-webui --restart always ghcr.io/open-webui/open-webui:cuda
|
docker run -d -p 3000:8080 --gpus all --add-host=host.docker.internal:host-gateway -v open-webui:/app/backend/data --name open-webui --restart always ghcr.io/open-webui/open-webui:cuda
|
||||||
|
@ -55,7 +55,7 @@ export const formatPythonCode = async (code: string) => {
|
|||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const downloadChatAsPDF = async (chat: object) => {
|
export const downloadChatAsPDF = async (title: string, messages: object[]) => {
|
||||||
let error = null;
|
let error = null;
|
||||||
|
|
||||||
const blob = await fetch(`${WEBUI_API_BASE_URL}/utils/pdf`, {
|
const blob = await fetch(`${WEBUI_API_BASE_URL}/utils/pdf`, {
|
||||||
@ -64,8 +64,8 @@ export const downloadChatAsPDF = async (chat: object) => {
|
|||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
},
|
},
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
title: chat.title,
|
title: title,
|
||||||
messages: chat.messages
|
messages: messages
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.then(async (res) => {
|
.then(async (res) => {
|
||||||
|
@ -493,6 +493,7 @@
|
|||||||
if (!$temporaryChatEnabled) {
|
if (!$temporaryChatEnabled) {
|
||||||
chat = await updateChatById(localStorage.token, chatId, {
|
chat = await updateChatById(localStorage.token, chatId, {
|
||||||
models: selectedModels,
|
models: selectedModels,
|
||||||
|
messages: messages,
|
||||||
history: history,
|
history: history,
|
||||||
params: params,
|
params: params,
|
||||||
files: chatFiles
|
files: chatFiles
|
||||||
@ -1808,6 +1809,7 @@
|
|||||||
chat = await updateChatById(localStorage.token, _chatId, {
|
chat = await updateChatById(localStorage.token, _chatId, {
|
||||||
models: selectedModels,
|
models: selectedModels,
|
||||||
history: history,
|
history: history,
|
||||||
|
messages: createMessagesList(history.currentId),
|
||||||
params: params,
|
params: params,
|
||||||
files: chatFiles
|
files: chatFiles
|
||||||
});
|
});
|
||||||
|
@ -80,7 +80,8 @@
|
|||||||
const updateChatHistory = async () => {
|
const updateChatHistory = async () => {
|
||||||
await tick();
|
await tick();
|
||||||
await updateChatById(localStorage.token, chatId, {
|
await updateChatById(localStorage.token, chatId, {
|
||||||
history: history
|
history: history,
|
||||||
|
messages: messages
|
||||||
});
|
});
|
||||||
|
|
||||||
currentChatPage.set(1);
|
currentChatPage.set(1);
|
||||||
@ -380,9 +381,19 @@
|
|||||||
{regenerateResponse}
|
{regenerateResponse}
|
||||||
{continueResponse}
|
{continueResponse}
|
||||||
{mergeResponses}
|
{mergeResponses}
|
||||||
{updateChatHistory}
|
|
||||||
{chatActionHandler}
|
|
||||||
{readOnly}
|
{readOnly}
|
||||||
|
on:action={async (e) => {
|
||||||
|
const message = history.messages[message.id];
|
||||||
|
if (typeof e.detail === 'string') {
|
||||||
|
await chatActionHandler(chatId, e.detail, message.model, message.id);
|
||||||
|
} else {
|
||||||
|
const { id, event } = e.detail;
|
||||||
|
await chatActionHandler(chatId, id, message.model, message.id, event);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
on:update={() => {
|
||||||
|
updateChatHistory();
|
||||||
|
}}
|
||||||
on:scroll={() => {
|
on:scroll={() => {
|
||||||
if (autoScroll) {
|
if (autoScroll) {
|
||||||
const element = document.getElementById('messages-container');
|
const element = document.getElementById('messages-container');
|
||||||
|
@ -11,7 +11,6 @@
|
|||||||
import MultiResponseMessages from './MultiResponseMessages.svelte';
|
import MultiResponseMessages from './MultiResponseMessages.svelte';
|
||||||
import ResponseMessage from './ResponseMessage.svelte';
|
import ResponseMessage from './ResponseMessage.svelte';
|
||||||
import UserMessage from './UserMessage.svelte';
|
import UserMessage from './UserMessage.svelte';
|
||||||
import { updateChatById } from '$lib/apis/chats';
|
|
||||||
|
|
||||||
export let chatId;
|
export let chatId;
|
||||||
export let idx = 0;
|
export let idx = 0;
|
||||||
@ -21,9 +20,6 @@
|
|||||||
|
|
||||||
export let user;
|
export let user;
|
||||||
|
|
||||||
export let updateChatHistory;
|
|
||||||
export let chatActionHandler;
|
|
||||||
|
|
||||||
export let showPreviousMessage;
|
export let showPreviousMessage;
|
||||||
export let showNextMessage;
|
export let showNextMessage;
|
||||||
|
|
||||||
@ -81,18 +77,10 @@
|
|||||||
{continueResponse}
|
{continueResponse}
|
||||||
{regenerateResponse}
|
{regenerateResponse}
|
||||||
on:action={async (e) => {
|
on:action={async (e) => {
|
||||||
console.log('action', e);
|
dispatch('action', e.detail);
|
||||||
const message = history.messages[messageId];
|
|
||||||
if (typeof e.detail === 'string') {
|
|
||||||
await chatActionHandler(chatId, e.detail, message.model, message.id);
|
|
||||||
} else {
|
|
||||||
const { id, event } = e.detail;
|
|
||||||
await chatActionHandler(chatId, id, message.model, message.id, event);
|
|
||||||
}
|
|
||||||
}}
|
}}
|
||||||
on:update={async (e) => {
|
on:update={async (e) => {
|
||||||
console.log('update', e);
|
dispatch('update');
|
||||||
updateChatHistory();
|
|
||||||
}}
|
}}
|
||||||
on:save={async (e) => {
|
on:save={async (e) => {
|
||||||
console.log('save', e);
|
console.log('save', e);
|
||||||
@ -100,13 +88,9 @@
|
|||||||
const message = e.detail;
|
const message = e.detail;
|
||||||
if (message) {
|
if (message) {
|
||||||
history.messages[message.id] = message;
|
history.messages[message.id] = message;
|
||||||
await updateChatById(localStorage.token, chatId, {
|
dispatch('update');
|
||||||
history: history
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
await updateChatById(localStorage.token, chatId, {
|
dispatch('update');
|
||||||
history: history
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
{readOnly}
|
{readOnly}
|
||||||
@ -123,40 +107,24 @@
|
|||||||
{regenerateResponse}
|
{regenerateResponse}
|
||||||
{mergeResponses}
|
{mergeResponses}
|
||||||
on:action={async (e) => {
|
on:action={async (e) => {
|
||||||
console.log('action', e);
|
dispatch('action', e.detail);
|
||||||
const message = history.messages[messageId];
|
|
||||||
if (typeof e.detail === 'string') {
|
|
||||||
await chatActionHandler(chatId, e.detail, message.model, message.id);
|
|
||||||
} else {
|
|
||||||
const { id, event } = e.detail;
|
|
||||||
await chatActionHandler(chatId, id, message.model, message.id, event);
|
|
||||||
}
|
|
||||||
}}
|
}}
|
||||||
on:update={async (e) => {
|
on:update={async (e) => {
|
||||||
console.log('update', e);
|
dispatch('update');
|
||||||
updateChatHistory();
|
|
||||||
}}
|
}}
|
||||||
on:save={async (e) => {
|
on:save={async (e) => {
|
||||||
console.log('save', e);
|
console.log('save', e);
|
||||||
|
|
||||||
const message = e.detail;
|
const message = e.detail;
|
||||||
if (message) {
|
if (message) {
|
||||||
history.messages[message.id] = message;
|
history.messages[message.id] = message;
|
||||||
await updateChatById(localStorage.token, chatId, {
|
dispatch('update');
|
||||||
history: history
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
await updateChatById(localStorage.token, chatId, {
|
dispatch('update');
|
||||||
history: history
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
on:change={async () => {
|
on:change={async () => {
|
||||||
await tick();
|
await tick();
|
||||||
await updateChatById(localStorage.token, chatId, {
|
dispatch('update');
|
||||||
history: history
|
|
||||||
});
|
|
||||||
|
|
||||||
dispatch('scroll');
|
dispatch('scroll');
|
||||||
}}
|
}}
|
||||||
{readOnly}
|
{readOnly}
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
const { saveAs } = fileSaver;
|
const { saveAs } = fileSaver;
|
||||||
|
|
||||||
import { downloadChatAsPDF } from '$lib/apis/utils';
|
import { downloadChatAsPDF } from '$lib/apis/utils';
|
||||||
import { copyToClipboard } from '$lib/utils';
|
import { copyToClipboard, createMessagesList } from '$lib/utils';
|
||||||
|
|
||||||
import { showOverview, showControls, mobile } from '$lib/stores';
|
import { showOverview, showControls, mobile } from '$lib/stores';
|
||||||
import { flyAndScale } from '$lib/utils/transitions';
|
import { flyAndScale } from '$lib/utils/transitions';
|
||||||
@ -32,7 +32,9 @@
|
|||||||
|
|
||||||
const getChatAsText = async () => {
|
const getChatAsText = async () => {
|
||||||
const _chat = chat.chat;
|
const _chat = chat.chat;
|
||||||
const chatText = _chat.messages.reduce((a, message, i, arr) => {
|
|
||||||
|
const messages = createMessagesList(_chat.history, _chat.history.currentId);
|
||||||
|
const chatText = messages.reduce((a, message, i, arr) => {
|
||||||
return `${a}### ${message.role.toUpperCase()}\n${message.content}\n\n`;
|
return `${a}### ${message.role.toUpperCase()}\n${message.content}\n\n`;
|
||||||
}, '');
|
}, '');
|
||||||
|
|
||||||
@ -51,9 +53,11 @@
|
|||||||
|
|
||||||
const downloadPdf = async () => {
|
const downloadPdf = async () => {
|
||||||
const _chat = chat.chat;
|
const _chat = chat.chat;
|
||||||
|
const messages = createMessagesList(_chat.history, _chat.history.currentId);
|
||||||
|
|
||||||
console.log('download', chat);
|
console.log('download', chat);
|
||||||
|
|
||||||
const blob = await downloadChatAsPDF(_chat);
|
const blob = await downloadChatAsPDF(_chat.title, messages);
|
||||||
|
|
||||||
// Create a URL for the blob
|
// Create a URL for the blob
|
||||||
const url = window.URL.createObjectURL(blob);
|
const url = window.URL.createObjectURL(blob);
|
||||||
|
@ -860,3 +860,16 @@ export const getWeekday = () => {
|
|||||||
const weekdays = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
|
const weekdays = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
|
||||||
return weekdays[date.getDay()];
|
return weekdays[date.getDay()];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const createMessagesList = (history, messageId) => {
|
||||||
|
if (messageId === null) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
const message = history.messages[messageId];
|
||||||
|
if (message?.parentId) {
|
||||||
|
return [...createMessagesList(history, message.parentId), message];
|
||||||
|
} else {
|
||||||
|
return [message];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user