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: generate title by backend

Wentao Lyu27515cb00aeb
diff --git a/api/server/routes/ask.js b/api/server/routes/ask.js
index d644af1624..ea246fb46d 100644
--- a/api/server/routes/ask.js
+++ b/api/server/routes/ask.js
@@ -138,13 +138,6 @@ router.post('/', async (req, res) => {
return handleError(res, 'Prompt empty or too short');
}
- // if (!parentMessageId) {
- // gptResponse.title = await titleConvo({
- // model,
- // message: text,
- // response: JSON.stringify(gptResponse.text)
- // });
- // }
gptResponse.sender = model === 'chatgptCustom' ? chatGptLabel : model;
// gptResponse.final = true;
gptResponse.text = await detectCode(gptResponse.text);
@@ -166,6 +159,19 @@ router.post('/', async (req, res) => {
responseMessage: gptResponse
});
res.end();
+
+ if (parentMessageId == '00000000-0000-0000-0000-000000000000') {
+ const title = await titleConvo({
+ model,
+ message: text,
+ response: JSON.stringify(gptResponse?.text)
+ });
+
+ await saveConvo({
+ conversationId,
+ title
+ })
+ }
} catch (error) {
console.log(error);
// await deleteMessages({ messageId: userMessageId });
diff --git a/api/server/routes/askBing.js b/api/server/routes/askBing.js
index 8c8238917a..975046986c 100644
--- a/api/server/routes/askBing.js
+++ b/api/server/routes/askBing.js
@@ -72,14 +72,6 @@ router.post('/', async (req, res) => {
userMessage.invocationId = response.invocationId;
await saveMessage(userMessage);
- // if (!convo.conversationSignature) {
- // response.title = await titleConvo({
- // model,
- // message: text,
- // response: JSON.stringify(response.response)
- // });
- // }
-
response.text = response.response;
delete response.response;
// response.id = response.details.messageId;
@@ -104,6 +96,19 @@ router.post('/', async (req, res) => {
responseMessage: gptResponse
});
res.end();
+
+ if (parentMessageId == '00000000-0000-0000-0000-000000000000') {
+ const title = await titleConvo({
+ model,
+ message: text,
+ response: JSON.stringify(gptResponse?.text)
+ });
+
+ await saveConvo({
+ conversationId,
+ title
+ })
+ }
} catch (error) {
console.log(error);
// await deleteMessages({ messageId: userMessageId });
diff --git a/api/server/routes/askSydney.js b/api/server/routes/askSydney.js
index 8738b625d0..a31c42e3f0 100644
--- a/api/server/routes/askSydney.js
+++ b/api/server/routes/askSydney.js
@@ -73,13 +73,6 @@ router.post('/', async (req, res) => {
// response.parentMessageId = convo.parentMessageId ? convo.parentMessageId : response.messageId;
response.parentMessageId = response.messageId;
response.invocationId = convo.invocationId ? convo.invocationId + 1 : 1;
- response.title = convo.jailbreakConversationId
- ? await getConvoTitle(conversationId)
- : await titleConvo({
- model,
- message: text,
- response: JSON.stringify(response.response)
- });
response.conversationId = conversationId
? conversationId
: crypto.randomUUID();
@@ -114,6 +107,19 @@ router.post('/', async (req, res) => {
responseMessage: gptResponse
});
res.end();
+
+ if (parentMessageId == '00000000-0000-0000-0000-000000000000') {
+ const title = await titleConvo({
+ model,
+ message: text,
+ response: JSON.stringify(gptResponse?.text)
+ });
+
+ await saveConvo({
+ conversationId,
+ title
+ })
+ }
} catch (error) {
console.log(error);
// await deleteMessages({ messageId: userMessageId });
diff --git a/client/src/components/Conversations/Conversation.jsx b/client/src/components/Conversations/Conversation.jsx
index cc41d62daf..4d90ecb2cc 100644
--- a/client/src/components/Conversations/Conversation.jsx
+++ b/client/src/components/Conversations/Conversation.jsx
@@ -74,7 +74,6 @@ export default function Conversation({
);
}
const data = await trigger();
- console.log('data', data);
if (chatGptLabel) {
dispatch(setModel('chatgptCustom'));
diff --git a/client/src/components/Main/TextChat.jsx b/client/src/components/Main/TextChat.jsx
index fe2c7b08eb..710b10f7c2 100644
--- a/client/src/components/Main/TextChat.jsx
+++ b/client/src/components/Main/TextChat.jsx
@@ -307,7 +307,7 @@ export default function TextChat({ messages }) {
const changeHandler = (e) => {
const { value } = e.target;
- console.log(value)
+
if (isSubmitting && (value === '' || value === '\n')) {
return;
}
diff --git a/client/src/components/Messages/index.jsx b/client/src/components/Messages/index.jsx
index f9452d2d23..5d191e61cf 100644
--- a/client/src/components/Messages/index.jsx
+++ b/client/src/components/Messages/index.jsx
@@ -26,8 +26,6 @@ const Messages = ({ messages }) => {
const messageTree = useMemo(() => buildTree(messages), [messages, ]);
- console.log('messageTree', messageTree);
-
function buildTree(messages) {
let messageMap = {};
let rootMessages = [];