Skip to content

Commit 2f63b48

Browse files
sararobcopybara-github
authored andcommitted
docs: Update prompt optimizer code in readme to use methods from prompts module
PiperOrigin-RevId: 861224156
1 parent 044c3fa commit 2f63b48

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

README.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -173,19 +173,19 @@ You can also run queries against the deployed agent:
173173
Prompt optimization
174174
^^^^^^^^^^^^^^^^^^^
175175

176-
To do a zero-shot prompt optimization, use the `optimize_prompt`
176+
To do a zero-shot prompt optimization, use the `optimize`
177177
method.
178178

179179
.. code-block:: Python
180180
181181
prompt = "Generate system instructions for a question-answering assistant"
182-
response = client.prompt_optimizer.optimize_prompt(prompt=prompt)
182+
response = client.prompts.optimize(prompt=prompt)
183183
print(response.raw_text_response)
184184
if response.parsed_response:
185185
print(response.parsed_response.suggested_prompt)
186186
187-
To call the data-driven prompt optimization, call the `optimize` method.
188-
In this case however, we need to provide `vapo_config`. This config needs to
187+
To call the data-driven prompt optimization, call the `launch_optimization_job` method.
188+
In this case however, we need to provide a VAPO (Vertex AI Prompt Optimizer) config. This config needs to
189189
have either service account or project **number** and the config path.
190190
Please refer to this [tutorial](https://cloud.google.com/vertex-ai/generative-ai/docs/learn/prompts/data-driven-optimizer)
191191
for more details on config parameter.
@@ -206,7 +206,7 @@ for more details on config parameter.
206206
# Set up logging to see the progress of the optimization job
207207
logging.basicConfig(encoding='utf-8', level=logging.INFO, force=True)
208208
209-
result = client.prompt_optimizer.optimize(method="vapo", config=vapo_config)
209+
result = client.prompts.launch_optimization_job(method=types.PromptOptimizerMethod.VAPO, config=vapo_config)
210210
211211
If you want to use the project number instead of the service account, you can
212212
instead use the following config:
@@ -219,11 +219,11 @@ instead use the following config:
219219
wait_for_completion=False
220220
)
221221
222-
We can also call optimize method async.
222+
We can also call the `launch_optimization_job` method asynchronously.
223223

224224
.. code-block:: Python
225225
226-
await client.aio.prompt_optimizer.optimize(method="vapo", config=vapo_config)
226+
await client.aio.prompts.launch_optimization_job(method=types.PromptOptimizerMethod.VAPO, config=vapo_config)
227227
228228
Prompt Management
229229
^^^^^^^^^^^^^^^^^

0 commit comments

Comments
 (0)