clones retrieved keys to messy object mutation shit

This commit is contained in:
nai-degen 2023-04-08 05:35:19 -05:00 committed by nai-degen
parent a4840e0fe6
commit 6ba5670f29
1 changed files with 2 additions and 1 deletions

View File

@ -107,7 +107,8 @@ function get(model: string) {
// Otherwise, return the oldest key
const oldestKey = availableKeys.sort((a, b) => a.lastUsed - b.lastUsed)[0];
logger.info("Using key", { key: oldestKey.hash });
return oldestKey;
oldestKey.lastUsed = Date.now();
return { ...oldestKey };
}
export const keys = { init, list, get, anyAvailable, disable };