mirror of
https://github.com/ollama/ollama-python.git
synced 2026-07-21 09:05:23 -04:00
about maintaining session continuity: how to get context by python clinet #171
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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?
@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