Skip to content

Commit 4f3ca6a

Browse files
vertex-sdk-botcopybara-github
authored andcommitted
feat: GenAI SDK client - add zero-shot prompt optimizer (streaming): an option to quickly improve or generate system instructions or a single prompt.
PiperOrigin-RevId: 789146000
1 parent 8f28c40 commit 4f3ca6a

File tree

3 files changed

+868
-725
lines changed

3 files changed

+868
-725
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
15+
# pylint: disable=protected-access,bad-continuation,missing-function-docstring
16+
17+
import logging
18+
19+
from tests.unit.vertexai.genai.replays import pytest_helper
20+
from vertexai._genai import types
21+
import pytest
22+
23+
logger = logging.getLogger("vertexai_genai.promptoptimizer")
24+
logging.basicConfig(encoding="utf-8", level=logging.DEBUG, force=True)
25+
26+
27+
def test_optimize_prompt(client):
28+
"""Tests the optimize request parameters method."""
29+
30+
logger.info("test_optimize_prompt")
31+
client._api_client._http_options.base_url = (
32+
"https://us-central1-autopush-aiplatform.sandbox.googleapis.com"
33+
)
34+
test_prompt = "Generate system instructions for analyzing medical articles"
35+
response = client.prompt_optimizer.optimize_prompt(prompt=test_prompt)
36+
logger.info("response type: %s", type(response))
37+
logger.info("response: %s", response)
38+
39+
40+
pytestmark = pytest_helper.setup(
41+
file=__file__,
42+
globals_for_file=globals(),
43+
test_method="prompt_optimizer.optimize_prompt",
44+
)

0 commit comments

Comments
 (0)