|
Cookies Manager Backend
|
Public Member Functions | |
| def | extract_model (self, str system_task, str content, response_model) |
| def | get_selector (self, str content) |
Static Public Member Functions | |
| def | save_model_as_json (dict model_dict) |
Static Public Attributes | |
| client = instructor.patch(OpenAI()) | |
| string | system_task_confirm_choices = "Find a button to confirm my choices" |
| string | system_task_open_settings = "Find a button to open cookie settings" |
| string | system_task_reject = "Find a button to reject the cookie policy" |
A client class for generating UI interaction rules using an AI model provided by OpenAI.
Attributes:
client (OpenAI): An instance of the OpenAI client, patched for specific functionalities.
system_task_reject (str): Description of the task to find a rejection button in the UI.
system_task_open_settings (str): Description of the task to find a settings button.
system_task_confirm_choices (str): Description of the task to find a confirmation button.
| def extract_model | ( | self, | |
| str | system_task, | ||
| str | content, | ||
| response_model | |||
| ) |
Sends a request to OpenAI's API to generate a response based on the provided system task and user content.
Args:
system_task (str): The predefined task for the system to execute (e.g., finding a button).
content (str): User-defined content that guides the AI in model generation.
response_model (Model): The Pydantic model expected as the response structure.
Returns:
The response from the OpenAI API as determined by the response_model.
| def get_selector | ( | self, | |
| str | content | ||
| ) |
Utilizes the extract_model method to get a CSS selector from the OpenAI model based on provided content.
Args:
content (str): The content used to guide the AI in selecting the appropriate CSS selector.
Returns:
str: The CSS selector as extracted from the model's response.
|
static |
Saves a model dictionary to a JSON file.
Args:
model_dict (dict): The dictionary containing model data to be serialized.
|
static |
|
static |
|
static |
|
static |