From ba880bcc400b5092851570c334c95e2adef0cb93 Mon Sep 17 00:00:00 2001 From: Mark Daoust Date: Fri, 28 Jun 2024 14:59:47 -0700 Subject: [PATCH 1/5] Add tuned_models samples Change-Id: I4b85a0179d2e7e4c112ed6250a7e602de57787c4 --- google/generativeai/types/__init__.py | 1 + google/generativeai/types/permission_types.py | 70 ++++- samples/increment_tuning_data.json | 62 ++++ samples/tuning.py | 282 ++++++++++++++++++ 4 files changed, 413 insertions(+), 2 deletions(-) create mode 100644 samples/increment_tuning_data.json create mode 100644 samples/tuning.py diff --git a/google/generativeai/types/__init__.py b/google/generativeai/types/__init__.py index 21768bbe6..0acfb1397 100644 --- a/google/generativeai/types/__init__.py +++ b/google/generativeai/types/__init__.py @@ -21,6 +21,7 @@ from google.generativeai.types.generation_types import * from google.generativeai.types.helper_types import * from google.generativeai.types.model_types import * +from google.generativeai.types.permission_types import * from google.generativeai.types.safety_types import * from google.generativeai.types.text_types import * diff --git a/google/generativeai/types/permission_types.py b/google/generativeai/types/permission_types.py index 1df831db0..0334ade2a 100644 --- a/google/generativeai/types/permission_types.py +++ b/google/generativeai/types/permission_types.py @@ -28,6 +28,7 @@ from google.generativeai.utils import flatten_update_paths from google.generativeai import string_utils +__all__ = ['Permission', 'Permissions'] GranteeType = protos.Permission.GranteeType Role = protos.Permission.Role @@ -89,7 +90,7 @@ def valid_id(name: str) -> bool: @string_utils.prettyprint -@dataclasses.dataclass +@dataclasses.dataclass(init=False) class Permission: """ A permission to access a resource. @@ -100,6 +101,24 @@ class Permission: grantee_type: Optional[GranteeType] email_address: Optional[str] = None + def __init__( + self, + name: str, + role: RoleOptions, + grantee_type: Optional[GranteeTypeOptions] = None, + email_address: Optional[str] = None, + ): + self.name = name + if role is None: + self.role = None + else: + self.role = to_role(role) + if grantee_type is None: + self.grantee_type = None + else: + self.grantee_type = to_grantee_type(grantee_type) + self.email_address = email_address + def delete( self, client: glm.PermissionServiceClient | None = None, @@ -133,7 +152,8 @@ def _apply_update(self, path, value): def update( self, - updates: dict[str, Any], + updates: dict[str, Any]|None, + *, client: glm.PermissionServiceClient | None = None, ) -> Permission: """ @@ -279,6 +299,12 @@ def _make_create_permission_request( f"Invalid operation: An 'email_address' must be provided when 'grantee_type' is not set to 'EVERYONE'. Currently, 'grantee_type' is set to '{grantee_type}' and 'email_address' is '{email_address if email_address else 'not provided'}'." ) + if email_address and grantee_type is None: + if email_address.endswith("googlegroups.com"): + grantee_type = GranteeType.GROUP + else: + grantee_type = GranteeType.USER + permission = protos.Permission( role=role, grantee_type=grantee_type, @@ -367,6 +393,10 @@ def list( permission = type(permission).to_dict(permission) yield Permission(**permission) + def __iter__(self): + return self.list() + + async def list_async( self, page_size: Optional[int] = None, @@ -385,6 +415,42 @@ async def list_async( permission = type(permission).to_dict(permission) yield Permission(**permission) + async def __aiter__(self): + return await self.async_list() + + @classmethod + def get( + cls, + name: str, + client: glm.PermissionServiceClient | None = None, + ) -> Permission: + """ + Get information about a specific permission. + + Args: + name: The name of the permission to get. + + Returns: + Requested permission as an instance of `Permission`. + """ + return Permission.get(name) + + @classmethod + async def get_async( + cls, + name: str + ): + """ + Get information about a specific permission. + + Args: + name: The name of the permission to get. + + Returns: + Requested permission as an instance of `Permission`. + """ + return await Permission.get_async(name) + def transfer_ownership( self, email_address: str, diff --git a/samples/increment_tuning_data.json b/samples/increment_tuning_data.json new file mode 100644 index 000000000..1c1ecc5ff --- /dev/null +++ b/samples/increment_tuning_data.json @@ -0,0 +1,62 @@ +[ + { + "text_input": "1", + "output": "2" + }, + { + "text_input": "3", + "output": "4" + }, + { + "text_input": "-3", + "output": "-2" + }, + { + "text_input": "twenty two", + "output": "twenty three" + }, + { + "text_input": "two hundred", + "output": "two hundred one" + }, + { + "text_input": "ninety nine", + "output": "one hundred" + }, + { + "text_input": "8", + "output": "9" + }, + { + "text_input": "-98", + "output": "-97" + }, + { + "text_input": "1,000", + "output": "1,001" + }, + { + "text_input": "10,100,000", + "output": "10,100,001" + }, + { + "text_input": "thirteen", + "output": "fourteen" + }, + { + "text_input": "eighty", + "output": "eighty one" + }, + { + "text_input": "one", + "output": "two" + }, + { + "text_input": "three", + "output": "four" + }, + { + "text_input": "seven", + "output": "eight" + } +] \ No newline at end of file diff --git a/samples/tuning.py b/samples/tuning.py new file mode 100644 index 000000000..977943f7d --- /dev/null +++ b/samples/tuning.py @@ -0,0 +1,282 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +from absl.testing import absltest + +import google +import google.generativeai as genai + +import pathlib + +samples = pathlib.Path(__file__).parent + + +class UnitTests(absltest.TestCase): + def test_tuned_models_create(self): + # [START tuned_models_create] + import time + + base_model = "models/gemini-1.0-pro-001" + training_data = [ + { + "text_input": "1", + "output": "2" + }, + # ... more examples ... + # [START_EXCLUDE] + { + "text_input": "3", + "output": "4" + }, + { + "text_input": "-3", + "output": "-2" + }, + { + "text_input": "twenty two", + "output": "twenty three" + }, + { + "text_input": "two hundred", + "output": "two hundred one" + }, + { + "text_input": "ninety nine", + "output": "one hundred" + }, + { + "text_input": "8", + "output": "9" + }, + { + "text_input": "-98", + "output": "-97" + }, + { + "text_input": "1,000", + "output": "1,001" + }, + { + "text_input": "10,100,000", + "output": "10,100,001" + }, + { + "text_input": "thirteen", + "output": "fourteen" + }, + { + "text_input": "eighty", + "output": "eighty one" + }, + { + "text_input": "one", + "output": "two" + }, + { + "text_input": "three", + "output": "four" + }, + # [END_EXCLUDE] + { + "text_input": "seven", + "output": "eight" + } + ] + operation = genai.create_tuned_model( + # You can use a tuned model here too. Set `source_model="tunedModels/..."` + display_name='increment', + source_model=base_model, + epoch_count=20, + batch_size=4, + learning_rate=0.001, + training_data=training_data + ) + + for status in operation.wait_bar(): + time.sleep(10) + + result = operation.result() + print(result) + # # You can plot the loss curve with: + # snapshots = pd.DataFrame(result.tuning_task.snapshots) + # sns.lineplot(data=snapshots, x='epoch', y='mean_loss') + + model = genai.GenerativeModel(model_name=result.name) + result = model.generate_content('III') + print(result.text) # IV + # [END tuned_models_create] + + def test_tuned_models_generate_content(self): + # [START tuned_models_generate_content] + model = genai.GenerativeModel(model_name="tunedModels/my-increment-model") + result = model.generate_content('III') + print(result.text) # "IV" + # [END tuned_models_create] + + def test_tuned_models_get(self): + # [START tuned_models_get] + model_info = genai.get_model("tunedModels/my-increment-model") + print(model_info) + # [END tuned_models_get] + + def test_tuned_models_list(self): + # [START tuned_models_list] + for model_info in genai.list_tuned_models(): + print(model_info.name) + # [END tuned_models_list] + + def test_tuned_models_delete(self): + import time + + base_model = "models/gemini-1.0-pro-001" + training_data = samples/"increment_tuning_data.json" + try: + operation = genai.create_tuned_model( + id="delete-this-model", + # You can use a tuned model here too. Set `source_model="tunedModels/..."` + display_name='increment', + source_model=base_model, + epoch_count=20, + batch_size=4, + learning_rate=0.001, + training_data=training_data + ) + except google.api_core.exceptions.AlreadyExists: + pass + else: + for status in operation.wait_bar(): + time.sleep(10) + + + # [START tuned_models_delete] + model_name = "tunedModels/delete-this-model" + model_info = genai.get_model(model_name) + print(model_info) + + # You can pass the model_info or name here. + genai.delete_tuned_model(model_name) + # [END tuned_models_delete] + + def test_tuned_models_permissions_create(self): + # [START tuned_models_permissions_create] + model_info = genai.get_model("tunedModels/my-increment-model") + # [START_EXCLUDE] + for p in model_info.permissions.list(): + if p.role.name != "OWNER": + p.delete() + # [END_EXCLUDE] + + public_permission = model_info.permissions.create( + role="READER", + grantee_type="EVERYONE", + ) + + group_permission = model_info.permissions.create( + role='READER', + # Use "user" for an individual email address. + grantee_type="group", + email_address="genai-samples-test-group@googlegroups.com" + ) + # [END tuned_models_permissions_create] + public_permission.delete() + group_permission.delete() + + def test_tuned_models_permissions_list(self): + # [START tuned_models_permissions_list] + model_info = genai.get_model("tunedModels/my-increment-model") + + # [START_EXCLUDE] + for p in model_info.permissions.list(): + if p.role.name != "OWNER": + p.delete() + + public_permission = model_info.permissions.create( + role="READER", + grantee_type="EVERYONE", + ) + + group_permission = model_info.permissions.create( + role='READER', + grantee_type="group", + email_address="genai-samples-test-group@googlegroups.com" + ) + # [END_EXCLUDE] + + for p in model_info.permissions.list(): + print(p) + # [END tuned_models_permissions_list] + public_permission.delete() + group_permission.delete() + + def test_tuned_models_permissions_get(self): + # [START tuned_models_permissions_get] + model_info = genai.get_model("tunedModels/my-increment-model") + + # [START_EXCLUDE] + for p in model_info.permissions.list(): + if p.role.name != "OWNER": + p.delete() + # [END_EXCLUDE] + + public = model_info.permissions.create( + role="READER", + grantee_type="EVERYONE", + ) + print(public) + name = public.name + print(name) # tunedModels/{tunedModel}/permissions/{permission} + + from_name = genai.types.Permissions.get(name) + print(from_name) + # [END tuned_models_permissions_get] + + def test_tuned_models_permissions_update(self): + # [START tuned_models_permissions_update] + model_info = genai.get_model("tunedModels/my-increment-model") + + # [START_EXCLUDE] + for p in model_info.permissions.list(): + if p.role.name != "OWNER": + p.delete() + # [END_EXCLUDE] + + test_group = model_info.permissions.create( + role='writer', + grantee_type="group", + email_address="genai-samples-test-group@googlegroups.com" + ) + + test_group.update({'role': 'READER'}) + # [END tuned_models_permissions_get] + + def test_tuned_models_permission_delete(self): + # [START tuned_models_permissions_create] + model_info = genai.get_model("tunedModels/my-increment-model") + # [START_EXCLUDE] + for p in model_info.permissions.list(): + if p.role.name != "OWNER": + p.delete() + # [END_EXCLUDE] + + public_permission = model_info.permissions.create( + role="READER", + grantee_type="EVERYONE", + ) + + public_permission.delete() + # [END tuned_models_permissions_create] + + +if __name__ == "__main__": + absltest.main() From 8ebb034b0a3c1c64f658bf429078aaf02c768d54 Mon Sep 17 00:00:00 2001 From: Mark Daoust Date: Fri, 28 Jun 2024 15:48:44 -0700 Subject: [PATCH 2/5] format Change-Id: I19e37673d0451fbb243f5041abf40a961dd03a2f --- google/generativeai/types/permission_types.py | 17 +-- samples/tuning.py | 110 +++++------------- 2 files changed, 36 insertions(+), 91 deletions(-) diff --git a/google/generativeai/types/permission_types.py b/google/generativeai/types/permission_types.py index 0334ade2a..e1ab6b40d 100644 --- a/google/generativeai/types/permission_types.py +++ b/google/generativeai/types/permission_types.py @@ -28,7 +28,7 @@ from google.generativeai.utils import flatten_update_paths from google.generativeai import string_utils -__all__ = ['Permission', 'Permissions'] +__all__ = ["Permission", "Permissions"] GranteeType = protos.Permission.GranteeType Role = protos.Permission.Role @@ -152,8 +152,7 @@ def _apply_update(self, path, value): def update( self, - updates: dict[str, Any]|None, - *, + updates: dict[str, Any], client: glm.PermissionServiceClient | None = None, ) -> Permission: """ @@ -396,7 +395,6 @@ def list( def __iter__(self): return self.list() - async def list_async( self, page_size: Optional[int] = None, @@ -419,11 +417,7 @@ async def __aiter__(self): return await self.async_list() @classmethod - def get( - cls, - name: str, - client: glm.PermissionServiceClient | None = None, - ) -> Permission: + def get(cls, name: str) -> Permission: """ Get information about a specific permission. @@ -436,10 +430,7 @@ def get( return Permission.get(name) @classmethod - async def get_async( - cls, - name: str - ): + async def get_async(cls, name: str) -> Permission: """ Get information about a specific permission. diff --git a/samples/tuning.py b/samples/tuning.py index 977943f7d..480fa24b4 100644 --- a/samples/tuning.py +++ b/samples/tuning.py @@ -29,78 +29,33 @@ def test_tuned_models_create(self): base_model = "models/gemini-1.0-pro-001" training_data = [ - { - "text_input": "1", - "output": "2" - }, + {"text_input": "1", "output": "2"}, # ... more examples ... # [START_EXCLUDE] - { - "text_input": "3", - "output": "4" - }, - { - "text_input": "-3", - "output": "-2" - }, - { - "text_input": "twenty two", - "output": "twenty three" - }, - { - "text_input": "two hundred", - "output": "two hundred one" - }, - { - "text_input": "ninety nine", - "output": "one hundred" - }, - { - "text_input": "8", - "output": "9" - }, - { - "text_input": "-98", - "output": "-97" - }, - { - "text_input": "1,000", - "output": "1,001" - }, - { - "text_input": "10,100,000", - "output": "10,100,001" - }, - { - "text_input": "thirteen", - "output": "fourteen" - }, - { - "text_input": "eighty", - "output": "eighty one" - }, - { - "text_input": "one", - "output": "two" - }, - { - "text_input": "three", - "output": "four" - }, + {"text_input": "3", "output": "4"}, + {"text_input": "-3", "output": "-2"}, + {"text_input": "twenty two", "output": "twenty three"}, + {"text_input": "two hundred", "output": "two hundred one"}, + {"text_input": "ninety nine", "output": "one hundred"}, + {"text_input": "8", "output": "9"}, + {"text_input": "-98", "output": "-97"}, + {"text_input": "1,000", "output": "1,001"}, + {"text_input": "10,100,000", "output": "10,100,001"}, + {"text_input": "thirteen", "output": "fourteen"}, + {"text_input": "eighty", "output": "eighty one"}, + {"text_input": "one", "output": "two"}, + {"text_input": "three", "output": "four"}, # [END_EXCLUDE] - { - "text_input": "seven", - "output": "eight" - } + {"text_input": "seven", "output": "eight"}, ] operation = genai.create_tuned_model( # You can use a tuned model here too. Set `source_model="tunedModels/..."` - display_name='increment', + display_name="increment", source_model=base_model, epoch_count=20, batch_size=4, learning_rate=0.001, - training_data=training_data + training_data=training_data, ) for status in operation.wait_bar(): @@ -113,15 +68,15 @@ def test_tuned_models_create(self): # sns.lineplot(data=snapshots, x='epoch', y='mean_loss') model = genai.GenerativeModel(model_name=result.name) - result = model.generate_content('III') - print(result.text) # IV + result = model.generate_content("III") + print(result.text) # IV # [END tuned_models_create] def test_tuned_models_generate_content(self): # [START tuned_models_generate_content] model = genai.GenerativeModel(model_name="tunedModels/my-increment-model") - result = model.generate_content('III') - print(result.text) # "IV" + result = model.generate_content("III") + print(result.text) # "IV" # [END tuned_models_create] def test_tuned_models_get(self): @@ -140,17 +95,17 @@ def test_tuned_models_delete(self): import time base_model = "models/gemini-1.0-pro-001" - training_data = samples/"increment_tuning_data.json" + training_data = samples / "increment_tuning_data.json" try: operation = genai.create_tuned_model( id="delete-this-model", # You can use a tuned model here too. Set `source_model="tunedModels/..."` - display_name='increment', + display_name="increment", source_model=base_model, epoch_count=20, batch_size=4, learning_rate=0.001, - training_data=training_data + training_data=training_data, ) except google.api_core.exceptions.AlreadyExists: pass @@ -158,7 +113,6 @@ def test_tuned_models_delete(self): for status in operation.wait_bar(): time.sleep(10) - # [START tuned_models_delete] model_name = "tunedModels/delete-this-model" model_info = genai.get_model(model_name) @@ -183,10 +137,10 @@ def test_tuned_models_permissions_create(self): ) group_permission = model_info.permissions.create( - role='READER', + role="READER", # Use "user" for an individual email address. grantee_type="group", - email_address="genai-samples-test-group@googlegroups.com" + email_address="genai-samples-test-group@googlegroups.com", ) # [END tuned_models_permissions_create] public_permission.delete() @@ -207,9 +161,9 @@ def test_tuned_models_permissions_list(self): ) group_permission = model_info.permissions.create( - role='READER', + role="READER", grantee_type="group", - email_address="genai-samples-test-group@googlegroups.com" + email_address="genai-samples-test-group@googlegroups.com", ) # [END_EXCLUDE] @@ -235,7 +189,7 @@ def test_tuned_models_permissions_get(self): ) print(public) name = public.name - print(name) # tunedModels/{tunedModel}/permissions/{permission} + print(name) # tunedModels/{tunedModel}/permissions/{permission} from_name = genai.types.Permissions.get(name) print(from_name) @@ -252,12 +206,12 @@ def test_tuned_models_permissions_update(self): # [END_EXCLUDE] test_group = model_info.permissions.create( - role='writer', + role="writer", grantee_type="group", - email_address="genai-samples-test-group@googlegroups.com" + email_address="genai-samples-test-group@googlegroups.com", ) - test_group.update({'role': 'READER'}) + test_group.update({"role": "READER"}) # [END tuned_models_permissions_get] def test_tuned_models_permission_delete(self): From affc5973b9ce1a76808d26c0eb3fd3f838ff39a2 Mon Sep 17 00:00:00 2001 From: Mark Daoust Date: Fri, 28 Jun 2024 15:52:19 -0700 Subject: [PATCH 3/5] fix tests and debug Change-Id: I8a71ea707f1ec9229d7ea1aee8b8fac25835c296 --- .github/workflows/test_pr.yaml | 2 +- google/generativeai/types/permission_types.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test_pr.yaml b/.github/workflows/test_pr.yaml index 9d8fdabbc..fedbddfb0 100644 --- a/.github/workflows/test_pr.yaml +++ b/.github/workflows/test_pr.yaml @@ -93,6 +93,6 @@ jobs: run: | python --version pip install -q . - pip install -q black + pip install black black . --check diff --git a/google/generativeai/types/permission_types.py b/google/generativeai/types/permission_types.py index e1ab6b40d..a3f88f901 100644 --- a/google/generativeai/types/permission_types.py +++ b/google/generativeai/types/permission_types.py @@ -414,7 +414,7 @@ async def list_async( yield Permission(**permission) async def __aiter__(self): - return await self.async_list() + return await self.list_async() @classmethod def get(cls, name: str) -> Permission: From c716b40a37aaf21b4b99216b584c310c83f47087 Mon Sep 17 00:00:00 2001 From: Mark Daoust Date: Fri, 28 Jun 2024 16:03:24 -0700 Subject: [PATCH 4/5] format Change-Id: I0514cff86d043c088aa70e2f10f0815326ed3d09 --- samples/count_tokens.py | 27 ++++++++++++++------------- samples/text_generation.py | 4 ++++ 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/samples/count_tokens.py b/samples/count_tokens.py index 81bedeb4b..42c40d8e1 100644 --- a/samples/count_tokens.py +++ b/samples/count_tokens.py @@ -20,9 +20,6 @@ media = pathlib.Path(__file__).parents[1] / "third_party" - - - class UnitTests(absltest.TestCase): def test_tokens_text_only(self): # [START tokens_text_only] @@ -84,8 +81,10 @@ def test_tokens_cached_content(self): def test_tokens_system_instruction(self): # [START tokens_system_instruction] document = genai.upload_file(path=media / "a11.txt") - model = genai.GenerativeModel("models/gemini-1.5-flash-001", - system_instruction="You are an expert analyzing transcripts. Give a summary of this document.") + model = genai.GenerativeModel( + "models/gemini-1.5-flash-001", + system_instruction="You are an expert analyzing transcripts. Give a summary of this document.", + ) print(model.count_tokens(document)) # [END tokens_system_instruction] @@ -95,25 +94,27 @@ def add(a: float, b: float): """returns a + b.""" return a + b - def subtract(a: float, b: float): """returns a - b.""" return a - b - def multiply(a: float, b: float): """returns a * b.""" return a * b - def divide(a: float, b: float): """returns a / b.""" return a / b - - model = genai.GenerativeModel("models/gemini-1.5-flash-001", - tools=[add, subtract, multiply, divide]) - - print(model.count_tokens("I have 57 cats, each owns 44 mittens, how many mittens is that in total?")) + + model = genai.GenerativeModel( + "models/gemini-1.5-flash-001", tools=[add, subtract, multiply, divide] + ) + + print( + model.count_tokens( + "I have 57 cats, each owns 44 mittens, how many mittens is that in total?" + ) + ) # [END tokens_tools] diff --git a/samples/text_generation.py b/samples/text_generation.py index 015a00e1f..6ba793dfa 100644 --- a/samples/text_generation.py +++ b/samples/text_generation.py @@ -41,6 +41,7 @@ def test_text_gen_text_only_prompt_streaming(self): def test_text_gen_multimodal_one_image_prompt(self): # [START text_gen_multimodal_one_image_prompt] import PIL + model = genai.GenerativeModel("gemini-1.5-flash") organ = PIL.Image.open(media / "organ.jpg") response = model.generate_content(["Tell me about this instrument", organ]) @@ -50,6 +51,7 @@ def test_text_gen_multimodal_one_image_prompt(self): def test_text_gen_multimodal_one_image_prompt_streaming(self): # [START text_gen_multimodal_one_image_prompt_streaming] import PIL + model = genai.GenerativeModel("gemini-1.5-flash") organ = PIL.Image.open(media / "organ.jpg") response = model.generate_content(["Tell me about this instrument", organ], stream=True) @@ -61,6 +63,7 @@ def test_text_gen_multimodal_one_image_prompt_streaming(self): def test_text_gen_multimodal_multi_image_prompt(self): # [START text_gen_multimodal_multi_image_prompt] import PIL + model = genai.GenerativeModel("gemini-1.5-flash") organ = PIL.Image.open(media / "organ.jpg") cajun_instrument = PIL.Image.open(media / "Cajun_instruments.jpg") @@ -73,6 +76,7 @@ def test_text_gen_multimodal_multi_image_prompt(self): def test_text_gen_multimodal_multi_image_prompt_streaming(self): # [START text_gen_multimodal_multi_image_prompt_streaming] import PIL + model = genai.GenerativeModel("gemini-1.5-flash") organ = PIL.Image.open(media / "organ.jpg") cajun_instrument = PIL.Image.open(media / "Cajun_instruments.jpg") From 4e74a4ae5afa64e31682438efce0db04f66f9814 Mon Sep 17 00:00:00 2001 From: Mark Daoust Date: Fri, 28 Jun 2024 16:07:26 -0700 Subject: [PATCH 5/5] revert -q Change-Id: I4f2dfabd14777182f01038d608c2c0b65f43d02f --- .github/workflows/test_pr.yaml | 2 +- google/generativeai/types/permission_types.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test_pr.yaml b/.github/workflows/test_pr.yaml index fedbddfb0..9d8fdabbc 100644 --- a/.github/workflows/test_pr.yaml +++ b/.github/workflows/test_pr.yaml @@ -93,6 +93,6 @@ jobs: run: | python --version pip install -q . - pip install black + pip install -q black black . --check diff --git a/google/generativeai/types/permission_types.py b/google/generativeai/types/permission_types.py index a3f88f901..48cc9c132 100644 --- a/google/generativeai/types/permission_types.py +++ b/google/generativeai/types/permission_types.py @@ -414,7 +414,7 @@ async def list_async( yield Permission(**permission) async def __aiter__(self): - return await self.list_async() + return self.list_async() @classmethod def get(cls, name: str) -> Permission: