gen_ai_hub.prompt_registry package

class OrchestrationConfigClient

Bases: PromptRegistryClient

Client for interacting with the Prompt Registry Orchestration Config API.

https://api.sap.com/api/PROMPT_REGISTRY_API/overview

create_orchestration_config(name, version, scenario, spec)

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:

OrchestrationConfigPostResponse

delete_orchestration_config_by_id(config_id)

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:

OrchestrationConfigDeleteResponse

export_orchestration_config(config_id)

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

get_orchestration_config_by_id(config_id, resolve_template_ref=None)

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:

OrchestrationConfigGetResponse

get_orchestration_config_history(scenario, name, version, include_spec=None, resolve_template_ref=None)

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:

OrchestrationConfigListResponse

get_orchestration_configs(scenario, name, version, retrieve=None, include_spec=None, resolve_template_ref=None)

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:

OrchestrationConfigListResponse

import_orchestration_config(file)

Import a runtime/declarative orchestration config into the design time environment.

Parameters:

file (bytes) -- binary file content

Returns:

A OrchestrationConfigPostResponse object.

Return type:

OrchestrationConfigPostResponse

class OrchestrationConfigDeleteResponse

Bases: BaseModel

Response to a delete orchestration config request.

Args:

message: Response message.

message: str
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class OrchestrationConfigGetResponse

Bases: BaseModel

Response to a get orchestration config request.

Args:

id: UUID of the config. name: Config name. version: Config version. scenario: Scenario name. creation_timestamp: When the config was created. managed_by: Who manages the config. is_version_head: Whether this is the head version. spec: The orchestration config specification (optional).

model_dump(**kwargs)

Dumps the model to a dictionary with default settings.

creation_timestamp: str | None
id: str | None
is_version_head: bool | None
managed_by: str | None
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

name: str | None
resource_group_id: str | None
scenario: str | None
spec: OrchestrationConfig | None
version: str | None
class OrchestrationConfigListResponse

Bases: BaseModel

Response to list orchestration configs request.

Args:

count: Number of configs returned. resources: List of OrchestrationConfigGetResponse objects.

model_dump(**kwargs)

Dumps the model to a dictionary with default settings.

count: int
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

resources: List[OrchestrationConfigGetResponse]
class OrchestrationConfigPostRequest

Bases: BaseModel

Request to create an orchestration config.

Args:

name: The name of the orchestration config. version: The version of the orchestration config. scenario: The scenario of the orchestration config. spec: The orchestration config specification.

model_dump(**kwargs)

Dumps the model to a dictionary with default settings.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

name: str
scenario: str
spec: OrchestrationConfig
version: str
class OrchestrationConfigPostResponse

Bases: BaseModel

Response to the orchestration config post request.

Args:

message: Response message. id: UUID of the created/updated config. scenario: The scenario name. name: The config name. version: The config version.

id: str
message: str
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

name: str
scenario: str
version: str
class PromptTemplate

Bases: BaseModel

Represents a prompt template.

Args:

role: The role of the prompt template.

content: The content of the prompt template.

classmethod content_validation(content)

Validates and maps the content field to the appropriate types.

content: str | List[str | TextPart | ImagePart | ImageItem]

The content of the prompt template.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

role: str

The role of the prompt template.

class PromptTemplateClient

Bases: PromptRegistryClient

Client for interacting with the Prompt Registry Prompt Template API.

https://api.sap.com/api/PROMPT_REGISTRY_API/overview

create_prompt_template(name, version, scenario, prompt_template_spec)

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:

PromptTemplatePostResponse

delete_prompt_template_by_id(template_id)

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:

PromptTemplateDeleteResponse

export_prompt_template(template_id)

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, name, version, input_params, metadata=False)

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:

PromptTemplateSubstitutionResponse

fill_prompt_template_by_id(template_id, input_params, metadata=False)

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:

PromptTemplateSubstitutionResponse

get_prompt_template_by_id(template_id)

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:

PromptTemplateGetResponse

get_prompt_template_history(scenario, name, version)

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:

PromptTemplateListResponse

get_prompt_templates(scenario, name, version, retrieve=None, include_spec=None)

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:

PromptTemplateListResponse

import_prompt_template(file)

Import a runtime/declarative prompt template into the design time environment.

Parameters:

file (bytes) -- binary file content

Returns:

A PromptTemplatePostResponse object.

Return type:

PromptTemplatePostResponse

class PromptTemplateDeleteResponse

Bases: BaseModel

Represents a response to a request to delete a prompt template.

Args:

message: The message of the response.

message: str

The message of the response.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class PromptTemplateGetResponse

Bases: BaseModel

Represents a response to a request to get a prompt template.

Args:

id: The ID of the prompt template.

name: The name of the prompt template.

version: The version of the prompt template.

scenario: The scenario of the prompt template.

creation_timestamp: The creation timestamp of the prompt template.

managed_by: The manager of the prompt template.

is_version_head: Whether the version is the head version.

spec: The specification of the prompt template.

creation_timestamp: str | None

The creation timestamp of the prompt template.

id: str

The ID of the prompt template.

