pdf analysis using gemini-1.5-pro

hello

i saw sample code for python sdk for generative-ai using gemini-1.5-pro model (below snippet)
i tried doing the same using node sdk, but it keeps throwing a 500 error. 
isn't this functionality available in the node sdk yet?

 

pdf_file_uri = "gs://cloud-samples-data/generative-ai/pdf/2403.05530.pdf"

prompt = """
  Your are a very professional document summarization specialist.
  Please summarize the given document.
"""

pdf_file = Part.from_uri(pdf_file_uri, mime_type="application/pdf")
contents = [pdf_file, prompt]

response = model.generate_content(contents)
print(response.text)

 

 

7 3 990
3 REPLIES 3

I think your error may be related to your authentication or some other issue, because I use the same code snippet and it works for me. Without more context I am not able to give much more help.

Hi, Could you pls let me know how to set the  pdf_file_url? Is this file you uploaded yourself? If yes, could you pls let me know how to do this? Thanks!

 

pdf_file_url can be just a cloud storage location link, something starting with "gs://"