Skip to content
Snippets Groups Projects
Unverified Commit 8be84aeb authored by Marcus Schiesser's avatar Marcus Schiesser Committed by GitHub
Browse files

chore: add gemini streaming example (#782)

parent 5b7b314b
No related branches found
No related tags found
No related merge requests found
import { gemini, GEMINI_MODEL } from "@llamaindex/google";
(async () => {
if (!process.env.GOOGLE_API_KEY) {
throw new Error("Please set the GOOGLE_API_KEY environment variable.");
}
const llm = gemini({
model: GEMINI_MODEL.GEMINI_PRO_LATEST,
});
const stream = await llm.chat({
messages: [
{ content: "You want to talk in rhymes.", role: "system" },
{
content:
"How much wood would a woodchuck chuck if a woodchuck could chuck wood?",
role: "user",
},
],
stream: true,
});
for await (const chunk of stream) {
process.stdout.write(chunk.delta);
}
console.log("\n\ndone");
})();
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment