我使用gemini调整了一个模型,并尝试通过普通的js代码在谷歌Chrome浏览器中访问该模型(我已经通过调整模型时使用的谷歌账户登录)。当我执行js代码时,显示了标题中的错误。
import { GoogleGenerativeAI } from "@google/generative-ai";// 获取您的API_KEY
const API_KEY = "MyApIKey";// 访问您的API密钥(请参见上面的"设置您的API密钥")
const genAI = new GoogleGenerativeAI(API_KEY);
async function run() {
// 对于仅文本输入,请使用gemini-pro模型
//const model = genAI.getGenerativeModel({ model: "gemini-pro"});
const model = genAI.getGenerativeModel({ model: "tunedModels/thefine-tuned-model-f64sf654sf" });
const prompt = "Some prompt for asking questions?"
const result = await model.generateContent(prompt);
const response = await result.response;
const text = response.text();
console.log(text);
}
run();
这段js代码是在html文件的script标签中使用的。
我想让提示(prompt)正常工作。请提供任何解决方案的建议。
回答:
调整后的模型可能包含您的数据,它需要比API密钥更严格的访问控制。您需要按照此处的文档,使用OAuth凭证设置用户身份验证。
这也在模型调整的故障排除部分中提到了。