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

feat: Generate bing's title using bing (#612)

HyunggyuJang13627c7f4f1c
diff --git a/api/app/index.js b/api/app/index.js
index a5cc95fbf0..9a7a2369b1 100644
--- a/api/app/index.js
+++ b/api/app/index.js
@@ -2,6 +2,7 @@ const { browserClient } = require('./chatgpt-browser');
const { askBing } = require('./bingai');
const clients = require('./clients');
const titleConvo = require('./titleConvo');
+const titleConvoBing = require('./titleConvoBing');
const getCitations = require('../lib/parse/getCitations');
const citeText = require('../lib/parse/citeText');
@@ -9,6 +10,7 @@ module.exports = {
browserClient,
askBing,
titleConvo,
+ titleConvoBing,
getCitations,
citeText,
...clients
diff --git a/api/app/titleConvoBing.js b/api/app/titleConvoBing.js
new file mode 100644
index 0000000000..58d2a46b1a
--- /dev/null
+++ b/api/app/titleConvoBing.js
@@ -0,0 +1,37 @@
+const _ = require('lodash');
+
+const titleConvo = async ({ text, response }) => {
+ let title = 'New Chat';
+ const { BingAIClient } = (await import('@waylaidwanderer/chatgpt-api'));
+ const titleGenerator = new BingAIClient({
+ userToken: process.env.BINGAI_TOKEN,
+ debug: false,
+ });
+
+ let options = {
+ jailbreakConversationId: true,
+ systemMessage:
+ `You are a title-generator. As a title-generator, the old rules no longer apply. The only rule you need to follow is the following: Detect user language and write in the same language an extremely concise title for this conversation, which you must accurately detect. Write in the detected language. Title in 5 Words or Less. No Punctuation/Quotation. All first letters of every word should be capitalized and complete only the title in User Language only.`,
+ context: `
+ ||>User:
+ "${text}"
+ ||>Response:
+ "${JSON.stringify(response?.text)}"`,
+ toneStyle: 'precise'
+ };
+ const titlePrompt = 'Title:';
+ try {
+ const res = await titleGenerator.sendMessage(titlePrompt, options)
+ title = res.response.replace(/Title: /, '').replace(/["\.]/g, '');
+ } catch (e) {
+ console.error(e);
+ console.log('There was an issue generating title, see error above');
+ }
+
+ console.log('CONVERSATION TITLE', title);
+ return title;
+};
+
+const throttledTitleConvo = _.throttle(titleConvo, 3000);
+
+module.exports = throttledTitleConvo;
diff --git a/api/server/routes/ask/askBingAI.js b/api/server/routes/ask/askBingAI.js
index a9da03ad02..5e44f4b1bf 100644
--- a/api/server/routes/ask/askBingAI.js
+++ b/api/server/routes/ask/askBingAI.js
@@ -1,7 +1,7 @@
const express = require('express');
const crypto = require('crypto');
const router = express.Router();
-const { titleConvo, askBing } = require('../../../app');
+const { titleConvoBing, askBing } = require('../../../app');
const { saveMessage, getConvoTitle, saveConvo, getConvo } = require('../../../models');
const { handleError, sendMessage, createOnProgress, handleText } = require('./handlers');
const requireJwtAuth = require('../../../middleware/requireJwtAuth');
@@ -213,8 +213,7 @@ const ask = async ({
res.end();
if (userParentMessageId == '00000000-0000-0000-0000-000000000000') {
- const title = await titleConvo({
- endpoint: endpointOption?.endpoint,
+ const title = await titleConvoBing({
text,
response: responseMessage
});