is_version_head: bool | None

Whether the version is the head version.

managed_by: str | None

The manager of the prompt template.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

name: str

The name of the prompt template.

scenario: str

The scenario of the prompt template.

spec: PromptTemplateSpec | None

The specification of the prompt template.

version: str

The version of the prompt template.

class PromptTemplateListResponse

Bases: BaseModel

Represents a response to a request to list prompt templates.

Args:

count: The number of prompt templates.

resources: The list of PromptGetResponse objects.

count: int

The number of prompt templates.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

resources: List[PromptTemplateGetResponse]

The list of PromptGetResponse objects.

class PromptTemplatePostRequest

Bases: BaseModel

Represents a request to create a prompt template.

Args:

name: The name of the prompt template.

version: The version of the prompt template.

scenario: The scenario of the prompt template.

spec: The specification of the prompt template.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

name: str

The name of the prompt template.

scenario: str

The scenario of the prompt template.

spec: PromptTemplateSpec

The specification of the prompt template.

version: str

The version of the prompt template.

class PromptTemplatePostResponse

Bases: BaseModel

Represents a response to a request to create a prompt template.

Args:

message: The message of the response.

id: The ID of the prompt template.

scenario: The scenario of the prompt template.

name: The name of the prompt template.

version: The version of the prompt template.

id: str

The ID of the prompt template.

message: str

The message of the response.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

name: str

The name of the prompt template.

scenario: str

The scenario of the prompt template.

version: str

The version of the prompt template.

class PromptTemplateSpec

Bases: BaseModel

Represents a prompt template specification.

Args:

Args: template: A list of prompt messages that form the template.

defaults: A dict of default values for template variables.

tools: A list of tool definitions.

response_format: A response format that the model output should adhere to.

additional_fields: Additional fields for the prompt template.

additional_fields: Dict[Any, Any] | None
defaults: dict | None
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

response_format: ResponseFormatText | ResponseFormatJsonObject | ResponseFormatJsonSchema | None
template: List[PromptTemplate]
tools: List[dict | FunctionTool] | None
class PromptTemplateSubstitutionRequest

Bases: BaseModel

Represents a request to substitute a prompt template.

Args:

input_params: User provided values to replace the placeholders of the prompt template.

input_params: Dict[Any, Any] | None

User provided values to replace the placeholders of the prompt template.

model_config: ClassVar[ConfigDict] = {'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}

Pydantic configuration to allow population by field name.

class PromptTemplateSubstitutionResponse

Bases: BaseModel

Represents a response to a request to substitute a prompt template.

Args:

parsed_prompt: The parsed prompt.

resource: List of TemplateGetResponse objects.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

parsed_prompt: List[PromptTemplate]

The parsed prompt.

resource: PromptTemplateGetResponse | None

List of TemplateGetResponse objects.

Subpackages

Submodules

gen_ai_hub.prompt_registry.client module

class OrchestrationConfigClient

Bases: PromptRegistryClient

Client for interacting with the Prompt Registry Orchestration Config API.

https://api.sap.com/api/PROMPT_REGISTRY_API/overview

create_orchestration_config(name, version, scenario, spec)

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:

OrchestrationConfigPostResponse

delete_orchestration_config_by_id(config_id)

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:

OrchestrationConfigDeleteResponse

export_orchestration_config(config_id)

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

get_orchestration_config_by_id(config_id, resolve_template_ref=None)

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:

OrchestrationConfigGetResponse

get_orchestration_config_history(scenario, name, version, include_spec=None, resolve_template_ref=None)

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:

OrchestrationConfigListResponse

get_orchestration_configs(scenario, name, version, retrieve=None, include_spec=None, resolve_template_ref=None)

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:

OrchestrationConfigListResponse

import_orchestration_config(file)

Import a runtime/declarative orchestration config into the design time environment.

Parameters:

file (bytes) -- binary file content

Returns:

A OrchestrationConfigPostResponse object.

Return type:

OrchestrationConfigPostResponse

class PromptTemplateClient

Bases: PromptRegistryClient

Client for interacting with the Prompt Registry Prompt Template API.

https://api.sap.com/api/PROMPT_REGISTRY_API/overview

create_prompt_template(name, version, scenario, prompt_template_spec)

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:

PromptTemplatePostResponse

delete_prompt_template_by_id(template_id)

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:

PromptTemplateDeleteResponse

export_prompt_template(template_id)

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, name, version, input_params, metadata=False)

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:

PromptTemplateSubstitutionResponse

fill_prompt_template_by_id(template_id, input_params, metadata=False)

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:

PromptTemplateSubstitutionResponse

get_prompt_template_by_id(template_id)

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:

PromptTemplateGetResponse

get_prompt_template_history(scenario, name, version)

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:

PromptTemplateListResponse

get_prompt_templates(scenario, name, version, retrieve=None, include_spec=None)

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:

PromptTemplateListResponse

import_prompt_template(file)

Import a runtime/declarative prompt template into the design time environment.

Parameters:

file (bytes) -- binary file content

Returns:

A PromptTemplatePostResponse object.

Return type:

PromptTemplatePostResponse