Core structures#
Conditioning Parser#
    
              Bases: ABC
Base class for conditioning parsers.
Use it to create custom conditioning parsers, not available natively in the library.
'parse_func_arguments' is the core method that needs to be overwritten by the subclasses.
    Parse the execution parameters of a function into a Conditioning object.
Inspects the signature of the function and passed arguments/keyword arguments.
| PARAMETER | DESCRIPTION | 
|---|---|
| method | The method 
                  
                    TYPE:
                       | 
| *args | Arguments of the method. 
                  
                    DEFAULT:
                       | 
| **kwargs | Keyword arguments of the method. 
                  
                    DEFAULT:
                       | 
| RETURNS | DESCRIPTION | 
|---|---|
| Conditioning | A Conditioning object parsed constructed based on the execution of the method. | 
| RAISES | DESCRIPTION | 
|---|---|
| NotJsonableError | when the parsed arguments cannot be serialized to json. | 
Source code in src/genai_monitor/structures/conditioning_parsers/base.py
              
abstractmethod
  
#
    Core function to be overwritten in subclasses.
Parse func arguments and convert into a jsonable object - the parsing and conversion approach may vary depending on the type of func arguments.
| PARAMETER | DESCRIPTION | 
|---|---|
| *args | Arguments of the method. 
                  
                    DEFAULT:
                       | 
| **kwargs | Keyword arguments of the method. 
                  
                    DEFAULT:
                       | 
| RETURNS | DESCRIPTION | 
|---|---|
| Jsonable | Parsed parameters that can be serialized to json. | 
Source code in src/genai_monitor/structures/conditioning_parsers/base.py
              Output Parser#
    
              Bases: ABC, Generic[T]
Abstract class for converting between sample and model output types.
abstractmethod
  
#
    Converts the model output to a byte representation.
| PARAMETER | DESCRIPTION | 
|---|---|
| model_output | The model output to convert. 
                  
                    TYPE:
                       | 
| RETURNS | DESCRIPTION | 
|---|---|
| bytes | The byte representation of the model output. | 
Source code in src/genai_monitor/structures/output_parsers/base.py
              
            
abstractmethod
  
#
    Converts a byte representation back into model output.
| PARAMETER | DESCRIPTION | 
|---|---|
| databytes | The byte representation of the model output. 
                  
                    TYPE:
                       | 
| RETURNS | DESCRIPTION | 
|---|---|
| T | The model output reconstructed from the byte representation. | 
Source code in src/genai_monitor/structures/output_parsers/base.py
              
    Calculates the hash value of the given data.
| PARAMETER | DESCRIPTION | 
|---|---|
| data | The data to calculate the hash value for. 
                  
                    TYPE:
                       | 
| RETURNS | DESCRIPTION | 
|---|---|
| str | The hash value of the data. | 
Source code in src/genai_monitor/structures/output_parsers/base.py
              
    Calculate the hash of the base data type stored in the model output.
| PARAMETER | DESCRIPTION | 
|---|---|
| model_output | The model outuput to extract the base type from. 
                  
                    TYPE:
                       | 
| RETURNS | DESCRIPTION | 
|---|---|
| str | The data in model output as one of the base supported types. | 
Source code in src/genai_monitor/structures/output_parsers/base.py
              
    Get the base type to calculate the hash upon.
| PARAMETER | DESCRIPTION | 
|---|---|
| model_output | The output of the model to extract the data from 
                  
                    TYPE:
                       | 
| RETURNS | DESCRIPTION | 
|---|---|
| BaseType | One of the base data types supported in the system | 
Source code in src/genai_monitor/structures/output_parsers/base.py
              
    Converts the model output to a sample.
| PARAMETER | DESCRIPTION | 
|---|---|
| model_output | The model output to convert to a sample. 
                  
                    TYPE:
                       | 
| RETURNS | DESCRIPTION | 
|---|---|
| Sample | The sample created from the model output. | 
Source code in src/genai_monitor/structures/output_parsers/base.py
              
    Converts the sample to model output.
| PARAMETER | DESCRIPTION | 
|---|---|
| sample | The sample to convert to model output. 
                  
                    TYPE:
                       | 
| RETURNS | DESCRIPTION | 
|---|---|
| T | The model output created from the sample. | 
| RAISES | DESCRIPTION | 
|---|---|
| ValueError | if the data of a sample is empty | 
Source code in src/genai_monitor/structures/output_parsers/base.py
              Persistency Manager#
    Manager for saving and loading model outputs in binary format to disk.
Source code in src/genai_monitor/structures/persistency_manager.py
                    
    Configures the persistency manager.
| PARAMETER | DESCRIPTION | 
|---|---|
| config | The configuration object specifying the parameters of PersistencyManager. 
                  
                    TYPE:
                       | 
