File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright 2023 Google LLC
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ from absl .testing import absltest
16
+
17
+ import google .generativeai as genai
18
+
19
+
20
+ class UnitTests (absltest .TestCase ):
21
+ def test_configure_model (self ):
22
+ # [START configure_model]
23
+ model = genai .GenerativeModel ("gemini-1.5-flash" )
24
+ response = model .generate_content (
25
+ "Tell me a story about a magic backpack." ,
26
+ generation_config = genai .types .GenerationConfig (
27
+ # Only one candidate for now.
28
+ candidate_count = 1 ,
29
+ stop_sequences = ["x" ],
30
+ max_output_tokens = 20 ,
31
+ temperature = 1.0 ,
32
+ ),
33
+ )
34
+
35
+ print (response .text )
36
+ # [END configure_model]
37
+
38
+
39
+ if __name__ == "__main__" :
40
+ absltest .main ()
You can’t perform that action at this time.
0 commit comments