Skip to content

Commit

Permalink
feat: +gpt 4o tiktoken
Browse files Browse the repository at this point in the history
  • Loading branch information
莘权 马 committed Aug 2, 2024
1 parent c036574 commit 61537c5
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions metagpt/utils/token_counter.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
"gpt-4-1106-preview": {"prompt": 0.01, "completion": 0.03},
"gpt-4-vision-preview": {"prompt": 0.01, "completion": 0.03}, # TODO add extra image price calculator
"gpt-4-1106-vision-preview": {"prompt": 0.01, "completion": 0.03},
"gpt-4o": {"prompt": 0.005, "completion": 0.015},
"gpt-4o-mini": {"prompt": 0.00015, "completion": 0.0006},
"text-embedding-ada-002": {"prompt": 0.0004, "completion": 0.0},
"glm-3-turbo": {"prompt": 0.0007, "completion": 0.0007}, # 128k version, prompt + completion tokens=0.005¥/k-tokens
"glm-4": {"prompt": 0.014, "completion": 0.014}, # 128k version, prompt + completion tokens=0.1¥/k-tokens
Expand Down Expand Up @@ -154,6 +156,8 @@
"gpt-4-0613": 8192,
"gpt-4-32k": 32768,
"gpt-4-32k-0613": 32768,
"gpt-4o-mini": 128000,
"gpt-4o": 128000,
"gpt-3.5-turbo-0125": 16385,
"gpt-3.5-turbo": 16385,
"gpt-3.5-turbo-1106": 16385,
Expand Down Expand Up @@ -207,6 +211,8 @@ def count_message_tokens(messages, model="gpt-3.5-turbo-0125"):
"gpt-4-1106-preview",
"gpt-4-vision-preview",
"gpt-4-1106-vision-preview",
"gpt-4o",
"gpt-4o-mini",
}:
tokens_per_message = 3 # # every reply is primed with <|start|>assistant<|message|>
tokens_per_name = 1
Expand Down

0 comments on commit 61537c5

Please sign in to comment.