Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 4a354fc

Browse files
committedFeb 28, 2025·
docs: fix incorrect usage of types.Part methods
types.Part.from_text and types.Part.from_uri do no accept positional argument
1 parent 08e9b65 commit 4a354fc

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed
 

‎google/genai/models.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -5145,9 +5145,9 @@ def generate_content(
51455145
response = client.models.generate_content(
51465146
model='gemini-1.5-flash-002',
51475147
contents=[
5148-
types.Part.from_text('What is shown in this image?'),
5149-
types.Part.from_uri('gs://generativeai-downloads/images/scones.jpg',
5150-
'image/jpeg')
5148+
types.Part.from_text(text='What is shown in this image?'),
5149+
types.Part.from_uri(file_uri='gs://generativeai-downloads/images/scones.jpg',
5150+
mime_type='image/jpeg')
51515151
]
51525152
)
51535153
print(response.text)
@@ -5264,9 +5264,9 @@ def generate_content_stream(
52645264
for chunk in client.models.generate_content_stream(
52655265
model='gemini-1.5-flash-002',
52665266
contents=[
5267-
types.Part.from_text('What is shown in this image?'),
5268-
types.Part.from_uri('gs://generativeai-downloads/images/scones.jpg',
5269-
'image/jpeg')
5267+
types.Part.from_text(text='What is shown in this image?'),
5268+
types.Part.from_uri(file_uri='gs://generativeai-downloads/images/scones.jpg',
5269+
mime_type='image/jpeg')
52705270
]
52715271
):
52725272
print(chunk.text)
@@ -6500,9 +6500,9 @@ async def generate_content_stream(
65006500
async for chunk in awiat client.aio.models.generate_content_stream(
65016501
model='gemini-1.5-flash-002',
65026502
contents=[
6503-
types.Part.from_text('What is shown in this image?'),
6504-
types.Part.from_uri('gs://generativeai-downloads/images/scones.jpg',
6505-
'image/jpeg')
6503+
types.Part.from_text(text='What is shown in this image?'),
6504+
types.Part.from_uri(file_uri='gs://generativeai-downloads/images/scones.jpg',
6505+
mime_type='image/jpeg')
65066506
]
65076507
):
65086508
print(chunk.text)

0 commit comments

Comments
 (0)
Please sign in to comment.