talkingheads.model_library

talkingheads.model_library.chatgpt

Class definition for ChatGPTClient

class talkingheads.model_library.chatgpt.ChatGPTClient(**kwargs)

Bases: BaseBrowser

ChatGPTClient class to interact with ChatGPT

get_custom_instruction(mode: str) str

Gets custom instructions

Parameters:

mode (str) – Either β€˜extra_information’ or β€˜modulation’. Check OpenAI help pages.

get_last_response() str

Retrieves the last response given by ChatGPT

Returns:

The last response

Return type:

str

interact(prompt: str) str

Sends a prompt and retrieves the response from the ChatGPT system.

This function interacts with the ChatGPT. It takes the prompt as input and sends it to the system. The prompt may contain multiple lines separated by β€˜n’. In this case, the function simulates pressing SHIFT+ENTER for each line. Upon arrival of the interaction, the function waits for the response. Once the response is ready, the function will return the response.

Parameters:

prompt (str) – The interaction text.

Returns:

The generated response.

Return type:

str

login(username: str, password: str)

Performs the login process with the provided username and password.

This function operates on the login page. It finds and clicks the login button, fills in the email and password textboxes

Parameters:
  • username (str) – The username to be entered.

  • password (str) – The password to be entered.

Returns:

None

open_custom_instruction_tab() bool

Opens the modal to access custom interactions.

Returns:

True if the process is successful, False otherwise

Return type:

bool

pass_verification(max_trial: int = 10, wait_time: int = 1) bool

Performs the verification process on the page if challenge is present.

This function checks if the login page is displayed in the browser. In that case, it looks for the verification button. This process is repeated until the login page is no longer displayed.

Returns: None

postload_custom_func()

A function to implement custom instructions after loading the webpage

regenerate_response() str

Clicks the response to generate a new one and returns the new response.

Parameters:

None –

Returns:

str

reset_thread() bool

Function to close the current thread and start new one

set_custom_instruction(mode: str, instruction: str)

Sets custom instructions

Parameters:
  • mode (str) – Either β€˜extra_information’ or β€˜modulation’. Check OpenAI help pages.

  • instruction (str) – _description_

switch_model(model_name: str) bool

Switch the model for ChatGPT+ users.

Parameters:

model_name – str = The name of the model, either GPT-3.5 or GPT-4

Returns:

True on success, False on fail

Return type:

bool

talkingheads.model_library.claude

Class definition for Claude client

class talkingheads.model_library.claude.ClaudeClient(**kwargs)

Bases: BaseBrowser

ClaudeClient class to interact with Claude. It helps you to conncet to https://claude.ai/. Apart from core functionality Claude supports web search. It is not possible to regenerate a response by using Claude

interact(prompt: str) str

Sends a prompt and retrieves the response from the ChatGPT system.

This function interacts with the Claude. It takes the prompt as input and sends it to the system. The prompt may contain multiple lines separated by β€˜n’. In this case, the function simulates pressing SHIFT+ENTER for each line. Upon arrival of the interaction, the function waits for the response. Once the response is ready, the function will return the response.

Parameters:

prompt (str) – The interaction text.

Returns:

The generated response.

Return type:

str

is_ready_to_prompt() bool

Checks if the Claude is ready to be prompted. The indication for an ongoing message generation process is a disabled send button. The indication for no input is the same disabled button. Therefore we put a dummy dot into the textarea and we are left with the only reason for the button to be disabled, that is, a message being generated.

Returns:

return if the system is ready to be prompted.

Return type:

bool

login(_1: str | None = None, _2: str | None = None) bool

It is only possible to login Claude manually.

Parameters:
  • _1 (str) – Unused parameter 1.

  • _2 (str) – Unused parameter 2.

Returns:

True

Return type:

bool

postload_custom_func() bool

In order to continue chat screen, a click on start button is required

regenerate_response() str

Abstract function to regenerate the responses.

reset_thread() bool

Function to close the current thread and start new one

Returns:

True if reset is successful, false otherwise.

Return type:

bool

switch_model(_: str) None

Abstract function to switch the model.

Parameters:

model_name – (str) = The name of the model.

talkingheads.model_library.copilot

Class definition for Copilot client

class talkingheads.model_library.copilot.CopilotClient(**kwargs)

Bases: BaseBrowser

PiClient class to interact with Pi. It helps you to connect to https://copilot.microsoft.com/. Apart from core functionality Copilot supports web search. It is not possible to regenerate a response by using Copilot

get_last_response(check_greeting: bool = False) str

Returns the last response in the chat view.

Parameters:

check_greeting (bool) – If set, checks the greeting message, provided after clicking New Topic.

Returns:

The last generated response

Return type:

str

get_models(get_active_model: bool = False) Dict[str, WebElement] | WebElement

