We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0cfc191 commit a3a005aCopy full SHA for a3a005a
samples/files.py
@@ -83,6 +83,18 @@ def test_files_create_pdf(self):
83
print(response.text)
84
# [END files_create_pdf]
85
86
+ def test_files_create_from_IO(self):
87
+ # [START files_create_io]
88
+ # You can pass a file-like object, instead of a path.
89
+ # Useful for streaming.
90
+ model = genai.GenerativeModel("gemini-1.5-flash")
91
+ fpath = media / "test.pdf"
92
+ with open(fpath, "rb") as f:
93
+ sample_pdf = genai.upload_file(f, mime_type="application/pdf")
94
+ response = model.generate_content(["Give me a summary of this pdf file.", sample_pdf])
95
+ print(response.text)
96
+ # [END files_create_io]
97
+
98
def test_files_list(self):
99
# [START files_list]
100
print("My files:")
0 commit comments