mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-02-19 08:58:09 +01:00
ci(backend-review.yml): add linter step to the backend review workflow (#625)
* ci(backend-review.yml): add linter step to the backend review workflow * chore(backend-review.yml): remove prettier from lint-action configuration * chore: apply new linting workflow * chore(lint-staged.config.js): reorder lint-staged tasks for JavaScript and TypeScript files * chore(eslint): update ignorePatterns in .eslintrc.js chore(lint-action): remove prettier option in backend-review.yml chore(package.json): add lint and lint:fix scripts * chore(lint-staged.config.js): remove prettier --write command for js, jsx, ts, tsx files * chore(titleConvo.js): remove unnecessary console.log statement chore(titleConvo.js): add missing comma in options object * chore: apply linting to all files * chore(lint-staged.config.js): update lint-staged configuration to include prettier formatting
This commit is contained in:
parent
637bb6bc11
commit
e5336039fc
231 changed files with 1688 additions and 1526 deletions
|
|
@ -29,23 +29,23 @@ const configSchema = mongoose.Schema(
|
|||
}
|
||||
return true;
|
||||
},
|
||||
message: 'Invalid tag value'
|
||||
}
|
||||
message: 'Invalid tag value',
|
||||
},
|
||||
},
|
||||
searchEnabled: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
default: false,
|
||||
},
|
||||
usersEnabled: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
default: false,
|
||||
},
|
||||
startupCounts: {
|
||||
type: Number,
|
||||
default: 0
|
||||
}
|
||||
default: 0,
|
||||
},
|
||||
},
|
||||
{ timestamps: true }
|
||||
{ timestamps: true },
|
||||
);
|
||||
|
||||
// Instance method
|
||||
|
|
@ -80,5 +80,5 @@ module.exports = {
|
|||
console.error(error);
|
||||
return { config: 'Error deleting configs' };
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ module.exports = {
|
|||
|
||||
return await Conversation.findOneAndUpdate({ conversationId: conversationId, user }, update, {
|
||||
new: true,
|
||||
upsert: true
|
||||
upsert: true,
|
||||
}).exec();
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
|
|
@ -61,9 +61,9 @@ module.exports = {
|
|||
promises.push(
|
||||
Conversation.findOne({
|
||||
user,
|
||||
conversationId: convo.conversationId
|
||||
}).exec()
|
||||
)
|
||||
conversationId: convo.conversationId,
|
||||
}).exec(),
|
||||
),
|
||||
);
|
||||
|
||||
const results = (await Promise.all(promises)).filter((convo, i) => {
|
||||
|
|
@ -94,7 +94,7 @@ module.exports = {
|
|||
pageSize,
|
||||
// will handle a syncing solution soon
|
||||
filter: new Set(deletedConvoIds),
|
||||
convoMap
|
||||
convoMap,
|
||||
};
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
|
|
@ -124,5 +124,5 @@ module.exports = {
|
|||
let deleteCount = await Conversation.deleteMany({ ...filter, user }).exec();
|
||||
deleteCount.messages = await deleteMessages({ conversationId: { $in: ids } });
|
||||
return deleteCount;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -34,9 +34,9 @@ module.exports = {
|
|||
cancelled,
|
||||
tokenCount,
|
||||
plugin,
|
||||
model
|
||||
model,
|
||||
},
|
||||
{ upsert: true, new: true }
|
||||
{ upsert: true, new: true },
|
||||
);
|
||||
|
||||
return {
|
||||
|
|
@ -59,7 +59,7 @@ module.exports = {
|
|||
const updatedMessage = await Message.findOneAndUpdate(
|
||||
{ messageId },
|
||||
update,
|
||||
{ new: true }
|
||||
{ new: true },
|
||||
);
|
||||
|
||||
if (!updatedMessage) {
|
||||
|
|
@ -111,5 +111,5 @@ module.exports = {
|
|||
console.error(`Error deleting messages: ${err}`);
|
||||
throw new Error('Failed to delete messages.');
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ module.exports = {
|
|||
return await Preset.findOneAndUpdate(
|
||||
{ presetId, user },
|
||||
{ $set: update },
|
||||
{ new: true, upsert: true }
|
||||
{ new: true, upsert: true },
|
||||
).exec();
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
|
|
@ -42,5 +42,5 @@ module.exports = {
|
|||
// const ids = toRemove.map((instance) => instance.presetId);
|
||||
let deleteCount = await Preset.deleteMany({ ...filter, user }).exec();
|
||||
return deleteCount;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -4,17 +4,17 @@ const promptSchema = mongoose.Schema(
|
|||
{
|
||||
title: {
|
||||
type: String,
|
||||
required: true
|
||||
required: true,
|
||||
},
|
||||
prompt: {
|
||||
type: String,
|
||||
required: true
|
||||
required: true,
|
||||
},
|
||||
category: {
|
||||
type: String
|
||||
}
|
||||
type: String,
|
||||
},
|
||||
},
|
||||
{ timestamps: true }
|
||||
{ timestamps: true },
|
||||
);
|
||||
|
||||
const Prompt = mongoose.models.Prompt || mongoose.model('Prompt', promptSchema);
|
||||
|
|
@ -24,7 +24,7 @@ module.exports = {
|
|||
try {
|
||||
await Prompt.create({
|
||||
title,
|
||||
prompt
|
||||
prompt,
|
||||
});
|
||||
return { title, prompt };
|
||||
} catch (error) {
|
||||
|
|
@ -47,5 +47,5 @@ module.exports = {
|
|||
console.error(error);
|
||||
return { prompt: 'Error deleting prompts' };
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -12,83 +12,83 @@ function log({ title, parameters }) {
|
|||
const Session = mongoose.Schema({
|
||||
refreshToken: {
|
||||
type: String,
|
||||
default: ''
|
||||
}
|
||||
default: '',
|
||||
},
|
||||
});
|
||||
|
||||
const userSchema = mongoose.Schema(
|
||||
{
|
||||
name: {
|
||||
type: String
|
||||
type: String,
|
||||
},
|
||||
username: {
|
||||
type: String,
|
||||
lowercase: true,
|
||||
required: [true, "can't be blank"],
|
||||
required: [true, 'can\'t be blank'],
|
||||
match: [/^[a-zA-Z0-9_-]+$/, 'is invalid'],
|
||||
index: true
|
||||
index: true,
|
||||
},
|
||||
email: {
|
||||
type: String,
|
||||
required: [true, "can't be blank"],
|
||||
required: [true, 'can\'t be blank'],
|
||||
lowercase: true,
|
||||
unique: true,
|
||||
match: [/\S+@\S+\.\S+/, 'is invalid'],
|
||||
index: true
|
||||
index: true,
|
||||
},
|
||||
emailVerified: {
|
||||
type: Boolean,
|
||||
required: true,
|
||||
default: false
|
||||
default: false,
|
||||
},
|
||||
password: {
|
||||
type: String,
|
||||
trim: true,
|
||||
minlength: 8,
|
||||
maxlength: 128
|
||||
maxlength: 128,
|
||||
},
|
||||
avatar: {
|
||||
type: String,
|
||||
required: false
|
||||
required: false,
|
||||
},
|
||||
provider: {
|
||||
type: String,
|
||||
required: true,
|
||||
default: 'local'
|
||||
default: 'local',
|
||||
},
|
||||
role: {
|
||||
type: String,
|
||||
default: 'USER'
|
||||
default: 'USER',
|
||||
},
|
||||
googleId: {
|
||||
type: String,
|
||||
unique: true,
|
||||
sparse: true
|
||||
sparse: true,
|
||||
},
|
||||
openidId: {
|
||||
type: String,
|
||||
unique: true,
|
||||
sparse: true
|
||||
sparse: true,
|
||||
},
|
||||
githubId: {
|
||||
type: String,
|
||||
unique: true,
|
||||
sparse: true
|
||||
sparse: true,
|
||||
},
|
||||
discordId: {
|
||||
type: String,
|
||||
unique: true,
|
||||
sparse: true
|
||||
sparse: true,
|
||||
},
|
||||
plugins: {
|
||||
type: Array,
|
||||
default: []
|
||||
default: [],
|
||||
},
|
||||
refreshToken: {
|
||||
type: [Session]
|
||||
}
|
||||
type: [Session],
|
||||
},
|
||||
},
|
||||
{ timestamps: true }
|
||||
{ timestamps: true },
|
||||
);
|
||||
|
||||
//Remove refreshToken from the response
|
||||
|
|
@ -96,7 +96,7 @@ userSchema.set('toJSON', {
|
|||
transform: function (_doc, ret) {
|
||||
delete ret.refreshToken;
|
||||
return ret;
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
userSchema.methods.toJSON = function () {
|
||||
|
|
@ -111,7 +111,7 @@ userSchema.methods.toJSON = function () {
|
|||
emailVerified: this.emailVerified,
|
||||
plugins: this.plugins,
|
||||
createdAt: this.createdAt,
|
||||
updatedAt: this.updatedAt
|
||||
updatedAt: this.updatedAt,
|
||||
};
|
||||
};
|
||||
|
||||
|
|
@ -121,10 +121,10 @@ userSchema.methods.generateToken = function () {
|
|||
id: this._id,
|
||||
username: this.username,
|
||||
provider: this.provider,
|
||||
email: this.email
|
||||
email: this.email,
|
||||
},
|
||||
process.env.JWT_SECRET,
|
||||
{ expiresIn: eval(process.env.SESSION_EXPIRY) }
|
||||
{ expiresIn: eval(process.env.SESSION_EXPIRY) },
|
||||
);
|
||||
return token;
|
||||
};
|
||||
|
|
@ -135,10 +135,10 @@ userSchema.methods.generateRefreshToken = function () {
|
|||
id: this._id,
|
||||
username: this.username,
|
||||
provider: this.provider,
|
||||
email: this.email
|
||||
email: this.email,
|
||||
},
|
||||
process.env.JWT_REFRESH_SECRET,
|
||||
{ expiresIn: eval(process.env.REFRESH_TOKEN_EXPIRY) }
|
||||
{ expiresIn: eval(process.env.REFRESH_TOKEN_EXPIRY) },
|
||||
);
|
||||
return refreshToken;
|
||||
};
|
||||
|
|
@ -164,7 +164,7 @@ module.exports.hashPassword = async (password) => {
|
|||
module.exports.validateUser = (user) => {
|
||||
log({
|
||||
title: 'Validate User',
|
||||
parameters: [{ name: 'Validate User', value: user }]
|
||||
parameters: [{ name: 'Validate User', value: user }],
|
||||
});
|
||||
const schema = {
|
||||
avatar: Joi.any(),
|
||||
|
|
@ -174,7 +174,7 @@ module.exports.validateUser = (user) => {
|
|||
.max(80)
|
||||
.regex(/^[a-zA-Z0-9_-]+$/)
|
||||
.required(),
|
||||
password: Joi.string().min(8).max(128).allow('').allow(null)
|
||||
password: Joi.string().min(8).max(128).allow('').allow(null),
|
||||
};
|
||||
|
||||
return schema.validate(user);
|
||||
|
|
|
|||
|
|
@ -16,5 +16,5 @@ module.exports = {
|
|||
getPreset,
|
||||
getPresets,
|
||||
savePreset,
|
||||
deletePresets
|
||||
deletePresets,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -68,8 +68,8 @@ const createMeiliMongooseModel = function ({ index, indexName, client, attribute
|
|||
function (results, value, key) {
|
||||
return { ...results, [key]: 1 };
|
||||
},
|
||||
{ _id: 1 }
|
||||
)
|
||||
{ _id: 1 },
|
||||
),
|
||||
);
|
||||
|
||||
// Add additional data from mongodb into Meili search hits
|
||||
|
|
@ -80,7 +80,7 @@ const createMeiliMongooseModel = function ({ index, indexName, client, attribute
|
|||
|
||||
return {
|
||||
...(originalHit ? originalHit.toJSON() : {}),
|
||||
...hit
|
||||
...hit,
|
||||
};
|
||||
});
|
||||
data.hits = populatedHits;
|
||||
|
|
@ -161,8 +161,8 @@ module.exports = function mongoMeili(schema, options) {
|
|||
type: Boolean,
|
||||
required: false,
|
||||
select: false,
|
||||
default: false
|
||||
}
|
||||
default: false,
|
||||
},
|
||||
});
|
||||
|
||||
const { host, apiKey, indexName, primaryKey } = options;
|
||||
|
|
@ -183,8 +183,8 @@ module.exports = function mongoMeili(schema, options) {
|
|||
return value.meiliIndex ? [...results, key] : results;
|
||||
// }, []), '_id'];
|
||||
},
|
||||
[]
|
||||
)
|
||||
[],
|
||||
),
|
||||
];
|
||||
|
||||
schema.loadClass(createMeiliMongooseModel({ index, indexName, client, attributesToIndex }));
|
||||
|
|
|
|||
|
|
@ -8,48 +8,48 @@ const convoSchema = mongoose.Schema(
|
|||
unique: true,
|
||||
required: true,
|
||||
index: true,
|
||||
meiliIndex: true
|
||||
meiliIndex: true,
|
||||
},
|
||||
title: {
|
||||
type: String,
|
||||
default: 'New Chat',
|
||||
meiliIndex: true
|
||||
meiliIndex: true,
|
||||
},
|
||||
user: {
|
||||
type: String,
|
||||
default: null
|
||||
default: null,
|
||||
},
|
||||
messages: [{ type: mongoose.Schema.Types.ObjectId, ref: 'Message' }],
|
||||
// google only
|
||||
examples: [{ type: mongoose.Schema.Types.Mixed }],
|
||||
agentOptions: {
|
||||
type: mongoose.Schema.Types.Mixed,
|
||||
default: null
|
||||
default: null,
|
||||
},
|
||||
...conversationPreset,
|
||||
// for bingAI only
|
||||
bingConversationId: {
|
||||
type: String,
|
||||
default: null
|
||||
default: null,
|
||||
},
|
||||
jailbreakConversationId: {
|
||||
type: String,
|
||||
default: null
|
||||
default: null,
|
||||
},
|
||||
conversationSignature: {
|
||||
type: String,
|
||||
default: null
|
||||
default: null,
|
||||
},
|
||||
clientId: {
|
||||
type: String,
|
||||
default: null
|
||||
default: null,
|
||||
},
|
||||
invocationId: {
|
||||
type: Number,
|
||||
default: 1
|
||||
}
|
||||
default: 1,
|
||||
},
|
||||
},
|
||||
{ timestamps: true }
|
||||
{ timestamps: true },
|
||||
);
|
||||
|
||||
if (process.env.MEILI_HOST && process.env.MEILI_MASTER_KEY) {
|
||||
|
|
@ -57,7 +57,7 @@ if (process.env.MEILI_HOST && process.env.MEILI_MASTER_KEY) {
|
|||
host: process.env.MEILI_HOST,
|
||||
apiKey: process.env.MEILI_MASTER_KEY,
|
||||
indexName: 'convos', // Will get created automatically if it doesn't exist already
|
||||
primaryKey: 'conversationId'
|
||||
primaryKey: 'conversationId',
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,156 +3,156 @@ const conversationPreset = {
|
|||
endpoint: {
|
||||
type: String,
|
||||
default: null,
|
||||
required: true
|
||||
required: true,
|
||||
},
|
||||
// for azureOpenAI, openAI, chatGPTBrowser only
|
||||
model: {
|
||||
type: String,
|
||||
default: null,
|
||||
required: false
|
||||
required: false,
|
||||
},
|
||||
// for azureOpenAI, openAI only
|
||||
chatGptLabel: {
|
||||
type: String,
|
||||
default: null,
|
||||
required: false
|
||||
required: false,
|
||||
},
|
||||
// for google only
|
||||
modelLabel: {
|
||||
type: String,
|
||||
default: null,
|
||||
required: false
|
||||
required: false,
|
||||
},
|
||||
promptPrefix: {
|
||||
type: String,
|
||||
default: null,
|
||||
required: false
|
||||
required: false,
|
||||
},
|
||||
temperature: {
|
||||
type: Number,
|
||||
default: 1,
|
||||
required: false
|
||||
required: false,
|
||||
},
|
||||
top_p: {
|
||||
type: Number,
|
||||
default: 1,
|
||||
required: false
|
||||
required: false,
|
||||
},
|
||||
// for google only
|
||||
topP: {
|
||||
type: Number,
|
||||
default: 0.95,
|
||||
required: false
|
||||
required: false,
|
||||
},
|
||||
topK: {
|
||||
type: Number,
|
||||
default: 40,
|
||||
required: false
|
||||
required: false,
|
||||
},
|
||||
maxOutputTokens: {
|
||||
type: Number,
|
||||
default: 1024,
|
||||
required: false
|
||||
required: false,
|
||||
},
|
||||
presence_penalty: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
required: false
|
||||
required: false,
|
||||
},
|
||||
frequency_penalty: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
required: false
|
||||
required: false,
|
||||
},
|
||||
// for bingai only
|
||||
jailbreak: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
default: false,
|
||||
},
|
||||
context: {
|
||||
type: String,
|
||||
default: null
|
||||
default: null,
|
||||
},
|
||||
systemMessage: {
|
||||
type: String,
|
||||
default: null
|
||||
default: null,
|
||||
},
|
||||
toneStyle: {
|
||||
type: String,
|
||||
default: null
|
||||
}
|
||||
default: null,
|
||||
},
|
||||
};
|
||||
|
||||
const agentOptions = {
|
||||
model: {
|
||||
type: String,
|
||||
default: null,
|
||||
required: false
|
||||
required: false,
|
||||
},
|
||||
// for azureOpenAI, openAI only
|
||||
chatGptLabel: {
|
||||
type: String,
|
||||
default: null,
|
||||
required: false
|
||||
required: false,
|
||||
},
|
||||
// for google only
|
||||
modelLabel: {
|
||||
type: String,
|
||||
default: null,
|
||||
required: false
|
||||
required: false,
|
||||
},
|
||||
promptPrefix: {
|
||||
type: String,
|
||||
default: null,
|
||||
required: false
|
||||
required: false,
|
||||
},
|
||||
temperature: {
|
||||
type: Number,
|
||||
default: 1,
|
||||
required: false
|
||||
required: false,
|
||||
},
|
||||
top_p: {
|
||||
type: Number,
|
||||
default: 1,
|
||||
required: false
|
||||
required: false,
|
||||
},
|
||||
// for google only
|
||||
topP: {
|
||||
type: Number,
|
||||
default: 0.95,
|
||||
required: false
|
||||
required: false,
|
||||
},
|
||||
topK: {
|
||||
type: Number,
|
||||
default: 40,
|
||||
required: false
|
||||
required: false,
|
||||
},
|
||||
maxOutputTokens: {
|
||||
type: Number,
|
||||
default: 1024,
|
||||
required: false
|
||||
required: false,
|
||||
},
|
||||
presence_penalty: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
required: false
|
||||
required: false,
|
||||
},
|
||||
frequency_penalty: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
required: false
|
||||
required: false,
|
||||
},
|
||||
context: {
|
||||
type: String,
|
||||
default: null
|
||||
default: null,
|
||||
},
|
||||
systemMessage: {
|
||||
type: String,
|
||||
default: null
|
||||
}
|
||||
default: null,
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
conversationPreset,
|
||||
agentOptions
|
||||
agentOptions,
|
||||
};
|
||||
|
|
@ -7,88 +7,88 @@ const messageSchema = mongoose.Schema(
|
|||
unique: true,
|
||||
required: true,
|
||||
index: true,
|
||||
meiliIndex: true
|
||||
meiliIndex: true,
|
||||
},
|
||||
conversationId: {
|
||||
type: String,
|
||||
required: true,
|
||||
meiliIndex: true
|
||||
meiliIndex: true,
|
||||
},
|
||||
model: {
|
||||
type: String
|
||||
type: String,
|
||||
},
|
||||
conversationSignature: {
|
||||
type: String
|
||||
type: String,
|
||||
// required: true
|
||||
},
|
||||
clientId: {
|
||||
type: String
|
||||
type: String,
|
||||
},
|
||||
invocationId: {
|
||||
type: String
|
||||
type: String,
|
||||
},
|
||||
parentMessageId: {
|
||||
type: String
|
||||
type: String,
|
||||
// required: true
|
||||
},
|
||||
tokenCount: {
|
||||
type: Number
|
||||
type: Number,
|
||||
},
|
||||
refinedTokenCount: {
|
||||
type: Number
|
||||
type: Number,
|
||||
},
|
||||
sender: {
|
||||
type: String,
|
||||
required: true,
|
||||
meiliIndex: true
|
||||
meiliIndex: true,
|
||||
},
|
||||
text: {
|
||||
type: String,
|
||||
required: true,
|
||||
meiliIndex: true
|
||||
meiliIndex: true,
|
||||
},
|
||||
refinedMessageText: {
|
||||
type: String
|
||||
type: String,
|
||||
},
|
||||
isCreatedByUser: {
|
||||
type: Boolean,
|
||||
required: true,
|
||||
default: false
|
||||
default: false,
|
||||
},
|
||||
unfinished: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
default: false,
|
||||
},
|
||||
cancelled: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
default: false,
|
||||
},
|
||||
error: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
default: false,
|
||||
},
|
||||
_meiliIndex: {
|
||||
type: Boolean,
|
||||
required: false,
|
||||
select: false,
|
||||
default: false
|
||||
default: false,
|
||||
},
|
||||
plugin: {
|
||||
latest: {
|
||||
type: String,
|
||||
required: false
|
||||
required: false,
|
||||
},
|
||||
inputs: {
|
||||
type: [mongoose.Schema.Types.Mixed],
|
||||
required: false
|
||||
required: false,
|
||||
},
|
||||
outputs: {
|
||||
type: String,
|
||||
required: false
|
||||
}
|
||||
}
|
||||
required: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
{ timestamps: true }
|
||||
{ timestamps: true },
|
||||
);
|
||||
|
||||
if (process.env.MEILI_HOST && process.env.MEILI_MASTER_KEY) {
|
||||
|
|
@ -96,7 +96,7 @@ if (process.env.MEILI_HOST && process.env.MEILI_MASTER_KEY) {
|
|||
host: process.env.MEILI_HOST,
|
||||
apiKey: process.env.MEILI_MASTER_KEY,
|
||||
indexName: 'messages',
|
||||
primaryKey: 'messageId'
|
||||
primaryKey: 'messageId',
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,17 +8,17 @@ const pluginAuthSchema = mongoose.Schema(
|
|||
},
|
||||
value: {
|
||||
type: String,
|
||||
required: true
|
||||
required: true,
|
||||
},
|
||||
userId: {
|
||||
type: String,
|
||||
required: true
|
||||
required: true,
|
||||
},
|
||||
pluginKey: {
|
||||
type: String,
|
||||
}
|
||||
},
|
||||
},
|
||||
{ timestamps: true }
|
||||
{ timestamps: true },
|
||||
);
|
||||
|
||||
const PluginAuth = mongoose.models.Plugin || mongoose.model('PluginAuth', pluginAuthSchema);
|
||||
|
|
|
|||
|
|
@ -6,26 +6,26 @@ const presetSchema = mongoose.Schema(
|
|||
type: String,
|
||||
unique: true,
|
||||
required: true,
|
||||
index: true
|
||||
index: true,
|
||||
},
|
||||
title: {
|
||||
type: String,
|
||||
default: 'New Chat',
|
||||
meiliIndex: true
|
||||
meiliIndex: true,
|
||||
},
|
||||
user: {
|
||||
type: String,
|
||||
default: null
|
||||
default: null,
|
||||
},
|
||||
// google only
|
||||
examples: [{ type: mongoose.Schema.Types.Mixed }],
|
||||
...conversationPreset,
|
||||
agentOptions: {
|
||||
type: mongoose.Schema.Types.Mixed,
|
||||
default: null
|
||||
}
|
||||
default: null,
|
||||
},
|
||||
},
|
||||
{ timestamps: true }
|
||||
{ timestamps: true },
|
||||
);
|
||||
|
||||
const Preset = mongoose.models.Preset || mongoose.model('Preset', presetSchema);
|
||||
|
|
|
|||
|
|
@ -5,18 +5,18 @@ const tokenSchema = new Schema({
|
|||
userId: {
|
||||
type: Schema.Types.ObjectId,
|
||||
required: true,
|
||||
ref: 'user'
|
||||
ref: 'user',
|
||||
},
|
||||
token: {
|
||||
type: String,
|
||||
required: true
|
||||
required: true,
|
||||
},
|
||||
createdAt: {
|
||||
type: Date,
|
||||
required: true,
|
||||
default: Date.now,
|
||||
expires: 900
|
||||
}
|
||||
expires: 900,
|
||||
},
|
||||
});
|
||||
|
||||
module.exports = mongoose.model('Token', tokenSchema);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue