debug: 添加上报费用的debug信息

This commit is contained in:
Rock Chin
2023-01-02 20:42:08 +08:00
parent f3974ed581
commit 8aa1dd24ac
2 changed files with 6 additions and 0 deletions

View File

@@ -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]