Unverified Commit 123620bc authored by Timothy Jaeryang Baek's avatar Timothy Jaeryang Baek Committed by GitHub
Browse files

Merge branch 'dev' into dev

parents 99dd81d7 dbdf83c5
...@@ -202,6 +202,7 @@ ...@@ -202,6 +202,7 @@
user: _user ?? undefined, user: _user ?? undefined,
content: userPrompt, content: userPrompt,
files: files.length > 0 ? files : undefined, files: files.length > 0 ? files : undefined,
models: selectedModels.filter((m, mIdx) => selectedModels.indexOf(m) === mIdx),
timestamp: Math.floor(Date.now() / 1000) // Unix epoch timestamp: Math.floor(Date.now() / 1000) // Unix epoch
}; };
...@@ -250,11 +251,12 @@ ...@@ -250,11 +251,12 @@
} }
}; };
const sendPrompt = async (prompt, parentId) => { const sendPrompt = async (prompt, parentId, modelId = null) => {
const _chatId = JSON.parse(JSON.stringify($chatId)); const _chatId = JSON.parse(JSON.stringify($chatId));
await Promise.all( await Promise.all(
(atSelectedModel !== '' ? [atSelectedModel.id] : selectedModels).map(async (modelId) => { (modelId ? [modelId] : atSelectedModel !== '' ? [atSelectedModel.id] : selectedModels).map(
async (modelId) => {
console.log('modelId', modelId); console.log('modelId', modelId);
const model = $models.filter((m) => m.id === modelId).at(0); const model = $models.filter((m) => m.id === modelId).at(0);
...@@ -291,7 +293,8 @@ ...@@ -291,7 +293,8 @@
} else { } else {
toast.error($i18n.t(`Model {{modelId}} not found`, { modelId })); toast.error($i18n.t(`Model {{modelId}} not found`, { modelId }));
} }
}) }
)
); );
await chats.set(await getChatList(localStorage.token)); await chats.set(await getChatList(localStorage.token));
...@@ -756,16 +759,14 @@ ...@@ -756,16 +759,14 @@
console.log('stopResponse'); console.log('stopResponse');
}; };
const regenerateResponse = async () => { const regenerateResponse = async (message) => {
console.log('regenerateResponse'); console.log('regenerateResponse');
if (messages.length != 0 && messages.at(-1).done == true) {
messages.splice(messages.length - 1, 1);
messages = messages;
let userMessage = messages.at(-1); if (messages.length != 0) {
let userMessage = history.messages[message.parentId];
let userPrompt = userMessage.content; let userPrompt = userMessage.content;
await sendPrompt(userPrompt, userMessage.id); await sendPrompt(userPrompt, userMessage.id, message.model);
} }
}; };
......
...@@ -210,7 +210,8 @@ ...@@ -210,7 +210,8 @@
user: _user ?? undefined, user: _user ?? undefined,
content: userPrompt, content: userPrompt,
files: files.length > 0 ? files : undefined, files: files.length > 0 ? files : undefined,
timestamp: Math.floor(Date.now() / 1000) // Unix epoch timestamp: Math.floor(Date.now() / 1000), // Unix epoch
models: selectedModels
}; };
// Add message to history and Set currentId to messageId // Add message to history and Set currentId to messageId
...@@ -255,11 +256,14 @@ ...@@ -255,11 +256,14 @@
await sendPrompt(userPrompt, userMessageId); await sendPrompt(userPrompt, userMessageId);
} }
}; };
const sendPrompt = async (prompt, parentId) => {
const sendPrompt = async (prompt, parentId, modelId = null) => {
const _chatId = JSON.parse(JSON.stringify($chatId)); const _chatId = JSON.parse(JSON.stringify($chatId));
await Promise.all( await Promise.all(
(atSelectedModel !== '' ? [atSelectedModel.id] : selectedModels).map(async (modelId) => { (modelId ? [modelId] : atSelectedModel !== '' ? [atSelectedModel.id] : selectedModels).map(
async (modelId) => {
console.log('modelId', modelId);
const model = $models.filter((m) => m.id === modelId).at(0); const model = $models.filter((m) => m.id === modelId).at(0);
if (model) { if (model) {
...@@ -295,7 +299,8 @@ ...@@ -295,7 +299,8 @@
} else { } else {
toast.error($i18n.t(`Model {{modelId}} not found`, { modelId })); toast.error($i18n.t(`Model {{modelId}} not found`, { modelId }));
} }
}) }
)
); );
await chats.set(await getChatList(localStorage.token)); await chats.set(await getChatList(localStorage.token));
...@@ -759,16 +764,14 @@ ...@@ -759,16 +764,14 @@
console.log('stopResponse'); console.log('stopResponse');
}; };
const regenerateResponse = async () => { const regenerateResponse = async (message) => {
console.log('regenerateResponse'); console.log('regenerateResponse');
if (messages.length != 0 && messages.at(-1).done == true) {
messages.splice(messages.length - 1, 1);
messages = messages;
let userMessage = messages.at(-1); if (messages.length != 0) {
let userMessage = history.messages[message.parentId];
let userPrompt = userMessage.content; let userPrompt = userMessage.content;
await sendPrompt(userPrompt, userMessage.id); await sendPrompt(userPrompt, userMessage.id, message.model);
} }
}; };
......
...@@ -339,7 +339,7 @@ SYSTEM """${system}"""`.replace(/^\s*\n/gm, ''); ...@@ -339,7 +339,7 @@ SYSTEM """${system}"""`.replace(/^\s*\n/gm, '');
if ( if (
inputFiles && inputFiles &&
inputFiles.length > 0 && inputFiles.length > 0 &&
['image/gif', 'image/jpeg', 'image/png'].includes(inputFiles[0]['type']) ['image/gif', 'image/webp', 'image/jpeg', 'image/png'].includes(inputFiles[0]['type'])
) { ) {
reader.readAsDataURL(inputFiles[0]); reader.readAsDataURL(inputFiles[0]);
} else { } else {
......
...@@ -238,7 +238,7 @@ ...@@ -238,7 +238,7 @@
if ( if (
inputFiles && inputFiles &&
inputFiles.length > 0 && inputFiles.length > 0 &&
['image/gif', 'image/jpeg', 'image/png'].includes(inputFiles[0]['type']) ['image/gif', 'image/webp', 'image/jpeg', 'image/png'].includes(inputFiles[0]['type'])
) { ) {
reader.readAsDataURL(inputFiles[0]); reader.readAsDataURL(inputFiles[0]);
} else { } else {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment