mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-02 12:05:54 +00:00
debug: 添加上报费用的debug信息
This commit is contained in:
@@ -78,6 +78,8 @@ class KeysManager:
|
||||
return self.fee[md5]
|
||||
|
||||
def report_fee(self, fee: float) -> bool:
|
||||
logging.debug("report fee:" + str(fee))
|
||||
|
||||
md5 = hashlib.md5(self.using_key.encode('utf-8')).hexdigest()
|
||||
if md5 not in self.fee:
|
||||
self.fee[md5] = 0
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import logging
|
||||
|
||||
pricing = {
|
||||
"base": { # 文字模型单位是1000字符
|
||||
"text-davinci-003": 0.02,
|
||||
@@ -13,9 +15,11 @@ pricing = {
|
||||
def language_base_price(model, text):
|
||||
salt_rate = 0.93
|
||||
length = ((len(text.encode('utf-8')) - len(text)) / 2 + len(text)) * salt_rate
|
||||
logging.debug("text length: %d" % length)
|
||||
|
||||
return pricing["base"][model] * length / 1000
|
||||
|
||||
|
||||
def image_price(size):
|
||||
logging.debug("image size: %s" % size)
|
||||
return pricing["image"][size]
|
||||
|
||||
Reference in New Issue
Block a user