22
22
23
23
24
24
class UnitTests (absltest .TestCase ):
25
- def test_files_create (self ):
26
- # [START files_create ]
25
+ def test_files_create_text (self ):
26
+ # [START files_create_text ]
27
27
myfile = genai .upload_file (media / "poem.txt" )
28
28
print (f"{ myfile = } " )
29
29
@@ -32,7 +32,29 @@ def test_files_create(self):
32
32
[myfile , "\n \n " , "Can you add a few more lines to this poem?" ]
33
33
)
34
34
print (f"{ result .text = } " )
35
- # [END files_create]
35
+ # [END files_create_text]
36
+
37
+ def test_files_create_image (self ):
38
+ # [START files_create_image]
39
+ myfile = genai .upload_file (media / "Cajun_instruments.jpg" )
40
+ print (f"{ myfile = } " )
41
+
42
+ model = genai .GenerativeModel ("gemini-1.5-flash" )
43
+ result = model .generate_content (
44
+ [myfile , "\n \n " , "Can you tell me about the instruments in this photo?" ]
45
+ )
46
+ print (f"{ result .text = } " )
47
+ # [END files_create_image]
48
+
49
+ def test_files_create_audio (self ):
50
+ # [START files_create_audio]
51
+ myfile = genai .upload_file (media / "sample.mp3" )
52
+ print (f"{ myfile = } " )
53
+
54
+ model = genai .GenerativeModel ("gemini-1.5-flash" )
55
+ result = model .generate_content ([myfile , "Describe this audio clip" ])
56
+ print (f"{ result .text = } " )
57
+ # [END files_create_audio]
36
58
37
59
def test_files_create_video (self ):
38
60
# [START files_create_video]
0 commit comments