It’s quite possible that my expression of this issue is part of the problem but I am struggling with this and hence am offering it to the human community for discussion and a solution.
Below is an extract from a simple Alexa skill project. The uncommented code ( ‘text-davinci-003’) works. The comments are partly ‘gpt-3.5-turbo’'s suggestions although the messages: [array] comes from OpenAi’s documentation.
‘speakOutput’ is the puzzle but maybe that’s only part of the story.
Extracted from Alexa skill index.js
const AskOpenAIIntentHandler = {canHandle(handlerInput) {
return Alexa.getRequestType(handlerInput.requestEnvelope) === ‘IntentRequest’
&& Alexa.getIntentName(handlerInput.requestEnvelope) === ‘AskOpenAIIntent’;
},
async handle(handlerInput) {const question =
Alexa.getSlotValue(handlerInput.requestEnvelope, ‘question’);
const response = await openai.createCompletion({
//const response = await openai.createChatCompletion({
//engine: 'textapi',
//model: 'gpt-3.5-turbo-0301',
model: 'text-davinci-003',
prompt: question,
/*
messages: [
{ role: "system", content: "You are an all round good egg" },
{ role: "assistant", content: "How else may I help" },
{ role: "user", content: question },
],
*/
temperature: 0.5,
max_tokens: 1024,
top_p: 1,
frequency_penalty: 0.0,
presence_penalty: 0.0,
/*
n: 1,
stop: '\n',
*/
});
const speakOutput = response.data.choices[0].text +
' What more would you like to know?';
/* **either**
const systemMessage = response.data.choices[0].message;
const userMessage = systemMessage.context;
const speakOutput = `${userMessage} ${systemMessage.content} What more would you like to know? `;
**or**
const speakOutput = response.data.choices[0].message.content +
' What more would you like to know?';
neither works
*/
return handlerInput.responseBuilder
.speak(speakOutput)
.reprompt("What else can I help you with?")
.getResponse();
}
};