Thoughts and files

Hi guys,

In my chatbot, using gemini-2.5-flash, I use the “@google/genai” SDK…

I create the object like this:
const model = config.MODEL;

const ai = new GoogleGenAI({

vertexai: true,

project: config.PROJECT_NAME,

location: config.MODEL_REGION,

});

Then create the chat:

chat = ai.chats.create({

        model: model,

        config: localConfig,

        history: history || \[\]

      });

Then save it in session (not best practice, but ignore).

Now, if i upload 4 pdf files and 3 docx files to a bucket.

When the prompt comes up, I build the “parts” array.

When i build the parts i put the uri of the pdf files.

i extract the docx documents and send it along with the prompt.

Now I send the prompt like this:

let streamResult = await chat.sendMessageStream({ message: _parts });

Now, after I get the answer, I can send a second prompt without sending the files again, e.g. “what is in section 3?”

He return an answer.

As far as I understand, the sdk, makes the object to keep “internal history” with all the data (pdf uri and docx text) and send it all again.

First, I’d like to know if its true?

Now about the thoughts:

I want to stream and save the “Thinking process”

From what I understood, I need to use ‘generatecontentstream’ instead of “sendMessageStream”.

Is it true?

Another thing: it looks like he doesn’t find the data i asked for in the second prompt.

Is it because it doen’t act like the first object that saves the data?

If I want to use it, I need to send all the files again?

What is the best approach to deal with this challenge?

Thanks