const config = require('../../config');
const providers = config.providers;
const crypto = require('crypto');
const bcrypt = require('bcrypt');
const moment = require('moment');

module.exports = function(sequelize, DataTypes) {
  const assistant_messages = sequelize.define(
    'assistant_messages',
    {
      id: {
        type: DataTypes.UUID,
        defaultValue: DataTypes.UUIDV4,
        primaryKey: true,
      },

sender: {
        type: DataTypes.ENUM,
      
      

        values: [

"user",


"assistant",


"system"

        ],

      },

content: {
        type: DataTypes.TEXT,
      
      

      },

model_name: {
        type: DataTypes.TEXT,
      
      

      },

prompt_tokens: {
        type: DataTypes.INTEGER,
      
      

      },

completion_tokens: {
        type: DataTypes.INTEGER,
      
      

      },

sent_at: {
        type: DataTypes.DATE,
      
      

      },

      importHash: {
        type: DataTypes.STRING(255),
        allowNull: true,
        unique: true,
      },
    },
    {
      timestamps: true,
      paranoid: true,
      freezeTableName: true,
    },
  );

  assistant_messages.associate = (db) => {


/// loop through entities and it's fields, and if ref === current e[name] and create relation has many on parent entity































//end loop



    db.assistant_messages.belongsTo(db.assistant_threads, {
      as: 'thread',
      foreignKey: {
        name: 'threadId',
      },
      constraints: false,
    });




    db.assistant_messages.belongsTo(db.users, {
      as: 'createdBy',
    });

    db.assistant_messages.belongsTo(db.users, {
      as: 'updatedBy',
    });
  };



  return assistant_messages;
};


