From 5a7b954d33f97ce08544cfac45fd72f9b8a04e96 Mon Sep 17 00:00:00 2001 From: Manish Jain <64866594+PandasPirate@users.noreply.github.com> Date: Thu, 25 Apr 2024 17:47:18 +0530 Subject: [PATCH 1/6] update_time defined twice hence removing once. --- google/generativeai/types/file_types.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/google/generativeai/types/file_types.py b/google/generativeai/types/file_types.py index 2f2f3e3da..a2612d47c 100644 --- a/google/generativeai/types/file_types.py +++ b/google/generativeai/types/file_types.py @@ -58,10 +58,6 @@ def update_time(self) -> datetime.datetime: def expiration_time(self) -> datetime.datetime: return self._proto.expiration_time - @property - def update_time(self) -> datetime.datetime: - return self._proto.update_time - @property def sha256_hash(self) -> bytes: return self._proto.sha256_hash From b7d4f3b24158ca21515aaa58f31429d4a1c1bcb8 Mon Sep 17 00:00:00 2001 From: ManishJain Date: Sat, 29 Jun 2024 14:38:32 +0530 Subject: [PATCH 2/6] removed redundant parentheses from some test cases --- tests/notebook/test_cmd_line_parser.py | 2 +- tests/notebook/test_sheets_sanitize_url.py | 2 +- tests/test_generation.py | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/notebook/test_cmd_line_parser.py b/tests/notebook/test_cmd_line_parser.py index 8e032f236..9295382ae 100644 --- a/tests/notebook/test_cmd_line_parser.py +++ b/tests/notebook/test_cmd_line_parser.py @@ -51,7 +51,7 @@ def _set_output_sink(text_result: str, sink: llmfn_outputs.LLMFnOutputsSink) -> llmfn_output_row.LLMFnOutputRow( data={ llmfn_outputs.ColumnNames.RESULT_NUM: 0, - llmfn_outputs.ColumnNames.TEXT_RESULT: (text_result), + llmfn_outputs.ColumnNames.TEXT_RESULT: text_result, }, result_type=str, ) diff --git a/tests/notebook/test_sheets_sanitize_url.py b/tests/notebook/test_sheets_sanitize_url.py index fe2377b57..dd1fc408c 100644 --- a/tests/notebook/test_sheets_sanitize_url.py +++ b/tests/notebook/test_sheets_sanitize_url.py @@ -38,7 +38,7 @@ def test_domain_must_be_docs_google_com(self): """Domain must be docs.google.com.""" with self.assertRaisesRegex( ValueError, - ('Domain for Sheets url must be "docs.google.com", got' ' "sheets.google.com"'), + 'Domain for Sheets url must be "docs.google.com", got' ' "sheets.google.com"', ): sanitize_sheets_url("https://sheets.google.com") diff --git a/tests/test_generation.py b/tests/test_generation.py index 3a5363d72..0cc3bfd07 100644 --- a/tests/test_generation.py +++ b/tests/test_generation.py @@ -116,7 +116,7 @@ def test_join_contents(self): result = generation_types._join_contents(contents) expected = { "parts": [ - {"text": ("Tell me a story about a magic backpack that looks like" " this: ")}, + {"text": "Tell me a story about a magic backpack that looks like" " this: "}, {"inline_data": {"mime_type": "image/png", "data": "REFUQSE="}}, ], "role": "assistant", @@ -254,7 +254,7 @@ def test_join_candidates(self): expected = { "content": { "parts": [ - {"text": ("Tell me a story about a magic backpack that looks like" " this: ")}, + {"text": "Tell me a story about a magic backpack that looks like" " this: "}, {"text": ""}, ], "role": "assistant", @@ -438,7 +438,7 @@ def test_join_prompt_feedbacks(self): { "content": { "parts": [ - {"text": ("Tell me a story about a magic backpack" " that looks like this: ")}, + {"text": "Tell me a story about a magic backpack" " that looks like this: "}, { "inline_data": { "mime_type": "image/png", From f0c88ef675fdb0ec57400fdab94e189e796f1c6f Mon Sep 17 00:00:00 2001 From: ManishJain Date: Sat, 29 Jun 2024 14:56:19 +0530 Subject: [PATCH 3/6] removed multi-step list initialization --- google/generativeai/notebook/sheets_utils.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/google/generativeai/notebook/sheets_utils.py b/google/generativeai/notebook/sheets_utils.py index c750e04a4..7ec862eba 100644 --- a/google/generativeai/notebook/sheets_utils.py +++ b/google/generativeai/notebook/sheets_utils.py @@ -102,8 +102,7 @@ def __init__(self, sid: sheets_id.SheetsIdentifier): def write_outputs(self, outputs: llmfn_outputs.LLMFnOutputsBase) -> None: # Transpose `outputs` into a list of rows. outputs_dict = outputs.as_dict() - outputs_rows: list[Sequence[Any]] = [] - outputs_rows.append(list(outputs_dict.keys())) + outputs_rows: list[Sequence[Any]] = [list(outputs_dict.keys())] outputs_rows.extend([list(x) for x in zip(*outputs_dict.values())]) gspread_client.get_client().write_records( From d1e6012a8d40d873655fd185bf456645545392d2 Mon Sep 17 00:00:00 2001 From: ManishJain Date: Sat, 29 Jun 2024 16:11:10 +0530 Subject: [PATCH 4/6] Removed unused import --- google/generativeai/answer.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/google/generativeai/answer.py b/google/generativeai/answer.py index 4bfabbf23..1ee84f69a 100644 --- a/google/generativeai/answer.py +++ b/google/generativeai/answer.py @@ -14,10 +14,8 @@ # limitations under the License. from __future__ import annotations -import dataclasses -from collections.abc import Iterable -import itertools -from typing import Any, Iterable, Union, Mapping, Optional + +from typing import Iterable, Union, Mapping, Optional from typing_extensions import TypedDict import google.ai.generativelanguage as glm From acbc17a284a816107446ad9dcd339ad254080c7e Mon Sep 17 00:00:00 2001 From: ManishJain Date: Sat, 29 Jun 2024 16:31:01 +0530 Subject: [PATCH 5/6] Revert "Removed unused import" This reverts commit d1e6012a8d40d873655fd185bf456645545392d2. --- google/generativeai/answer.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/google/generativeai/answer.py b/google/generativeai/answer.py index 1ee84f69a..4bfabbf23 100644 --- a/google/generativeai/answer.py +++ b/google/generativeai/answer.py @@ -14,8 +14,10 @@ # limitations under the License. from __future__ import annotations - -from typing import Iterable, Union, Mapping, Optional +import dataclasses +from collections.abc import Iterable +import itertools +from typing import Any, Iterable, Union, Mapping, Optional from typing_extensions import TypedDict import google.ai.generativelanguage as glm From 425d350b896c7d8f944c1099fcc3423c7e79295e Mon Sep 17 00:00:00 2001 From: ManishJain Date: Sat, 29 Jun 2024 16:48:56 +0530 Subject: [PATCH 6/6] fix black issue --- samples/chat.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/samples/chat.py b/samples/chat.py index 5958979cc..5089450d9 100644 --- a/samples/chat.py +++ b/samples/chat.py @@ -31,7 +31,7 @@ def test_chat(self): ] ) response = chat.send_message("I have 2 dogs in my house.") - print(response.text) + print(response.text) response = chat.send_message("How many paws are in my house?") print(response.text) # [END chat] @@ -62,11 +62,14 @@ def test_chat_streaming_with_images(self): model = genai.GenerativeModel("gemini-1.5-flash") chat = model.start_chat() - response = chat.send_message("Hello, I'm interested in learning about musical instruments. Can I show you one?", stream=True) + response = chat.send_message( + "Hello, I'm interested in learning about musical instruments. Can I show you one?", + stream=True, + ) for chunk in response: print(chunk.text) # Yes. print("_" * 80) - + organ = genai.upload_file(media / "organ.jpg") response = chat.send_message( ["What family of intruments does this instrument belong to?", organ], stream=True