All files / services/agent-config/src/models Agent.js

100% Statements 27/27
100% Branches 1/1
100% Functions 0/0
100% Lines 27/27

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 281x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x  
const mongoose = require('mongoose');
 
const agentSchema = new mongoose.Schema({
  organizationId: {
    type: mongoose.Schema.Types.ObjectId,
    ref: 'Organization',
    required: true,
    index: true
  },
  userId: { type: String, required: true, index: true },
  name: { type: String, required: true },
  description: { type: String, default: '' },
  knowledgeBaseIds: { type: [String], default: [] },
  llmModel: { type: String, default: 'deepseek/deepseek-v4-flash' },
  systemPrompt: { type: String, default: 'Tu es un assistant helpful qui répond aux questions en utilisant le contexte fourni.' },
  maxSessionMessages: { type: Number, default: 20 },
  openrouterApiKey: { type: String, default: null, select: false },
  apiKeyId: { type: String, default: null },
  createdAt: { type: Date, default: Date.now },
  updatedAt: { type: Date, default: Date.now }
});
 
agentSchema.index({ organizationId: 1, userId: 1, createdAt: -1 });
 
const Agent = mongoose.model('Agent', agentSchema);
 
module.exports = Agent;