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]: Ollama provider error: Invalid URL (version 3.2.2) #416

Open
roeniss opened this issue Sep 12, 2024 · 8 comments
Open

[Bug]: Ollama provider error: Invalid URL (version 3.2.2) #416

roeniss opened this issue Sep 12, 2024 · 8 comments
Labels
bug Something isn't working

Comments

@roeniss
Copy link

roeniss commented Sep 12, 2024

Opencommit Version

3.2.2

Node Version

20.11.1

NPM Version

10.8.3

What OS are you seeing the problem on?

Mac

What happened?

❯❯❯ oco
┌  open-commit
│
◇  1 staged files:
  src/main/kotlin/[REDACTED].kt
│
◇  ✖ Failed to generate the commit message
Error: Ollama provider error: Invalid URL
    at OllamaEngine.generateCommitMessage (/Users/roeniss/.nvm/versions/node/v20.11.1/lib/node_modules/opencommit/out/cli.cjs:40212:13)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async generateCommitMessageByDiff (/Users/roeniss/.nvm/versions/node/v20.11.1/lib/node_modules/opencommit/out/cli.cjs:45082:27)
    at async generateCommitMessageFromGitDiff (/Users/roeniss/.nvm/versions/node/v20.11.1/lib/node_modules/opencommit/out/cli.cjs:45293:25)
    at async trytm (/Users/roeniss/.nvm/versions/node/v20.11.1/lib/node_modules/opencommit/out/cli.cjs:45261:18)
    at async commit (/Users/roeniss/.nvm/versions/node/v20.11.1/lib/node_modules/opencommit/out/cli.cjs:45458:35)
│
└  ✖ Ollama provider error: Invalid URL
❯❯❯ oco --version
3.2.2
❯❯❯ cat ~/.opencommit
OCO_AI_PROVIDER=ollama
OCO_MODEL=llama3:latest
OCO_API_URL=undefined
OCO_API_KEY=undefined
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=true
OCO_WHY=false
❯❯❯ cat ~/.opencommit_migrations
[
  "00_use_single_api_key_and_url",
  "01_remove_obsolete_config_keys_from_global_file",
  "02_set_missing_default_values"
]%

Expected Behavior

.

Current Behavior

.

Possible Solution

No response

Steps to Reproduce

No response

Relevant log output

No response

@roeniss roeniss added the bug Something isn't working label Sep 12, 2024
@di-sukharev
Copy link
Owner

di-sukharev commented Sep 12, 2024

@bjornsnoen
Copy link

API_URL should not be undefined

see https://github.com/di-sukharev/opencommit?tab=readme-ov-file#running-locally-with-ollama

According to the section you linked to, OCO_API_URL is optional and only needs to be set if ollama isn't running on the localhost. In the past this default value worked, now it's suddenly necessary to set it explicitly, and again, this isn't mentioned in the readme.

@di-sukharev
Copy link
Owner

ohh yeah.. you are correct, my apologies :) i will then look into it, looks like it's kinda mandatory, but should have been kept optional for OCO_AI_PROVIDER=ollama

@di-sukharev
Copy link
Owner

hmm.. but it looks like we handle this case https://github.com/di-sukharev/opencommit/blob/master/src/engine/ollama.ts#L16 so it needs a deeper look

anyway @bjornsnoen if you feel like opening the PR with a fix— please do. i will myself get to it ~weekend

@rchouinard
Copy link

I think any fix should take into account the OLLAMA_HOST env var as well. To me, the order should be:

  1. configured OCO_API_URL
  2. OLLAMA_HOST + endpoint path
  3. default localhost + endpoint path

@roeniss
Copy link
Author

roeniss commented Sep 12, 2024

I'm not sure i'm following you guys. Even after remove those API_URL lines I get error as same.

❯❯❯ cat ~/.opencommit
OCO_AI_PROVIDER=ollama
OCO_MODEL=llama3:latest
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=true
OCO_WHY=false
❯❯❯ cat ~/.opencommit_migrations
[
  "00_use_single_api_key_and_url",
  "01_remove_obsolete_config_keys_from_global_file",
  "02_set_missing_default_values"
]%
❯❯❯ oco
┌  open-commit
│
◇  1 staged files:
  build.gradle.kts
│
◇  ✖ Failed to generate the commit message
Error: Ollama provider error: Invalid URL
    at OllamaEngine.generateCommitMessage (/Users/roeniss/.nvm/versions/node/v20.11.1/lib/node_modules/opencommit/out/cli.cjs:40212:13)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async generateCommitMessageByDiff (/Users/roeniss/.nvm/versions/node/v20.11.1/lib/node_modules/opencommit/out/cli.cjs:45082:27)
    at async generateCommitMessageFromGitDiff (/Users/roeniss/.nvm/versions/node/v20.11.1/lib/node_modules/opencommit/out/cli.cjs:45293:25)
    at async trytm (/Users/roeniss/.nvm/versions/node/v20.11.1/lib/node_modules/opencommit/out/cli.cjs:45261:18)
    at async commit (/Users/roeniss/.nvm/versions/node/v20.11.1/lib/node_modules/opencommit/out/cli.cjs:45458:35)
│
└  ✖ Ollama provider error: Invalid URL

@roeniss
Copy link
Author

roeniss commented Sep 12, 2024

it worked after I added OCO_API_URL=http://localhost:11434/api/chat to ~/.opencommit

@di-sukharev
Copy link
Owner

@roeniss you can add it like oco config set OCO_API_URL=http://localhost:11434/api/chat, lets consider this as a workaround until we fix this

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

No branches or pull requests

4 participants