backend.generators module¶
- class backend.generators.PrivacyPolicyGenerator(regulation_query_engine: SubQuestionQueryEngine, syllabus_pipeline: QueryPipeline, generate_pipeline: QueryPipeline, regenerate_pipeline: QueryPipeline, judge_pipeline: QueryPipeline)¶
Bases:
object- classmethod from_defaults(links_df: DataFrame, model_name: str = 'Equall/Saul-7B-Instruct-v1', model_url: str | None = None, verbose: bool = False)¶
Create a privacy policy generator from defaults
- Parameters:
links_df – a DataFrame with columns ‘regulations’ and ‘links’
verbose – whether to show verbose output
- Params model_url:
the model url; if passed, use TGI, else load locally
- Returns:
a privacy policy generator
- generate(section_name: str, information: str, threshold: int = 5) Dict[str, Any]¶
Generate a section of a privacy policy
- Parameters:
section_name – the name of the section
information – the information for generating the section
threshold – the maximum number of attempts to regenerate
- Returns:
success or not and the generated section
- get_syllabus(regulations: List[str]) Dict[str, List[str]]¶
Get a privacy policy syllabus
- Parameters:
regulations – the regulations to comply with
- Returns:
a privacy policy syllabus
- regenerate(section_name: str, section_text: str, suggestions: str, threshold: int = 5)¶
Regenerate a section of a privacy policy
- Parameters:
section_name – the name of the section
section_text – the text of the section
suggestions – the suggestions for improvement
threshold – the maximum number of attempts to regenerate
- Returns:
success or not and the regenerated section