Unable to update an existing prompt in the vertex ai prompt library using python SDK. #6409
|
I am using the following command to fetch the existing prompt from the library existing_prompt = client.prompts.get(prompt_id="12356644445433333") I am using the below command to update its content existing_prompt.prompt_data = types.PromptData( After the above modification I verified that prompt id is intact by using the following command print(f"After modification {existing_prompt.prompt_id}") I used the following command to create the version for the prompt. version = client.prompts.create_version(prompt=existing_prompt) #since prompt id is deprecated, I am not passing it. Instead of updating the existing prompt, its creating a newer prompt with the updated content. How to fix this. The following packages are utilized import vertexai -- Subbu S. |
Replies: 1 comment 1 reply
|
Pass the prompt id explicitly to prompt_id = "12356644445433333"
existing_prompt = client.prompts.get(prompt_id=prompt_id)
existing_prompt.prompt_data = types.PromptData(
contents=[genai_types.Content(parts=[genai_types.Part(text=content)])],
model=MODEL,
)
version = client.prompts.create_version(
prompt=existing_prompt,
prompt_id=prompt_id,
)The current Agent Platform prompt management docs still show |
@barry166 - This option is deprecated now. There is an alternate function provided for this purpose with the following signature
client.prompts.update(
prompt=prompt,
config=config,
prompt_id=PROMPT_ID
)
This is creating a revision for the existing prompt.