mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-30 17:24:59 +00:00
refactor: generalize token calculation using division in Model class
This commit is contained in:
parent
ff41f9bd9a
commit
d24376608e
1 changed files with 2 additions and 7 deletions
|
@ -920,13 +920,8 @@ class Model(ModelSettings):
|
|||
self.keys_in_environment = res.get("keys_in_environment")
|
||||
|
||||
max_input_tokens = self.info.get("max_input_tokens") or 0
|
||||
# generalize this with division. ai!
|
||||
if max_input_tokens < 16 * 1024:
|
||||
self.max_chat_history_tokens = 1 * 1024
|
||||
elif max_input_tokens < 32 * 1024:
|
||||
self.max_chat_history_tokens = 2 * 1024
|
||||
else:
|
||||
self.max_chat_history_tokens = 4 * 1024
|
||||
# Calculate max_chat_history_tokens as 1/16th of max_input_tokens, with minimum 1k and maximum 4k
|
||||
self.max_chat_history_tokens = min(max(max_input_tokens // 16, 1024), 4096)
|
||||
|
||||
self.configure_model_settings(model)
|
||||
if weak_model is False:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue