style: Run linter and fix whitespace issues in models.py and sendchat.py

This commit is contained in:
Paul Gauthier (aider) 2025-02-04 11:33:05 -08:00
parent 60aff26d94
commit 24b1360eb8
2 changed files with 4 additions and 4 deletions

View file

@ -528,9 +528,11 @@ class Model(ModelSettings):
def send_completion(self, messages, functions, stream, temperature=0, extra_params=None): def send_completion(self, messages, functions, stream, temperature=0, extra_params=None):
if os.environ.get("AIDER_SANITY_CHECK_TURNS"): if os.environ.get("AIDER_SANITY_CHECK_TURNS"):
from aider.sendchat import sanity_check_messages from aider.sendchat import sanity_check_messages
sanity_check_messages(messages) sanity_check_messages(messages)
if "deepseek-reasoner" in self.name: if "deepseek-reasoner" in self.name:
from aider.sendchat import ensure_alternating_roles from aider.sendchat import ensure_alternating_roles
messages = ensure_alternating_roles(messages) messages = ensure_alternating_roles(messages)
kwargs = dict( kwargs = dict(
model=self.name, model=self.name,
@ -549,6 +551,7 @@ class Model(ModelSettings):
# dump(kwargs) # dump(kwargs)
hash_object = hashlib.sha1(key) hash_object = hashlib.sha1(key)
from aider.sendchat import CACHE, litellm from aider.sendchat import CACHE, litellm
if not stream and CACHE is not None and key in CACHE: if not stream and CACHE is not None and key in CACHE:
return hash_object, CACHE[key] return hash_object, CACHE[key]
res = litellm.completion(**kwargs) res = litellm.completion(**kwargs)
@ -559,6 +562,7 @@ class Model(ModelSettings):
def simple_send_with_retries(self, messages): def simple_send_with_retries(self, messages):
from aider.exceptions import LiteLLMExceptions from aider.exceptions import LiteLLMExceptions
from aider.sendchat import RETRY_TIMEOUT, ensure_alternating_roles from aider.sendchat import RETRY_TIMEOUT, ensure_alternating_roles
litellm_ex = LiteLLMExceptions() litellm_ex = LiteLLMExceptions()
if "deepseek-reasoner" in self.name: if "deepseek-reasoner" in self.name:
messages = ensure_alternating_roles(messages) messages = ensure_alternating_roles(messages)

View file

@ -75,7 +75,3 @@ def ensure_alternating_roles(messages):
prev_role = current_role prev_role = current_role
return fixed_messages return fixed_messages