UNPKG

@convo-lang/convo-lang

Version:
33 lines 1.21 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ConvoHashCacheBase = void 0; const common_1 = require("@iyio/common"); /** * Base conversation cache that uses the sorted object hash of the messages of a conversation as * a caching key. `getSortedObjectHash` from @iyio/iyio-common is used to hash the messages. * ConvoHashCacheBase does not itself cache messages but serves as a base for caches that use * message hash based caching. ConvoHashCacheBase can act as a pass-through cache for testing or * as a placeholder. */ class ConvoHashCacheBase { cacheType; constructor(type) { this.cacheType = type; } getCachedResponse(flat) { const key = (0, common_1.getSortedObjectHash)(flat.messages); return this.getMessagesByKey(key); } getMessagesByKey(key) { return undefined; } cachedResponse(flat, messages) { const key = (0, common_1.getSortedObjectHash)(flat.messages); return this.cacheMessagesByKey(key, messages); } cacheMessagesByKey(key, messages) { // do nothing } } exports.ConvoHashCacheBase = ConvoHashCacheBase; //# sourceMappingURL=ConvoHashCacheBase.js.map