GeezerVison is showing github.com — docs: Update Gemini docs · googleapis/python-aiplatform@c561aa6
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: README.rst +4-12Lines changed: 4 additions & 12 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -3,6 +3,10 @@ Vertex AI SDK for Python | 3 | 3 |
| 4 | 4 | |GA| |pypi| |versions| |unit-tests| |system-tests| |sample-tests| | 5 | 5 |
| | 6 | +.. note:: | | 7 | + | | 8 | + For Gemini API and Generative AI on Vertex AI, please reference `Vertex Generative AI SDK for Python`_ | | 9 | +.. _Vertex Generative AI SDK for Python: https://cloud.google.com/vertex-ai/generative-ai/docs/reference/python/latest | 6 | 10 |
| 7 | 11 | `Vertex AI`_: Google Vertex AI is an integrated suite of machine learning tools and services for building and using ML models with AutoML or custom code. It offers both novices and experts the best workbench for the entire machine learning development lifecycle. | 8 | 12 |
| @@ -113,18 +117,6 @@ Vertex AI SDK resource based functionality can be used by importing the followin | 113 | 117 |
| 114 | 118 | from google.cloud import aiplatform | 115 | 119 |
| 116 | | -Vertex AI SDK preview functionality can be used by importing the following namespace: | 117 | | - | 118 | | -.. code-block:: Python | 119 | | -
| 120 | | - from vertexai import preview | 121 | | -
| 122 | | -Vertex AI SDK general availability (GA) functionality can be used by importing the following namespace: | 123 | | - | 124 | | -.. code-block:: Python | 125 | | -
| 126 | | - import vertexai | 127 | | -
| 128 | 120 | Initialization | 129 | 121 | ^^^^^^^^^^^^^^ | 130 | 122 | Initialize the SDK to store common configurations that you use with the SDK. | |
Collapse file Copy file name to clipboardExpand all lines: docs/README.rst +16-22Lines changed: 16 additions & 22 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | Vertex AI SDK for Python | 2 | 2 | ================================================= | 3 | 3 |
| 4 | | -|GA| |pypi| |versions| | | 4 | +|GA| |pypi| |versions| |unit-tests| |system-tests| |sample-tests| | | 5 | + | | 6 | +.. note:: | | 7 | + | | 8 | + For Gemini API and Generative AI on Vertex AI, please reference `Vertex Generative AI SDK for Python`_ | | 9 | +.. _Vertex Generative AI SDK for Python: https://cloud.google.com/vertex-ai/generative-ai/docs/reference/python/latest | 5 | 10 |
| 6 | 11 | `Vertex AI`_: Google Vertex AI is an integrated suite of machine learning tools and services for building and using ML models with AutoML or custom code. It offers both novices and experts the best workbench for the entire machine learning development lifecycle. | 7 | 12 |
| @@ -14,11 +19,16 @@ Vertex AI SDK for Python | 14 | 19 | :target: https://pypi.org/project/google-cloud-aiplatform/ | 15 | 20 | .. |versions| image:: https://img.shields.io/pypi/pyversions/google-cloud-aiplatform.svg | 16 | 21 | :target: https://pypi.org/project/google-cloud-aiplatform/ | | 22 | +.. |unit-tests| image:: https://storage.googleapis.com/cloud-devrel-public/python-aiplatform/badges/sdk-unit-tests.svg | | 23 | + :target: https://storage.googleapis.com/cloud-devrel-public/python-aiplatform/badges/sdk-unit-tests.html | | 24 | +.. |system-tests| image:: https://storage.googleapis.com/cloud-devrel-public/python-aiplatform/badges/sdk-system-tests.svg | | 25 | + :target: https://storage.googleapis.com/cloud-devrel-public/python-aiplatform/badges/sdk-system-tests.html | | 26 | +.. |sample-tests| image:: https://storage.googleapis.com/cloud-devrel-public/python-aiplatform/badges/sdk-sample-tests.svg | | 27 | + :target: https://storage.googleapis.com/cloud-devrel-public/python-aiplatform/badges/sdk-sample-tests.html | 17 | 28 | .. _Vertex AI: https://cloud.google.com/vertex-ai/docs | 18 | | -.. _Client Library Documentation: https://cloud.google.com/python/docs/reference/aiplatform/latest/summary_overview | | 29 | +.. _Client Library Documentation: https://cloud.google.com/python/docs/reference/aiplatform/latest | 19 | 30 | .. _Product Documentation: https://cloud.google.com/vertex-ai/docs | 20 | 31 |
| 21 | | - | 22 | 32 | Quick Start | 23 | 33 | ----------- | 24 | 34 |
| @@ -59,7 +69,6 @@ Mac/Linux | 59 | 69 | <your-env>/bin/pip install google-cloud-aiplatform | 60 | 70 |
| 61 | 71 |
| 62 | | -
| 63 | 72 | Windows | 64 | 73 | ^^^^^^^ | 65 | 74 |
| @@ -70,6 +79,7 @@ Windows | 70 | 79 | <your-env>\Scripts\activate | 71 | 80 | <your-env>\Scripts\pip.exe install google-cloud-aiplatform | 72 | 81 |
| | 82 | +
| 73 | 83 | Supported Python Versions | 74 | 84 | ^^^^^^^^^^^^^^^^^^^^^^^^^ | 75 | 85 | Python >= 3.8 | @@ -107,18 +117,6 @@ Vertex AI SDK resource based functionality can be used by importing the followin | 107 | 117 |
| 108 | 118 | from google.cloud import aiplatform | 109 | 119 |
| 110 | | -Vertex AI SDK preview functionality can be used by importing the following namespace: | 111 | | - | 112 | | -.. code-block:: Python | 113 | | -
| 114 | | - from vertexai import preview | 115 | | -
| 116 | | -Vertex AI SDK general availability (GA) functionality can be used by importing the following namespace: | 117 | | - | 118 | | -.. code-block:: Python | 119 | | -
| 120 | | - import vertexai | 121 | | -
| 122 | 120 | Initialization | 123 | 121 | ^^^^^^^^^^^^^^ | 124 | 122 | Initialize the SDK to store common configurations that you use with the SDK. | @@ -175,8 +173,8 @@ You can also create and import a dataset in separate steps: | 175 | 173 | my_dataset = aiplatform.TextDataset.create( | 176 | 174 | display_name="my-dataset") | 177 | 175 |
| 178 | | - my_dataset.import( | 179 | | - gcs_source=['gs://path/to/my/dataset.csv'] | | 176 | + my_dataset.import_data( | | 177 | + gcs_source=['gs://path/to/my/dataset.csv'], | 180 | 178 | import_schema_uri=aiplatform.schema.dataset.ioformat.text.multi_label_classification | 181 | 179 | ) | 182 | 180 |
| @@ -232,7 +230,6 @@ It must write the model artifact to the environment variable populated by the tr | 232 | 230 | container_uri="us-docker.pkg.dev/vertex-ai/training/tf-cpu.2-2:latest", | 233 | 231 | requirements=["gcsfs==0.7.1"], | 234 | 232 | model_serving_container_image_uri="us-docker.pkg.dev/vertex-ai/prediction/tf2-cpu.2-2:latest", | 235 | | -
| 236 | 233 | ) | 237 | 234 |
| 238 | 235 | model = job.run(my_dataset, | @@ -312,7 +309,6 @@ Please visit `Importing models to Vertex AI`_ for a detailed overview: | 312 | 309 |
| 313 | 310 | .. _Importing models to Vertex AI: https://cloud.google.com/vertex-ai/docs/general/import-model | 314 | 311 |
| 315 | | - | 316 | 312 | Model Evaluation | 317 | 313 | ---------------- | 318 | 314 |
| @@ -417,7 +413,6 @@ To get predictions from endpoints: | 417 | 413 |
| 418 | 414 | endpoint.predict(instances=[[6.7, 3.1, 4.7, 1.5], [4.6, 3.1, 1.5, 0.2]]) | 419 | 415 |
| 420 | | -
| 421 | 416 | To undeploy models from an endpoint: | 422 | 417 |
| 423 | 418 | .. code-block:: Python | @@ -540,7 +535,6 @@ To use Explanation Metadata in endpoint deployment and model upload: | 540 | 535 | aiplatform.Model.upload(..., explanation_metadata=explanation_metadata) | 541 | 536 |
| 542 | 537 |
| 543 | | -
| 544 | 538 | Cloud Profiler | 545 | 539 | ---------------------------- | 546 | 540 |
| |
Collapse file Copy file name to clipboardExpand all lines: gemini_docs/README.md +16-11Lines changed: 16 additions & 11 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | # Vertex Generative AI SDK for Python | 2 | 2 | The Vertex Generative AI SDK helps developers use Google's generative AI | 3 | 3 | [Gemini models](http://cloud.google.com/vertex-ai/docs/generative-ai/multimodal/overview) | 4 | | -and [PaLM language models](http://cloud.google.com/vertex-ai/docs/generative-ai/language-model-overview) | 5 | 4 | to build AI-powered features and applications. | 6 | 5 | The SDKs support use cases like the following: | 7 | 6 |
| @@ -25,7 +24,13 @@ For detailed instructions, see [quickstart](http://cloud.google.com/vertex-ai/do | 25 | 24 |
| 26 | 25 | #### Imports: | 27 | 26 | ```python | 28 | | -from vertexai.generative_models import GenerativeModel, Image, Content, Part, Tool, FunctionDeclaration, GenerationConfig | | 27 | +import vertexai | | 28 | +``` | | 29 | + | | 30 | +#### Initialization: | | 31 | + | | 32 | +```python | | 33 | +vertexai.init(project='my-project', location='us-central1') | 29 | 34 | ``` | 30 | 35 |
| 31 | 36 | #### Basic generation: | @@ -54,7 +59,7 @@ print(vision_model.generate_content(["What is in the video? ", video_part])) | 54 | 59 | ``` | 55 | 60 |
| 56 | 61 | #### Chat | 57 | | -``` | | 62 | +```python | 58 | 63 | from vertexai.generative_models import GenerativeModel, Image | 59 | 64 | vision_model = GenerativeModel("gemini-ultra-vision") | 60 | 65 | vision_chat = vision_model.start_chat() | @@ -64,7 +69,7 @@ print(vision_chat.send_message("What things do I like?.")) | 64 | 69 | ``` | 65 | 70 |
| 66 | 71 | #### System instructions | 67 | | -``` | | 72 | +```python | 68 | 73 | from vertexai.generative_models import GenerativeModel | 69 | 74 | model = GenerativeModel( | 70 | 75 | "gemini-1.0-pro", | @@ -78,7 +83,7 @@ print(model.generate_content("Why is sky blue?")) | 78 | 83 |
| 79 | 84 | #### Function calling | 80 | 85 |
| 81 | | -``` | | 86 | +```python | 82 | 87 | # First, create tools that the model is can use to answer your questions. | 83 | 88 | # Describe a function by specifying it's schema (JsonSchema format) | 84 | 89 | get_current_weather_func = generative_models.FunctionDeclaration( | @@ -132,7 +137,7 @@ print(chat.send_message( | 132 | 137 |
| 133 | 138 | #### Automatic Function calling | 134 | 139 |
| 135 | | -``` | | 140 | +```python | 136 | 141 | from vertexai.preview.generative_models import GenerativeModel, Tool, FunctionDeclaration, AutomaticFunctionCallingResponder | 137 | 142 |
| 138 | 143 | # First, create functions that the model can use to answer your questions. | @@ -179,7 +184,7 @@ print(chat.send_message("What is the weather like in Boston?")) | 179 | 184 |
| 180 | 185 | - To perform bring-your-own-response(BYOR) evaluation, provide the model responses in the `response` column in the dataset. If a pairwise metric is used for BYOR evaluation, provide the baseline model responses in the `baseline_model_response` column. | 181 | 186 |
| 182 | | -``` | | 187 | +```python | 183 | 188 | import pandas as pd | 184 | 189 | from vertexai.evaluation import EvalTask, MetricPromptTemplateExamples | 185 | 190 |
| @@ -203,7 +208,7 @@ eval_result = eval_task.evaluate(experiment_run_name="eval-experiment-run") | 203 | 208 | ``` | 204 | 209 | - To perform evaluation with Gemini model inference, specify the `model` parameter with a `GenerativeModel` instance. The input column name to the model is `prompt` and must be present in the dataset. | 205 | 210 |
| 206 | | -``` | | 211 | +```python | 207 | 212 | from vertexai.evaluation import EvalTask | 208 | 213 | from vertexai.generative_models import GenerativeModel | 209 | 214 |
| @@ -223,7 +228,7 @@ result = EvalTask( | 223 | 228 |
| 224 | 229 | - If a `prompt_template` is specified, the `prompt` column is not required. Prompts can be assembled from the evaluation dataset, and all prompt template variable names must be present in the dataset columns. | 225 | 230 |
| 226 | | -``` | | 231 | +```python | 227 | 232 | import pandas as pd | 228 | 233 | from vertexai.evaluation import EvalTask, MetricPromptTemplateExamples | 229 | 234 | from vertexai.generative_models import GenerativeModel | @@ -245,7 +250,7 @@ result = EvalTask( | 245 | 250 | parameter with a custom inference function. The input column name to the | 246 | 251 | custom inference function is `prompt` and must be present in the dataset. | 247 | 252 |
| 248 | | -``` | | 253 | +```python | 249 | 254 | from openai import OpenAI | 250 | 255 | from vertexai.evaluation import EvalTask, MetricPromptTemplateExamples | 251 | 256 |
| @@ -279,7 +284,7 @@ the `baseline_model` input to a `PairwiseMetric` instance and the candidate | 279 | 284 | `model` input to the `EvalTask.evaluate()` function. The input column name | 280 | 285 | to both models is `prompt` and must be present in the dataset. | 281 | 286 |
| 282 | | -``` | | 287 | +```python | 283 | 288 | import pandas as pd | 284 | 289 | from vertexai.evaluation import EvalTask, MetricPromptTemplateExamples, PairwiseMetric | 285 | 290 | from vertexai.generative_models import GenerativeModel | |
|