about maintaining session continuity: how to get context by python clinet #171

Closed
opened 2026-02-15 16:28:28 -05:00 by yindo · 1 comment
Owner

Originally created by @huijunzi on GitHub (Nov 27, 2024).

If using an HTTP client, the context can be obtained from the last returned JSON of the previous generate request, and this context can be passed as a context parameter in the new generate, thus maintaining session continuity. However, when using a Python client, it is not possible to obtain the context in the JSON returned by the last request, making it impossible to implement this function. Does the Python client not provide this feature?

Originally created by @huijunzi on GitHub (Nov 27, 2024). If using an HTTP client, the context can be obtained from the last returned JSON of the previous generate request, and this context can be passed as a context parameter in the new generate, thus maintaining session continuity. However, when using a Python client, it is not possible to obtain the context in the JSON returned by the last request, making it impossible to implement this function. Does the Python client not provide this feature?
yindo closed this issue 2026-02-15 16:28:28 -05:00
Author
Owner

@ParthSareen commented on GitHub (Nov 27, 2024):

Hey! The pattern is a bit different when using the chat interface. Refer to this example here to see how you can attach assistant responses: https://github.com/ollama/ollama-python/blob/main/examples/chat-with-history.py

@ParthSareen commented on GitHub (Nov 27, 2024): Hey! The pattern is a bit different when using the chat interface. Refer to this example here to see how you can attach assistant responses: https://github.com/ollama/ollama-python/blob/main/examples/chat-with-history.py
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: ollama/ollama-python#171