tokenlog


Nametokenlog JSON
Version 0.0.2 PyPI version JSON
download
home_pageNone
SummarySimplest token log system for your LLM, embedding model calls.
upload_time2024-03-31 07:02:45
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseMIT License Copyright (c) 2024 Jeffrey (Dongkyu) Kim Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords llm logging log embedding openai huggingface token
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # tokenlog

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

## Installation
Get on pypi.

```bash
pip install tokenlog
```

## How to use

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

```python
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
```

### Batch logging

You can log multiple queries and answers at once.

```python
import tokenlog

t_logger = tokenlog.getLogger('session_2', 'gpt-3.5-turbo') # write logger name and model name that you are using
query_ids = t_logger.query_batch(['This is the query that you used in LLM', 'This is the second query'])
t_logger.query(['This is the first answer', 'This is the second answer'], query_ids)
```


## Support Models

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


## Use Case

This library used in [AutoRAG](https://github.com/Marker-Inc-Korea/AutoRAG) project.


## To-do

- [ ] Add Handlers for exporting logs
- [ ] Support more models
- [ ] Batch logging

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "tokenlog",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "LLM, logging, log, embedding, OpenAI, Huggingface, Token",
    "author": null,
    "author_email": "vkehfdl1 <vkehfdl1@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/9f/b7/27b87176ed0c091d64987b709ce024747a68a84d89c702678dabb59cc9a9/tokenlog-0.0.2.tar.gz",
    "platform": null,
    "description": "# tokenlog\n\nSimplest token log system for your LLM, embedding model calls.\n\n## Installation\nGet on pypi.\n\n```bash\npip install tokenlog\n```\n\n## How to use\n\nStart with initializing the logger.\nEach logger with the same name is singleton.\n\n```python\nimport tokenlog\n\nt_logger = tokenlog.getLogger('session_1', 'gpt-3.5-turbo') # write logger name and model name that you are using\nq1 = t_logger.query('This is the query that you used in LLM') # log the query\n\nt_logger.answer('This is an answer from LLM', q1) # log the answer\n\nt_logger.get_token_usage() # get total token usage from all queries\n\nt_logger.get_history() # get history of token usage\n\nt_logger.clear() # clear all histories\n```\n\n### Batch logging\n\nYou can log multiple queries and answers at once.\n\n```python\nimport tokenlog\n\nt_logger = tokenlog.getLogger('session_2', 'gpt-3.5-turbo') # write logger name and model name that you are using\nquery_ids = t_logger.query_batch(['This is the query that you used in LLM', 'This is the second query'])\nt_logger.query(['This is the first answer', 'This is the second answer'], query_ids)\n```\n\n\n## Support Models\n\nWe support all **OpenAI** models with tiktoken and **Huggingface** models that support `AutoTokenizer`.\n\n\n## Use Case\n\nThis library used in [AutoRAG](https://github.com/Marker-Inc-Korea/AutoRAG) project.\n\n\n## To-do\n\n- [ ] Add Handlers for exporting logs\n- [ ] Support more models\n- [ ] Batch logging\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2024 Jeffrey (Dongkyu) Kim  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "Simplest token log system for your LLM, embedding model calls.",
    "version": "0.0.2",
    "project_urls": {
        "Homepage": "https://github.com/vkehfdl1/tokenlog"
    },
    "split_keywords": [
        "llm",
        " logging",
        " log",
        " embedding",
        " openai",
        " huggingface",
        " token"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "fc8404badf38aa8fabd606ac02764540ad912e73ef93189c2397b01739d4a656",
                "md5": "a78006bf463707a4481988519033473d",
                "sha256": "20711298360472fdc951cef4da9429e2c0ca406064785766d19a268a18beccac"
            },
            "downloads": -1,
            "filename": "tokenlog-0.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a78006bf463707a4481988519033473d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 5510,
            "upload_time": "2024-03-31T07:02:43",
            "upload_time_iso_8601": "2024-03-31T07:02:43.651004Z",
            "url": "https://files.pythonhosted.org/packages/fc/84/04badf38aa8fabd606ac02764540ad912e73ef93189c2397b01739d4a656/tokenlog-0.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9fb727b87176ed0c091d64987b709ce024747a68a84d89c702678dabb59cc9a9",
                "md5": "a2033b3998f809bf4dfc5383ec2c40f4",
                "sha256": "4ec6497c9d8a4a344788dae6cd9504cfd4cf6e1c36e4037a0a4273c24c2abffd"
            },
            "downloads": -1,
            "filename": "tokenlog-0.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "a2033b3998f809bf4dfc5383ec2c40f4",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 8471,
            "upload_time": "2024-03-31T07:02:45",
            "upload_time_iso_8601": "2024-03-31T07:02:45.285190Z",
            "url": "https://files.pythonhosted.org/packages/9f/b7/27b87176ed0c091d64987b709ce024747a68a84d89c702678dabb59cc9a9/tokenlog-0.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-31 07:02:45",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "vkehfdl1",
    "github_project": "tokenlog",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "tokenlog"
}
        
Elapsed time: 0.21237s