#Gemini API Uncaught TypeError Web

1 messages · Page 1 of 1 (latest)

dapper widget
#

I am trying to create a chrome extension that uses Gemini AI.

I read the web documentation for Gemini AI and tried to create some code: popup.js: import { GoogleGenerativeAI } from "@google/generative-ai";

const API_KEY = "lol not showing";

const genAI = new GoogleGenerativeAI(API_KEY);

const model = genAI.getGenerativeModel({ model: "gemini-pro"});

async function run() {
// For text-only input, use the gemini-pro model
const model = genAI.getGenerativeModel({ model: "gemini-pro"});

const prompt = "Write a story about a magic backpack."

const result = await model.generateContent(prompt);
const response = await result.response;
const text = response.text();
console.log(text);

}

run();

popup.html: //some code, all that matters is this

<script type="module" src="popup.js"></script>

I recieve an error:
Uncaught TypeError: Failed to resolve module specifier "@google/generative-ai". Relative references must start with either "/", "./", or "../".

I'm not using node.js. Sorry if I am stupid, I am new.

#

Gemini API Uncaught TypeError