Skip to content

Commit 06ce38e

Browse files
committed
Rename library, add changelog
1 parent 0b301cb commit 06ce38e

File tree

10 files changed

+24
-14
lines changed

10 files changed

+24
-14
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
## [0.0.4] - April 21, 2024
6+
7+
- Rename to openai-messages-token-helper from llm-messages-token-helper to reflect library's current OpenAI focus.
8+
9+
## [0.0.3] - April 21, 2024
10+
11+
- Fix for `count_tokens_for_message` function to match OpenAI output precisely, particularly for calls with images to GPT-4 vision.

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# llm-messages-token-helper
1+
# openai-messages-token-helper
22

33
A helper library for estimating tokens used by messages and building messages lists that fit within the token limits of a model.
44
Currently designed to work with the OpenAI GPT models (including GPT-4 turbo with vision).
@@ -9,7 +9,7 @@ Uses the tiktoken library for tokenizing text and the Pillow library for image-r
99
Install the package:
1010

1111
```sh
12-
python3 -m pip install llm-messages-token-helper
12+
python3 -m pip install openai-messages-token-helper
1313
```
1414

1515
## Usage
@@ -43,7 +43,7 @@ Returns:
4343
Example:
4444

4545
```python
46-
from llm_messages_token_helper import build_messages
46+
from openai_messages_token_helper import build_messages
4747

4848
messages = build_messages(
4949
model="gpt-35-turbo",
@@ -87,7 +87,7 @@ Returns:
8787
Example:
8888

8989
```python
90-
from llm_messages_token_helper import count_tokens_for_message
90+
from openai_messages_token_helper import count_tokens_for_message
9191

9292
message = {
9393
"role": "user",
@@ -116,7 +116,7 @@ Example:
116116
Count the number of tokens for an image sent to GPT-4-vision:
117117

118118
```python
119-
from llm_messages_token_helper import count_tokens_for_image
119+
from openai_messages_token_helper import count_tokens_for_image
120120

121121
image = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEA..."
122122
num_tokens = count_tokens_for_image(image)
@@ -137,7 +137,7 @@ Returns:
137137
Example:
138138

139139
```python
140-
from llm_messages_token_helper import get_token_limit
140+
from openai_messages_token_helper import get_token_limit
141141

142142
model = "gpt-4"
143143
max_tokens = get_token_limit(model)

pyproject.toml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[project]
2-
name = "llm-messages-token-helper"
3-
description = "A helper library for estimating tokens used by messages."
4-
version = "0.0.3"
2+
name = "openai-messages-token-helper"
3+
description = "A helper library for estimating tokens used by messages sent through OpenAI Chat Completions API."
4+
version = "0.0.4"
55
authors = [{name = "Pamela Fox"}]
66
requires-python = ">=3.9"
77
readme = "README.md"
@@ -15,15 +15,14 @@ classifiers = [
1515
"License :: OSI Approved :: MIT License",
1616
"Programming Language :: Python",
1717
"Programming Language :: Python :: 3",
18-
"Programming Language :: Python :: 3.8",
1918
"Programming Language :: Python :: 3.9",
2019
"Programming Language :: Python :: 3.10",
2120
"Programming Language :: Python :: 3.11",
2221
"Framework :: Pytest"
2322
]
2423

2524
[project.urls]
26-
Home = "https://github.com/pamelafox/llm-messages-token-helper"
25+
Home = "https://github.com/pamelafox/openai-messages-token-helper"
2726

2827
[project.optional-dependencies]
2928
dev = [
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

tests/test_imageshelper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import base64
22

33
import pytest
4-
from llm_messages_token_helper import count_tokens_for_image
4+
from openai_messages_token_helper import count_tokens_for_image
55

66

77
@pytest.fixture

tests/test_messagebuilder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from llm_messages_token_helper import build_messages, count_tokens_for_message
1+
from openai_messages_token_helper import build_messages, count_tokens_for_message
22

33
from .messages import system_message_short, system_message_unicode, user_message, user_message_unicode
44

tests/test_modelhelper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import pytest
2-
from llm_messages_token_helper import count_tokens_for_message, get_token_limit
2+
from openai_messages_token_helper import count_tokens_for_message, get_token_limit
33

44
from .messages import system_message, system_message_with_name, text_and_image_message, user_message
55

0 commit comments

Comments
 (0)