diff --git a/src/BingAIClient.js b/src/BingAIClient.js index 59d6e0a5..783d3a3e 100644 --- a/src/BingAIClient.js +++ b/src/BingAIClient.js @@ -13,9 +13,16 @@ const genRanHex = size => [...Array(size)].map(() => Math.floor(Math.random() * export default class BingAIClient { constructor(options) { - const cacheOptions = options.cache || {}; - cacheOptions.namespace = cacheOptions.namespace || 'bing'; - this.conversationsCache = new Keyv(cacheOptions); + if (options.keyv) { + if (!options.keyv.namespace) { + console.warn('The given Keyv object has no namespace. This is a bad idea if you share a database.'); + } + this.conversationsCache = options.keyv; + } else { + const cacheOptions = options.cache || {}; + cacheOptions.namespace = cacheOptions.namespace || 'bing'; + this.conversationsCache = new Keyv(cacheOptions); + } this.setOptions(options); }