mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-30 17:24:59 +00:00
fix: Update content handling in ChatChunks class
feat: Add date-based caching for prompts refactor: Simplify current date/time formatting in Coder class
This commit is contained in:
parent
a0fd982546
commit
36663cf04e
2 changed files with 12 additions and 5 deletions
|
@ -91,7 +91,7 @@ class ChatChunks:
|
|||
if not messages:
|
||||
return
|
||||
|
||||
content = messages[-1]
|
||||
content = messages[-1]["content"]
|
||||
if type(content) is str:
|
||||
content = dict(
|
||||
type="text",
|
||||
|
@ -99,6 +99,8 @@ class ChatChunks:
|
|||
)
|
||||
content["cache_control"] = {"type": "ephemeral"}
|
||||
|
||||
messages[-1]["content"] = [content]
|
||||
|
||||
|
||||
class Coder:
|
||||
abs_fnames = None
|
||||
|
@ -910,8 +912,12 @@ class Coder:
|
|||
if user_lang:
|
||||
platform_text += f"- Language: {user_lang}\n"
|
||||
|
||||
dt = datetime.now().astimezone().strftime("%Y-%m-%dT%H:%M:%S%z")
|
||||
platform_text += f"- Current date/time: {dt}"
|
||||
if self.cache_prompts:
|
||||
dt = datetime.now().astimezone().strftime("%Y-%m-%d")
|
||||
platform_text += f"- Current date: {dt}"
|
||||
else:
|
||||
dt = datetime.now().astimezone().strftime("%Y-%m-%dT%H:%M:%S%z")
|
||||
platform_text += f"- Current date/time: {dt}"
|
||||
|
||||
prompt = prompt.format(
|
||||
fence=self.fence,
|
||||
|
@ -1020,7 +1026,8 @@ class Coder:
|
|||
if self.cache_prompts and self.main_model.cache_control:
|
||||
chunks.add_cache_control_headers()
|
||||
|
||||
return chunks.all_messages()
|
||||
msgs = chunks.all_messages()
|
||||
return msgs
|
||||
|
||||
def send_message(self, inp):
|
||||
self.aider_edited_files = None
|
||||
|
|
|
@ -17,7 +17,7 @@ from aider.dump import dump # noqa: F401
|
|||
from aider.llm import AIDER_APP_NAME, AIDER_SITE_URL, litellm
|
||||
|
||||
DEFAULT_MODEL_NAME = "gpt-4o"
|
||||
ANTHROPIC_BETA_HEADER = "max-tokens-3-5-sonnet-2024-07-15, prompt-caching-2024-07-31"
|
||||
ANTHROPIC_BETA_HEADER = "max-tokens-3-5-sonnet-2024-07-15,prompt-caching-2024-07-31"
|
||||
|
||||
OPENAI_MODELS = """
|
||||
gpt-4
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue