Reputation: 525
I am creating a chat session, conducting a series of automatic requests but I can't find a way using the python API to close the session in order to initiate another and not leave the context alive.
I am creating the session using:
chat_model = GenerativeModel('gemini-pro')
chat_model.start_chat()
Any help will be highly appreciated.
Thank you.
Upvotes: 0
Views: 1236
Reputation: 6812
You do not need to explicitly close the chat session. The is no open connection os anything like that. And the API itself is stateless (from API perspective, there are no chat sessions).
Also you can start multiple sessions:
chat_model = GenerativeModel('gemini-pro')
chat1 = chat_model.start_chat()
chat2 = chat_model.start_chat()
You can send messages to them whenever you want or just abandon them.
Upvotes: 0
Reputation: 50711
The context is purely stored locally on your system where the code is running.
The easiest way to initiate a new session is to create a new model with GenerativeModel('gemini-pro')
again.
Upvotes: 0