From 005d8fb1787065a37e56b39d5df2db888fc9976b Mon Sep 17 00:00:00 2001 From: Daniel Avila Date: Tue, 28 Mar 2023 19:50:37 -0400 Subject: [PATCH] edit titleConvo for consistent results --- api/app/titleConvo.js | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/api/app/titleConvo.js b/api/app/titleConvo.js index 249e75c8b4..44c2b9f5e8 100644 --- a/api/app/titleConvo.js +++ b/api/app/titleConvo.js @@ -18,20 +18,31 @@ const proxyEnvToAxiosProxy = proxyString => { const titleConvo = async ({ model, text, response }) => { let title = 'New Chat'; + const messages = [ + { + role: 'system', + content: + // `You are a title-generator with one job: giving a conversation, detect the language and titling the conversation provided by a user, using the same language. The requirement are: 1. If possible, generate in 5 words or less, 2. Using title case, 3. must give the title using the language as the user said. 4. Don't refer to the participants of the conversation. 5. Do not include punctuation or quotation marks. 6. Your response should be in title case, exclusively containing the title. 7. don't say anything except the title. + `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 words should be capitalized and complete only the title in User Language only. + +||>User: +"${text}" +||>Response: +"${JSON.stringify(response?.text)}" + +||>Title:` + } + // { + // role: 'user', + // content: `User:\n "${text}"\n\n${model}: \n"${JSON.stringify(response?.text)}"\n\n` + // } + ]; + + console.log('MESSAGES', messages[0]); const request = { model: 'gpt-3.5-turbo', - messages: [ - { - role: 'system', - content: - "You are a title-generator with one job: giving a conversation, detect the language and titling the conversation provided by a user, using the same language. The requirement are: 1. If possible, generate in 5 words or less, 2. Using title case, 3. must give the title using the language as the user said. 4. Don't refer to the participants of the conversation. 5. Do not include punctuation or quotation marks. 6. Your response should be in title case, exclusively containing the title. 7. don't say anything except the title." - }, - { - role: 'user', - content: `User:\n "${text}"\n\n${model}: \n"${JSON.stringify(response?.text)}"\n\n` - } - ], + messages, temperature: 0, presence_penalty: 0, frequency_penalty: 0