All notable changes to this project will be documented in this file.
- When no "detail" is provided for an "image_url" message part, "auto" is now assumed.
- Add additional OpenAI.com model names to the
get_token_limit
function.
- Add gpt-4o-mini support, by adding a 33.3x multiplier to the token cost.
- Fix the type for the tool_choice param to be inclusive of "auto" and other options.
- Fix bug where you couldn't pass in example tool calls in
few_shots
tobuild_messages
.
- Fix bug where you couldn't pass in
tools
anddefault_to_cl100k
to True with a non-OpenAI model.
- Remove spurious
print
call when counting tokens for function calling.
- Add support and tests for gpt-4o, which has a different tokenizer.
- Use openai type annotations for more precise type hints, and add a typing test.
- Add
py.typed
file so that mypy can find the type hints in this package.
- Add
count_tokens_for_system_and_tools
to count tokens for system message and tools. You should count the tokens for both together, since the token count for tools varies based off whether a system message is provided. - Updated
build_messages
to allow fortools
andtool_choice
to be passed in. - Breaking change: Changed
new_user_message
tonew_user_content
inbuild_messages
for clarity.
- Add keyword argument
fallback_to_default
tobuild_messages
function to allow for defaulting to the CL100k token encoder and minimum GPT token limit if the model is not found. - Fixed usage of
past_messages
argument ofbuild_messages
to not skip the last past message. (New user message should not be passed in)
- Add keyword argument
default_to_cl100k
tocount_tokens_for_message
function to allow for defaulting to the CL100k token limit if the model is not found. - Add keyword argument
default_to_minimum
toget_token_limit
function to allow for defaulting to the minimum token limit if the model is not found.
- Rename to openai-messages-token-helper from llm-messages-token-helper to reflect library's current OpenAI focus.
- Fix for
count_tokens_for_message
function to match OpenAI output precisely, particularly for calls with images to GPT-4 vision.