talkingheads API documentationο
Subpackagesο
- talkingheads.model_library
- talkingheads.model_library.chatgpt
ChatGPTClientChatGPTClient.get_custom_instruction()ChatGPTClient.get_last_response()ChatGPTClient.interact()ChatGPTClient.login()ChatGPTClient.open_custom_instruction_tab()ChatGPTClient.pass_verification()ChatGPTClient.postload_custom_func()ChatGPTClient.regenerate_response()ChatGPTClient.reset_thread()ChatGPTClient.set_custom_instruction()ChatGPTClient.switch_model()
- talkingheads.model_library.claude
- talkingheads.model_library.copilot
CopilotClientCopilotClient.get_last_response()CopilotClient.get_models()CopilotClient.get_plugin()CopilotClient.interact()CopilotClient.is_ready_to_prompt()CopilotClient.login()CopilotClient.postload_custom_func()CopilotClient.regenerate_response()CopilotClient.remove_attached_image()CopilotClient.reset_thread()CopilotClient.switch_model()CopilotClient.toggle_plugin()CopilotClient.upload_image()
- talkingheads.model_library.gemini
- talkingheads.model_library.huggingchat
- talkingheads.model_library.lechat
- talkingheads.model_library.pi
- talkingheads.model_library.chatgpt
- talkingheads.multiagent
talkingheads.base_browserο
Class definition for ChatGPT_Client
- class talkingheads.base_browser.BaseBrowser(client_name: str, url: str, uname_var: str | None = None, pwd_var: str | None = None, username: str | None = None, password: str | None = None, headless: bool = True, cold_start: bool = False, incognito: bool = True, driver_arguments: List | Dict | None = None, driver_version: int | None = None, timeout_dur: int = 90, auto_save: bool = False, save_path: str | None = None, verbose: bool = False, credential_check: bool = True, skip_login: bool = False, user_data_dir: str | None = None, uc_params: dict | None = None, tag: str | None = None)ο
Bases:
objectBaseBrowser class to provide utility function and flow for LLMs
- Parameters:
client_name (str) β A string representing the name of the client.
url (str) β The URL to be used as an entrypoint.
uname_var (str) β The username environment variable, to enable multiple agents.
pwd_var (str) β The password environment variable, to enable multiple agents.
username (str, optional) β Deprecated. Use environment variables instead.
password (str, optional) β Deprecated. Use environment variables instead.
headless (bool, optional) β Enables/disables headless mode. Default: True.
cold_start (bool, optional) β If set, loads the chat endpoints and returns. Default: False.
incognito (bool, optional) β A boolean to set incognito mode. Default: True.
driver_arguments (list, optional) β A list of arguments for the driver. Default: None.
driver_version (int, optional) β The version of the chromedriver. Default: None.
auto_save (bool, optional) β A boolean to enable/disable automatic saving. Default: False.
save_path (str, optional) β The file path to save chat logs. Default: None.
verbose (bool, optional) β A boolean to enable/disable logging. Default: False.
credential_check (bool, optional) β Enables/disables credential check. Default: True.
skip_login (bool, optional) β If True, skips the login procedure. Default: False.
user_data_dir (str, optional) β The directory path to user profile. Default: None.
uc_params (dict, optional) β Parameters for uc.Chrome(). Some examples : driver_executable_path, browser_executable_path
- Returns:
The base driver object.
- Return type:
- check_login_page()ο
Checks if the login page is displayed in the browser.
- Returns:
True if the login page is not present, False otherwise.
- Return type:
bool
- find_or_fail(by: By, elem_query: str, return_type: str = 'first', return_shadow: bool = False, fail_ok: bool = False, dom_element: WebElement | None = None)ο
Finds a list of elements given elem_query, if none of the items exists, throws an error
- Parameters:
by (selenium.webdriver.common.by.By) β The method used to locate the element.
elem_query (str) β The elem_query string to locate the element.
return_type (str) β first|all|last. Return first element, all elements or the last one.
fail_ok (bool) β Do not produce error if it is ok to fail.
dom_element (WebElement) β If set, finds within that element.
- Returns:
Web element or None if not found.
- Return type:
WebElement
- abstract interact(prompt: str) strο
Abstract function to interact with the language model.
- log_chat(prompt: str | None = None, response: str | None = None, regenerated: bool = False) boolο
Log a chat interaction in the chat history.
- Parameters:
prompt (str) β The userβs prompt to be logged.
response (str) β The response to the userβs prompt to be logged.
- Returns:
True if the interaction is logged, False otherwise.
- Return type:
bool
- abstract login(username: str, password: str) boolο
Performs the login process with the provided username and password.
- pass_verification() boolο
Performs the verification process on the page if challenge is present. :returns: None
- postload_custom_func() Noneο
A function to implement custom instructions after loading the webpage
- preload_custom_func() Noneο
A function to implement custom instructions before loading the webpage
- abstract regenerate_response() strο
Abstract function to regenerate the responses.
- abstract reset_thread() boolο
Abstract function to open a new thread.
- save() boolο
Saves the conversation.
- set_save_path(save_path: str)ο
Sets the path to save the file
- Parameters:
save_path (str) β The saving path
- abstract switch_model(model_name: str) boolο
Abstract function to switch the model.
- Parameters:
model_name β (str) = The name of the model.
- wait_until_appear(by: By, elem_query: str) WebElement | Noneο
Waits until the specified web element appears on the page.
This function continuously checks for the presence of a web element. It waits until the element is present on the page. Once the element has appeared, the function returns.
- Parameters:
by (selenium.webdriver.common.by.By) β The method used to locate the element.
elem_query (str) β The elem_query string to locate the element.
timeout_dur (int, optional) β Waiting time before the timeout. Default: 15.
- Returns:
If element is appeared, it returns the element. Otherwise, it returns None.
- Return type:
(WebElement | None)
- wait_until_disappear(by: By, elem_query: str) boolο
Waits until the specified web element disappears from the page.
This function continuously checks for the presence of a web element. It waits until the element is no longer present on the page. Once the element has disappeared, the function returns.
- Parameters:
by (selenium.webdriver.common.by.By) β The method used to locate the element.
elem_query (str) β The elem_query string to locate the element.
timeout_dur (int, optional) β Waiting time before the timeout. Default: 15.
- Returns:
True if element disappears, false otherwise.
- Return type:
(bool)
talkingheads.object_mapο
Storage of the xpath, class and id identifiers
talkingheads.utilsο
Utility functions of talkingheads library
- talkingheads.utils.check_filetype(filepath, extensions: List[str]) boolο
Checks if the given file is expected, return False if the extension is not included in expected extensions
- Parameters:
filepath (str) β the path to file
extensions (List[str]) β accepted file extensions
- Returns:
True if file extension exists in extension list, False otherwise
- Return type:
bool
- talkingheads.utils.detect_chrome_version(version_num: int | None = None) int | Noneο
Detects the Google Chrome version on Linux and macOS machines.
- Args
version_num (int, optional): The chromedriver version number. Default: None.
- Returns:
The detected Google Chrome version number.
- Return type:
int
Note: - If version_num is provided, it will be returned without any detection.
Uses subprocess to execute the βgoogle-chrome βversionβ command for detection.
If the command output doesnβt match the expected format, it returns None.
Logs information about the detected or default version using the logging module.
- talkingheads.utils.is_url(possible_url: str) boolο
Checks if the given string is a valid url
- Parameters:
possible_url (str) β A string, possibly a url
- Returns:
True if possible_url is a valid url, false otherwise
- Return type:
bool