I’m building an application where an AI agent acts as a “game master”. To ensure the agent has a consistent understanding of the game’s state and player actions, I need to maintain separate threads for each user.
However, I haven’t found a way to achieve this using Gemini 1.5 or 1.5 Flash. Is there a solution outside of tools like Agent Builder and Dialogflow CX?
Essentially, I’m looking for something analogous to the “threads” concept within OpenAI API. Gemini 1.0 falls short in terms of reasoning and summarization capabilities, so I’m hoping there’s a way to achieve this with a more recent model.
Welcome to the forums!
You definitely don’t need Agent Builder for something like this.
It sounds like you just need to keep track of the history of the conversation you have with each player.
You don’t indicate what programming language you’re using, but most of the libraries for Gemini include a startChat
or start_chat
function which takes existing history (or none) and creates a chat history object. This object can store the history (if you’re doing it in memory) or lets you get the history to save in a data store of some sort. Some higher level libraries, such as LangChain or LangChain.js will manage this history loading and saving for you.
For your purposes, you would create a history session for each player and manage each separately. This is similar to what the OpenAI threads would require.
Hi! You’re right, I’m talking about keeping track of each player’s conversation history. I’m using Python and LangChain (for RAG) but I’m still learning the ropes.
It sounds like creating a separate chat history object for each player is the way to go. I’m hoping to use this history later on to train models, which is why I’m keen to keep everything organized. Thanks for pointing out those functions, they were definitely not obvious to me!
Maybe you can point any specific suggestions for how to best structure and store these chat histories properly?
I’m not too familiar with the Python side of Langchain, but they call the feature “memory”.
Take a look at Add message history (memory) | 🦜️🔗 LangChain which provides an overview and example using in-memory… er… memory… {: But does link to ways to have that memory automatically stored in a variety of data stores.