Slide 10
Slide 10 text
AskChatgptIntentHandler ポイント 3/3
if( locale === 'ja-JP')
{
// 翻訳
let rs = await getAwsTranslate(question,'ja','en');
const completion = await openai.createChatCompletion({
model: "gpt-3.5-turbo",
messages: [
{role: "system", content: "You are a helpful smart speaker assistant. "},
{role: "system", content: "You will give a concise answer of about 100 characters so that it is easy to understand by listening to the voice."},
{role: "user", content: rs.TranslatedText}
],
});
console.log(completion);
console.log(completion.data.choices[0].message.content);
// console.log(completion.data.choices[0].message);
// 英語を日本語に翻訳する
let en_ja = await getAwsTranslate(completion.data.choices[0].message.content,'en','ja');
console.log(en_ja);
speakOutput = en_ja.TranslatedText.trim() + handlerInput.t('REPROMPT_MSG');
ChatGPTに次のように振舞うように指示しています。
あなたは、親切なスマートスピーカーアシスタントです。声
で聴いて理解しやすい簡潔に100文字程度の回答を返します。
8秒制限に引っかからないように、
長すぎる回答を防止するため
10
以上です。ありがとうございます。