Files - can I refer to/send two files in the same call?

I have to files. A pdf with exercises and a pdf with solutions.
I would like to send both files in one call.
So, I’d give one file the name “exercises” and the other “solutions” and would include that logic in the prompt.
Something like this:

files = client_gemini.files.upload(file=[file_exercises, file_solutions], config={'display_name': ["exercises", "solutions"]})

Why not just append it to one file?
I want to extract questions from the file with their solutions. The solutions are at the very end of the document. When I send it as one file, gemini gets confused and extracts the questions from the solution part too instead of mapping it to the exercises… and yes, the pdf is rather clear when it comes to solutions as on every solution pages it says SOLUTIONS. And also the chapter begins with the title “Solutions”.

1 Like

Hi @robo , Welcome to the forum.

I guess we can upload only one file at a time using the FileAPI. Instead, you can use generate_content method to process multiple files.

response = client.models.generate_content(
  model=model_name,
  contents=[prompt1, sample_pdf_1, sample_pdf_2, prompt2])

Hi, thanks! Ah, so I would not used the “files API”? Does it accept the same file types as the files API?

PDF - application/pdf
JavaScript - application/x-javascript, text/javascript
Python - application/x-python, text/x-python
TXT - text/plain
HTML - text/html
CSS - text/css
Markdown - text/md
CSV - text/csv
XML - text/xml
RTF - text/rtf