Skip to content

Commit e36edb4

Browse files
feat: update genai textgen_with_pdf.py example (#13294)
1 parent 2c06813 commit e36edb4

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

genai/text_generation/textgen_with_pdf.py

+9-4
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,13 @@ def generate_content() -> str:
2424
model_id = "gemini-2.0-flash-001"
2525

2626
prompt = """
27-
You are a highly skilled document summarization specialist. Your task is to provide a concise executive summary of no more than 300 words. Please summarize the given document for a general audience.
27+
You are a highly skilled document summarization specialist.
28+
Your task is to provide a concise executive summary of no more than 300 words.
29+
Please summarize the given document for a general audience.
2830
"""
2931

3032
pdf_file = Part.from_uri(
31-
file_uri="gs://cloud-samples-data/generative-ai/pdf/2403.05530.pdf",
33+
file_uri="gs://cloud-samples-data/generative-ai/pdf/1706.03762v7.pdf",
3234
mime_type="application/pdf",
3335
)
3436

@@ -39,9 +41,12 @@ def generate_content() -> str:
3941

4042
print(response.text)
4143
# Example response:
42-
# Here's a summary of the Google DeepMind Gemini 1.5 report:
44+
# Here is a summary of the document in 300 words.
4345
#
44-
# This report introduces Gemini 1.5 Pro...
46+
# The paper introduces the Transformer, a novel neural network architecture for
47+
# sequence transduction tasks like machine translation. Unlike existing models that rely on recurrent or
48+
# convolutional layers, the Transformer is based entirely on attention mechanisms.
49+
# ...
4550
# [END googlegenaisdk_textgen_with_pdf]
4651
return response.text
4752

0 commit comments

Comments
 (0)