Get the current model. (style) :param get_active_model: bool = If set, returns the current element

Returns:

Dictionary of models and their element.

Return type:

Dict[str, WebElement]

get_plugin(plugin_name: str) WebElement | None

Returns if the plugin is enabled

Parameters:

plugin_name (str) – The name of the plugin

Returns:

True if the plugin is enabled, False if disabled. None if not plugin doesn’t exist

Return type:

Union[WebElement, None]

interact(prompt: str, image_path: str | Path | None = None) str

Sends a prompt and retrieves the response from the Copilot system.

This function interacts with the Copilot. It takes the prompt as input and sends it to the system. The prompt may contain multiple lines separated by β€˜n’. In this case, the function simulates pressing SHIFT+ENTER for each line. Upon arrival of the interaction, the function waits for the response. Once the response is ready, the function will return the response.

Parameters:
  • prompt (str) – The interaction text.

  • image_path (str, Optional) – The path to image from local, or the url of the image.

Returns:

The generated response.

Return type:

Dict[str]

is_ready_to_prompt(text_area, shadow_element) bool

Checks if the Copilot is ready to be prompted. The indication for an ongoing message generation process is a disabled send button. The indication for no input is the same disabled button. Therefore we put a dummy dot into the textarea and we are left with the only reason for the button to be disabled, that is, a message being generated.

Returns:

return if the system is ready to be prompted.

Return type:

bool

login(username: str | None = None, password: str | None = None)

Performs the login process with the provided username and password. You don’t need to login to use Pi

This function operates on the login page. It finds and clicks the login button, fills in the email and password textboxes

Parameters:
  • username (str) – The username to be entered.

  • password (str) – The password to be entered.

Returns:

True

Return type:

bool

postload_custom_func() None

Copilot requires to accept privacy terms, the cookie below provides the response.

regenerate_response()

Abstract function to regenerate the responses.

remove_attached_image() bool

Removes the attached image from prompt

Returns:

True if the action is valid

Return type:

bool

reset_thread() bool

Function to close the current thread and start new one

Returns:

False always, it is not possible to reset in Pi.

Return type:

bool

switch_model(model_name: str) bool

Switch the model. (style)

Parameters:

model_name – str = The name of the model

Returns:

True on success, False on fail

Return type:

bool

toggle_plugin(plugin_name: str) bool

Toggles the status of the plugin. In order to use plugins, search plugin should be active.

Parameters:

plugin_name (str) – The name of the plugin

Returns:

True if toggle action is successful, False if operation fails.

Return type:

bool

upload_image(action_bar: ShadowRoot, image_path: str | Path) bool

Upload an image or a url and wait until it is uploaded, then returns.

Parameters:
  • action_bar (ShadowRoot) – Action bar shadow root to find sub elements.

  • image_path (str) – the file path to image or the url.

Returns:

True if the image loaded properly, False otherwise

Return type:

bool

talkingheads.model_library.gemini

Class definition for GeminiClient

class talkingheads.model_library.gemini.GeminiClient(**kwargs)

Bases: BaseBrowser

GeminiClient class to interact with Gemini

get_response() str

Get the response from chat board

Returns:

The interaction text

Return type:

str

interact(prompt: str, image_path: str | Path | None = None) str

Sends a prompt and retrieves the response from the ChatGPT system.

This function interacts with the Gemini. It takes the prompt as input and sends it to the system. The prompt may contain multiple lines separated by β€˜n’. In this case, the function simulates pressing SHIFT+ENTER for each line. Upon arrival of the interaction, the function waits for the response. Once the response is ready, the function will return the response.

Parameters:
  • prompt (str) – The interaction text.

  • image_path (str, optional) – The image path for multimodal functionality

Returns:

The generated response.

Return type:

str

login(username: str, password: str) bool

Performs the login process with the provided username and password.

This function operates on the login page. It finds and clicks the login button, fills in the email and password textboxes

Parameters:
  • username (str) – The username to be entered.

  • password (str) – The password to be entered.

Returns:

True if login succesful, False otherwise.

Return type:

bool

modify_response(mode: str) str

Closes the current thread and starts a new one.

Parameters:

mode – Select the modification mode.

Returns:

The regenerated response or empty string in case of failure.

Return type:

str

postload_custom_func()

A function to implement custom instructions after loading the webpage

regenerate_response() str

Closes the current thread and starts a new one.

Parameters:

None –

Returns:

The regenerated response or empty string in case of failure.

Return type:

str

reset_thread() bool

Function to close the current thread and start new one

Returns:

True new chat button is clicked, false otherwise

Return type:

bool

switch_model(model_name: str) bool

Abstract function to switch the model.

Parameters:

model_name – (str) = The name of the model.

upload_image(image_path: str | Path) bool

Upload an image or a url and wait until it is uploaded, then returns.

