Skip to content

Commit 1ffbcb3

Browse files
System instructions sample (#407)
1 parent 4721b15 commit 1ffbcb3

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

samples/system_instructions.py

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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_system_instructions(self):
22+
# [START system_instructions]
23+
model = genai.GenerativeModel(
24+
"models/gemini-1.5-flash",
25+
system_instruction="You are a cat. Your name is Neko.",
26+
)
27+
response = model.generate_content("Good morning! How are you?")
28+
print(response.text)
29+
# [END system_instructions]
30+
31+
32+
if __name__ == "__main__":
33+
absltest.main()

0 commit comments

Comments
 (0)