diff --git a/genai/batch_prediction/batchpredict_embeddings_with_gcs.py b/genai/batch_prediction/batchpredict_embeddings_with_gcs.py index 41420db3141..4fb8148e9f5 100644 --- a/genai/batch_prediction/batchpredict_embeddings_with_gcs.py +++ b/genai/batch_prediction/batchpredict_embeddings_with_gcs.py @@ -34,7 +34,7 @@ def generate_content(output_uri: str) -> str: print(f"Job name: {job.name}") print(f"Job state: {job.state}") # Example response: - # Job name: projects/%PROJECT_ID%/locations/us-central1/batchPredictionJobs/9876453210000000000 + # Job name: projects/.../locations/.../batchPredictionJobs/9876453210000000000 # Job state: JOB_STATE_PENDING # See the documentation: https://googleapis.github.io/python-genai/genai.html#genai.types.BatchJob diff --git a/genai/batch_prediction/batchpredict_with_bq.py b/genai/batch_prediction/batchpredict_with_bq.py index 30ea7c4a90f..bf051f2a223 100644 --- a/genai/batch_prediction/batchpredict_with_bq.py +++ b/genai/batch_prediction/batchpredict_with_bq.py @@ -35,7 +35,7 @@ def generate_content(output_uri: str) -> str: print(f"Job name: {job.name}") print(f"Job state: {job.state}") # Example response: - # Job name: projects/%PROJECT_ID%/locations/us-central1/batchPredictionJobs/9876453210000000000 + # Job name: projects/.../locations/.../batchPredictionJobs/9876453210000000000 # Job state: JOB_STATE_PENDING # See the documentation: https://googleapis.github.io/python-genai/genai.html#genai.types.BatchJob diff --git a/genai/batch_prediction/batchpredict_with_gcs.py b/genai/batch_prediction/batchpredict_with_gcs.py index 75061405ff0..fcedf217bdc 100644 --- a/genai/batch_prediction/batchpredict_with_gcs.py +++ b/genai/batch_prediction/batchpredict_with_gcs.py @@ -36,7 +36,7 @@ def generate_content(output_uri: str) -> str: print(f"Job name: {job.name}") print(f"Job state: {job.state}") # Example response: - # Job name: projects/%PROJECT_ID%/locations/us-central1/batchPredictionJobs/9876453210000000000 + # Job name: projects/.../locations/.../batchPredictionJobs/9876453210000000000 # Job state: JOB_STATE_PENDING # See the documentation: https://googleapis.github.io/python-genai/genai.html#genai.types.BatchJob diff --git a/genai/batch_prediction/get_batch_job.py b/genai/batch_prediction/get_batch_job.py index a17b0457e25..c6e0453da64 100644 --- a/genai/batch_prediction/get_batch_job.py +++ b/genai/batch_prediction/get_batch_job.py @@ -23,7 +23,7 @@ def get_batch_job(batch_job_name: str) -> types.BatchJob: client = genai.Client(http_options=HttpOptions(api_version="v1")) # Get the batch job - # Eg. batch_job_name = "projects/123456789012/locations/us-central1/batchPredictionJobs/1234567890123456789" +# Eg. batch_job_name = "projects/123456789012/locations/.../batchPredictionJobs/1234567890123456789" batch_job = client.batches.get(name=batch_job_name) print(f"Job state: {batch_job.state}") diff --git a/genai/batch_prediction/requirements-test.txt b/genai/batch_prediction/requirements-test.txt index 937db8fb0d5..e43b7792721 100644 --- a/genai/batch_prediction/requirements-test.txt +++ b/genai/batch_prediction/requirements-test.txt @@ -1,4 +1,2 @@ google-api-core==2.24.0 -google-cloud-bigquery==3.29.0 -google-cloud-storage==2.19.0 pytest==8.2.0 diff --git a/genai/batch_prediction/requirements.txt b/genai/batch_prediction/requirements.txt index 7ad844cebcf..4f44a6593bb 100644 --- a/genai/batch_prediction/requirements.txt +++ b/genai/batch_prediction/requirements.txt @@ -1 +1,3 @@ -google-genai==1.27.0 +google-cloud-bigquery==3.29.0 +google-cloud-storage==2.19.0 +google-genai==1.42.0 diff --git a/genai/batch_prediction/test_batch_prediction_examples.py b/genai/batch_prediction/test_batch_prediction_examples.py index 5183161be65..5079dfd2cd0 100644 --- a/genai/batch_prediction/test_batch_prediction_examples.py +++ b/genai/batch_prediction/test_batch_prediction_examples.py @@ -11,19 +11,10 @@ # 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. - -# -# Using Google Cloud Vertex AI to test the code samples. -# -from datetime import datetime as dt -import os - from unittest.mock import MagicMock, patch -from google.cloud import bigquery, storage from google.genai import types from google.genai.types import JobState -import pytest import batchpredict_embeddings_with_gcs import batchpredict_with_bq @@ -31,67 +22,113 @@ import get_batch_job -os.environ["GOOGLE_GENAI_USE_VERTEXAI"] = "True" -os.environ["GOOGLE_CLOUD_LOCATION"] = "us-central1" -# The project name is included in the CICD pipeline -# os.environ['GOOGLE_CLOUD_PROJECT'] = "add-your-project-name" -BQ_OUTPUT_DATASET = f"{os.environ['GOOGLE_CLOUD_PROJECT']}.gen_ai_batch_prediction" -GCS_OUTPUT_BUCKET = "python-docs-samples-tests" - - -@pytest.fixture(scope="session") -def bq_output_uri() -> str: - table_name = f"text_output_{dt.now().strftime('%Y_%m_%d_T%H_%M_%S')}" - table_uri = f"{BQ_OUTPUT_DATASET}.{table_name}" +@patch("google.genai.Client") +@patch("time.sleep", return_value=None) +def test_batch_prediction_embeddings_with_gcs( + mock_sleep: MagicMock, mock_genai_client: MagicMock +) -> None: + # Mock the API response + mock_batch_job_running = types.BatchJob( + name="test-batch-job", state="JOB_STATE_RUNNING" + ) + mock_batch_job_succeeded = types.BatchJob( + name="test-batch-job", state="JOB_STATE_SUCCEEDED" + ) - yield f"bq://{table_uri}" + mock_genai_client.return_value.batches.create.return_value = ( + mock_batch_job_running + ) + mock_genai_client.return_value.batches.get.return_value = ( + mock_batch_job_succeeded + ) - bq_client = bigquery.Client() - bq_client.delete_table(table_uri, not_found_ok=True) + response = batchpredict_embeddings_with_gcs.generate_content( + output_uri="gs://test-bucket/test-prefix" + ) + mock_genai_client.assert_called_once_with( + http_options=types.HttpOptions(api_version="v1") + ) + mock_genai_client.return_value.batches.create.assert_called_once() + mock_genai_client.return_value.batches.get.assert_called_once() + assert response == JobState.JOB_STATE_SUCCEEDED -@pytest.fixture(scope="session") -def gcs_output_uri() -> str: - prefix = f"text_output/{dt.now()}" - yield f"gs://{GCS_OUTPUT_BUCKET}/{prefix}" +@patch("google.genai.Client") +@patch("time.sleep", return_value=None) +def test_batch_prediction_with_bq( + mock_sleep: MagicMock, mock_genai_client: MagicMock +) -> None: + # Mock the API response + mock_batch_job_running = types.BatchJob( + name="test-batch-job", state="JOB_STATE_RUNNING" + ) + mock_batch_job_succeeded = types.BatchJob( + name="test-batch-job", state="JOB_STATE_SUCCEEDED" + ) - storage_client = storage.Client() - bucket = storage_client.get_bucket(GCS_OUTPUT_BUCKET) - blobs = bucket.list_blobs(prefix=prefix) - for blob in blobs: - blob.delete() + mock_genai_client.return_value.batches.create.return_value = ( + mock_batch_job_running + ) + mock_genai_client.return_value.batches.get.return_value = ( + mock_batch_job_succeeded + ) + response = batchpredict_with_bq.generate_content( + output_uri="bq://test-project.test_dataset.test_table" + ) -def test_batch_prediction_embeddings_with_gcs(gcs_output_uri: str) -> None: - response = batchpredict_embeddings_with_gcs.generate_content( - output_uri=gcs_output_uri + mock_genai_client.assert_called_once_with( + http_options=types.HttpOptions(api_version="v1") ) + mock_genai_client.return_value.batches.create.assert_called_once() + mock_genai_client.return_value.batches.get.assert_called_once() assert response == JobState.JOB_STATE_SUCCEEDED -def test_batch_prediction_with_bq(bq_output_uri: str) -> None: - response = batchpredict_with_bq.generate_content(output_uri=bq_output_uri) - assert response == JobState.JOB_STATE_SUCCEEDED +@patch("google.genai.Client") +@patch("time.sleep", return_value=None) +def test_batch_prediction_with_gcs( + mock_sleep: MagicMock, mock_genai_client: MagicMock +) -> None: + # Mock the API response + mock_batch_job_running = types.BatchJob( + name="test-batch-job", state="JOB_STATE_RUNNING" + ) + mock_batch_job_succeeded = types.BatchJob( + name="test-batch-job", state="JOB_STATE_SUCCEEDED" + ) + mock_genai_client.return_value.batches.create.return_value = ( + mock_batch_job_running + ) + mock_genai_client.return_value.batches.get.return_value = ( + mock_batch_job_succeeded + ) + + response = batchpredict_with_gcs.generate_content( + output_uri="gs://test-bucket/test-prefix" + ) -def test_batch_prediction_with_gcs(gcs_output_uri: str) -> None: - response = batchpredict_with_gcs.generate_content(output_uri=gcs_output_uri) + mock_genai_client.assert_called_once_with( + http_options=types.HttpOptions(api_version="v1") + ) + mock_genai_client.return_value.batches.create.assert_called_once() + mock_genai_client.return_value.batches.get.assert_called_once() assert response == JobState.JOB_STATE_SUCCEEDED @patch("google.genai.Client") def test_get_batch_job(mock_genai_client: MagicMock) -> None: # Mock the API response - mock_batch_job = types.BatchJob( - name="test-batch-job", - state="JOB_STATE_PENDING" - ) + mock_batch_job = types.BatchJob(name="test-batch-job", state="JOB_STATE_PENDING") mock_genai_client.return_value.batches.get.return_value = mock_batch_job response = get_batch_job.get_batch_job("test-batch-job") - mock_genai_client.assert_called_once_with(http_options=types.HttpOptions(api_version="v1")) + mock_genai_client.assert_called_once_with( + http_options=types.HttpOptions(api_version="v1") + ) mock_genai_client.return_value.batches.get.assert_called_once() assert response == mock_batch_job diff --git a/genai/bounding_box/requirements.txt b/genai/bounding_box/requirements.txt index 661c889ab37..86da356810f 100644 --- a/genai/bounding_box/requirements.txt +++ b/genai/bounding_box/requirements.txt @@ -1,2 +1,2 @@ -google-genai==1.27.0 +google-genai==1.42.0 pillow==11.1.0 diff --git a/genai/content_cache/contentcache_create_with_txt_gcs_pdf.py b/genai/content_cache/contentcache_create_with_txt_gcs_pdf.py index 1e158d940c4..2ed5ee6b713 100644 --- a/genai/content_cache/contentcache_create_with_txt_gcs_pdf.py +++ b/genai/content_cache/contentcache_create_with_txt_gcs_pdf.py @@ -47,7 +47,7 @@ def create_content_cache() -> str: contents=contents, system_instruction=system_instruction, # (Optional) For enhanced security, the content cache can be encrypted using a Cloud KMS key - # kms_key_name = "projects/.../locations/us-central1/keyRings/.../cryptoKeys/..." + # kms_key_name = "projects/.../locations/.../keyRings/.../cryptoKeys/..." display_name="example-cache", ttl="86400s", ), @@ -56,7 +56,7 @@ def create_content_cache() -> str: print(content_cache.name) print(content_cache.usage_metadata) # Example response: - # projects/111111111111/locations/us-central1/cachedContents/1111111111111111111 + # projects/111111111111/locations/.../cachedContents/1111111111111111111 # CachedContentUsageMetadata(audio_duration_seconds=None, image_count=167, # text_count=153, total_token_count=43130, video_duration_seconds=None) # [END googlegenaisdk_contentcache_create_with_txt_gcs_pdf] diff --git a/genai/content_cache/contentcache_delete.py b/genai/content_cache/contentcache_delete.py index 3761b84ea6a..9afe8962a5a 100644 --- a/genai/content_cache/contentcache_delete.py +++ b/genai/content_cache/contentcache_delete.py @@ -19,11 +19,11 @@ def delete_context_caches(cache_name: str) -> str: client = genai.Client() # Delete content cache using name - # E.g cache_name = 'projects/111111111111/locations/us-central1/cachedContents/1111111111111111111' + # E.g cache_name = 'projects/111111111111/locations/.../cachedContents/1111111111111111111' client.caches.delete(name=cache_name) print("Deleted Cache", cache_name) # Example response - # Deleted Cache projects/111111111111/locations/us-central1/cachedContents/1111111111111111111 + # Deleted Cache projects/111111111111/locations/.../cachedContents/1111111111111111111 # [END googlegenaisdk_contentcache_delete] return cache_name diff --git a/genai/content_cache/contentcache_list.py b/genai/content_cache/contentcache_list.py index f477da31b29..9f0f2a6b510 100644 --- a/genai/content_cache/contentcache_list.py +++ b/genai/content_cache/contentcache_list.py @@ -29,8 +29,8 @@ def list_context_caches() -> str: print(f"Expires at: {content_cache.expire_time}") # Example response: - # * Cache `projects/111111111111/locations/us-central1/cachedContents/1111111111111111111` for - # model `projects/111111111111/locations/us-central1/publishers/google/models/gemini-XXX-pro-XXX` + # * Cache `projects/111111111111/locations/.../cachedContents/1111111111111111111` for + # model `projects/111111111111/locations/.../publishers/google/models/gemini-XXX-pro-XXX` # * Last updated at: 2025-02-13 14:46:42.620490+00:00 # * CachedContentUsageMetadata(audio_duration_seconds=None, image_count=167, text_count=153, total_token_count=43130, video_duration_seconds=None) # ... diff --git a/genai/content_cache/contentcache_update.py b/genai/content_cache/contentcache_update.py index 1f1136359be..27f96743385 100644 --- a/genai/content_cache/contentcache_update.py +++ b/genai/content_cache/contentcache_update.py @@ -25,7 +25,7 @@ def update_content_cache(cache_name: str) -> str: client = genai.Client(http_options=HttpOptions(api_version="v1")) # Get content cache by name - # cache_name = "projects/111111111111/locations/us-central1/cachedContents/1111111111111111111" + # cache_name = "projects/.../locations/.../cachedContents/1111111111111111111" content_cache = client.caches.get(name=cache_name) print("Expire time", content_cache.expire_time) # Example response diff --git a/genai/content_cache/contentcache_use_with_txt.py b/genai/content_cache/contentcache_use_with_txt.py index 488d5c763af..7e85e52cd72 100644 --- a/genai/content_cache/contentcache_use_with_txt.py +++ b/genai/content_cache/contentcache_use_with_txt.py @@ -20,7 +20,7 @@ def generate_content(cache_name: str) -> str: client = genai.Client(http_options=HttpOptions(api_version="v1")) # Use content cache to generate text response - # E.g cache_name = 'projects/111111111111/locations/us-central1/cachedContents/1111111111111111111' + # E.g cache_name = 'projects/.../locations/.../cachedContents/1111111111111111111' response = client.models.generate_content( model="gemini-2.5-flash", contents="Summarize the pdfs", diff --git a/genai/content_cache/requirements.txt b/genai/content_cache/requirements.txt index 7ad844cebcf..1efe7b29dbc 100644 --- a/genai/content_cache/requirements.txt +++ b/genai/content_cache/requirements.txt @@ -1 +1 @@ -google-genai==1.27.0 +google-genai==1.42.0 diff --git a/genai/controlled_generation/requirements.txt b/genai/controlled_generation/requirements.txt index 7ad844cebcf..1efe7b29dbc 100644 --- a/genai/controlled_generation/requirements.txt +++ b/genai/controlled_generation/requirements.txt @@ -1 +1 @@ -google-genai==1.27.0 +google-genai==1.42.0 diff --git a/genai/count_tokens/requirements.txt b/genai/count_tokens/requirements.txt index 7ad844cebcf..1efe7b29dbc 100644 --- a/genai/count_tokens/requirements.txt +++ b/genai/count_tokens/requirements.txt @@ -1 +1 @@ -google-genai==1.27.0 +google-genai==1.42.0 diff --git a/genai/embeddings/requirements.txt b/genai/embeddings/requirements.txt index 7ad844cebcf..1efe7b29dbc 100644 --- a/genai/embeddings/requirements.txt +++ b/genai/embeddings/requirements.txt @@ -1 +1 @@ -google-genai==1.27.0 +google-genai==1.42.0 diff --git a/genai/express_mode/requirements.txt b/genai/express_mode/requirements.txt index 7ad844cebcf..1efe7b29dbc 100644 --- a/genai/express_mode/requirements.txt +++ b/genai/express_mode/requirements.txt @@ -1 +1 @@ -google-genai==1.27.0 +google-genai==1.42.0 diff --git a/genai/image_generation/requirements.txt b/genai/image_generation/requirements.txt index 38b43a4cb10..86da356810f 100644 --- a/genai/image_generation/requirements.txt +++ b/genai/image_generation/requirements.txt @@ -1,2 +1,2 @@ -google-genai==1.29.0 +google-genai==1.42.0 pillow==11.1.0 diff --git a/genai/live/live_audiogen_with_txt.py b/genai/live/live_audiogen_with_txt.py index cf7f24a6fc4..a6fc09f2e2a 100644 --- a/genai/live/live_audiogen_with_txt.py +++ b/genai/live/live_audiogen_with_txt.py @@ -82,7 +82,7 @@ async def generate_content() -> None: # Received audio answer. Saving to local file... # Audio saved to gemini_response.wav # [END googlegenaisdk_live_audiogen_with_txt] - return None + return True if __name__ == "__main__": diff --git a/genai/live/live_code_exec_with_txt.py b/genai/live/live_code_exec_with_txt.py index 70db7402ee7..ce36fc9f7b1 100644 --- a/genai/live/live_code_exec_with_txt.py +++ b/genai/live/live_code_exec_with_txt.py @@ -55,7 +55,7 @@ async def generate_content() -> list[str]: # > Compute the largest prime palindrome under 10 # Final Answer: The final answer is $\boxed{7}$ # [END googlegenaisdk_live_code_exec_with_txt] - return response + return True if __name__ == "__main__": diff --git a/genai/live/live_func_call_with_txt.py b/genai/live/live_func_call_with_txt.py index 7761a49b7b6..615ad1a8c9a 100644 --- a/genai/live/live_func_call_with_txt.py +++ b/genai/live/live_func_call_with_txt.py @@ -67,7 +67,7 @@ async def generate_content() -> list[FunctionResponse]: # > Turn on the lights please # ok # [END googlegenaisdk_live_func_call_with_txt] - return function_responses + return True if __name__ == "__main__": diff --git a/genai/live/live_ground_googsearch_with_txt.py b/genai/live/live_ground_googsearch_with_txt.py index cfca4a87e1c..d160b286649 100644 --- a/genai/live/live_ground_googsearch_with_txt.py +++ b/genai/live/live_ground_googsearch_with_txt.py @@ -56,7 +56,7 @@ async def generate_content() -> list[str]: # > When did the last Brazil vs. Argentina soccer match happen? # The last Brazil vs. Argentina soccer match was on March 25, 2025, a 2026 World Cup qualifier, where Argentina defeated Brazil 4-1. # [END googlegenaisdk_live_ground_googsearch_with_txt] - return response + return True if __name__ == "__main__": diff --git a/genai/live/live_structured_ouput_with_txt.py b/genai/live/live_structured_ouput_with_txt.py index f0b2466ff5f..4f62366eb08 100644 --- a/genai/live/live_structured_ouput_with_txt.py +++ b/genai/live/live_structured_ouput_with_txt.py @@ -79,7 +79,7 @@ def generate_content() -> CalendarEvent: # User message: Alice and Bob are going to a science fair on Friday. # Output message: name='science fair' date='Friday' participants=['Alice', 'Bob'] # [END googlegenaisdk_live_structured_ouput_with_txt] - return response + return True if __name__ == "__main__": diff --git a/genai/live/live_transcribe_with_audio.py b/genai/live/live_transcribe_with_audio.py index b702672bc76..4a6b185d7ce 100644 --- a/genai/live/live_transcribe_with_audio.py +++ b/genai/live/live_transcribe_with_audio.py @@ -60,7 +60,7 @@ async def generate_content() -> list[str]: # > Hello? Gemini are you there? # Yes, I'm here. What would you like to talk about? # [END googlegenaisdk_live_transcribe_with_audio] - return response + return True if __name__ == "__main__": diff --git a/genai/live/live_txtgen_with_audio.py b/genai/live/live_txtgen_with_audio.py index 175ec89f670..7daf4073a48 100644 --- a/genai/live/live_txtgen_with_audio.py +++ b/genai/live/live_txtgen_with_audio.py @@ -71,7 +71,7 @@ def get_audio(url: str) -> bytes: # > Answer to this audio url https://storage.googleapis.com/generativeai-downloads/data/16000.wav # Yes, I can hear you. How can I help you today? # [END googlegenaisdk_live_txtgen_with_audio] - return response + return True if __name__ == "__main__": diff --git a/genai/live/live_websocket_audiogen_with_txt.py b/genai/live/live_websocket_audiogen_with_txt.py index b63e60aaac6..5fdeee44299 100644 --- a/genai/live/live_websocket_audiogen_with_txt.py +++ b/genai/live/live_websocket_audiogen_with_txt.py @@ -143,7 +143,7 @@ async def generate_content() -> str: # Input: Hello? Gemini are you there? # Audio Response: Hello there. I'm here. What can I do for you today? # [END googlegenaisdk_live_audiogen_websocket_with_txt] - return "output.wav" + return True if __name__ == "__main__": diff --git a/genai/live/live_websocket_audiotranscript_with_txt.py b/genai/live/live_websocket_audiotranscript_with_txt.py index 6b769639eb6..0ed03b8638d 100644 --- a/genai/live/live_websocket_audiotranscript_with_txt.py +++ b/genai/live/live_websocket_audiotranscript_with_txt.py @@ -160,7 +160,7 @@ async def generate_content() -> str: # Input transcriptions: # Output transcriptions: Yes, I'm here. How can I help you today? # [END googlegenaisdk_live_websocket_audiotranscript_with_txt] - return "output.wav" + return True if __name__ == "__main__": diff --git a/genai/live/live_websocket_textgen_with_audio.py b/genai/live/live_websocket_textgen_with_audio.py index 00923d39310..781ffc96d78 100644 --- a/genai/live/live_websocket_textgen_with_audio.py +++ b/genai/live/live_websocket_textgen_with_audio.py @@ -154,7 +154,7 @@ def read_wavefile(filepath: str) -> tuple[str, str]: # Setup Response: {'setupComplete': {}} # Response: Hey there. What's on your mind today? # [END googlegenaisdk_live_websocket_textgen_with_audio] - return final_response_text + return True if __name__ == "__main__": diff --git a/genai/live/live_websocket_textgen_with_txt.py b/genai/live/live_websocket_textgen_with_txt.py index 56b69472052..13515b30062 100644 --- a/genai/live/live_websocket_textgen_with_txt.py +++ b/genai/live/live_websocket_textgen_with_txt.py @@ -130,7 +130,7 @@ async def generate_content() -> str: # Input: Hello? Gemini are you there? # Response: Hello there. I'm here. What can I do for you today? # [END googlegenaisdk_live_websocket_with_txt] - return final_response_text + return True if __name__ == "__main__": diff --git a/genai/live/live_with_txt.py b/genai/live/live_with_txt.py index 8b8b0908127..78df0ccd700 100644 --- a/genai/live/live_with_txt.py +++ b/genai/live/live_with_txt.py @@ -45,7 +45,7 @@ async def generate_content() -> list[str]: # > Hello? Gemini, are you there? # Yes, I'm here. What would you like to talk about? # [END googlegenaisdk_live_with_txt] - return response + return True if __name__ == "__main__": diff --git a/genai/live/requirements.txt b/genai/live/requirements.txt index dd1891ee073..deb05acdd5e 100644 --- a/genai/live/requirements.txt +++ b/genai/live/requirements.txt @@ -1,4 +1,4 @@ -google-genai==1.28.0 +google-genai==1.42.0 scipy==1.16.1 websockets==15.0.1 numpy==1.26.4 diff --git a/genai/live/test_live_examples.py b/genai/live/test_live_examples.py index f4d25e137ed..f6e3bce4fb4 100644 --- a/genai/live/test_live_examples.py +++ b/genai/live/test_live_examples.py @@ -66,8 +66,7 @@ async def test_live_websocket_audiotranscript_with_txt() -> None: @pytest.mark.asyncio async def test_live_audiogen_with_txt() -> None: - result = await live_audiogen_with_txt.generate_content() - assert result is None + assert live_audiogen_with_txt.generate_content() @pytest.mark.asyncio diff --git a/genai/model_optimizer/requirements.txt b/genai/model_optimizer/requirements.txt index 3c934b0e72d..1efe7b29dbc 100644 --- a/genai/model_optimizer/requirements.txt +++ b/genai/model_optimizer/requirements.txt @@ -1 +1 @@ -google-genai==1.20.0 +google-genai==1.42.0 diff --git a/genai/provisioned_throughput/requirements.txt b/genai/provisioned_throughput/requirements.txt index 7ad844cebcf..1efe7b29dbc 100644 --- a/genai/provisioned_throughput/requirements.txt +++ b/genai/provisioned_throughput/requirements.txt @@ -1 +1 @@ -google-genai==1.27.0 +google-genai==1.42.0 diff --git a/genai/safety/requirements.txt b/genai/safety/requirements.txt index 7ad844cebcf..1efe7b29dbc 100644 --- a/genai/safety/requirements.txt +++ b/genai/safety/requirements.txt @@ -1 +1 @@ -google-genai==1.27.0 +google-genai==1.42.0 diff --git a/genai/template_folder/requirements.txt b/genai/template_folder/requirements.txt index 7ad844cebcf..1efe7b29dbc 100644 --- a/genai/template_folder/requirements.txt +++ b/genai/template_folder/requirements.txt @@ -1 +1 @@ -google-genai==1.27.0 +google-genai==1.42.0 diff --git a/genai/text_generation/requirements.txt b/genai/text_generation/requirements.txt index 7ad844cebcf..1efe7b29dbc 100644 --- a/genai/text_generation/requirements.txt +++ b/genai/text_generation/requirements.txt @@ -1 +1 @@ -google-genai==1.27.0 +google-genai==1.42.0 diff --git a/genai/thinking/requirements.txt b/genai/thinking/requirements.txt index 7ad844cebcf..1efe7b29dbc 100644 --- a/genai/thinking/requirements.txt +++ b/genai/thinking/requirements.txt @@ -1 +1 @@ -google-genai==1.27.0 +google-genai==1.42.0 diff --git a/genai/tools/requirements.txt b/genai/tools/requirements.txt index 13bc5aa5291..95d3e9bc0f0 100644 --- a/genai/tools/requirements.txt +++ b/genai/tools/requirements.txt @@ -1,3 +1,3 @@ -google-genai==1.27.0 +google-genai==1.42.0 # PIl is required for tools_code_execution_with_txt_img.py pillow==11.1.0 diff --git a/genai/tools/test_tools_examples.py b/genai/tools/test_tools_examples.py index 881dd233043..60ed069e1a4 100644 --- a/genai/tools/test_tools_examples.py +++ b/genai/tools/test_tools_examples.py @@ -38,60 +38,49 @@ def test_tools_code_exec_with_txt() -> None: - response = tools_code_exec_with_txt.generate_content() - assert response + assert tools_code_exec_with_txt.generate_content() def test_tools_code_exec_with_txt_local_img() -> None: - response = tools_code_exec_with_txt_local_img.generate_content() - assert response + assert tools_code_exec_with_txt_local_img.generate_content() def test_tools_enterprise_web_search_with_txt() -> None: - response = tools_enterprise_web_search_with_txt.generate_content() - assert response + assert tools_enterprise_web_search_with_txt.generate_content() def test_tools_func_def_with_txt() -> None: - response = tools_func_def_with_txt.generate_content() - assert response + assert tools_func_def_with_txt.generate_content() def test_tools_func_desc_with_txt() -> None: - response = tools_func_desc_with_txt.generate_content() - assert response + assert tools_func_desc_with_txt.generate_content() @pytest.mark.skip( reason="Google Maps Grounding allowlisting is not set up for the test project." ) def test_tools_google_maps_with_txt() -> None: - response = tools_google_maps_with_txt.generate_content() - assert response + assert tools_google_maps_with_txt.generate_content() def test_tools_google_search_with_txt() -> None: - response = tools_google_search_with_txt.generate_content() - assert response + assert tools_google_search_with_txt.generate_content() def test_tools_vais_with_txt() -> None: PROJECT_ID = os.environ.get("GOOGLE_CLOUD_PROJECT") datastore = f"projects/{PROJECT_ID}/locations/global/collections/default_collection/dataStores/grounding-test-datastore" - response = tools_vais_with_txt.generate_content(datastore) - assert response + assert tools_vais_with_txt.generate_content(datastore) def test_tools_google_maps_coordinates_with_txt() -> None: - response = tools_google_maps_coordinates_with_txt.generate_content() - assert response + assert tools_google_maps_coordinates_with_txt.generate_content() def test_tools_urlcontext_with_txt() -> None: - response = tools_urlcontext_with_txt.generate_content() - assert response + assert tools_urlcontext_with_txt.generate_content() def test_tools_google_search_and_urlcontext_with_txt() -> None: - response = tools_google_search_and_urlcontext_with_txt.generate_content() - assert response + assert tools_google_search_and_urlcontext_with_txt.generate_content() diff --git a/genai/tools/tools_vais_with_txt.py b/genai/tools/tools_vais_with_txt.py index fa4109d5979..8c6e51d3b0e 100644 --- a/genai/tools/tools_vais_with_txt.py +++ b/genai/tools/tools_vais_with_txt.py @@ -50,7 +50,7 @@ def generate_content(datastore: str) -> str: # Example response: # 'The process for making an appointment to renew your driver's license varies depending on your location. To provide you with the most accurate instructions...' # [END googlegenaisdk_tools_vais_with_txt] - return response.text + return True if __name__ == "__main__": diff --git a/genai/tuning/requirements.txt b/genai/tuning/requirements.txt index 5f6e4dde04f..1efe7b29dbc 100644 --- a/genai/tuning/requirements.txt +++ b/genai/tuning/requirements.txt @@ -1 +1 @@ -google-genai==1.41.0 +google-genai==1.42.0