All files action.js

100% Statements 39/39
100% Branches 2/2
100% Functions 1/1
100% Lines 39/39

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 391x 1x 1x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 1x 1x 1x 1x 1x 1x 1x 1x
"use strict"
import Reference from './reference.js';
 
async function respond(memory, api, player, message) {
 
  const params = {
    messages: [{ role: 'user', content: message }],
    model: 'gpt-3.5-turbo'
  };
 
  // if (memory.exists(player)) {
 
  //   // if there's prior reference for the player
  //   // then send the message with the reference information
  //   // in order to provide context to the conversation
  //   previousReference = memory.retrieve(player);
  //   // TODO: add previousReference details to the message params
  // }
 
  const chatCompletion = await api.chat.completions.create(params);
  const reply = chatCompletion.choices[0].message.content;
 
  // memorise current reference against the player
  const reference = new Reference(
    chatCompletion.id,
    chatCompletion.id
  );
  memory.register(player, reference);
 
  return reply;
}
 
const exports = {
  respond: respond
};
 
export {
  exports as default
};