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:
PromptTargetThe 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]#
Initialize 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[, ...])Initialize the HuggingFaceEndpointTarget with API credentials and model parameters.
dispose_db_engine()Dispose database engine to release database connections and resources.
get_identifier()Get an identifier dictionary for this prompt target.
Check if the target supports JSON as a response format.
send_prompt_async(**kwargs)Send a normalized prompt async to the prompt target.
set_model_name(*, model_name)Set the model name for this target.
Attributes
A list of PromptConverters that are supported by the prompt target.
- is_json_response_supported() bool[source]#
Check if the target supports JSON as a response format.
- Returns:
True if JSON response is supported, False otherwise.
- Return type:
- async send_prompt_async(**kwargs)#
Send a normalized prompt async to the prompt target.