mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-05-15 11:02:36 +02:00
Merge branch 'main' into feature/oas3
This commit is contained in:
commit
bb3e079b35
14 changed files with 165 additions and 128 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