gpt-tokens
Advanced tools
Comparing version 1.3.5 to 1.3.6
@@ -1,10 +0,5 @@ | ||
import { Tiktoken } from 'js-tiktoken'; | ||
import { TokenPrice } from './tokenPrice'; | ||
export declare function getEncodingForModelCached(model: supportModelType): Tiktoken; | ||
/** | ||
* This is a port of the Python code from | ||
* | ||
* https://notebooks.githubusercontent.com/view/ipynb?browser=edge&bypass_fastly=true&color_mode=dark&commit=d67c4181abe9dfd871d382930bb778b7014edc66&device=unknown_device&docs_host=https%3A%2F%2Fdocs.github.com&enc_url=68747470733a2f2f7261772e67697468756275736572636f6e74656e742e636f6d2f6f70656e61692f6f70656e61692d636f6f6b626f6f6b2f643637633431383161626539646664383731643338323933306262373738623730313465646336362f6578616d706c65732f486f775f746f5f636f756e745f746f6b656e735f776974685f74696b746f6b656e2e6970796e62&logged_in=true&nwo=openai%2Fopenai-cookbook&path=examples%2FHow_to_count_tokens_with_tiktoken.ipynb&platform=mac&repository_id=468576060&repository_type=Repository&version=114#6d8d98eb-e018-4e1f-8c9e-19b152a97aaf | ||
*/ | ||
export type supportModelType = 'gpt-3.5-turbo' | 'gpt-3.5-turbo-16k' | 'gpt-4' | 'gpt-4-32k' | 'gpt-4-turbo-preview' | 'gpt-3.5-turbo-0301' | 'gpt-3.5-turbo-0613' | 'gpt-3.5-turbo-1106' | 'gpt-3.5-turbo-0125' | 'gpt-3.5-turbo-16k-0613' | 'gpt-4-0314' | 'gpt-4-0613' | 'gpt-4-32k-0314' | 'gpt-4-32k-0613' | 'gpt-4-1106-preview' | 'gpt-4-0125-preview' | 'gpt-4-turbo-2024-04-09' | 'gpt-4-turbo'; | ||
import type { Tiktoken } from 'js-tiktoken'; | ||
import type { supportModelType } from './pricing'; | ||
export type { supportModelType }; | ||
interface MessageItem { | ||
@@ -15,2 +10,3 @@ name?: string; | ||
} | ||
export declare function getEncodingForModelCached(model: supportModelType): Tiktoken; | ||
export declare class GPTTokens extends TokenPrice { | ||
@@ -68,2 +64,1 @@ constructor(options: { | ||
} | ||
export {}; |
@@ -7,3 +7,3 @@ "use strict"; | ||
const tokenPrice_1 = require("./tokenPrice"); | ||
let modelEncodingCache = {}; | ||
const modelEncodingCache = {}; | ||
function getEncodingForModelCached(model) { | ||
@@ -136,3 +136,7 @@ if (!modelEncodingCache[model]) { | ||
encoding = getEncodingForModelCached(model); | ||
// Python 2 Typescript by gpt-4 | ||
// This is a port of the Python code from | ||
// | ||
// Python => Typescript by gpt-4 | ||
// | ||
// https://notebooks.githubusercontent.com/view/ipynb?browser=edge&bypass_fastly=true&color_mode=dark&commit=d67c4181abe9dfd871d382930bb778b7014edc66&device=unknown_device&docs_host=https%3A%2F%2Fdocs.github.com&enc_url=68747470733a2f2f7261772e67697468756275736572636f6e74656e742e636f6d2f6f70656e61692f6f70656e61692d636f6f6b626f6f6b2f643637633431383161626539646664383731643338323933306262373738623730313465646336362f6578616d706c65732f486f775f746f5f636f756e745f746f6b656e735f776974685f74696b746f6b656e2e6970796e62&logged_in=true&nwo=openai%2Fopenai-cookbook&path=examples%2FHow_to_count_tokens_with_tiktoken.ipynb&platform=mac&repository_id=468576060&repository_type=Repository&version=114#6d8d98eb-e018-4e1f-8c9e-19b152a97aaf | ||
for (const message of messages) { | ||
@@ -139,0 +143,0 @@ num_tokens += tokens_per_message; |
@@ -0,1 +1,2 @@ | ||
export type supportModelType = 'gpt-3.5-turbo' | 'gpt-3.5-turbo-16k' | 'gpt-4' | 'gpt-4-32k' | 'gpt-4-turbo-preview' | 'gpt-3.5-turbo-0301' | 'gpt-3.5-turbo-0613' | 'gpt-3.5-turbo-1106' | 'gpt-3.5-turbo-0125' | 'gpt-3.5-turbo-16k-0613' | 'gpt-4-0314' | 'gpt-4-0613' | 'gpt-4-32k-0314' | 'gpt-4-32k-0613' | 'gpt-4-1106-preview' | 'gpt-4-0125-preview' | 'gpt-4-turbo-2024-04-09' | 'gpt-4-turbo' | 'gpt-4o' | 'gpt-4o-2024-05-13'; | ||
/** | ||
@@ -2,0 +3,0 @@ * Pricing |
{ | ||
"name": "gpt-tokens", | ||
"version": "1.3.5", | ||
"version": "1.3.6", | ||
"description": "Calculate the token consumption and amount of openai gpt message", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -38,2 +38,4 @@ # gpt-tokens | ||
* gpt-4-turbo | ||
* gpt-4o | ||
* gpt-4o-2024-05-13 | ||
@@ -40,0 +42,0 @@ ### Fine Tune Models |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
21168
175