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

sync updates and merge with feat-resubmit

Wentao Lyub0284b6974d8
diff --git a/api/models/Conversation.js b/api/models/Conversation.js
index fbed894712..9c30e1575a 100644
--- a/api/models/Conversation.js
+++ b/api/models/Conversation.js
@@ -85,8 +85,6 @@ module.exports = {
update.promptPrefix = null;
}
- console.error(user)
-
return await Conversation.findOneAndUpdate(
{ conversationId: conversationId, user: user },
{ $set: update },
diff --git a/api/server/routes/ask.js b/api/server/routes/ask.js
index f23d5c7dcc..f016a49b30 100644
--- a/api/server/routes/ask.js
+++ b/api/server/routes/ask.js
@@ -37,7 +37,7 @@ router.post('/', async (req, res) => {
});
await saveMessage(userMessage);
- await saveConvo({ ...userMessage, model, ...convo });
+ await saveConvo(req?.session?.user?.username, { ...userMessage, model, ...convo });
return await ask({
userMessage,
@@ -178,7 +178,7 @@ const ask = async ({
await saveMessage(gptResponse);
await saveConvo(req?.session?.user?.username, gptResponse);
sendMessage(res, {
- title: await getConvoTitle(conversationId),
+ title: await getConvoTitle(req?.session?.user?.username, conversationId),
final: true,
requestMessage: userMessage,
responseMessage: gptResponse
@@ -188,10 +188,13 @@ const ask = async ({
if (userParentMessageId == '00000000-0000-0000-0000-000000000000') {
const title = await titleConvo({ model, text, response: gptResponse });
- await saveConvo({
- conversationId,
- title
- });
+ await saveConvo(
+ req?.session?.user?.username,
+ {
+ conversationId,
+ title
+ }
+ );
}
} catch (error) {
console.log(error);
diff --git a/api/server/routes/askBing.js b/api/server/routes/askBing.js
index dcf9138374..0614faf86a 100644
--- a/api/server/routes/askBing.js
+++ b/api/server/routes/askBing.js
@@ -38,7 +38,7 @@ router.post('/', async (req, res) => {
});
await saveMessage(userMessage);
- await saveConvo({ ...userMessage, model, ...convo });
+ await saveConvo(req?.session?.user?.username, { ...userMessage, model, ...convo });
return await ask({
isNewConversation,
@@ -108,10 +108,13 @@ const ask = async ({
// Attition: the api will also create new conversationId while using invalid userMessage.parentMessageId,
// but in this situation, don't change the conversationId, but create new convo.
if (conversationId != userMessage.conversationId && isNewConversation)
- await saveConvo({
- conversationId: conversationId,
- newConversationId: userMessage.conversationId
- });
+ await saveConvo(
+ req?.session?.user?.username,
+ {
+ conversationId: conversationId,
+ newConversationId: userMessage.conversationId
+ }
+ );
conversationId = userMessage.conversationId;
response.text = response.response;
@@ -132,7 +135,7 @@ const ask = async ({
await saveConvo(req?.session?.user?.username, { ...response, model, chatGptLabel: null, promptPrefix: null, ...convo });
sendMessage(res, {
- title: await getConvoTitle(conversationId),
+ title: await getConvoTitle(req?.session?.user?.username, conversationId),
final: true,
requestMessage: userMessage,
responseMessage: response
@@ -142,10 +145,13 @@ const ask = async ({
if (userParentMessageId == '00000000-0000-0000-0000-000000000000') {
const title = await titleConvo({ model, text, response });
- await saveConvo({
- conversationId,
- title
- });
+ await saveConvo(
+ req?.session?.user?.username,
+ {
+ conversationId,
+ title
+ }
+ );
}
} catch (error) {
console.log(error);
diff --git a/api/server/routes/askSydney.js b/api/server/routes/askSydney.js
index c2cf02f32e..a2017cf7d6 100644
--- a/api/server/routes/askSydney.js
+++ b/api/server/routes/askSydney.js
@@ -38,7 +38,7 @@ router.post('/', async (req, res) => {
});
await saveMessage(userMessage);
- await saveConvo({ ...userMessage, model, ...convo });
+ await saveConvo(req?.session?.user?.username, { ...userMessage, model, ...convo });
return await ask({
isNewConversation,
@@ -132,10 +132,13 @@ const ask = async ({
// Attition: the api will also create new conversationId while using invalid userMessage.parentMessageId,
// but in this situation, don't change the conversationId, but create new convo.
if (conversationId != userMessage.conversationId && isNewConversation)
- await saveConvo({
- conversationId: conversationId,
- newConversationId: userMessage.conversationId
- });
+ await saveConvo(
+ req?.session?.user?.username,
+ {
+ conversationId: conversationId,
+ newConversationId: userMessage.conversationId
+ }
+ );
conversationId = userMessage.conversationId;
response.text = await handleText(response, true);
@@ -144,7 +147,7 @@ const ask = async ({
await saveConvo(req?.session?.user?.username, { ...response, model, chatGptLabel: null, promptPrefix: null, ...convo });
sendMessage(res, {
- title: await getConvoTitle(conversationId),
+ title: await getConvoTitle(req?.session?.user?.username, conversationId),
final: true,
requestMessage: userMessage,
responseMessage: response
@@ -154,10 +157,13 @@ const ask = async ({
if (userParentMessageId == '00000000-0000-0000-0000-000000000000') {
const title = await titleConvo({ model, text, response });
- await saveConvo({
- conversationId,
- title
- });
+ await saveConvo(
+ req?.session?.user?.username,
+ {
+ conversationId,
+ title
+ }
+ );
}
} catch (error) {
console.log(error);
diff --git a/api/server/routes/convos.js b/api/server/routes/convos.js
index 11dbb7a545..0364684fad 100644
--- a/api/server/routes/convos.js
+++ b/api/server/routes/convos.js
@@ -18,17 +18,18 @@ router.post('/gen_title', async (req, res) => {
const secondMessage = (await getMessages({ conversationId }))[1]
const title = convo.jailbreakConversationId
- ? await getConvoTitle(conversationId)
+ ? await getConvoTitle(req?.session?.user?.username, conversationId)
: await titleConvo({
model: convo?.model,
message: firstMessage?.text,
response: JSON.stringify(secondMessage?.text || '')
});
- await saveConvo(req?.session?.user?.username,
+ await saveConvo(
+ req?.session?.user?.username,
{
- conversationId,
- title
+ conversationId,
+ title
}
)