feat: token counting according to model's context size #230

Open
opened 2025-11-11 14:12:30 -06:00 by GiteaMirror · 4 comments
Owner

Originally created by @peperunas on GitHub (Jan 25, 2024).

Is your feature request related to a problem? Please describe.

I believe a crucial feature would be to have an idea of the context size of the conversation with a model. In this way, the user is aware of how much more the chat can continue.

As of now, it seems there is no "official" way to pull a model's context size from Ollama via its API. The issue has been raised and tracked here 1.

I guess this issue can track the advancement of the API endpoint on Ollama's side as well.

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Originally created by @peperunas on GitHub (Jan 25, 2024). **Is your feature request related to a problem? Please describe.** I believe a crucial feature would be to have an idea of the context size of the conversation with a model. In this way, the user is aware of how much more the chat can continue. As of now, it seems there is no "official" way to pull a model's context size from Ollama via its API. The issue has been raised and tracked here [1]. I guess this issue can track the advancement of the API endpoint on Ollama's side as well. [1]: https://github.com/ollama/ollama/issues/1473 **Describe the solution you'd like** A clear and concise description of what you want to happen. **Describe alternatives you've considered** A clear and concise description of any alternative solutions or features you've considered. **Additional context** Add any other context or screenshots about the feature request here.
GiteaMirror added the enhancementgood first issuehelp wantednon-core labels 2025-11-11 14:12:31 -06:00
Author
Owner

@jukofyork commented on GitHub (Feb 3, 2024):

You can sort of see this by clicking on the little "info" icon I think but agree it would be nice to have a clearer representation.

@jukofyork commented on GitHub (Feb 3, 2024): You can sort of see this by clicking on the little "info" icon I think but agree it would be nice to have a clearer representation.
Author
Owner

@justinh-rahb commented on GitHub (Feb 19, 2024):

should be a way to set "num_ctx" like when using ollama in code

Example of this:
ollamaLLM1 = Ollama(model="mistral:7b", temperature=0.9, num_ctx=8192)

It is already an option to set the "temperature", should be doable to add the "num_ctx" for manual context length.
or even automatic if that information can be pulled from the ollama api, but to my knowledge there is no way to do that, so it just defaults to 2048.

I'm not sure you've got this in the right place. This seems like a suggestion to make to the Ollama project, not here.

@justinh-rahb commented on GitHub (Feb 19, 2024): > should be a way to set "num_ctx" like when using ollama in code > > Example of this: > ollamaLLM1 = Ollama(model="mistral:7b", temperature=0.9, num_ctx=8192) > > It is already an option to set the "temperature", should be doable to add the "num_ctx" for manual context length. > or even automatic if that information can be pulled from the ollama api, but to my knowledge there is no way to do that, so it just defaults to 2048. I'm not sure you've got this in the right place. This seems like a suggestion to make to the Ollama project, not here.
Author
Owner

@scscgit commented on GitHub (Aug 7, 2024):

Cross-linking with issue https://github.com/open-webui/open-webui/discussions/4246#discussioncomment-10264834 which has been sadly turned into a discussion

@scscgit commented on GitHub (Aug 7, 2024): Cross-linking with issue https://github.com/open-webui/open-webui/discussions/4246#discussioncomment-10264834 which has been sadly turned into a discussion
Author
Owner

@evolutioned commented on GitHub (Jul 22, 2025):

i would suggest removing this as a "Good First Issue", as it requires a deep understanding of how to work with Ollama in the backend. It's a complex problem for a first timer.

@evolutioned commented on GitHub (Jul 22, 2025): i would suggest removing this as a "Good First Issue", as it requires a deep understanding of how to work with Ollama in the backend. It's a complex problem for a first timer.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#230