Represents a Semantic Cache that uses CosmosDB NoSQL backend as the underlying storage system.

const embeddings = new OpenAIEmbeddings();
const cache = new AzureCosmosDBNoSQLSemanticCache(embeddings, {
databaseName: DATABASE_NAME,
containerName: CONTAINER_NAME
});
const model = new ChatOpenAI({cache});

// Invoke the model to perform an action
const response = await model.invoke("Do something random!");
console.log(response);

Hierarchy

  • BaseCache
    • AzureCosmosDBNoSQLSemanticCache

Constructors

Methods

Constructors

Methods

  • Retrieves data from the cache.

    Parameters

    • prompt: string

      The prompt for lookup.

    • llmKey: string

      The LLM key used to construct the cache key.

    Returns Promise<null | any[]>

    An array of Generations if found, null otherwise.

  • Updates the cache with new data.

    Parameters

    • prompt: string

      The prompt for update.

    • llmKey: string

      The LLM key used to construct the cache key.

    • returnValue: Generation[]

    Returns Promise<void>