Skip to content

Commit efa8434

Browse files
committed
Updated files.
1 parent ef04c64 commit efa8434

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

src/main.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ import { SplitLayout } from "@googlemaps/extended-component-library/split_layout
1313
import Base64 from "base64-js";
1414
import "./style.css";
1515

16+
// Add a delay function here
17+
function delay(ms: number) {
18+
return new Promise(resolve => setTimeout(resolve, ms));
19+
}
20+
1621
// TODO: Get a Gemini API key:
1722
/*
1823
* 1. Open the Project IDX view by pressing Ctrl+Shift+P / Cmd+Shift+P and type "IDX focus", then select "IDX: Focus on Project IDX View"
@@ -95,7 +100,7 @@ form.addEventListener("submit", async (e) => {
95100
// Call the gemini-pro-vision model, and get a stream of results
96101
const genAI = new GoogleGenerativeAI(GEMINI_API_KEY);
97102
const model = genAI.getGenerativeModel({
98-
model: "gemini-pro-vision",
103+
model: "gemini-2.5-flash",
99104
safetySettings: [
100105
{
101106
category: HarmCategory.HARM_CATEGORY_HARASSMENT,
@@ -104,6 +109,8 @@ form.addEventListener("submit", async (e) => {
104109
],
105110
});
106111

112+
await delay(60000); // This will wait for 60 seconds
113+
107114
// Read from the stream and render the output
108115
const result = await model.generateContentStream({ contents });
109116
for await (const response of result.stream) {

src/travel.js

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,8 @@ async function generateReviewTitle() {
8484
outputHTML.innerHTML = `<h2>${promptTitle.value}</h2><p>${reviewText}</p>`;
8585
} else {
8686
// Fallback to Gemini API
87-
const genAI = new GoogleGenerativeAI(
88-
"AIzaSyA8bYErDRE8xfRAIvZJkL06l0oMp5wHVx8"
89-
);
90-
const model = await genAI.getGenerativeModel({ model: "gemini-pro" });
87+
const genAI = new GoogleGenerativeAI(GEMINI_API_KEY);
88+
const model = await genAI.getGenerativeModel({ model: "gemini-2.5-flash" });
9189
const result = await model.generateContent([
9290
`Generate a catchy title for this travel review: ${reviewText} to ${placeName}`,
9391
]);
@@ -163,10 +161,8 @@ async function checkToxicity() {
163161
// outputHTML.innerHTML = (`Tone Score: ${toxicityScore}`); // Or display in a more user-friendly way
164162

165163
// Fallback to Gemini API
166-
const genAI = new GoogleGenerativeAI(
167-
"AIzaSyA8bYErDRE8xfRAIvZJkL06l0oMp5wHVx8"
168-
);
169-
const model = await genAI.getGenerativeModel({ model: "gemini-pro" });
164+
const genAI = new GoogleGenerativeAI(GEMINI_API_KEY);
165+
const model = await genAI.getGenerativeModel({ model: "gemini-2.5-flash" });
170166
const result = await model.generateContent([
171167
`Analyze the toxicity level of this text:: ${reviewText}`,
172168
]);
@@ -199,10 +195,8 @@ async function runBuiltInAIModel(streaming) {
199195

200196
// Function to run the Gemini API model
201197
async function runGeminiAPIModel(streaming) {
202-
const genAI = new GoogleGenerativeAI(
203-
"AIzaSyA8bYErDRE8xfRAIvZJkL06l0oMp5wHVx8"
204-
);
205-
const model = await genAI.getGenerativeModel({ model: "gemini-pro" });
198+
const genAI = new GoogleGenerativeAI(GEMINI_API_KEY);
199+
const model = await genAI.getGenerativeModel({ model: "gemini-2.5-flash" });
206200
outputHTML.innerHTML = "Generating answer...Please wait...";
207201

208202
if (streaming) {

0 commit comments

Comments
 (0)