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
Release history Release notifications | RSS feed
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)
Built Distribution
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
Algorithm | Hash digest | |
---|---|---|
SHA256 | b94f79fbe8fc04da96ba6c8253e41395ed8c6acb7afe710cd415e886fcfb2b2b |
|
MD5 | 5064821c9e36fd1757affd5ca47a3b4c |
|
BLAKE2b-256 | 431947110f693f0fbaf2818dd65a4bc10eb648f742de54743d9ca5d112f48c38 |
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
Algorithm | Hash digest | |
---|---|---|
SHA256 | bb2441617808ded7f2fff03d94acb4f95289399ee7a58bab47ee4f9e792c1ce9 |
|
MD5 | 39af62d3ac3ef880bb0a65d505c054be |
|
BLAKE2b-256 | a7245e193ffdce0032f405dffe6c13fc186213a420a871be4c8bbbb44f8de88d |