Skip to content

Commit df864f6

Browse files
test with local images
1 parent 0956c7b commit df864f6

File tree

4 files changed

+13
-5
lines changed

4 files changed

+13
-5
lines changed
52 KB
Loading
384 KB
Loading

genai/text_generation/test_text_generation.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ def test_textgen_with_multi_img() -> None:
3434

3535

3636
def test_textgen_with_multi_local_img() -> None:
37-
response = textgen_with_multi_local_img.generate_content()
37+
response = textgen_with_multi_local_img.generate_content(
38+
"./test_data/latte.jpg",
39+
"./test_data/scones.jpg",
40+
)
3841
assert response
3942

4043

genai/text_generation/textgen_with_multi_local_img.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,19 @@
1313
# limitations under the License.
1414

1515

16-
def generate_content() -> str:
16+
def generate_content(image_path_1: str, image_path_2: str) -> str:
1717
# [START googlegenaisdk_textgen_with_multi_local_img]
1818
from google import genai
1919
from google.genai.types import Part
2020

2121
client = genai.Client()
2222

2323
# TODO(Developer): Update the below file paths to your images
24-
with open("path/to/your/image1.jpeg", "rb") as f:
24+
# image_path_1 = "path/to/your/image1.jpg"
25+
# image_path_2 = "path/to/your/image2.jpg"
26+
with open(image_path_1, "rb") as f:
2527
image_1_bytes = f.read()
26-
with open("path/to/your/image2.jpeg", "rb") as f:
28+
with open(image_path_2, "rb") as f:
2729
image_2_bytes = f.read()
2830

2931
response = client.models.generate_content(
@@ -49,4 +51,7 @@ def generate_content() -> str:
4951

5052

5153
if __name__ == "__main__":
52-
generate_content()
54+
generate_content(
55+
"./test_data/latte.jpg",
56+
"./test_data/scones.jpg",
57+
)

0 commit comments

Comments
 (0)