Skip to content

Commit 5e7b6c3

Browse files
committed
refactor(genai): Update docs, filename and comments
* update template folder examples
1 parent 0586ab2 commit 5e7b6c3

File tree

7 files changed

+67
-148
lines changed

7 files changed

+67
-148
lines changed

genai/template_folder/advanced_example.py

Lines changed: 0 additions & 66 deletions
This file was deleted.

genai/template_folder/noxfile_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
TEST_CONFIG_OVERRIDE = {
2424
# You can opt out from the test for specific Python versions.
25-
"ignored_versions": ["2.7", "3.7", "3.8", "3.10", "3.11"],
25+
"ignored_versions": ["2.7", "3.7", "3.8", "3.10", "3.11", "3.12"],
2626
# Old samples are opted out of enforcing Python type hints
2727
# All new samples should feature them
2828
"enforce_type_hints": True,
Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1 @@
1-
# pandas==1.3.5; python_version == '3.7'
2-
# pandas==2.0.3; python_version == '3.8'
3-
# pandas==2.1.4; python_version > '3.8'
4-
# pillow==10.3.0; python_version < '3.8'
5-
# pillow==10.3.0; python_version >= '3.8'
6-
# google-cloud-aiplatform[all]==1.69.0
7-
# sentencepiece==0.2.0
8-
# google-auth==2.29.0
9-
# anthropic[vertex]==0.28.0
10-
# langchain-core==0.2.33
11-
# langchain-google-vertexai==1.0.10
12-
# numpy<2
13-
# openai==1.30.5
14-
# immutabledict==4.2.0
1+
# google-genai==1.2.0

genai/template_folder/simple_example.py

Lines changed: 0 additions & 41 deletions
This file was deleted.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Copyright 2024 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
16+
def simple_example() -> int:
17+
"Simple example for <template_folder> feature."
18+
# TODO: <ADD-START-REGION-TAG-HERE>
19+
from vertexai.preview.tokenization import get_tokenizer_for_model
20+
21+
# Using local tokenzier
22+
tokenizer = get_tokenizer_for_model("gemini-1.5-flash-002")
23+
24+
prompt = "hello world"
25+
response = tokenizer.count_tokens(prompt)
26+
print(f"Prompt Token Count: {response.total_tokens}")
27+
# Example response:
28+
# Prompt Token Count: 2
29+
30+
prompt = ["hello world", "what's the weather today"]
31+
response = tokenizer.count_tokens(prompt)
32+
print(f"Prompt Token Count: {response.total_tokens}")
33+
# Example response:
34+
# Prompt Token Count: 8
35+
36+
# TODO: <ADD-START-REGION-TAG-HERE>
37+
return response.total_tokens
38+
39+
40+
if __name__ == "__main__":
41+
simple_example()

genai/template_folder/test_template_folder_examples.py

Lines changed: 0 additions & 26 deletions
This file was deleted.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Copyright 2024 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import templatefolder_with_txt
16+
17+
18+
def test_templatefolder_with_txt() -> None:
19+
assert response
20+
21+
22+
def test_advanced_example() -> None:
23+
response = advanced_example.advanced_example()
24+
assert response

0 commit comments

Comments
 (0)