mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-02-13 04:54:24 +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;
|
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 };
|
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) {
|
if (metadata && metadata.unsetFields && Object.keys(metadata.unsetFields).length > 0) {
|
||||||
updateOperation.$unset = metadata.unsetFields;
|
updateOperation.$unset = metadata.unsetFields;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,7 @@ export const excludedKeys = new Set([
|
||||||
'_id',
|
'_id',
|
||||||
'tools',
|
'tools',
|
||||||
'model',
|
'model',
|
||||||
|
'modelHistory',
|
||||||
'files',
|
'files',
|
||||||
'spec',
|
'spec',
|
||||||
'disableParams',
|
'disableParams',
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue