gen_ai_hub.prompt_registry.client module¶
- class gen_ai_hub.prompt_registry.client.PromptTemplateClient(proxy_client: GenAIHubProxyClient | None = None)¶
Bases:
PromptRegistryClientClient for interacting with the Prompt Registry Prompt Template API.
https://api.sap.com/api/PROMPT_REGISTRY_API/overview
- create_prompt_template(name: str, version: str, scenario: str, prompt_template_spec: PromptTemplateSpec) PromptTemplatePostResponse¶
Create or update a prompt template.
- Parameters:
name (str) – the name of the prompt template.
version (str) – the version of the prompt template.
scenario (str) – the scenario name of the prompt template.
prompt_template_spec (PromptTemplateSpec) – the specification of the prompt template.
- Returns:
A PromptTemplatePostResponse object.
- Return type:
- get_prompt_templates(scenario: str, name: str, version: str, retrieve: str = None, include_spec: bool = None) PromptTemplateListResponse¶
Retrieve the latest version of every prompt template based on the filters.
- Parameters:
scenario (str) – the scenario name of the prompt template.
name (str) – the name of the prompt template.
version (str) – the version of the prompt template.
retrieve (str, optional) – both(default), imperative, declarative
include_spec (bool, optional) – false(default), true
- Returns:
A PromptTemplateListResponse object.
- Return type:
- get_prompt_template_by_id(template_id: str) PromptTemplateGetResponse¶
Retrieve a specific version of the prompt template by ID.
- Parameters:
template_id (str) – The ID of the prompt template to retrieve.
- Returns:
A PromptTemplateGetResponse object.
- Return type:
- get_prompt_template_history(scenario: str, name: str, version: str) PromptTemplateListResponse¶
Retrieve the history of edits to the prompt template. Only for imperative managed prompt templates.
- Parameters:
scenario (str) – The scenario name of the prompt template.
name (str) – The name of the prompt template.
version (str) – The version ID of the prompt template.
- Returns:
A PromptTemplateListResponse object.
- Return type:
- delete_prompt_template_by_id(template_id: str) PromptTemplateDeleteResponse¶
Delete a specific version of the prompt template by ID.
- Parameters:
template_id (str) – The ID of the prompt template to delete.
- Returns:
A PromptTemplateDeleteResponse object.
- Return type:
- import_prompt_template(file: bytes) PromptTemplatePostResponse¶
Import a runtime/declarative prompt template into the design time environment.
- Parameters:
file (bytes) – binary file content
- Returns:
A PromptTemplatePostResponse object.
- Return type:
- export_prompt_template(template_id: str) bytes¶
Export a design time template in a declarative compatible yaml file. Supports only single file export.
- Parameters:
template_id (str) – The id of the prompt template to export.
- Returns:
bytes: The content of the exported file
- Return type:
bytes
- fill_prompt_template(scenario: str, name: str, version: str, input_params: dict, metadata: bool = False) PromptTemplateSubstitutionResponse¶
Replace the placeholders of the prompt template referenced via scenario-name-version with user provided values.
- Parameters:
scenario (str) – the scenario name of the prompt template.
name (str) – the name of the prompt template.
version (str) – the version of the prompt template.
input_params (dict) – User provided values to replace the placeholders of the prompt template.
metadata (bool, optional) – False(default), True return resource object with all details.
- Returns:
A PromptTemplateSubstitutionResponse object.
- Return type:
- fill_prompt_template_by_id(template_id: str, input_params: dict, metadata: bool = False) PromptTemplateSubstitutionResponse¶
Replace the placeholders of the prompt template referenced via template_id with user provided values.
- Parameters:
template_id (str) – The ID of the prompt template.
input_params (dict) – User provided values to replace the placeholders of the prompt template.
metadata (bool, optional) – False(default), True return resource object with all details.
- Returns:
A PromptTemplateSubstitutionResponse object.
- Return type:
- class gen_ai_hub.prompt_registry.client.OrchestrationConfigClient(proxy_client: GenAIHubProxyClient | None = None)¶
Bases:
PromptRegistryClientClient for interacting with the Prompt Registry Orchestration Config API.
https://api.sap.com/api/PROMPT_REGISTRY_API/overview
- create_orchestration_config(name: str, version: str, scenario: str, spec: OrchestrationConfig | dict) OrchestrationConfigPostResponse¶
Create an orchestration config.
- Parameters:
name (str) – the name of the orchestration config.
version (str) – the version of the orchestration config.
scenario (str) – the scenario name of the orchestration config.
spec (Union[dict, OrchestrationConfig]) – the specification of the orchestration config.
- Returns:
An OrchestrationConfigPostResponse object.
- Return type:
- get_orchestration_configs(scenario: str, name: str, version: str, retrieve: str = None, include_spec: bool = None, resolve_template_ref: bool = None) OrchestrationConfigListResponse¶
Retrieve the latest version of every orchestration config based on the filters.
- Parameters:
scenario (str) – the scenario name of the orchestration config.
name (str) – the name of the orchestration config.
version (str) – the version of the orchestration config.
retrieve (str, optional) – both(default), imperative, declarative
include_spec (bool, optional) – false(default), true
resolve_template_ref (bool, optional) – false(default), true
- Returns:
An OrchestrationConfigListResponse object.
- Return type:
- get_orchestration_config_by_id(config_id: str, resolve_template_ref: bool = None) OrchestrationConfigGetResponse¶
Retrieve a specific version of the orchestration config by ID.
- Parameters:
config_id (str) – The ID of the orchestration config to retrieve.
resolve_template_ref (bool, optional) – false(default), true
- Returns:
An OrchestrationConfigGetResponse object.
- Return type:
- get_orchestration_config_history(scenario: str, name: str, version: str, include_spec: bool = None, resolve_template_ref: bool = None) OrchestrationConfigListResponse¶
Retrieve the history of edits to the orchestration config.
- Parameters:
scenario (str) – The scenario name of the orchestration config.
name (str) – The name of the orchestration config.
version (str) – The version ID of the orchestration config.
include_spec (bool, optional) – false(default), true
resolve_template_ref (bool, optional) – false(default), true
- Returns:
An OrchestrationConfigListResponse object.
- Return type:
- delete_orchestration_config_by_id(config_id: str) OrchestrationConfigDeleteResponse¶
Delete a specific version of the orchestration config by ID.
- Parameters:
config_id (str) – The ID of the orchestration config.
- Returns:
An OrchestrationConfigDeleteResponse object.
- Return type:
- import_orchestration_config(file: bytes) OrchestrationConfigPostResponse¶
Import a runtime/declarative orchestration config into the design time environment.
- Parameters:
file (bytes) – binary file content
- Returns:
A OrchestrationConfigPostResponse object.
- Return type:
- export_orchestration_config(config_id: str) bytes¶
Export a design orchestration config in a declarative compatible yaml file. Supports only single file export.
- Parameters:
config_id (str) – The id of the orchestration config to export.
- Returns:
bytes: The content of the exported file
- Return type:
bytes