diff --git a/generative_ai/inference/inference_api_test.py b/generative_ai/inference/inference_api_test.py deleted file mode 100644 index b3c1f238a9d..00000000000 --- a/generative_ai/inference/inference_api_test.py +++ /dev/null @@ -1,38 +0,0 @@ -# Copyright 2024 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 -# -# https://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. - -import non_stream_multimodality_basic -import non_stream_text_basic -import stream_multimodality_basic -import stream_text_basic - - -def test_non_stream_text_basic() -> None: - response = non_stream_text_basic.generate_content() - assert response - - -def test_non_stream_multi_modality_basic() -> None: - response = non_stream_multimodality_basic.generate_content() - assert response - - -def test_stream_text_basic() -> None: - responses = stream_text_basic.generate_content() - assert responses - - -def test_stream_multi_modality_basic() -> None: - responses = stream_multimodality_basic.generate_content() - assert responses diff --git a/generative_ai/inference/non_stream_multimodality_basic.py b/generative_ai/inference/non_stream_multimodality_basic.py deleted file mode 100644 index b4130a27cbe..00000000000 --- a/generative_ai/inference/non_stream_multimodality_basic.py +++ /dev/null @@ -1,49 +0,0 @@ -# Copyright 2024 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 -# -# https://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. - -import os - -PROJECT_ID = os.getenv("GOOGLE_CLOUD_PROJECT") - - -def generate_content() -> object: - # [START generativeaionvertexai_non_stream_multimodality_basic] - import vertexai - - from vertexai.generative_models import GenerativeModel, Part - - vertexai.init(project=PROJECT_ID, location="us-central1") - - model = GenerativeModel("gemini-1.5-flash-002") - response = model.generate_content( - [ - Part.from_uri( - "gs://cloud-samples-data/generative-ai/video/animals.mp4", "video/mp4" - ), - Part.from_uri( - "gs://cloud-samples-data/generative-ai/image/character.jpg", - "image/jpeg", - ), - "Are these video and image correlated?", - ] - ) - - print(response.text) - # [END generativeaionvertexai_non_stream_multimodality_basic] - - return response - - -if __name__ == "__main__": - generate_content() diff --git a/generative_ai/inference/non_stream_text_basic.py b/generative_ai/inference/non_stream_text_basic.py deleted file mode 100644 index 07a5727f8ab..00000000000 --- a/generative_ai/inference/non_stream_text_basic.py +++ /dev/null @@ -1,38 +0,0 @@ -# Copyright 2024 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 -# -# https://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. - -import os - -PROJECT_ID = os.getenv("GOOGLE_CLOUD_PROJECT") - - -def generate_content() -> object: - # [START generativeaionvertexai_non_stream_text_basic] - import vertexai - - from vertexai.generative_models import GenerativeModel - - vertexai.init(project=PROJECT_ID, location="us-central1") - - model = GenerativeModel("gemini-1.5-flash-002") - response = model.generate_content("Write a story about a magic backpack.") - - print(response.text) - # [END generativeaionvertexai_non_stream_text_basic] - - return response - - -if __name__ == "__main__": - generate_content() diff --git a/generative_ai/inference/noxfile_config.py b/generative_ai/inference/noxfile_config.py deleted file mode 100644 index 962ba40a926..00000000000 --- a/generative_ai/inference/noxfile_config.py +++ /dev/null @@ -1,42 +0,0 @@ -# Copyright 2021 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. - -# Default TEST_CONFIG_OVERRIDE for python repos. - -# You can copy this file into your directory, then it will be imported from -# the noxfile.py. - -# The source of truth: -# https://github.com/GoogleCloudPlatform/python-docs-samples/blob/main/noxfile_config.py - -TEST_CONFIG_OVERRIDE = { - # You can opt out from the test for specific Python versions. - "ignored_versions": ["2.7", "3.7", "3.8", "3.10", "3.11", "3.13"], - # Old samples are opted out of enforcing Python type hints - # All new samples should feature them - "enforce_type_hints": True, - # An envvar key for determining the project id to use. Change it - # to 'BUILD_SPECIFIC_GCLOUD_PROJECT' if you want to opt in using a - # build specific Cloud project. You can also use your own string - # to use your own Cloud project. - "gcloud_project_env": "GOOGLE_CLOUD_PROJECT", - # 'gcloud_project_env': 'BUILD_SPECIFIC_GCLOUD_PROJECT', - # If you need to use a specific version of pip, - # change pip_version_override to the string representation - # of the version number, for example, "20.2.4" - "pip_version_override": None, - # A dictionary you want to inject into your test. Don't put any - # secrets here. These values will override predefined values. - "envs": {}, -} diff --git a/generative_ai/inference/requirements-test.txt b/generative_ai/inference/requirements-test.txt deleted file mode 100644 index 92281986e50..00000000000 --- a/generative_ai/inference/requirements-test.txt +++ /dev/null @@ -1,4 +0,0 @@ -backoff==2.2.1 -google-api-core==2.19.0 -pytest==8.2.0 -pytest-asyncio==0.23.6 diff --git a/generative_ai/inference/requirements.txt b/generative_ai/inference/requirements.txt deleted file mode 100644 index 8c94bb4d15a..00000000000 --- a/generative_ai/inference/requirements.txt +++ /dev/null @@ -1,14 +0,0 @@ -pandas==2.2.3; python_version == '3.7' -pandas==2.2.3; python_version == '3.8' -pandas==2.2.3; python_version > '3.8' -pillow==10.3.0; python_version < '3.8' -pillow==10.3.0; python_version >= '3.8' -google-cloud-aiplatform[all]==1.69.0 -sentencepiece==0.2.0 -google-auth==2.38.0 -anthropic[vertex]==0.28.0 -langchain-core==0.2.33 -langchain-google-vertexai==1.0.10 -numpy<2 -openai==1.30.5 -immutabledict==4.2.0 diff --git a/generative_ai/inference/stream_multimodality_basic.py b/generative_ai/inference/stream_multimodality_basic.py deleted file mode 100644 index 63d9f7d457b..00000000000 --- a/generative_ai/inference/stream_multimodality_basic.py +++ /dev/null @@ -1,49 +0,0 @@ -# Copyright 2024 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 -# -# https://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. -import os - -PROJECT_ID = os.getenv("GOOGLE_CLOUD_PROJECT") - - -def generate_content() -> object: - # [START generativeaionvertexai_stream_multimodality_basic] - import vertexai - - from vertexai.generative_models import GenerativeModel, Part - - # TODO(developer): Update & un-comment the lines below - # PROJECT_ID = "your-project-id" - - vertexai.init(project=PROJECT_ID, location="us-central1") - - model = GenerativeModel("gemini-1.5-flash-002") - responses = model.generate_content( - [ - Part.from_uri( - "gs://cloud-samples-data/generative-ai/video/animals.mp4", "video/mp4" - ), - Part.from_uri( - "gs://cloud-samples-data/generative-ai/image/character.jpg", - "image/jpeg", - ), - "Are these video and image correlated?", - ], - stream=True, - ) - - for response in responses: - print(response) - # [END generativeaionvertexai_stream_multimodality_basic] - - return responses diff --git a/generative_ai/inference/stream_text_basic.py b/generative_ai/inference/stream_text_basic.py deleted file mode 100644 index 28c11807159..00000000000 --- a/generative_ai/inference/stream_text_basic.py +++ /dev/null @@ -1,42 +0,0 @@ -# Copyright 2024 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 -# -# https://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. - -import os - -PROJECT_ID = os.getenv("GOOGLE_CLOUD_PROJECT") - - -def generate_content() -> object: - # [START generativeaionvertexai_stream_text_basic] - import vertexai - - from vertexai.generative_models import GenerativeModel - - # TODO(developer): Update Project ID - vertexai.init(project=PROJECT_ID, location="us-central1") - - model = GenerativeModel("gemini-1.5-flash-002") - responses = model.generate_content( - "Write a story about a magic backpack.", stream=True - ) - - for response in responses: - print(response.text) - # [END generativeaionvertexai_stream_text_basic] - - return responses - - -if __name__ == "__main__": - generate_content()