Skip to main content

Simplest token log system for your LLM, embedding model calls.

Project description

tokenlog

Simplest token log system for your LLM, embedding model calls.

Installation

Get on pypi.

pip install tokenlog

How to use

Start with initializing the logger. Each logger with the same name is singleton.

import tokenlog

t_logger = tokenlog.getLogger('session_1', 'gpt-3.5-turbo') # write logger name and model name that you are using
q1 = t_logger.query('This is the query that you used in LLM') # log the query

t_logger.answer('This is an answer from LLM', q1) # log the answer

t_logger.get_token_usage() # get total token usage from all queries

t_logger.get_history() # get history of token usage

t_logger.clear() # clear all histories

Support Models

We support all OpenAI models with tiktoken and Huggingface models that support AutoTokenizer.

Use Case

This library used in AutoRAG project.

To-do

  • Add Handlers for exporting logs
  • Support more models
  • Batch logging

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

tokenlog-0.0.1.tar.gz (8.0 kB view details)

Uploaded Source

Built Distribution

tokenlog-0.0.1-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file tokenlog-0.0.1.tar.gz.

File metadata

  • Download URL: tokenlog-0.0.1.tar.gz
  • Upload date:
  • Size: 8.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.6

File hashes

Hashes for tokenlog-0.0.1.tar.gz
Algorithm Hash digest
SHA256 b94f79fbe8fc04da96ba6c8253e41395ed8c6acb7afe710cd415e886fcfb2b2b
MD5 5064821c9e36fd1757affd5ca47a3b4c
BLAKE2b-256 431947110f693f0fbaf2818dd65a4bc10eb648f742de54743d9ca5d112f48c38

See more details on using hashes here.

File details

Details for the file tokenlog-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: tokenlog-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 5.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.6

File hashes

Hashes for tokenlog-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 bb2441617808ded7f2fff03d94acb4f95289399ee7a58bab47ee4f9e792c1ce9
MD5 39af62d3ac3ef880bb0a65d505c054be
BLAKE2b-256 a7245e193ffdce0032f405dffe6c13fc186213a420a871be4c8bbbb44f8de88d

See more details on using hashes here.

Supported by

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