Skip to main content

Tools for human-machine interaction based on large language models.

Project description

chattools

The most simple tool for AI chat, such as gemini, deepseek, ollama

plz save the API keys in .env.key file in the current path.

Example

run python path/to/test.py (deepseek)

run python path/to/test-mistral.py to utilize mistral AI.

Make CLI

create ollama-chat.py

#!/usr/bin/env python3

# default model is `gpt-oss:120b`

from chat_tools import OllamaChat

description="Intelligent enough to help me for anything."
name="Asistant"

with OllamaChat(description=description, name=name) as chat:
    chat.run()

run chmod dommand and ollama-chat.py

Code

# import YourLLM API 
from mixin import ChatMixin
from utils import get_api_key

# api_key = get_api_key


class YourChat(ChatMixin, YourLLM):

    def __init__(self, description=None, history=[], name='Assistant', model="model-name", *args, **kwargs):
        super().__init__(api_key=api_key, *args, **kwargs)  # init method of super class
        self.description = description
        self.name = name
        self.model = model
        self.chat_params = {}

        self.history = history

    def _reply(self, messages, max_retries=100):
        """The wrapper method of the original `chat` method
        """

        k = 0
        while True:
            # try `max_retries` times
            try:
                """
                get the response of the model. such as 
                self.chat.completions.create(
                        model=self.model,
                        messages=messages,
                        **self.chat_params)
                """
            except:
                ...

Commands

register a command as follows

from chat_tools.commands import Commands

@Commands.register("read")
def read_history(obj, path):
    # obj.history = read from `path`
    pass

use the command in the chat as !read path


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

chat_tools-3.1.tar.gz (8.0 kB view details)

Uploaded Source

Built Distribution

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

chat_tools-3.1-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

Details for the file chat_tools-3.1.tar.gz.

File metadata

  • Download URL: chat_tools-3.1.tar.gz
  • Upload date:
  • Size: 8.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for chat_tools-3.1.tar.gz
Algorithm Hash digest
SHA256 f1a203b657a69c6ed0a9196a7949e1b629cd7cf583bc42cb18e67f220348dfb0
MD5 d1713a5c9c5e61148c1e9da82e5e3bf0
BLAKE2b-256 6d11357018736f0eb2898e8f8aaad97fe2d47a12e6bdffe39a7351b6b7dbd591

See more details on using hashes here.

Provenance

The following attestation bundles were made for chat_tools-3.1.tar.gz:

Publisher: python-publish.yml on Freakwill/chat-tools

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file chat_tools-3.1-py3-none-any.whl.

File metadata

  • Download URL: chat_tools-3.1-py3-none-any.whl
  • Upload date:
  • Size: 9.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for chat_tools-3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f59024b301948660e51e980015683ae08740074a4d8b08e93e362dd5b6b4f352
MD5 c35849dc4c6a74df9a3ddaf8628cb6b9
BLAKE2b-256 a841a098af4fb30accb4dbcf1fe728c1b45939d4d5f466cfef2d062c853a2e30

See more details on using hashes here.

Provenance

The following attestation bundles were made for chat_tools-3.1-py3-none-any.whl:

Publisher: python-publish.yml on Freakwill/chat-tools

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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