mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-29 14:48:51 +01:00
feat: add addToSet update operation to saveConvo to efficiently update modelHistory whenever a new model/endpoint combo is used
This commit is contained in:
parent
cb8e76e27e
commit
465c81adee
2 changed files with 11 additions and 1 deletions
|
|
@ -112,8 +112,17 @@ module.exports = {
|
|||
update.expiredAt = null;
|
||||
}
|
||||
|
||||
/** @type {{ $set: Partial<TConversation>; $unset?: Record<keyof TConversation, number> }} */
|
||||
/** @type {{ $set: Partial<TConversation>; $addToSet?: Record<string, any>; $unset?: Record<keyof TConversation, number> }} */
|
||||
const updateOperation = { $set: update };
|
||||
|
||||
if (convo.model && convo.endpoint) {
|
||||
updateOperation.$addToSet = {
|
||||
modelHistory: {
|
||||
model: convo.model,
|
||||
endpoint: convo.endpoint,
|
||||
},
|
||||
};
|
||||
}
|
||||
if (metadata && metadata.unsetFields && Object.keys(metadata.unsetFields).length > 0) {
|
||||
updateOperation.$unset = metadata.unsetFields;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ export const excludedKeys = new Set([
|
|||
'_id',
|
||||
'tools',
|
||||
'model',
|
||||
'modelHistory',
|
||||
'files',
|
||||
'spec',
|
||||
'disableParams',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue