diff --git a/aider/history.py b/aider/history.py index 2141a7f81..4f22f3a8e 100644 --- a/aider/history.py +++ b/aider/history.py @@ -26,6 +26,12 @@ class ChatSummary: return sized def summarize(self, messages, depth=0): + messages = self.summarize_real(messages) + if messages and messages[-1]["role"] != "assistant": + messages.append(dict(role="assistant", content="Ok.")) + return messages + + def summarize_real(self, messages, depth=0): if not self.models: raise ValueError("No models available for summarization") @@ -88,7 +94,7 @@ class ChatSummary: if summary_tokens + tail_tokens < self.max_tokens: return result - return self.summarize(result, depth + 1) + return self.summarize_real(result, depth + 1) def summarize_all(self, messages): content = "" diff --git a/aider/models.py b/aider/models.py index 892f83913..e9354213e 100644 --- a/aider/models.py +++ b/aider/models.py @@ -625,6 +625,7 @@ MODEL_SETTINGS = [ ModelSettings( "deepseek/deepseek-reasoner", "diff", + weak_model_name="deepseek/deepseek-chat", editor_model_name="deepseek/deepseek-chat", editor_edit_format="editor-diff", use_repo_map=True, diff --git a/aider/resources/model-metadata.json b/aider/resources/model-metadata.json index 2c63c0851..d8ab09461 100644 --- a/aider/resources/model-metadata.json +++ b/aider/resources/model-metadata.json @@ -1,2 +1,18 @@ { + "deepseek-reasoner": { + "max_tokens": 8192, + "max_input_tokens": 128000, + "max_output_tokens": 8192, + "input_cost_per_token": 0.00000055, + "input_cost_per_token_cache_hit": 0.00000014, + "cache_read_input_token_cost": 0.00000014, + "cache_creation_input_token_cost": 0.0, + "output_cost_per_token": 0.00000219, + "litellm_provider": "deepseek", + "mode": "chat", + //"supports_function_calling": true, + "supports_assistant_prefill": true, + //"supports_tool_choice": true, + "supports_prompt_caching": true + }, } diff --git a/aider/sendchat.py b/aider/sendchat.py index 4e88f3023..ccf1c9f50 100644 --- a/aider/sendchat.py +++ b/aider/sendchat.py @@ -5,6 +5,7 @@ import time from aider.dump import dump # noqa: F401 from aider.exceptions import LiteLLMExceptions from aider.llm import litellm +from aider.utils import format_messages # from diskcache import Cache @@ -30,7 +31,9 @@ def sanity_check_messages(messages): continue if last_role and role == last_role: - return False + print(format_messages(messages)) + # import sys ; sys.exit() + raise ValueError("Messages don't properly alternate user/assistant") last_role = role last_non_system_role = role @@ -47,6 +50,8 @@ def send_completion( temperature=0, extra_params=None, ): + # sanity_check_messages(messages) + kwargs = dict( model=model_name, messages=messages, diff --git a/aider/utils.py b/aider/utils.py index ae850248d..322a44316 100644 --- a/aider/utils.py +++ b/aider/utils.py @@ -112,7 +112,7 @@ def format_messages(messages, title=None): output.append(f"{title.upper()} {'*' * 50}") for msg in messages: - output.append("") + output.append("-------") role = msg["role"].upper() content = msg.get("content") if isinstance(content, list): # Handle list content (e.g., image messages) diff --git a/benchmark/benchmark.py b/benchmark/benchmark.py index a6840970e..6f9411113 100755 --- a/benchmark/benchmark.py +++ b/benchmark/benchmark.py @@ -16,6 +16,7 @@ from types import SimpleNamespace from typing import List, Optional import git +import importlib_resources import lox import pandas as pd import prompts @@ -737,6 +738,10 @@ def run_test_real( chat_history_file=history_fname, ) + resource_metadata = importlib_resources.files("aider.resources").joinpath("model-metadata.json") + model_metadata_files_loaded = models.register_litellm_models([resource_metadata]) + dump(model_metadata_files_loaded) + # weak_model_name = model_name weak_model_name = None @@ -747,6 +752,8 @@ def run_test_real( editor_edit_format=editor_edit_format, ) + dump(main_model.max_chat_history_tokens) + if num_ctx: if not main_model.extra_params: main_model.extra_params = {}