UNPKG

@convo-lang/convo-lang

Version:
28 lines 1.02 kB
import { getSortedObjectHash } from "@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. */ export class ConvoHashCacheBase { constructor(type) { this.cacheType = type; } getCachedResponse(flat) { const key = getSortedObjectHash(flat.messages); return this.getMessagesByKey(key); } getMessagesByKey(key) { return undefined; } cachedResponse(flat, messages) { const key = getSortedObjectHash(flat.messages); return this.cacheMessagesByKey(key, messages); } cacheMessagesByKey(key, messages) { // do nothing } } //# sourceMappingURL=ConvoHashCacheBase.js.map