[GH-ISSUE #4564] Clear session context via API #2864

Closed
opened 2026-04-12 13:12:44 -05:00 by GiteaMirror · 3 comments
Owner

Originally created by @atalw on GitHub (May 21, 2024).
Original GitHub issue: https://github.com/ollama/ollama/issues/4564

It's possible in interactive mode using /clear. Would be good to have via the API too.

Originally created by @atalw on GitHub (May 21, 2024). Original GitHub issue: https://github.com/ollama/ollama/issues/4564 It's possible in interactive mode using `/clear`. Would be good to have via the API too.
GiteaMirror added the feature request label 2026-04-12 13:12:44 -05:00
Author
Owner

@pdevine commented on GitHub (May 21, 2024):

Hi @atalw the API does not hold the context. It's entirely held in the client and passed to the server for each request. To get the same functionality:

  • for /api/generate don't pass back the old prompt; and
  • for /api/chat don't pass back the old messages array
<!-- gh-comment-id:2123518390 --> @pdevine commented on GitHub (May 21, 2024): Hi @atalw the API does not hold the context. It's entirely held in the client and passed to the server for each request. To get the same functionality: * for `/api/generate` don't pass back the old `prompt`; and * for `/api/chat` don't pass back the old `messages` array
Author
Owner

@mdhuzaifapatel commented on GitHub (Nov 20, 2024):

Hi @atalw the API does not hold the context. It's entirely held in the client and passed to the server for each request. To get the same functionality:

  • for /api/generate don't pass back the old prompt; and
  • for /api/chat don't pass back the old messages array

Hi, can you please let me know how to send context in current api call. I mean I want to implement the exactly opposite of what you are saying in this answer.
Pls help me out I'm unable to use context parameter. If possible pls provide a code example
Thanks.

<!-- gh-comment-id:2489461719 --> @mdhuzaifapatel commented on GitHub (Nov 20, 2024): > Hi @atalw the API does not hold the context. It's entirely held in the client and passed to the server for each request. To get the same functionality: > > * for `/api/generate` don't pass back the old `prompt`; and > * for `/api/chat` don't pass back the old `messages` array Hi, can you please let me know how to send context in current api call. I mean I want to implement the exactly opposite of what you are saying in this answer. Pls help me out I'm unable to use context parameter. If possible pls provide a code example Thanks.
Author
Owner

@mdhuzaifapatel commented on GitHub (Nov 20, 2024):

Can you guys please tell me (if possible with a code example) how to use context (list of numbers) which we get from current response in next response?

Everytime I'm hitting Ollama API it's generating general answers, not related to the conversation history, I mean, I think it's not using previous responses context .
Please help me out
Thanks

<!-- gh-comment-id:2489461897 --> @mdhuzaifapatel commented on GitHub (Nov 20, 2024): Can you guys please tell me (if possible with a code example) how to use context (list of numbers) which we get from current response in next response? Everytime I'm hitting Ollama API it's generating general answers, not related to the conversation history, I mean, I think it's not using previous responses context . Please help me out Thanks
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#2864