Skip to content

Commit 3f7f976

Browse files
sararobcopybara-github
authored andcommitted
feat: GenAI SDK client - Add experimental delete_prompt() and delete_version() methods to Prompt Management
PiperOrigin-RevId: 808607739
1 parent 415cf26 commit 3f7f976

File tree

3 files changed

+651
-0
lines changed

3 files changed

+651
-0
lines changed
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
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+
from google.genai import types as genai_types
22+
23+
TEST_PROMPT_DATASET_ID = "6550997480673116160"
24+
TEST_PROMPT_VERSION_ID = "2"
25+
26+
27+
def test_delete_dataset(client, caplog):
28+
caplog.set_level(logging.INFO)
29+
prompt = client.prompt_management.create_version(
30+
prompt=types.Prompt(
31+
prompt_data=types.PromptData(
32+
model="gemini-2.5-flash",
33+
contents=[
34+
genai_types.Content(
35+
parts=[genai_types.Part(text="What is the capital of France?")],
36+
)
37+
],
38+
)
39+
),
40+
config=types.CreatePromptConfig(
41+
prompt_display_name="test_delete_prompt_dataset",
42+
version_display_name="test_delete_prompt_dataset_version",
43+
),
44+
)
45+
client.prompt_management.delete_prompt(
46+
prompt_id=prompt.prompt_id,
47+
)
48+
assert "Deleted prompt with id: " in caplog.text
49+
50+
51+
def test_delete_dataset_version(client, caplog):
52+
caplog.set_level(logging.INFO)
53+
prompt = client.prompt_management.create_version(
54+
prompt=types.Prompt(
55+
prompt_data=types.PromptData(
56+
model="gemini-2.5-flash",
57+
contents=[
58+
genai_types.Content(
59+
parts=[genai_types.Part(text="What is the capital of France?")],
60+
)
61+
],
62+
)
63+
),
64+
config=types.CreatePromptConfig(
65+
prompt_display_name="test_delete_prompt_dataset",
66+
version_display_name="test_delete_prompt_dataset_version",
67+
),
68+
)
69+
version_id = prompt.dataset_version.name.split("/")[-1]
70+
client.prompt_management.delete_version(
71+
prompt_id=prompt.prompt_id,
72+
version_id=version_id,
73+
)
74+
assert "Deleted prompt version" in caplog.text
75+
76+
77+
pytestmark = pytest_helper.setup(
78+
file=__file__,
79+
globals_for_file=globals(),
80+
test_method="prompt_management.delete",
81+
)

0 commit comments

Comments
 (0)