Open hackeropjohn opened 2 months ago
I fixed this by modifying src/models/gemini.js
.
Modify the constructor:
constructor(model_name, url) {
this.model_name = model_name;
this.url = url;
this.safetySettings = [
{
category: HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT,
threshold: HarmBlockThreshold.BLOCK_NONE,
},
{
category: HarmCategory.HARM_CATEGORY_HARASSMENT,
threshold: HarmBlockThreshold.BLOCK_NONE,
},
{
category: HarmCategory.HARM_CATEGORY_HATE_SPEECH,
threshold: HarmBlockThreshold.BLOCK_NONE,
},
{
category: HarmCategory.HARM_CATEGORY_SEXUALLY_EXPLICIT,
threshold: HarmBlockThreshold.BLOCK_NONE,
},
];
this.genAI = new GoogleGenerativeAI(getKey('GEMINI_API_KEY'));
}
Add an import:
import { HarmBlockThreshold, HarmCategory } from "@google/generative-ai";
You can also use the new and experimental Gemini models by updating the @google/generative-ai
to the newest version.
npm remove @google/generative-ai
npm install @google/generative-ai
This will remove the specific version that Mindcraft comes with and update to the newest generative-ai. ❤️
file:///C:/Users/gg/node_modules/@google/generative-ai/dist/index.mjs:454 throw new GoogleGenerativeAIResponseError(
${formatBlockErrorMessage(response)}
, response); ^GoogleGenerativeAIResponseError: [GoogleGenerativeAI Error]: Candidate was blocked due to SAFETY at response.text (file:///C:/Users/gg/node_modules/@google/generative-ai/dist/index.mjs:454:23) at Gemini.sendRequest (file:///C:/Users/gg/Downloads/mindcraft-main/src/models/gemini.js:31:31) at process.processTicksAndRejections (node:internal/process/task_queues:105:5) at async Prompter.promptConvo (file:///C:/Users/gg/Downloads/mindcraft-main/src/agent/prompter.js:165:16) at async Agent.handleMessage (file:///C:/Users/gg/Downloads/mindcraft-main/src/agent/agent.js:139:23) { response: { candidates: [ { finishReason: 'SAFETY', index: 0, safetyRatings: [ { category: 'HARM_CATEGORY_SEXUALLY_EXPLICIT', probability: 'NEGLIGIBLE' }, { category: 'HARM_CATEGORY_HATE_SPEECH', probability: 'NEGLIGIBLE' }, { category: 'HARM_CATEGORY_HARASSMENT', probability: 'NEGLIGIBLE' }, { category: 'HARM_CATEGORY_DANGEROUS_CONTENT', probability: 'MEDIUM' } ] } ], usageMetadata: { promptTokenCount: 1561, totalTokenCount: 1561 }, text: [Function (anonymous)], functionCall: [Function (anonymous)], functionCalls: [Function (anonymous)] } }
Node.js v22.8.0 Agent process exited with code 1 and signal null Restarting agent... Using chat settings: { model: 'gemini-pro', api: 'google' } Using embedding settings: { api: 'google' } (node:6212) [DEP0040] DeprecationWarning: The
punycode
module is deprecated. Please use a userland alternative instead. (Usenode --trace-deprecation ...
to show where the warning was created)I think that gemini safety settings has issue so like how do i solve this issue.