browser javascript api misses caching and upload.
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.
The /server package contains server specific code, like file management which is what seems to be triggering your error. However I am not clear on what is exactly your ask. Do you want the SDK to cache the Chat history inside of a session so the user of your web app can only send the last message and have the session on the server side handle the history?