Skip to main content

kittychat

The purrfect chat utils library! With Kittychat, you'll be feline fine as a kittycat, since it ensures your threads stay within the LLMs token limits by whisking away old messages.

install

pip install kittychat

usage

import logging

from kittychat.msg_dropping import MessageDropper
from kittychat.errors import NotEnoughTokens

thread = [
    {
        "content": "What is the weather like in Boston?",
        "role": "user",
    },
]
functions = [
    {
        "name": "get_current_weather",
        "description": "Get the current weather in a given location",
        "parameters": {
            "type": "object",
            "properties": {
                "location": {
                    "type": "string",
                    "description": "The city and state, e.g. San Francisco, CA",
                },
            },
            "required": ["location"],
        },
    }
]
model = "openai/gpt-3.5-turbo-0613"

msgd = MessageDropper(model)
length, max_tokens, is_too_big = msgd.check_thread_length(thread, functions)
if is_too_big:
    logging.warn(f"Thread too big: {length} tokens; max is {max_tokens} for model '{model}'.")
try:
    cropped_thread = msgd.run(thread, functions)
except NotEnoughTokens as e:
    raise YourPromptTooBigException(e.token_count, e.max_tokens, model)
return cropped_thread

Metadata

Release files for kittychat 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for kittychat 0.1.4
File Size Uploaded Provenance Actions
kittychat-0.1.4.tar.gz 3.7 kB Without provenance Details for kittychat-0.1.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for kittychat 0.1.4
File Interpreter ABI Platform Actions
kittychat-0.1.4-py3-none-any.whl Python 3 none any Details for kittychat-0.1.4-py3-none-any.whl

Total release size: 7.3 kB

Release files / kittychat-0.1.4.tar.gz

Download URL kittychat-0.1.4.tar.gz
Size 3.7 kB
Tags Source
SHA-256 checksum
How to use checksums
dac2948f521c1cc9ea0eaf1edffb8c6ad1bcf0004b9f76101ad62d465cb1d819
BLAKE2b-256 checksum
How to use checksums
f4083f6e9b5200daa0e6f3522fddf7c96f5ac8c0d006e1e3ad82d7c4f86753f8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.11.9

Release files / kittychat-0.1.4-py3-none-any.whl

Download URL kittychat-0.1.4-py3-none-any.whl
Size 3.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4f56f3b3c9c2fdd28fe044bc0dc60b8220c842664613e936c2f06cf953b4cd8c
BLAKE2b-256 checksum
How to use checksums
e8404ddbb6e012d30272b67b2da213603987de91b1dad399371a7e800145d3e2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.11.9

Security for kittychat 0.1.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page