mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-31 01:35:00 +00:00
feat: Add methods to identify deepseek and ollama models
This commit is contained in:
parent
606fce65ab
commit
f21ef30482
1 changed files with 12 additions and 1 deletions
|
@ -529,11 +529,20 @@ class Model(ModelSettings):
|
|||
map_tokens = max(map_tokens, 1024)
|
||||
return map_tokens
|
||||
|
||||
def is_deepseek_r1(self):
|
||||
name = self.name.lower()
|
||||
if "deepseek" not in name:
|
||||
return
|
||||
return "r1" in name or "reasoner" in name
|
||||
|
||||
def is_ollama(self):
|
||||
return self.name.startswith("ollama/") or self.name.startswith("ollama_chat/")
|
||||
|
||||
def send_completion(self, messages, functions, stream, temperature=0):
|
||||
if os.environ.get("AIDER_SANITY_CHECK_TURNS"):
|
||||
sanity_check_messages(messages)
|
||||
|
||||
if "deepseek-reasoner" in self.name:
|
||||
if self.is_deepseek_r1():
|
||||
messages = ensure_alternating_roles(messages)
|
||||
|
||||
kwargs = dict(
|
||||
|
@ -552,6 +561,8 @@ class Model(ModelSettings):
|
|||
if self.extra_params:
|
||||
kwargs.update(self.extra_params)
|
||||
|
||||
# if is_ollama and kwargs[num_ctx] isn't set: num_ctx = token_count(messages) * 1.5 ai!
|
||||
|
||||
key = json.dumps(kwargs, sort_keys=True).encode()
|
||||
# dump(kwargs)
|
||||
hash_object = hashlib.sha1(key)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue