mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-05-27 14:25:20 +02:00
Merge branch 'geekan:main' into main
This commit is contained in:
commit
1f469d55b5
20 changed files with 284 additions and 137 deletions
|
|
@ -96,7 +96,7 @@ def count_string_tokens(string: str, model_name: str) -> int:
|
|||
return len(encoding.encode(string))
|
||||
|
||||
|
||||
def get_max_completion_tokens(messages: list[dict], model: str, default: int) -> int:
|
||||
def get_max_completion_tokens(messages: list[dict], model: str, default: int) -> int:
|
||||
"""Calculate the maximum number of completion tokens for a given model and list of messages.
|
||||
|
||||
Args:
|
||||
|
|
@ -108,4 +108,4 @@ def get_max_completion_tokens(messages: list[dict], model: str, default: int) ->
|
|||
"""
|
||||
if model not in TOKEN_MAX:
|
||||
return default
|
||||
return TOKEN_MAX[model] - count_message_tokens(messages)
|
||||
return TOKEN_MAX[model] - count_message_tokens(messages) - 1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue