mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-25 14:55:00 +00:00
refactor into Model.token_count()
This commit is contained in:
parent
90f57664a6
commit
c24a4a4392
3 changed files with 24 additions and 10 deletions
|
@ -1,4 +1,3 @@
|
|||
import json
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
|
@ -109,14 +108,13 @@ class Commands:
|
|||
dict(role="system", content=self.coder.gpt_prompts.main_system),
|
||||
dict(role="system", content=self.coder.gpt_prompts.system_reminder),
|
||||
]
|
||||
tokens = self.coder.main_model.token_count(json.dumps(msgs))
|
||||
tokens = self.coder.main_model.token_count(msgs)
|
||||
res.append((tokens, "system messages", ""))
|
||||
|
||||
# chat history
|
||||
msgs = self.coder.done_messages + self.coder.cur_messages
|
||||
if msgs:
|
||||
msgs = [dict(role="dummy", content=msg) for msg in msgs]
|
||||
msgs = json.dumps(msgs)
|
||||
tokens = self.coder.main_model.token_count(msgs)
|
||||
res.append((tokens, "chat history", "use /clear to clear"))
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue