Module blind_llama.completion
Functions
def create(model: str = 'meta-llama/Llama-2-70b-chat-hf', prompt: str = '', temperature: float = 0.7, verbose: bool = False) ‑> str
-
Start a prediction.
Args
- model (str, default = "meta-llama/Llama-2-70b-chat-hf"): The model on which you want to run a prediction on.
prompt
:str
- The prompt on which you want to run a prediction on.
temperature
:float
, default= 0.7
- The temperature requested (default to 0.7).
verbose
:bool
, default= False
- Allows to print all details of the verification process.
Returns
str
- The result of the prediction made by the server
Classes
class AICertInvalidAttestationException (message: str, *args: object)
-
Invalid attestation error
Ancestors
- AICertException
- builtins.Exception
- builtins.BaseException
class AICertInvalidAttestationFormatException (err: Exception)
-
AICert attestation parsing error (json)
Ancestors
- AICertException
- builtins.Exception
- builtins.BaseException
class Client (verbose: bool = False)
-
A class to represent a connection to a BlindLlama server.
Init the Client class.
Args
verbose
:bool
, default= False
- Allows to print all details of the verification process.
Returns
Client
- Client object.
Methods
def predict(self, prompt: str, temperature: float = 0.7) ‑> str
-
Start a prediction.
Args
prompt
:str
- The prompt on which you want to run a prediction on.
temperature
:float
, default= 0.7
- The temperature requested.
Returns
str
- The result of the prediction made by the server
def verify_build_response(self, build_response: bytes, ca_cert='', expected_pcr='')
-
Verify received attesation validity
- Parse the JSON reponse
- Check simulation mode
- Verify certificate chain
- Verify quote signature
- Verify boot PCRs (firmware, bootloader, initramfs, OS)
- Verify event log (final hash in PCR_FOR_MEASUREMENT) by replaying it (works like a chain of hashes)
- Verify TLS certificate (final hash in PCR_FOR_CERTIFICATE)
Args
build_response
:bytes
- reponse of the attestation endpoint
verbose
:bool
, default= False
- whether to print verification information in stdout
def verify_server_certificate(self, expected_pcr)
-
Retrieve server certificate and validate it with the attestation report.
class PromptRequest (**data: Any)
-
Usage docs: https://docs.pydantic.dev/2.2/usage/models/
A base class for creating Pydantic models.
Attributes
__class_vars__
- The names of classvars defined on the model.
__private_attributes__
- Metadata about the private attributes of the model.
__signature__
- The signature for instantiating the model.
__pydantic_complete__
- Whether model building is completed, or if there are still undefined fields.
__pydantic_core_schema__
- The pydantic-core schema used to build the SchemaValidator and SchemaSerializer.
__pydantic_custom_init__
- Whether the model has a custom
__init__
function. __pydantic_decorators__
- Metadata containing the decorators defined on the model.
This replaces
Model.__validators__
andModel.__root_validators__
from Pydantic V1. __pydantic_generic_metadata__
- Metadata for generic models; contains data used for a similar purpose to args, origin, parameters in typing-module generics. May eventually be replaced by these.
__pydantic_parent_namespace__
- Parent namespace of the model, used for automatic rebuilding of models.
__pydantic_post_init__
- The name of the post-init method for the model, if defined.
__pydantic_root_model__
- Whether the model is a
RootModel
. __pydantic_serializer__
- The pydantic-core SchemaSerializer used to dump instances of the model.
__pydantic_validator__
- The pydantic-core SchemaValidator used to validate instances of the model.
__pydantic_extra__
- An instance attribute with the values of extra fields from validation when
model_config['extra'] == 'allow'
. __pydantic_fields_set__
- An instance attribute with the names of fields explicitly specified during validation.
__pydantic_private__
- Instance attribute with the values of private attributes set on the model instance.
Create a new model by parsing and validating input data from keyword arguments.
Raises [
ValidationError
][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.__init__
uses__pydantic_self__
instead of the more commonself
for the first arg to allowself
as a field name.Ancestors
- pydantic.main.BaseModel
Class variables
var inputs : str
var model_config
var model_fields
var temperature : float
Static methods
def valid_input(v)
def valid_temperature(v)