[GH-ISSUE #1893] response_json['eval_count'] doesn't exists - llms/ollama.py #1086

Closed
opened 2026-04-12 10:50:17 -05:00 by GiteaMirror · 3 comments
Owner

Originally created by @mongolu on GitHub (Jan 10, 2024).
Original GitHub issue: https://github.com/ollama/ollama/issues/1893

after some time this error pops out.
i think it's related with same situation for response_json['prompt_eval_count']

Logs:

 'created_at': '2024-01-10T08:52:17.111694849Z',
 'done': True,
 'eval_duration': 516371613757000,
 'load_duration': 260310,
 'model': 'MixtralOrochi8x7B:latest',
 'response': '',
 'total_duration': 306412003}
Traceback (most recent call last):
  File "/opt/miniconda3/lib/python3.11/site-packages/litellm/llms/ollama.py", line 325, in ollama_acompletion
    completion_tokens = response_json["eval_count"]
                        ~~~~~~~~~~~~~^^^^^^^^^^^^^^
KeyError: 'eval_count'
Originally created by @mongolu on GitHub (Jan 10, 2024). Original GitHub issue: https://github.com/ollama/ollama/issues/1893 after some time this error pops out. i think it's related with same situation for `response_json['prompt_eval_count']` Logs: ``` 'created_at': '2024-01-10T08:52:17.111694849Z', 'done': True, 'eval_duration': 516371613757000, 'load_duration': 260310, 'model': 'MixtralOrochi8x7B:latest', 'response': '', 'total_duration': 306412003} Traceback (most recent call last): File "/opt/miniconda3/lib/python3.11/site-packages/litellm/llms/ollama.py", line 325, in ollama_acompletion completion_tokens = response_json["eval_count"] ~~~~~~~~~~~~~^^^^^^^^^^^^^^ KeyError: 'eval_count' ```
Author
Owner

@mongolu commented on GitHub (Jan 10, 2024):

sry, it's for litellm project.

<!-- gh-comment-id:1884657660 --> @mongolu commented on GitHub (Jan 10, 2024): sry, it's for litellm project.
Author
Owner

@frgfm commented on GitHub (Jan 18, 2024):

Mmmh I'm having the same problem with "prompt_eval_count" after updating to ollama 0.1.20 🤔

I first thought it was a mistake for one specific model, but running it against multiple ones, fetching the keys of the response gets me (some on generate or chat, using tinyllama:1.1b-chat-v1-q4_0 or deepseek-coder:6.7b-instruct-q4_0

dict_keys(['model', 'created_at', 'response', 'done', 'context', 'total_duration', 'load_duration', 'prompt_eval_duration', 'eval_count', 'eval_duration'])

Checking versions, the API response in either generate or chat are missing some keys depending on the version:

  • main/0.1.20: prompt_eval_count
  • 0.1.19: load_duration (cf. #1524)

It looks like it's omitted when empty in the LLM response: https://github.com/jmorganca/ollama/blob/main/api/types.go#L78
And the problem doesn't look like it's from https://github.com/jmorganca/ollama/blob/main/server/routes.go

Trying to locate why the field could be empty for the eval_count and not duration 🕵️

Any idea @jmorganca @BruceMacD ? 🙏

<!-- gh-comment-id:1898327757 --> @frgfm commented on GitHub (Jan 18, 2024): Mmmh I'm having the same problem with "prompt_eval_count" after updating to ollama 0.1.20 :thinking: I first thought it was a mistake for one specific model, but running it against multiple ones, fetching the keys of the response gets me (some on generate or chat, using tinyllama:1.1b-chat-v1-q4_0 or deepseek-coder:6.7b-instruct-q4_0 ``` dict_keys(['model', 'created_at', 'response', 'done', 'context', 'total_duration', 'load_duration', 'prompt_eval_duration', 'eval_count', 'eval_duration']) ``` Checking versions, the API response in either generate or chat are missing some keys depending on the version: - main/0.1.20: prompt_eval_count - 0.1.19: load_duration (cf. #1524) It looks like it's omitted when empty in the LLM response: https://github.com/jmorganca/ollama/blob/main/api/types.go#L78 And the problem doesn't look like it's from https://github.com/jmorganca/ollama/blob/main/server/routes.go Trying to locate why the field could be empty for the eval_count and not duration :detective: Any idea @jmorganca @BruceMacD ? :pray:
Author
Owner

@gregnwosu commented on GitHub (Apr 8, 2024):

i thought it was to do with prompt cache

<!-- gh-comment-id:2042364909 --> @gregnwosu commented on GitHub (Apr 8, 2024): i thought it was to do with prompt cache
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#1086