Description
Description of the bug:
in theory to cache contents (like the full session) you should use:
<script type="importmap">
{
"imports": {
"@google/generative-ai": "https://esm.run/@google/generative-ai",
"@google/generative-ai/server": "https://esm.run/@google/generative-ai/server"
}
}
</script>
<script type="module">
import { GoogleGenerativeAI } from "@google/generative-ai";
import "@google/generative-ai/server";
Actual vs expected behavior:
The problem is that the server import gives error:
Error: Failed to bundle using Rollup v2.79.1: the file imports a not supported node.js built-in module "fs".
Any other information you'd like to share?
Possible solution:
implement the local file system.
Reason:
without this, every time a message is sent to the model, ALL history is sent every single time.
Alternatives:
When instantiating a chat, create internally a session so the subsequent prompts won't need to include everything every time.
Use case:
let's say I have a document and I want to talk with the model about it.
As the api is right now, every new prompt sends to the model the full chat hiostory and the document (if inlined in base64).
That is so wrong. Once instantiated the session, the only thing that should be sent is the prompt or other inlined attachments, not the whole damn thing.