di-sukharev / opencommit

Generate conventional git commit messages with AI in 1 second 🤯🔫
https://www.npmjs.com/package/opencommit
MIT License
6.15k stars 328 forks source link

[Bug]: GoogleGenerativeAI Error Bad request after new update #406

Closed FernandoAurelius closed 2 months ago

FernandoAurelius commented 2 months ago

Opencommit Version

3.1.2

Node Version

22.7.0

NPM Version

10.8.2

What OS are you seeing the problem on?

Windows

What happened?

After the 3.1.1 update, which I was alerted that it was available by npm yesterday, everytime I try to run "oco" I get the following error:

✖ [GoogleGenerativeAI Error]: Error fetching from https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash:generateContent: [400 Bad Request] Invalid value at 'generation_config.max_output_tokens' (TYPE_INT32), "undefined" [{"@type":"type.googleapis.com/google.rpc.BadRequest","fieldViolations":[{"field":"generation_config.max_output_tokens","description":"Invalid value at 'generation_config.max_output_tokens' (TYPE_INT32), \"undefined\""}]}].

I've already installed the new version of OpenCommit (3.1.2), but the problem continues.

Expected Behavior

I expected the software to work as usual, because before the update it was working normally. I don't neither LLAMA or OpenAI to generate the commit message for me, but I found very confortable to work with Gemini, and he was the one that I chose to work with OpenCommit.

Current Behavior

See What happened.

Possible Solution

I don't think I have, unfortunately.

Steps to Reproduce

  1. Install the version 3.1.2 of OpenCommit using npm.
  2. Configure the Google AI Studio API key using oco config set OCO_GEMINI_API_KEY="your_key_here"
  3. Configure the AI provider of OpenCommit using oco config set OCO_AI_PROVIDER=gemini
  4. Configure the Gemini model to be used using oco config set OCO_MODEL=gemini-1.5-flash
  5. Create a repository, make any changes, stage them using git add .
  6. Try to make a commit using oco

Relevant log output

PS C:\Users\florz\OneDrive\Área de Trabalho\Conteúdos de Estudo\parallax-website-sample> oco      
(node:20860) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
┌  open-commit
│                                                                                                                                                              
◇  7 staged files:                                                                                                                                             
  assets/moon.png
  assets/mountains_behind.png
  assets/mountains_front.png
  assets/stars.png
  index.html
  js/app.js
  styles/style.css
│
└  Some files are excluded by default from 'git diff'. No commit messages are generated for this files:
assets/moon.png
assets/mountains_behind.png
assets/mountains_front.png
assets/stars.png

│
◇  📝 Commit message generated
│
└  ✖ [GoogleGenerativeAI Error]: Error fetching from https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash:generateContent: [400 Bad Request] Invalid value at 'generation_config.max_output_tokens' (TYPE_INT32), "undefined" [{"@type":"type.googleapis.com/google.rpc.BadRequest","fieldViolations":[{"field":"generation_config.max_output_tokens","description":"Invalid value at 'generation_config.max_output_tokens' (TYPE_INT32), \"undefined\""}]}]
di-sukharev commented 2 months ago

@FernandoAurelius could you try to set OCO_TOKENS_MAX_INPUT and OCO_TOKENS_MAX_OUTPUT, let me know if it works please

FernandoAurelius commented 2 months ago

Sure, but just to be sure, how many tokens I should set in max input and max output?

di-sukharev commented 2 months ago

Try 10000 each

FernandoAurelius commented 2 months ago

I setted to 10000 each, but had this error:

image

So I tried to define it to 4096 and It worked!

I'm happy that worked but I tried to use opencommit with an older version (I think 3.10) and it worked properly, without the need to define this extra configuration. Anyway, it's fine, thank you for your help.