Attachments

set_attachment_fact(self, file_to_upload, fact_id: str, description: str = None, html_rendering_hint: str = None, allow_large_files: bool = False) None

Set attachment fact for given model use case.

Parameters:
  • file_to_upload (str) – Attachment file path to upload.

  • fact_id (str) – Fact id for the attachment.

  • description (str) – (Optional) Description about the attachment file.

  • html_rendering_hint (str) – (Optional) HTML rendering hint. Available options are in ibm_aigov_facts_client.utils.enums.RenderingHints.

A way to use me is:

>>> model_usecase.set_attachment_fact(file_to_upload="./artifacts/image.png", description="<file description>", fact_id="<custom fact id>")
>>> model_usecase.set_attachment_fact(file_to_upload="./artifacts/image.png", description="<file description>", fact_id="<custom fact id>", html_rendering_hint="<render hint>")
set_cell_attachment_fact(self, description: str, fact_id: str) None

Set attachment fact using captured cell output. Supported for CPD version >=4.6.5.

Parameters:
  • fact_id (str) – Fact id for the attachment

  • description (str) – (Optional) Description about the cell facts attachment file

A way to use me is:

model_usecase.set_cell_attachment_fact(description='<file description>', fact_id='<custom fact id>')
has_attachment(self, fact_id: str = None) bool

Check if attachment/s exist. Supported for CPD version >=4.6.5

Parameters:

fact_id (str, optional) – Id of attachment fact

Return type:

bool

The way to use me is :

>>> model_usecase.has_attachment()
>>> model_usecase.has_attachment(fact_id=<fact id>)
list_attachments(self, filter_by_factid: str = None, format: str = 'dict')

List available attachment facts. Supported for CPD version >=4.6.5.

Parameters:
  • filter_by_factid (str) – (Optional) Fact id for the attachment to filter by.

  • format (str) – Result output format (‘dict’ or ‘str’). Defaults to ‘dict’.

A way to use me is:

Use this format if using output for set_custom_fact():

model_usecase.list_attachments(format="str")
model_usecase.list_attachments()  # Get all attachment facts
# Filter by associated fact_id_1.
model_usecase.list_attachments(filter_by_factid="fact_id_1")
get_download_URL(self, attachment_id: str) str

Constructs and returns the download URL for a given attachment.

Args:

attachment_id (str): The unique identifier of the attachment.

Returns:

str: The URL that can be used to download the specified attachment.

Raises:

ValueError: If the attachment_id is invalid or if there is an issue generating the URL.

Example:
>>> url = ai_usecase.get_download_URL(attachment_id="12345")
>>> print(url) 
remove_attachment(self, fact_id: str)

Remove available attachments facts for given id. Supported for CPD version >=4.6.5

Parameters:

fact_id (str) – Fact id of the attachment

A way to use me is:

>>> model_usecase.remove_attachment(fact_id=<fact id of attachment>)
remove_all_attachments(self)

Remove all attachments facts for given asset. Supported for CPD version >=4.6.5

A way to use me is:

>>> model_usecase.remove_all_attachments()