chore: persistent augroup name pattern (#250)

for better augroup management

Signed-off-by: Aaron Pham <contact@aarnphm.xyz>
This commit is contained in:
Aaron Pham
2024-08-26 22:31:57 -04:00
committed by GitHub
parent f03c0918c9
commit 07af0a91f2
8 changed files with 30 additions and 34 deletions

View File

@@ -2,18 +2,14 @@
local Tiktoken = require("avante.tiktoken")
local Tokens = {}
--[[
cost_per_token
@param {string} token_name
@return {number} cost_per_token
]]
---@type table<[string], number>
local cost_per_token = {
davinci = 0.000002,
}
--- Calculate the number of tokens in a given text.
-- @param text The text to calculate the number of tokens for.
-- @return The number of tokens in the given text.
---@param text string The text to calculate the number of tokens for.
---@return integer The number of tokens in the given text.
function Tokens.calculate_tokens(text)
if Tiktoken.available() then
return Tiktoken.count(text)