Skip to main content

Prompt Guard | Python SDK

Prompt Guard service client.

PromptGuard(token, config, logger_name, config_id)

Initializes a new Prompt Guard client.

str

Pangea API token.

PangeaConfig | None

Pangea service configuration.

str

Logger name.

str | None

Configuration ID.

from pangea import PangeaConfig
from pangea.services import PromptGuard

config = PangeaConfig(domain="aws.us.pangea.cloud")
prompt_guard = PromptGuard(token="pangea_token", config=config)

Download file

PromptGuard.download_file(url, filename)

Download a file from the specified URL and save it with the given filename.

str

URL of the file to download

str | None

Name to save the downloaded file as. If not provided, the filename will be determined from the Content-Disposition header or the URL.

Guard

PromptGuard.guard(messages, analyzers, classify)

Guard messages.

Iterable[Message]

Prompt content and role array in JSON format. The content is the text that will be analyzed for redaction.

Iterable[str] | None

Specific analyzers to be used in the call

bool | None

Boolean to enable classification of the content

from pangea.services.prompt_guard import Message

response = prompt_guard.guard([Message(role="user", content="hello world")])

Poll result

PromptGuard.poll_result(exception)

Returns request's result that has been accepted by the server

Optional[AcceptedRequestException]

Exception that was previously raised by the SDK on a call that is being processed.

PangeaResponse

response = service.poll_result(exception)