| RAISES | DESCRIPTION | 
|---|---|
| ValueError | If the configuration file cannot be loaded. | 
Source code in src/genai_monitor/structures/persistency_manager.py
              
    Saves the sample data to a binary file.
| PARAMETER | DESCRIPTION | 
|---|---|
| sample | The sample to save. 
                  
                    TYPE:
                       | 
| RAISES | DESCRIPTION | 
|---|---|
| ValueError | If the sample data is None. | 
| ValueError | If the sample ID is None. | 
| ValueError | If the PersistencyManager is disabled. | 
Source code in src/genai_monitor/structures/persistency_manager.py
              
    Loads the binary file for the given sample.
| PARAMETER | DESCRIPTION | 
|---|---|
| sample | The sample to load. 
                  
                    TYPE:
                       | 
| RETURNS | DESCRIPTION | 
|---|---|
| bytes | The binary data from the file. | 
| RAISES | DESCRIPTION | 
|---|---|
| ValueError | If the PersistencyManager is disabled. | 
| ValueError | If the sample ID is None. | 
| FileNotFoundError | If the binary file for the sample ID is not found. | 
| ValueError | If the PersistencyManager has not been configured. | 
Source code in src/genai_monitor/structures/persistency_manager.py
              
    Saves the bytes to a binary file.
| PARAMETER | DESCRIPTION | 
|---|---|
| data | The bytes to save. 
                  
                    TYPE:
                       | 
| filename | The name of the file to save the bytes to. 
                  
                    TYPE:
                       | 
| RAISES | DESCRIPTION | 
|---|---|
| ValueError | If the PersistencyManager is disabled. | 
Source code in src/genai_monitor/structures/persistency_manager.py
              
    Loads the bytes from a binary file.
| PARAMETER | DESCRIPTION | 
|---|---|
| filename | The name of the file to load the bytes from. 
                  
                    TYPE:
                       | 
| RETURNS | DESCRIPTION | 
|---|---|
| bytes | The bytes from the file. | 
| RAISES | DESCRIPTION | 
|---|---|
| FileNotFoundError | If the file is not found. | 
Source code in src/genai_monitor/structures/persistency_manager.py
              
    Checks if the PersistencyManager has been configured.
| RETURNS | DESCRIPTION | 
|---|---|
| bool | Boolean indicating if the PersistencyManager has been configured. | 
    Saves the artifact data to a binary file.
| PARAMETER | DESCRIPTION | 
|---|---|
| artifact | The artifact to save. 
                  
                    TYPE:
                       | 
| RAISES | DESCRIPTION | 
|---|---|
| ValueError | If the artifact ID is None. | 
| ValueError | If the PersistencyManager is disabled. | 
Source code in src/genai_monitor/structures/persistency_manager.py
              
    Loads the binary file for the given artifact.
| PARAMETER | DESCRIPTION | 
|---|---|
| artifact | The artifact to load. 
                  
                    TYPE:
                       | 
| RETURNS | DESCRIPTION | 
|---|---|
| bytes | The binary data from the file. | 
| RAISES | DESCRIPTION | 
|---|---|
| ValueError | If the PersistencyManager is disabled. | 
| ValueError | If the artifact ID is None. | 
| FileNotFoundError | If the binary file for the artifact ID is not found. | 
| ValueError | If the PersistencyManager has not been configured. | 
Source code in src/genai_monitor/structures/persistency_manager.py
              
    Saves the conditioning data to a binary file.
| PARAMETER | DESCRIPTION | 
|---|---|
| conditioning | The conditioning to save. 
                  
                    TYPE:
                       | 
| RAISES | DESCRIPTION | 
|---|---|
| ValueError | If the conditioning ID is None. | 
| ValueError | If the PersistencyManager is disabled. | 
Source code in src/genai_monitor/structures/persistency_manager.py
              
    Loads the binary file for the given conditioning.
| PARAMETER | DESCRIPTION | 
|---|---|
| conditioning | The conditioning to load. 
                  
                    TYPE:
                       | 
| RETURNS | DESCRIPTION | 
|---|---|
| Dict | The binary data from the file. | 
| RAISES | DESCRIPTION | 
|---|---|
| ValueError | If the PersistencyManager is disabled. | 
| ValueError | If the conditioning ID is None. | 
| FileNotFoundError | If the binary file for the conditioning ID is not found. | 
| ValueError | If the PersistencyManager has not been configured. | 
Source code in src/genai_monitor/structures/persistency_manager.py
              Runtime Manager#
    Class for managing runtime data.
| ATTRIBUTE | DESCRIPTION | 
|---|---|
| user_id | The user ID. 
                  
                    TYPE:
                       | 
| version | The runtime version identifier. 
                  
                    TYPE:
                       | 
| latest_sample | The most recently created sample. 
                  
                    TYPE:
                       | 
| artifacts_for_next_sample | Collection of artifacts to be associated with the next sample. 
                  
                    TYPE:
                       |