Skip to content

Commit 2b84142

Browse files
sasha-gitgcopybara-github
authored andcommitted
docs: Update Gemini docs
PiperOrigin-RevId: 676646774
1 parent 55553ba commit 2b84142

File tree

3 files changed

+36
-45
lines changed

3 files changed

+36
-45
lines changed

README.rst

+4-12
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ Vertex AI SDK for Python
33

44
|GA| |pypi| |versions| |unit-tests| |system-tests| |sample-tests|
55

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
610

711
`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.
812

@@ -113,18 +117,6 @@ Vertex AI SDK resource based functionality can be used by importing the followin
113117
114118
from google.cloud import aiplatform
115119
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-
128120
Initialization
129121
^^^^^^^^^^^^^^
130122
Initialize the SDK to store common configurations that you use with the SDK.

docs/README.rst

+16-22
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
Vertex AI SDK for Python
22
=================================================
33

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
510

611
`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.
712

@@ -14,11 +19,16 @@ Vertex AI SDK for Python
1419
:target: https://pypi.org/project/google-cloud-aiplatform/
1520
.. |versions| image:: https://img.shields.io/pypi/pyversions/google-cloud-aiplatform.svg
1621
: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
1728
.. _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
1930
.. _Product Documentation: https://cloud.google.com/vertex-ai/docs
2031

21-
2232
Quick Start
2333
-----------
2434

@@ -59,7 +69,6 @@ Mac/Linux
5969
<your-env>/bin/pip install google-cloud-aiplatform
6070
6171
62-
6372
Windows
6473
^^^^^^^
6574

@@ -70,6 +79,7 @@ Windows
7079
<your-env>\Scripts\activate
7180
<your-env>\Scripts\pip.exe install google-cloud-aiplatform
7281
82+
7383
Supported Python Versions
7484
^^^^^^^^^^^^^^^^^^^^^^^^^
7585
Python >= 3.8
@@ -107,18 +117,6 @@ Vertex AI SDK resource based functionality can be used by importing the followin
107117
108118
from google.cloud import aiplatform
109119
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-
122120
Initialization
123121
^^^^^^^^^^^^^^
124122
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:
175173
my_dataset = aiplatform.TextDataset.create(
176174
display_name="my-dataset")
177175
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'],
180178
import_schema_uri=aiplatform.schema.dataset.ioformat.text.multi_label_classification
181179
)
182180
@@ -232,7 +230,6 @@ It must write the model artifact to the environment variable populated by the tr
232230
container_uri="us-docker.pkg.dev/vertex-ai/training/tf-cpu.2-2:latest",
233231
requirements=["gcsfs==0.7.1"],
234232
model_serving_container_image_uri="us-docker.pkg.dev/vertex-ai/prediction/tf2-cpu.2-2:latest",
235-
236233
)
237234
238235
model = job.run(my_dataset,
@@ -312,7 +309,6 @@ Please visit `Importing models to Vertex AI`_ for a detailed overview:
312309

313310
.. _Importing models to Vertex AI: https://cloud.google.com/vertex-ai/docs/general/import-model
314311

315-
316312
Model Evaluation
317313
----------------
318314

@@ -417,7 +413,6 @@ To get predictions from endpoints:
417413
418414
endpoint.predict(instances=[[6.7, 3.1, 4.7, 1.5], [4.6, 3.1, 1.5, 0.2]])
419415
420-
421416
To undeploy models from an endpoint:
422417

423418
.. code-block:: Python
@@ -540,7 +535,6 @@ To use Explanation Metadata in endpoint deployment and model upload:
540535
aiplatform.Model.upload(..., explanation_metadata=explanation_metadata)
541536
542537
543-
544538
Cloud Profiler
545539
----------------------------
546540

gemini_docs/README.md

+16-11
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# Vertex Generative AI SDK for Python
22
The Vertex Generative AI SDK helps developers use Google's generative AI
33
[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)
54
to build AI-powered features and applications.
65
The SDKs support use cases like the following:
76

@@ -25,7 +24,13 @@ For detailed instructions, see [quickstart](http://cloud.google.com/vertex-ai/do
2524

2625
#### Imports:
2726
```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')
2934
```
3035

3136
#### Basic generation:
@@ -54,7 +59,7 @@ print(vision_model.generate_content(["What is in the video? ", video_part]))
5459
```
5560

5661
#### Chat
57-
```
62+
```python
5863
from vertexai.generative_models import GenerativeModel, Image
5964
vision_model = GenerativeModel("gemini-ultra-vision")
6065
vision_chat = vision_model.start_chat()
@@ -64,7 +69,7 @@ print(vision_chat.send_message("What things do I like?."))
6469
```
6570

6671
#### System instructions
67-
```
72+
```python
6873
from vertexai.generative_models import GenerativeModel
6974
model = GenerativeModel(
7075
"gemini-1.0-pro",
@@ -78,7 +83,7 @@ print(model.generate_content("Why is sky blue?"))
7883

7984
#### Function calling
8085

81-
```
86+
```python
8287
# First, create tools that the model is can use to answer your questions.
8388
# Describe a function by specifying it's schema (JsonSchema format)
8489
get_current_weather_func = generative_models.FunctionDeclaration(
@@ -132,7 +137,7 @@ print(chat.send_message(
132137

133138
#### Automatic Function calling
134139

135-
```
140+
```python
136141
from vertexai.preview.generative_models import GenerativeModel, Tool, FunctionDeclaration, AutomaticFunctionCallingResponder
137142

138143
# 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?"))
179184

180185
- 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.
181186

182-
```
187+
```python
183188
import pandas as pd
184189
from vertexai.evaluation import EvalTask, MetricPromptTemplateExamples
185190

@@ -203,7 +208,7 @@ eval_result = eval_task.evaluate(experiment_run_name="eval-experiment-run")
203208
```
204209
- 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.
205210

206-
```
211+
```python
207212
from vertexai.evaluation import EvalTask
208213
from vertexai.generative_models import GenerativeModel
209214

@@ -223,7 +228,7 @@ result = EvalTask(
223228

224229
- 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.
225230

226-
```
231+
```python
227232
import pandas as pd
228233
from vertexai.evaluation import EvalTask, MetricPromptTemplateExamples
229234
from vertexai.generative_models import GenerativeModel
@@ -245,7 +250,7 @@ result = EvalTask(
245250
parameter with a custom inference function. The input column name to the
246251
custom inference function is `prompt` and must be present in the dataset.
247252

248-
```
253+
```python
249254
from openai import OpenAI
250255
from vertexai.evaluation import EvalTask, MetricPromptTemplateExamples
251256

@@ -279,7 +284,7 @@ the `baseline_model` input to a `PairwiseMetric` instance and the candidate
279284
`model` input to the `EvalTask.evaluate()` function. The input column name
280285
to both models is `prompt` and must be present in the dataset.
281286

282-
```
287+
```python
283288
import pandas as pd
284289
from vertexai.evaluation import EvalTask, MetricPromptTemplateExamples, PairwiseMetric
285290
from vertexai.generative_models import GenerativeModel

0 commit comments

Comments
 (0)