Parameters:

image_path (Union[str, Path]) – the file path to image or the url.

Returns:

True if the image loaded properly, False otherwise.

Return type:

bool

talkingheads.model_library.huggingchat

Class definition for HuggingChat client

class talkingheads.model_library.huggingchat.HuggingChatClient(**kwargs)

Bases: BaseBrowser

HuggingChatClient class to interact with HuggingChat. It helps you to conncet to https://huggingface.co/chat/ and login. Apart from core functionality HuggingChat supports web search. It is not possible to regenerate a response by using HuggingChat

interact(prompt: str)

Sends a prompt and retrieves the response from the HuggingChat system.

This function interacts with the HuggingChat. It takes the prompt as input and sends it to the system. The prompt may contain multiple lines seperated by β€˜n’. In this case, the function simulates pressing SHIFT+ENTER for each line. Upon arrival of the interaction, the function waits for the response. Once the response is ready, the function will return the response.

Parameters:

prompt (str) – The interaction text.

Returns:

The generated response.

Return type:

str

login(username: str, password: str)

Performs the login process with the provided username and password.

This function operates on the login page. It finds and clicks the login button, fills in the email and password textboxes

Parameters:
  • username (str) – The username to be entered.

  • password (str) – The password to be entered.

Returns:

True if login is successful

Return type:

bool

regenerate_response()

Abstract function to regenerate the responses.

reset_thread() bool

Function to close the current thread and start new one

switch_model(model_name: str) bool

Switch the model.

Parameters:

model_name – str = The name of the model

Returns:

True on success, False on fail

Return type:

bool

toggle_search_web() bool

Function to enable/disable web search feature

talkingheads.model_library.lechat

Class definition for LeChat client

class talkingheads.model_library.lechat.LeChatClient(**kwargs)

Bases: BaseBrowser

LeChatClient class to interact with LeChat. It helps you to conncet to https://chat.mistral.ai/chat and login. It is not possible to regenerate a response by using LeChat

get_last_response() str

Retrieves the last response given by ChatGPT

Returns:

The last response

Return type:

str

interact(prompt: str)

Sends a prompt and retrieves the response.

This function interacts with the LeChat. It takes the prompt as input and sends it to the system. The prompt may contain multiple lines seperated by β€˜n’. In this case, the function simulates pressing SHIFT+ENTER for each line. Upon arrival of the interaction, the function waits for the response. Once the response is ready, the function will return the response.

Parameters:

prompt (str) – The interaction text.

Returns:

The generated response.

Return type:

str

login(username: str, password: str)

Performs the login process with the provided username and password.

This function operates on the login page. It finds and clicks the login button, fills in the email and password textboxes

Parameters:
  • username (str) – The username to be entered.

  • password (str) – The password to be entered.

Returns:

True if login is successful

Return type:

bool

regenerate_response()

Abstract function to regenerate the responses.

reset_thread()

Function to close the current thread and start new one

switch_model(model_name: str)

Switch the model.

Parameters:

model_name – str = The name of the model

Returns:

True on success, False on fail

Return type:

bool

talkingheads.model_library.pi

Class definition for PI client

class talkingheads.model_library.pi.PiClient(**kwargs)

Bases: BaseBrowser

PiClient class to interact with Pi. It helps you to conncet to https://pi.ai/. Apart from core functionality Pi supports web search. It is not possible to regenerate a response by using Pi

interact(prompt: str)

Sends a prompt and retrieves the response from the ChatGPT system.

This function interacts with the PI. It takes the prompt as input and sends it to the system. The prompt may contain multiple lines separated by β€˜n’. In this case, the function simulates pressing SHIFT+ENTER for each line. Upon arrival of the interaction, the function waits for the response. Once the response is ready, the function will return the response.

Parameters:

prompt (str) – The interaction text.

Returns:

The generated response.

Return type:

str

is_ready_to_prompt() bool

Checks if the Pi is ready to be prompted. The indication for an ongoing message generation process is a disabled send button. The indication for no input is the same disabled button. Therefore we put a dummy dot into the textarea and we are left with the only reason for the button to be disabled, that is, a message being generated.

Returns:

return if the system is ready to be prompted.

Return type:

bool

login(username: str | None = None, password: str | None = None)

Performs the login process with the provided username and password. You don’t need to login to use Pi

This function operates on the login page. It finds and clicks the login button, fills in the email and password textboxes

Parameters:
  • username (str) – The username to be entered.

  • password (str) – The password to be entered.

Returns:

True

Return type:

bool

postload_custom_func() None

Pi starts with a welcome message, we should wait until the message to finish.

regenerate_response()

Abstract function to regenerate the responses.

reset_thread() bool

Function to close the current thread and start new one

Returns:

False always, it is not possible to reset in Pi.

Return type:

bool