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

Error: No tokenizer found for model with Ollama #291

Open
luochen1990 opened this issue Sep 27, 2024 · 3 comments
Open

Error: No tokenizer found for model with Ollama #291

luochen1990 opened this issue Sep 27, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@luochen1990
Copy link

Describe the bug

Trying to use ollama but failed with Error: No tokenizer found for model, tried to change the model but still same error.

To Reproduce

[openai]
api_base = "http://127.0.0.1:11434/v1"
api_key = ""
model = "llama3.1:latest"
retries = 2
proxy = ""
  1. Run ollama server locally
  2. Exec ollama run llama3.1:latest
  3. Try some talk to Confirm that ollama is running without issue
  4. Edit ~/.config/gptcommit/config.toml and add above config
  5. git add something and Execute git commit
  6. See error

Expected behavior

Works correctly and without error

Screenshots
If applicable, add screenshots to help explain your problem.
Run your command with the RUST_LOG=trace environment variable for the best support

image

image

System Info (please complete the following information):

  • OS: linux (NixOS unstable)
  • Version: gptcommit v0.5.16
@luochen1990 luochen1990 added the bug Something isn't working label Sep 27, 2024
@assafmo
Copy link

assafmo commented Sep 27, 2024

Happens to me to with groq:

[openai]
api_base = "https://api.groq.com/openai/v1"
api_key = "XXX"
model = "llama-3.2-90b-text-preview"
retries = 2
proxy = ""

@scylamb
Copy link

scylamb commented Oct 4, 2024

Happens to me to with gpt-4o-mini

STDERR: Error: No tokenizer found for model gpt-4o-mini

@rmnilin
Copy link

rmnilin commented Dec 25, 2024

This error occurs here

let prompt_token_limit = get_completion_max_tokens(&self.model, prompt)?;

because this library relies on https://github.com/zurawiki/tiktoken-rs to count and limit prompt tokens. Both libraries are intended to be used exclusively with OpenAI models:

For ollama users, there's a workaround that involves creating an alias for a target model. Here's how you can do it:

$ ollama cp qwen2.5-coder:7b gpt-4--gptcommit-workaround-alias--qwen2.5-coder:7b
# gptcommit/config.toml
[openai]
api_base = "http://localhost:11434/v1"
api_key = ""
model = "gpt-4--gptcommit-workaround-alias--qwen2.5-coder:7b"
retries = 2
proxy = ""

To remove the alias when you no longer need it, use the following command:

$ ollama rm gpt-4--gptcommit-workaround-alias--qwen2.5-coder:7b

Only alias will be removed, not the original model.

Also note that you can use any name or prefix from the zurawiki/tiktoken-rs enums linked above, but there are different logic depending on the model prefix, see

pub(crate) fn should_use_chat_completion(model: &str) -> bool {

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