@langchain/community
Version:
Third-party integrations for LangChain.js
1 lines • 1.27 kB
Source Map (JSON)
{"version":3,"file":"momento.cjs","names":["client: ICacheClient","cacheName: string","CreateCache"],"sources":["../../src/utils/momento.ts"],"sourcesContent":["/* eslint-disable no-instanceof/no-instanceof */\nimport { ICacheClient, CreateCache } from \"@gomomento/sdk-core\";\n\n/**\n * Utility function to ensure that a Momento cache exists.\n * If the cache does not exist, it is created.\n *\n * @param client The Momento cache client.\n * @param cacheName The name of the cache to ensure exists.\n */\nexport async function ensureCacheExists(\n client: ICacheClient,\n cacheName: string\n): Promise<void> {\n const createResponse = await client.createCache(cacheName);\n if (\n createResponse instanceof CreateCache.Success ||\n createResponse instanceof CreateCache.AlreadyExists\n ) {\n // pass\n } else if (createResponse instanceof CreateCache.Error) {\n throw createResponse.innerException();\n } else {\n throw new Error(`Unknown response type: ${createResponse.toString()}`);\n }\n}\n"],"mappings":";;;;;;;;;;;AAUA,eAAsB,kBACpBA,QACAC,WACe;CACf,MAAM,iBAAiB,MAAM,OAAO,YAAY,UAAU;AAC1D,KACE,0BAA0BC,iCAAY,WACtC,0BAA0BA,iCAAY,eACtC,CAED,WAAU,0BAA0BA,iCAAY,MAC/C,OAAM,eAAe,gBAAgB;KAErC,OAAM,IAAI,MAAM,CAAC,uBAAuB,EAAE,eAAe,UAAU,EAAE;AAExE"}