mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-16 20:07:49 +01:00
refac
This commit is contained in:
@@ -73,7 +73,6 @@ class ChatForm(BaseModel):
|
|||||||
class ChatImportForm(ChatForm):
|
class ChatImportForm(ChatForm):
|
||||||
meta: Optional[dict] = {}
|
meta: Optional[dict] = {}
|
||||||
pinned: Optional[bool] = False
|
pinned: Optional[bool] = False
|
||||||
folder_id: Optional[str] = None
|
|
||||||
created_at: Optional[int] = None
|
created_at: Optional[int] = None
|
||||||
updated_at: Optional[int] = None
|
updated_at: Optional[int] = None
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { WEBUI_API_BASE_URL } from '$lib/constants';
|
import { WEBUI_API_BASE_URL } from '$lib/constants';
|
||||||
import { getTimeRange } from '$lib/utils';
|
import { getTimeRange } from '$lib/utils';
|
||||||
|
|
||||||
export const createNewChat = async (token: string, chat: object) => {
|
export const createNewChat = async (token: string, chat: object, folderId: string | null) => {
|
||||||
let error = null;
|
let error = null;
|
||||||
|
|
||||||
const res = await fetch(`${WEBUI_API_BASE_URL}/chats/new`, {
|
const res = await fetch(`${WEBUI_API_BASE_URL}/chats/new`, {
|
||||||
@@ -12,7 +12,8 @@ export const createNewChat = async (token: string, chat: object) => {
|
|||||||
authorization: `Bearer ${token}`
|
authorization: `Bearer ${token}`
|
||||||
},
|
},
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
chat: chat
|
chat: chat,
|
||||||
|
folder_id: folderId ?? null
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.then(async (res) => {
|
.then(async (res) => {
|
||||||
|
|||||||
@@ -1979,18 +1979,22 @@
|
|||||||
let _chatId = $chatId;
|
let _chatId = $chatId;
|
||||||
|
|
||||||
if (!$temporaryChatEnabled) {
|
if (!$temporaryChatEnabled) {
|
||||||
chat = await createNewChat(localStorage.token, {
|
chat = await createNewChat(
|
||||||
id: _chatId,
|
localStorage.token,
|
||||||
title: $i18n.t('New Chat'),
|
{
|
||||||
models: selectedModels,
|
id: _chatId,
|
||||||
system: $settings.system ?? undefined,
|
title: $i18n.t('New Chat'),
|
||||||
params: params,
|
models: selectedModels,
|
||||||
history: history,
|
system: $settings.system ?? undefined,
|
||||||
messages: createMessagesList(history, history.currentId),
|
params: params,
|
||||||
tags: [],
|
history: history,
|
||||||
...($selectedFolder ? { folder_id: $selectedFolder?.id } : {}),
|
messages: createMessagesList(history, history.currentId),
|
||||||
timestamp: Date.now()
|
tags: [],
|
||||||
});
|
|
||||||
|
timestamp: Date.now()
|
||||||
|
},
|
||||||
|
$selectedFolder?.id
|
||||||
|
);
|
||||||
|
|
||||||
_chatId = chat.id;
|
_chatId = chat.id;
|
||||||
await chatId.set(_chatId);
|
await chatId.set(_chatId);
|
||||||
|
|||||||
Reference in New Issue
Block a user