Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Conversation context in google.generativeai.chat

Is there a way to have multiple chats happening at the same time with different contexts with google.generativeai.chat? i.e. running off the same API endpoint. 

Solved Solved
1 2 1,922
1 ACCEPTED SOLUTION

If you maintain a history of the state for each chat, most definitely. You just need to pass in the history and other relevant for each call. In the docs, check out the "messages" parameter for the function call.

View solution in original post

2 REPLIES 2

Google's GenerativeAI Chat (the underlying technology behind Google's chat services) doesn't officially support parallel conversations with different contexts using a single API endpoint. The API is typically designed to handle one conversation context at a time per session.

However, developers can simulate multiple conversations by managing different sessions or instances of the API. Each instance or session would handle a separate conversation context. This requires careful management and tracking of each conversation's state separately.

Creating a system that orchestrates multiple conversations through different sessions would involve coordinating session management, context switching, and ensuring each conversation maintains its coherence without mixing contexts.

If you maintain a history of the state for each chat, most definitely. You just need to pass in the history and other relevant for each call. In the docs, check out the "messages" parameter for the function call.