Skip to content

Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active

fix: add PaLM icon as SVG and improve meilisearch syncing to prevent large indicing jobs (#600)

Danny Avila9eefa3e24c32
diff --git a/api/app/clients/BaseClient.js b/api/app/clients/BaseClient.js
index f5d83c514e..3ecd7f45a1 100644
--- a/api/app/clients/BaseClient.js
+++ b/api/app/clients/BaseClient.js
@@ -71,7 +71,7 @@ class BaseClient {
};
}
- createUserMessage({ messageId, parentMessageId, conversationId, text}) {
+ createUserMessage({ messageId, parentMessageId, conversationId, text }) {
const userMessage = {
messageId,
parentMessageId,
@@ -293,7 +293,7 @@ class BaseClient {
};
}
- async handleContextStrategy({instructions, orderedMessages, formattedMessages}) {
+ async handleContextStrategy({ instructions, orderedMessages, formattedMessages }) {
let payload = this.addInstructions(formattedMessages, instructions);
let orderedWithInstructions = this.addInstructions(orderedMessages, instructions);
let {
@@ -350,7 +350,7 @@ class BaseClient {
}
if (index === refineIndex) {
- map.refined = { ...refinedMessage, messageId: message.messageId};
+ map.refined = { ...refinedMessage, messageId: message.messageId };
}
map[message.messageId] = payload[index].tokenCount;
@@ -457,7 +457,7 @@ class BaseClient {
}
async saveMessageToDatabase(message, endpointOptions, user = null) {
- await saveMessage({ ...message, unfinished: false });
+ await saveMessage({ ...message, unfinished: false, cancelled: false });
await saveConvo(user, {
conversationId: message.conversationId,
endpoint: this.options.endpoint,
diff --git a/api/models/plugins/mongoMeili.js b/api/models/plugins/mongoMeili.js
index d157eccacc..b123b3153b 100644
--- a/api/models/plugins/mongoMeili.js
+++ b/api/models/plugins/mongoMeili.js
@@ -190,19 +190,55 @@ module.exports = function mongoMeili(schema, options) {
schema.post('remove', function (doc) {
doc.postRemoveHook();
});
- schema.post('deleteMany', function () {
- // console.log('deleteMany hook', doc);
- if (Object.prototype.hasOwnProperty.call(schema.obj, 'messages')) {
- console.log('Syncing convos...');
- mongoose.model('Conversation').syncWithMeili();
- }
- if (Object.prototype.hasOwnProperty.call(schema.obj, 'messageId')) {
- console.log('Syncing messages...');
- mongoose.model('Message').syncWithMeili();
+ schema.pre('deleteMany', async function (next) {
+ try {
+ if (Object.prototype.hasOwnProperty.call(schema.obj, 'messages')) {
+ const convoIndex = client.index('convos');
+ const deletedConvos = await mongoose.model('Conversation').find(this._conditions).lean();
+ let promises = [];
+ for (const convo of deletedConvos) {
+ promises.push(convoIndex.deleteDocument(convo.conversationId));
+ }
+ await Promise.all(promises);
+ }
+
+ if (Object.prototype.hasOwnProperty.call(schema.obj, 'messageId')) {
+ const messageIndex = client.index('messages');
+ const deletedMessages = await mongoose.model('Message').find(this._conditions).lean();
+ let promises = [];
+ for (const message of deletedMessages) {
+ promises.push(messageIndex.deleteDocument(message.messageId));
+ }
+ await Promise.all(promises);
+ }
+ return next();
+ } catch (error) {
+ console.log('[Meilisearch] There was an issue deleting conversation indexes upon deletion, next startup may be slow due to syncing');
+ console.error(error);
+ return next(error);
}
});
- schema.post('findOneAndUpdate', function (doc) {
+
+ schema.post('findOneAndUpdate', async function (doc) {
+ if (doc.unfinished) {
+ return;
+ }
+
+ let meiliDoc;
+ // Doc is a Conversation
+ if (doc.messages) {
+ try {
+ meiliDoc = await client.index('convos').getDocument(doc.conversationId);
+ } catch (error) {
+ console.log('[Meilisearch] Convo not found and will index', doc.conversationId);
+ }
+ }
+
+ if (meiliDoc && meiliDoc.title === doc.title) {
+ return;
+ }
+
doc.postSaveHook();
});
};
diff --git a/api/server/routes/ask/gptPlugins.js b/api/server/routes/ask/gptPlugins.js
index 90792caea2..c672aacc86 100644
--- a/api/server/routes/ask/gptPlugins.js
+++ b/api/server/routes/ask/gptPlugins.js
@@ -117,8 +117,8 @@ const ask = async ({ text, endpoint, endpointOption, parentMessageId = null, con
parentMessageId: overrideParentMessageId || userMessageId,
text: partialText,
model: endpointOption.modelOptions.model,
- unfinished: false,
- cancelled: true,
+ unfinished: true,
+ cancelled: false,
error: false
});
}
diff --git a/api/server/routes/ask/openAI.js b/api/server/routes/ask/openAI.js
index e123f462fa..d5baf81663 100644
--- a/api/server/routes/ask/openAI.js
+++ b/api/server/routes/ask/openAI.js
@@ -88,8 +88,8 @@ const ask = async ({ text, endpointOption, parentMessageId = null, endpoint, con
parentMessageId: overrideParentMessageId || userMessageId,
text: partialText,
model: endpointOption.modelOptions.model,
- unfinished: false,
- cancelled: true,
+ unfinished: true,
+ cancelled: false,
error: false
});
}
diff --git a/client/public/assets/google-palm.svg b/client/public/assets/google-palm.svg
new file mode 100644
index 0000000000..5c345fe1c1
--- /dev/null
+++ b/client/public/assets/google-palm.svg
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Generator: Adobe Illustrator 27.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
+<svg version="1.1" id="Standard_product_icon__x28_1:1_x29_"
+ xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="192px" height="192px"
+ viewBox="0 0 192 192" enable-background="new 0 0 192 192" xml:space="preserve">
+<symbol id="material_x5F_product_x5F_standard_x5F_icon_x5F_keylines_00000077318920148093339210000006245950728745084294_" viewBox="-96 -96 192 192">
+ <g opacity="0.4">
+ <defs>
+ <path id="SVGID_1_" opacity="0.4" d="M-96,96V-96H96V96H-96z"/>
+ </defs>
+ <clipPath id="SVGID_00000071517564283228984050000017848131202901217410_">
+ <use xlink:href="#SVGID_1_" overflow="visible"/>
+ </clipPath>
+ <g clip-path="url(#SVGID_00000071517564283228984050000017848131202901217410_)">
+ <g>
+ <path d="M95.75,95.75v-191.5h-191.5v191.5H95.75 M96,96H-96V-96H96V96L96,96z"/>
+ </g>
+ <circle fill="none" stroke="#000000" stroke-width="0.25" stroke-miterlimit="10" cx="0" cy="0" r="64"/>
+ </g>
+
+ <circle clip-path="url(#SVGID_00000071517564283228984050000017848131202901217410_)" fill="none" stroke="#000000" stroke-width="0.25" stroke-miterlimit="10" cx="0" cy="0" r="88"/>
+
+ <path clip-path="url(#SVGID_00000071517564283228984050000017848131202901217410_)" fill="none" stroke="#000000" stroke-width="0.25" stroke-miterlimit="10" d="
+ M64,76H-64c-6.6,0-12-5.4-12-12V-64c0-6.6,5.4-12,12-12H64c6.6,0,12,5.4,12,12V64C76,70.6,70.6,76,64,76z"/>
+
+ <path clip-path="url(#SVGID_00000071517564283228984050000017848131202901217410_)" fill="none" stroke="#000000" stroke-width="0.25" stroke-miterlimit="10" d="
+ M52,88H-52c-6.6,0-12-5.4-12-12V-76c0-6.6,5.4-12,12-12H52c6.6,0,12,5.4,12,12V76C64,82.6,58.6,88,52,88z"/>
+
+ <path clip-path="url(#SVGID_00000071517564283228984050000017848131202901217410_)" fill="none" stroke="#000000" stroke-width="0.25" stroke-miterlimit="10" d="
+ M76,64H-76c-6.6,0-12-5.4-12-12V-52c0-6.6,5.4-12,12-12H76c6.6,0,12,5.4,12,12V52C88,58.6,82.6,64,76,64z"/>
+ </g>
+</symbol>
+<rect id="bounding_box_1_" display="none" fill="none" width="192" height="192"/>
+<g id="art_layer">
+ <g>
+ <path fill="#F9AB00" d="M96,181.92L96,181.92c6.63,0,12-5.37,12-12v-104H84v104C84,176.55,89.37,181.92,96,181.92z"/>
+ <g>
+ <path fill="#5BB974" d="M143.81,103.87C130.87,90.94,111.54,88.32,96,96l51.37,51.37c2.12,2.12,5.77,1.28,6.67-1.57
+ C158.56,131.49,155.15,115.22,143.81,103.87z"/>
+ </g>
+ <g>
+ <path fill="#129EAF" d="M48.19,103.87C61.13,90.94,80.46,88.32,96,96l-51.37,51.37c-2.12,2.12-5.77,1.28-6.67-1.57
+ C33.44,131.49,36.85,115.22,48.19,103.87z"/>
+ </g>
+ <g>
+ <path fill="#AF5CF7" d="M140,64c-20.44,0-37.79,13.4-44,32h81.24c3.33,0,5.55-3.52,4.04-6.49C173.56,74.36,157.98,64,140,64z"/>
+ </g>
+ <g>
+ <path fill="#FF8BCB" d="M104.49,42.26C90.03,56.72,87.24,78.45,96,96l57.45-57.45c2.36-2.36,1.44-6.42-1.73-7.45
+ C135.54,25.85,117.2,29.55,104.49,42.26z"/>
+ </g>
+ <g>
+ <path fill="#FA7B17" d="M87.51,42.26C101.97,56.72,104.76,78.45,96,96L38.55,38.55c-2.36-2.36-1.44-6.42,1.73-7.45
+ C56.46,25.85,74.8,29.55,87.51,42.26z"/>
+ </g>
+ <g>
+ <g>
+ <path fill="#4285F4" d="M52,64c20.44,0,37.79,13.4,44,32H14.76c-3.33,0-5.55-3.52-4.04-6.49C18.44,74.36,34.02,64,52,64z"/>
+ </g>
+ </g>
+ </g>
+</g>
+<g id="keylines" display="none">
+
+ <use xlink:href="#material_x5F_product_x5F_standard_x5F_icon_x5F_keylines_00000077318920148093339210000006245950728745084294_" width="192" height="192" id="material_x5F_product_x5F_standard_x5F_icon_x5F_keylines" x="-96" y="-96" transform="matrix(1 0 0 -1 96 96)" display="inline" overflow="visible"/>
+</g>
+</svg>
diff --git a/client/public/assets/palm.png b/client/public/assets/palm.png
deleted file mode 100644
index 3488a71457..0000000000
Binary files a/client/public/assets/palm.png and /dev/null differ
diff --git a/client/src/utils/getIcon.jsx b/client/src/utils/getIcon.jsx
index 35e4f4a577..d0a435f44f 100644
--- a/client/src/utils/getIcon.jsx
+++ b/client/src/utils/getIcon.jsx
@@ -14,7 +14,7 @@ const getIcon = (props) => {
width: size,
height: size
}}
- className={`relative flex items-center justify-center` + props?.className}
+ className={'relative flex items-center justify-center' + props?.className}
>
<img
className="rounded-sm"
@@ -51,12 +51,12 @@ const getIcon = (props) => {
name = 'Plugins';
} else if (endpoint === 'google') {
const { modelLabel } = props;
- icon = <img src="/assets/palm.png" />;
+ icon = <img src="/assets/google-palm.svg" alt="Palm Icon"/>;
name = modelLabel || 'PaLM2';
} else if (endpoint === 'bingAI') {
const { jailbreak } = props;
icon = <BingIcon size={size * 0.7} />;
- bg = jailbreak ? `radial-gradient(circle at 90% 110%, #F0F0FA, #D0E0F9)` : `transparent`;
+ bg = jailbreak ? 'radial-gradient(circle at 90% 110%, #F0F0FA, #D0E0F9)' : 'transparent';
name = jailbreak ? 'Sydney' : 'BingAI';
} else if (endpoint === 'chatGPTBrowser') {
icon = <GPTIcon size={size * 0.7} />;
@@ -67,11 +67,11 @@ const getIcon = (props) => {
name = 'ChatGPT';
} else if (endpoint === null) {
icon = <GPTIcon size={size * 0.7} />;
- bg = `grey`;
+ bg = 'grey';
name = 'N/A';
} else {
icon = <GPTIcon size={size * 0.7} />;
- bg = `grey`;
+ bg = 'grey';
name = 'UNKNOWN';
}
@@ -84,7 +84,7 @@ const getIcon = (props) => {
height: size
}}
className={
- `relative flex items-center justify-center rounded-sm text-white ` + props?.className
+ 'relative flex items-center justify-center rounded-sm text-white ' + props?.className
}
>
{icon}