Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Hook needs env vars set even when using ollama #378

Closed
bjornsnoen opened this issue Aug 8, 2024 · 2 comments · Fixed by #402
Closed

[Bug]: Hook needs env vars set even when using ollama #378

bjornsnoen opened this issue Aug 8, 2024 · 2 comments · Fixed by #402
Labels
bug Something isn't working

Comments

@bjornsnoen
Copy link

bjornsnoen commented Aug 8, 2024

Opencommit Version

3.0.17

Node Version

18.18.2

NPM Version

9.8.1

What OS are you seeing the problem on?

Other Linux Distro

What happened?

I used oco hook set to install the prepare commit msg hook and tried to run git commit, which produced the following error message:

┌  opencommit
│
└  ✖ Error: No OPEN_AI_API or OCO_ANTHROPIC_API_KEY or OCO_AZURE_API_KEY exists. Set your key in ~/.opencommit

Simply running oco does work as expected but I'd like to be able to edit the commit message.

This is my .opencommit config:

OCO_DESCRIPTION=false
OCO_EMOJI=false
OCO_LANGUAGE=en
OCO_MESSAGE_TEMPLATE_PLACEHOLDER=$msg
OCO_PROMPT_MODULE=conventional-commit
OCO_AI_PROVIDER=ollama
OCO_GITPUSH=false
OCO_ONE_LINE_COMMIT=false
OCO_TEST_MOCK_TYPE=commit-message

Expected Behavior

Generates a commit message and opens my $EDITOR to allow me to modify the message before commiting.

Current Behavior

Commit gets interrupted with the message above.

Possible Solution

Unify config handling between hook and regular command mode.

Steps to Reproduce

  1. Set provider to ollama with oco config set OCO_AI_PROVIDER=ollama
  2. Clean up config file according to [Bug]: Unsupported config key OCO_AZURE_ENDPOINT - even when provider is set to openai #352 (comment)
  3. Install git hook with oco hook set
  4. Run git commit

Relevant log output

No response

@bjornsnoen bjornsnoen added the bug Something isn't working label Aug 8, 2024
@di-sukharev
Copy link
Owner

merged, will be released in 3.1.0 today

@bjornsnoen
Copy link
Author

@di-sukharev rather than create a new issue I believe it's correct to reopen this as a regression? Still have ollama set up so should not need these api keys.

$ git commit
✔ Preparing lint-staged...
✔ Running tasks for staged files...
✔ Applying modifications from tasks...
✔ Cleaning up temporary files...
┌  opencommit
│
└  No OCO_API_KEY is set. Set your key via `oco config set OCO_API_KEY=<value>. For more info see https://github.com/di-sukharev/opencommit

My .opencommit file:

OCO_MODEL=llama3:8b
OCO_API_URL=http://localhost:11434/api/chat
OCO_API_KEY=undefined
OCO_AI_PROVIDER=ollama
OCO_TOKENS_MAX_INPUT=40960
OCO_TOKENS_MAX_OUTPUT=4096
OCO_DESCRIPTION=false
OCO_EMOJI=false
OCO_LANGUAGE=en
OCO_MESSAGE_TEMPLATE_PLACEHOLDER=$msg
OCO_PROMPT_MODULE=conventional-commit
OCO_ONE_LINE_COMMIT=false
OCO_TEST_MOCK_TYPE=commit-message
OCO_GITPUSH=false
OCO_WHY=false

I tested removing the _API_KEY line but same result.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants