Sometimes, my OpenAI API on call like
const completion = await openai.createChatCompletion({
model: 'gpt-3.5-turbo',
messages: [
{
role: 'system',
content: `You are ChatbotAssistant, an automated service to answer questions of a website visitors.` +
`You respond in a short, very conversational friendly style. If you can't find an answer, provide no answer and apologize.`
},
{role: 'user', content: userQuestion}
]
})
const responseText = completion.data.choices[0].message.content
gives answer with "A:" or "Answer:" prepended. Since I don't need that, I tried to instruct it explicitly not to do it, by changing system message like:
`You are ChatbotAssistant, an automated service to answer questions of a website visitors.` +
`Do not prepend "A:" or "Answer:" to your answers` +
`You respond in a short, very conversational friendly style. If you can't find an
answer, provide no answer and apologize.`
but to no effect.
I know I can handle this in Javascript like e.g.
let cleanedText = responseText
if (responseText.startsWith('A:') || responseText.startsWith('Answer:')) {
cleanedText = responseText.replace(/^(A:|Answer:)\s*/, '')
}
but is there OpenAI solution to this? Thanks.