https://www.boundaryml.com logo
How to maintain chat history in Gemini?
# help
c
I am building a chat agent. My current implementation involves passing chat history to Gemini at the start of the session. How would you do that with BAML? https://cdn.discordapp.com/attachments/1403147644657733763/1403147644913848421/Screenshot_2025-08-08_at_4.16.27_AM.png?ex=68967e93&is=68952d13&hm=765a41c0ef70ae0b0eaf09b24f5c77c5aec6448f3e9fdba2f31284f421a8b4f8&
v
yep! you can just do it via a function parameter: https://docs.boundaryml.com/examples/prompt-engineering/chat
we should update our docs to link to that where it says do not use 🙂
c
Oh, so the history is passed within the prompt?
Hahaha yeah that'll be super
v
yep, just pass in the parameter to the function so its an array
the idea is more like this
you're basically building the agent thing
so your param into the LLM function needs to be something that can mimic state somehow
so typically thats
MyType[]
but it could be an object or whatever
c
Hmm, interesting. But this means that the prompt keeps growing as the chat session goes on, right?
v
yep!
exactly the same thing that happens when you use openai / chat completions etc
c
Yep, makes complete sense. Are there any limitations/constraints that I should keep in mind while building?
I'm assuming Gemini's constraints would apply here, as to how large the prompt can be etc
v
yea exactly
nothing baml specific
c
Perfect, all I needed.
This was really helpful, Vaibhav. Thank you so much for your time and help. Much appreciated ✨
v
thanks for using BAML ❤️
soon @bammy will be here to help even faster