Skip to main content

A Python utility for interacting with large language models (LLMs) through a command-line interface

Project description

talktollm

A Python utility for interacting with large language models (LLMs) through a command-line interface. It leverages image recognition to automate interactions with LLM web interfaces, enabling seamless conversations and task execution.

Features

  • Command-Line Interaction: Provides a simple and intuitive command-line interface for interacting with LLMs.
  • Automated Image Recognition: Employs image recognition techniques to identify and interact with elements on the LLM interface, such as input fields and submit buttons.
  • Multi-LLM Support: Currently supports DeepSeek and Gemini, with the potential for expansion to other LLMs.
  • Automated Conversations: Facilitates automated conversations and task execution by simulating user interactions with the LLM interface.
  • Image Support: Allows sending images to the LLM, handling the image processing and clipboard operations.
  • Easy to use: The package is very easy to set up and use.

Core Functionality

The core function of talktollm is the talkto(llm, prompt, imagedata=None, debug=False) function. This function takes the following arguments:

  • llm: The name of the LLM to interact with (e.g., 'deepseek' or 'gemini').
  • prompt: The text prompt to send to the LLM.
  • imagedata: Optional image data to send to the LLM. This should be a list of base64 encoded strings representing the images.
  • debug: A boolean flag to enable debugging output.

The talkto function performs the following steps:

  1. Opens the LLM's website in a new browser tab.
  2. Finds the message input box using image recognition (optimisewait).
  3. If image data is provided, it iterates through the images, converts them to the correct format, and pastes them into the LLM input.
  4. Pastes the provided text prompt into the LLM input.
  5. Finds and clicks the 'run' button using image recognition.
  6. Waits for the LLM to finish processing (for Gemini, it waits for a 'done' indicator).
  7. Finds and clicks the 'copy' button using image recognition.
  8. Closes the browser tab.
  9. Retrieves the LLM's response from the clipboard.

Image Handling

talktollm includes functionality for handling images to be sent to the LLMs.

  • set_clipboard_image(image_data, retries=3, delay=0.2) is used to set the image to the clipboard. This function takes base64 encoded image data, decodes it, converts it to a bitmap, and places it on the clipboard.
  • set_image_path(llm, debug=False) is used to determine where the image is on the users computer by using the copy_images_to_temp function.
  • copy_images_to_temp(llm, debug=False): Copies images used for image recognition to the temporary directory.

Installation

This section provides instructions on how to install the talktollm package.

pip install talktollm

Usage

This will start by trying to find the LLM in the top left of the primary monitor. Basic usage instructions and examples are presented here.

python
import talktollm
response = talktollm.talkto('gemini', 'Write a poem about cats.')
print(response)

# Example with image
# response = talktollm.talkto('gemini', 'Describe this image', imagedata=['data:image/png;base64,iVBOR...'])

Dependencies

Lists the external libraries that talktollm depends on.

  • pywin32
  • pyautogui
  • pillow
  • optimisewait

Contributing

Describes how others can contribute to the development of talktollm.

Pull requests are welcome! For significant changes, it's recommended to open an issue first to discuss the proposed modifications. This helps ensure that contributions align with the project's goals and maintain overall consistency.

License

Specifies the license under which talktollm is distributed.

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

talktollm-0.2.0.tar.gz (19.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

talktollm-0.2.0-py3-none-any.whl (18.2 kB view details)

Uploaded Python 3

File details

Details for the file talktollm-0.2.0.tar.gz.

File metadata

  • Download URL: talktollm-0.2.0.tar.gz
  • Upload date:
  • Size: 19.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for talktollm-0.2.0.tar.gz
Algorithm Hash digest
SHA256 787f10d482689a8f77a5876eb2322ff50aab0e834d02381d748fb945828081bc
MD5 c87b74d8735fe3c9753f76b906212a99
BLAKE2b-256 62127d775940e7baf1e58e0fd4a5b56faad8abefcd000703a14040501f5ef1cd

See more details on using hashes here.

File details

Details for the file talktollm-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: talktollm-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 18.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for talktollm-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0ed3ad8abf5c96a8fa41e9a602e2f53a73a656aaa64c7a2b218f88280db12053
MD5 0cf02bc972da5092d31d275060f765e9
BLAKE2b-256 b52bfa4d896acc35568661b6d81cd6254220a7d45fed54c06fcdb11e48d5bc4e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page