Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions packages/gen/gen_ai_hub/prompt_registry/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def get_prompt_template_by_id(self, template_id: str) -> PromptTemplateGetRespon

return PromptTemplateGetResponse(**response)

def get_prompt_template_history(self, scenario: str, name: str, version: str) -> PromptTemplateListResponse:
def get_prompt_template_history(self, scenario: str, name: str, version: str, top: int = None, skip: int = None) -> PromptTemplateListResponse:
"""Retrieve the history of edits to the prompt template. Only for imperative managed prompt templates.

:param scenario: The scenario name of the prompt template.
Expand All @@ -125,11 +125,24 @@ def get_prompt_template_history(self, scenario: str, name: str, version: str) ->
:type name: str
:param version: The version ID of the prompt template.
:type version: str
:param top: Number of prompt templates to be retrieved, defaults to None
:type top: int, optional
:param skip: Number of prompt templates to be skipped, from the list of the queried executions, defaults to None
:type skip: int, optional
:return: A PromptTemplateListResponse object.
:rtype: PromptTemplateListResponse
"""

response = self.rest_client.get(f"{PATH_SCENARIOS}/{scenario}/promptTemplates/{name}/versions/{version}/history")
params = {}
if top is not None:
params['$top'] = top
if skip is not None:
params['$skip'] = skip

response = self.rest_client.get(
f"{PATH_SCENARIOS}/{scenario}/promptTemplates/{name}/versions/{version}/history",
params = params or None
)

return PromptTemplateListResponse(**response)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def test_get_prompt_template_by_id_not_found(self):

def test_get_prompt_template_history(self):
response = self.client.get_prompt_template_history(scenario=self.scenario, name=self.template_name,
version=self.version)
version=self.version, top=500)
self.assertIsInstance(response, PromptTemplateListResponse)

def test_delete_prompt_template_by_id(self):
Expand Down
2 changes: 1 addition & 1 deletion packages/gen/tests/prompt_registry/test_pr_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def test_get_prompt_template_history(self, mock_get):
response = self.test_client.get_prompt_template_history(SCENARIO, TEMPLATE_NAME, VERSION)
self.assertEqual(response, TEMPLATE_LIST_RESPONSE)
mock_get.assert_called_once_with(path=f'{PATH_SCENARIOS}/{SCENARIO}/promptTemplates/{TEMPLATE_NAME}/'
f'versions/{VERSION}/history')
f'versions/{VERSION}/history', params=None)

@patch('ai_api_client_sdk.helpers.rest_client.RestClient.delete')
def test_delete_prompt_template_by_id(self, mock_delete):
Expand Down