Skip to content

Commit 4983cff

Browse files
authored
1 parent 2f2bfd1 commit 4983cff

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

gemini-chat.html

+4-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
userInput.value = "";
5050

5151
try {
52-
chatHistory.push({ role: "user", parts: [{ text: message }] });
5352
const startTime = performance.now();
5453
const result = await chat.sendMessageStream(message);
5554
let fullResponse = "";
@@ -60,7 +59,11 @@
6059
}
6160
const endTime = performance.now();
6261
const duration = ((endTime - startTime) / 1000).toFixed(2);
62+
63+
// Add the user's message and the model's response to chatHistory after the interaction
64+
chatHistory.push({ role: "user", parts: [{ text: message }] });
6365
chatHistory.push({ role: "model", parts: [{ text: fullResponse }] });
66+
6467
let usage = (await result.response).usageMetadata;
6568
console.log("Full result:", result);
6669
updateUsageMetadata(usage);

0 commit comments

Comments
 (0)