Can you use Caching with Function Calling?

I am trying to use caching with tools / Function Calling, but it seems that the two do not work together. I noticed the tools object from the cache is always undefined either when creating or getting the cache. You can also not insert the tools object later on which leads me to belive that currently the two features do not work together. Am I correct on this?

Here’s a snippet of what I’m talking about.

  const response = await cacheManager.create({
    model: MODEL,
    tools: TOOLS,
    systemInstruction: getSystemInstruction(storeName),
    contents: [
      {
        role: "user",
        parts: [
          {
            text: paddedDocument,
          },
        ],
      },
    ],
    ttlSeconds,
  });
  response.tools //is undefined

Getting the cache and trying to add the tools object example:

const cache = await cacheManager.get(cacheId);
cache.tools; //undefined
const model = genAI.getGenerativeModelFromCachedContent({
  ...cache,
  tools: TOOLS, //adding this throws an error
});
1 Like