pyrit.prompt_target.HuggingFaceEndpointTarget#

class HuggingFaceEndpointTarget(*, hf_token: str, endpoint: str, model_id: str, max_tokens: int = 400, temperature: float = 1.0, top_p: float = 1.0, max_requests_per_minute: int | None = None, verbose: bool = False)[source]#

Bases: PromptTarget

The HuggingFaceEndpointTarget interacts with HuggingFace models hosted on cloud endpoints.

Inherits from PromptTarget to comply with the current design standards.

__init__(*, hf_token: str, endpoint: str, model_id: str, max_tokens: int = 400, temperature: float = 1.0, top_p: float = 1.0, max_requests_per_minute: int | None = None, verbose: bool = False) None[source]#

Initializes the HuggingFaceEndpointTarget with API credentials and model parameters.

Parameters:
  • hf_token (str) – The Hugging Face token for authenticating with the Hugging Face endpoint.

  • endpoint (str) – The endpoint URL for the Hugging Face model.

  • model_id (str) – The model ID to be used at the endpoint.

  • max_tokens (int, Optional) – The maximum number of tokens to generate. Defaults to 400.

  • temperature (float, Optional) – The sampling temperature to use. Defaults to 1.0.

  • top_p (float, Optional) – The cumulative probability for nucleus sampling. Defaults to 1.0.

  • max_requests_per_minute (Optional[int]) – The maximum number of requests per minute. Defaults to None.

  • verbose (bool, Optional) – Flag to enable verbose logging. Defaults to False.

Methods

__init__(*, hf_token, endpoint, model_id[, ...])

Initializes the HuggingFaceEndpointTarget with API credentials and model parameters.

dispose_db_engine()

Dispose database engine to release database connections and resources.

get_identifier()

is_json_response_supported()

Indicates that this target supports JSON response format.

send_prompt_async(**kwargs)

Sends a normalized prompt async to the prompt target.

set_model_name(*, model_name)

Set the model name for this target.

Attributes

is_json_response_supported() bool[source]#

Indicates that this target supports JSON response format.

async send_prompt_async(**kwargs)#

Sends a normalized prompt async to the prompt target.

supported_converters: list#