Merge pull request #1291 from usamimeri/update_spark

Feat: support async spark api
This commit is contained in:
Alexander Wu 2024-05-29 16:20:29 +08:00 committed by GitHub
commit 519be03d4a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 123 additions and 191 deletions

View file

@ -258,6 +258,14 @@ BEDROCK_TOKEN_COSTS = {
"ai21.j2-ultra-v1": {"prompt": 0.0188, "completion": 0.0188},
}
# https://xinghuo.xfyun.cn/sparkapi?scr=price
SPARK_TOKENS = {
"general": {"prompt": 0.0, "completion": 0.0}, # Spark-Lite
"generalv2": {"prompt": 0.0188, "completion": 0.0188}, # Spark V2.0
"generalv3": {"prompt": 0.0035, "completion": 0.0035}, # Spark Pro
"generalv3.5": {"prompt": 0.0035, "completion": 0.0035}, # Spark3.5 Max
}
def count_input_tokens(messages, model="gpt-3.5-turbo-0125"):
"""Return the number of tokens used by a list of messages."""